Commit 057f31a7 authored by 罗林杰's avatar 罗林杰

修改动态

parent 4d1ba464
...@@ -15,7 +15,7 @@ public class opmArticleDTO extends CyIdIncreEntity<opmArticleDTO> { ...@@ -15,7 +15,7 @@ public class opmArticleDTO extends CyIdIncreEntity<opmArticleDTO> {
/** /**
* 发布人 * 发布人
*/ */
private Integer createUser; private String createUser;
/** /**
* 发布时间 * 发布时间
......
package org.rcisoft.business.opmArticle.controller;
/*固定导入*/
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import jakarta.servlet.http.HttpServletResponse;
import org.rcisoft.business.opmArticle.entity.OpmArticle;
import org.rcisoft.business.opmArticle.service.OpmArticleService;
import org.rcisoft.core.anno.CyOpeLogAnno;
import org.rcisoft.core.constant.CyMessCons;
import org.rcisoft.core.controller.CyPaginationController;
import org.rcisoft.core.model.CyGridModel;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.operlog.enums.CyLogTypeEnum;
import org.rcisoft.core.result.CyResult;
import org.rcisoft.core.util.CyEpExcelUtil;
import org.rcisoft.core.util.CyResultGenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* Created by cy on 2024年3月30日 下午1:51:15.
*/
@RestController
@RequestMapping("/opmarticle")
public class OpmArticleController extends CyPaginationController<OpmArticle> {
@Autowired
private OpmArticleService opmArticleServiceImpl;
@PreAuthorize("@cyPerm.hasPerm('cms:banner:increase')")
@CyOpeLogAnno(title = "system-banner管理管理-新增banner管理", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="添加banner管理", description="添加banner管理")
@PostMapping(value = "/add")
public CyResult add(@Valid OpmArticle opmArticle, BindingResult bindingResult) {
CyPersistModel data = opmArticleServiceImpl.persist(opmArticle);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticle);
}
@PreAuthorize("@cyPerm.hasPerm('cms:banner:removing')")
@CyOpeLogAnno(title = "system-banner管理管理-删除banner管理", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="逻辑删除banner管理", description="逻辑删除banner管理")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true)})
@DeleteMapping("/deleteLogical/{businessId:\\w+}")
public CyResult deleteLogical(@PathVariable String businessId,OpmArticle opmArticle) {
opmArticle.setBusinessId(Integer.valueOf(businessId));
CyPersistModel data = opmArticleServiceImpl.removeLogical(opmArticle);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
//@PreAuthorize("@cyPerm.hasPerm('sys:banner:delete')")
@CyOpeLogAnno(title = "system-banner管理管理-删除banner管理", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="删除banner管理", description="删除banner管理")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true)})
@DeleteMapping("/delete/{businessId:\\w+}")
public CyResult delete(@PathVariable String businessId,OpmArticle opmArticle) {
opmArticle.setBusinessId(Integer.valueOf(businessId));
CyPersistModel data = opmArticleServiceImpl.remove(opmArticle);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
businessId);
}
@PreAuthorize("@cyPerm.hasPerm('cms:banner:modifications')")
@CyOpeLogAnno(title = "system-banner管理管理-修改banner管理", businessType = CyLogTypeEnum.UPDATE)
@Operation(summary="修改banner管理", description="修改banner管理")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = false)})
@PutMapping("/update/{businessId:\\w+}")
public CyResult update(@PathVariable String businessId, @Valid OpmArticle opmArticle, BindingResult bindingResult) {
opmArticle.setBusinessId(Integer.valueOf(businessId));
CyPersistModel data = opmArticleServiceImpl.merge(opmArticle);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticle);
}
@PreAuthorize("@cyPerm.hasPerm('cms:banner:singleSearch')")
@CyOpeLogAnno(title = "system-banner管理管理-查询banner管理", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询单一banner管理", description="查询单一banner管理")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true)})
@GetMapping("/detail/{businessId:\\w+}")
public CyResult detail(@PathVariable String businessId) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticleServiceImpl.findById(businessId));
}
@PreAuthorize("@cyPerm.hasPerm('cms:banner:search')")
@CyOpeLogAnno(title = "system-banner管理管理-查询banner管理", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询banner管理集合", description="查询banner管理集合")
@GetMapping(value = "/queryOpmArticle")
public CyResult queryCmsBanners(OpmArticle opmArticle) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticleServiceImpl.findAll(opmArticle));
}
// @PreAuthorize("@cyPerm.hasPerm('cms:banner:pageSearch')")
@CyOpeLogAnno(title = "system-banner管理管理-查询banner管理", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="分页查询banner管理集合", description="分页查询banner管理集合")
@GetMapping(value = "/list")
public CyGridModel listByPagination(OpmArticle opmArticle) {
opmArticleServiceImpl.findAllByPagination(getPaginationUtility(), opmArticle);
return getGridModelResponse();
}
@PreAuthorize("@cyPerm.hasPerm('cms:banner:derive')")
@CyOpeLogAnno(title = "system-banner管理管理-查询banner管理", businessType = CyLogTypeEnum.EXPORT)
@Operation(summary = "导出banner管理信息", description = "导出banner管理信息")
@GetMapping(value = "/export")
public void outCmsBanner(HttpServletResponse response, OpmArticle opmArticle, @PathVariable @RequestParam(defaultValue = "0") String excelId) {
String excelName="";
switch(excelId){
case "0": excelName="banner管理信息.xls";break;
case "1": excelName="banner管理信息.xlsx";break;
case "2": excelName="banner管理信息.csv";break;
}
List<OpmArticle> opmArticleList = opmArticleServiceImpl.export(opmArticle);
CyEpExcelUtil.exportExcel(opmArticleList, "banner管理信息", "banner管理信息", OpmArticle.class, excelName, response);
}
}
package org.rcisoft.business.opmArticle.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.rcisoft.business.cmsBanner.entity.CmsBanner;
import org.rcisoft.business.opmArticle.entity.ArticleCommentDTO;
import org.rcisoft.business.opmArticle.entity.OpmArticle;
import org.rcisoft.core.mapper.CyBaseMapper;
import org.rcisoft.core.model.CyPageInfo;
import java.util.List;
/**
* Created with cy on 2024年3月30日 下午1:51:15.
*/
public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
List<OpmArticle> queryOpmArticle(@Param("entity") OpmArticle cmsBanner);
/**
* 分页查询 cmsBanner
*
*/
IPage<OpmArticle> queryOpmArticlePaged(CyPageInfo cyPageInfo, @Param("entity") OpmArticle cmsBanner);
OpmArticle selectByIdWithUrl(String id);
List<ArticleCommentDTO> SelectArticleComment(Integer businessId);
}
package org.rcisoft.business.opmArticle.entity;
import lombok.Data;
@Data
public class ArticleCommentDTO {
/**
* 业务Id
*/
Integer businessId;
/**
* 会员编号
*/
String memCode;
/**
* 评论内容
*/
String content;
/**
* 父级Id
*/
Integer parentId;
/**
* 用户头像
*/
String path;
}
package org.rcisoft.business.opmArticle.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.rcisoft.core.entity.CyIdIncreEntity;
import java.util.List;
/**
* Created with cy on 2024年3月30日 下午1:51:15.
*/
@Data
@TableName("opm_article")
public class OpmArticle extends CyIdIncreEntity<OpmArticle> {
/**
* @desc 图片
* @column picture_id
* @default
*/
private Integer pictureId;
/**
* @desc 内容
* @column content
* @default
*/
private String content;
/**
* @desc 评论数
* @column comment_count
* @default
*/
private Integer commentCount;
/**
* @desc 点赞数
* @column like_count
* @default
*/
private Integer likeCount;
/**
* @desc 审核状态
* @column exam_status
* @default
*/
private String examStatus;
/**
* @desc 是否动态
* @column is_article
* @default
*/
private String isArticle;
/**
* @desc 话题Id
* @column topic_id
* @default
*/
private Integer topicId;
/**
* 图片地址
*/
@TableField(exist = false)
private String path;
/**
* 话题名称
*/
@TableField(exist = false)
private String topic;
/**
* 创建人会员号
*/
@TableField(exist = false)
private String memCode;
/**
* 开始时间
*/
@JsonIgnore
@TableField(exist = false)
private String beginTime;
/**
* 结束时间
*/
@JsonIgnore
@TableField(exist = false)
private String endTime;
/**
* 评论列表
*/
@TableField(exist = false)
List<ArticleCommentDTO> articleCommentDTOList;
}
package org.rcisoft.business.opmArticle.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.rcisoft.business.cmsBanner.entity.CmsBanner;
import org.rcisoft.business.opmArticle.entity.OpmArticle;
import org.rcisoft.core.model.CyPageInfo;
import org.rcisoft.core.model.CyPersistModel;
import java.util.List;
/**
* Created by cy on 2024年3月30日 下午1:51:15.
*/
public interface OpmArticleService {
/**
* 保存 opmArticle管理
* @param opmArticle
* @return
*/
CyPersistModel persist(OpmArticle opmArticle);
/**
* 删除 opmArticle管理
* @param opmArticle
* @return
*/
CyPersistModel remove(OpmArticle opmArticle);
/**
* 逻辑删除 opmArticle管理
* @param opmArticle
* @return
*/
CyPersistModel removeLogical(OpmArticle opmArticle);
/**
* 修改 opmArticle管理
* @param opmArticle
* @return
*/
CyPersistModel merge(OpmArticle opmArticle);
/**
* 根据id查询 opmArticle管理
* @param id
* @return
*/
OpmArticle findById(String id);
/**
* 分页查询 opmArticle管理
* @param opmArticle
* @return
*/
IPage<OpmArticle> findAllByPagination(CyPageInfo<OpmArticle> paginationUtility,
OpmArticle opmArticle);
/**
* 查询list opmArticle管理
* @param opmArticle
* @return
*/
List<OpmArticle> findAll(OpmArticle opmArticle);
/**
* 导出opmArticle管理
* @return
*/
List<OpmArticle> export(OpmArticle opmArticle);
}
package org.rcisoft.business.opmArticle.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.opmArticle.dao.OpmArticleRepository;
import org.rcisoft.business.opmArticle.entity.ArticleCommentDTO;
import org.rcisoft.business.opmArticle.entity.OpmArticle;
import org.rcisoft.business.opmArticle.service.OpmArticleService;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.model.CyPageInfo;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.core.util.CyUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* Created by cy on 2024年3月30日 下午1:51:15.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, OpmArticle> implements OpmArticleService {
@Autowired
private Global global;
/**
* 保存 opmArticle管理
* @param opmArticle
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel persist(OpmArticle opmArticle){
//增加操作
int line = baseMapper.insert(opmArticle);
log.debug(CyUserUtil.getAuthenUsername()+"新增了ID为"+
opmArticle.getBusinessId()+"的opmArticle管理信息");
return new CyPersistModel(line);
}
/**
* 删除 opmArticle管理
* @param opmArticle
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel remove(OpmArticle opmArticle){
int line = baseMapper.realDelete(opmArticle);
log.debug(CyUserUtil.getAuthenUsername()+"删除了ID为"+
opmArticle.getBusinessId()+"的opmArticle管理信息");
return new CyPersistModel(line);
}
/**
* 逻辑删除 opmArticle管理
* @param opmArticle
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel removeLogical(OpmArticle opmArticle){
opmArticle.setDeleted();
int line = baseMapper.deleteById(opmArticle);
log.debug(CyUserUtil.getAuthenUsername()+"逻辑删除了ID为"+
opmArticle.getBusinessId()+"的opmArticle管理信息");
return new CyPersistModel(line);
}
/**
* 修改 opmArticle管理
* @param opmArticle
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel merge(OpmArticle opmArticle){
int line = baseMapper.updateById(opmArticle);
log.debug(CyUserUtil.getAuthenUsername()+"修改了ID为"+ opmArticle.getBusinessId()+"的opmArticle管理信息");
return new CyPersistModel(line);
}
/**
* 根据id查询 opmArticle管理
* @param id
* @return
*/
@Override
public OpmArticle findById(String id){
OpmArticle opmArticle = baseMapper.selectByIdWithUrl(id);
if (opmArticle.getPath()!=null){
opmArticle.setPath(global.getBase_Discovery()+opmArticle.getPath());
}
List<ArticleCommentDTO> list = baseMapper.SelectArticleComment(opmArticle.getBusinessId());
opmArticle.setArticleCommentDTOList(list);
return opmArticle;
}
/**
* 分页查询 opmArticle管理
* @param opmArticle
* @return
*/
@Override
public IPage<OpmArticle> findAllByPagination(CyPageInfo<OpmArticle> paginationUtility,
OpmArticle opmArticle){
IPage<OpmArticle> result = baseMapper.queryOpmArticlePaged(paginationUtility,opmArticle);
List<OpmArticle> opmArticleList = result.getRecords();
for (OpmArticle article : opmArticleList){
if (article.getPath()!=null){
article.setPath(global.getBase_Discovery()+article.getPath());
}
}
return result;
}
/**
* 查询list opmArticle管理
* @param opmArticle
* @return
*/
@Override
public List<OpmArticle> findAll(OpmArticle opmArticle){
return baseMapper.queryOpmArticle(opmArticle);
}
/**
* 导出opmArticle管理
* @return
*/
@Override
public List<OpmArticle> export(OpmArticle opmArticle) {
List<OpmArticle> opmArticleList = baseMapper.queryOpmArticle(opmArticle);
return opmArticleList;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.opmArticle.dao.OpmArticleRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.opmArticle.entity.OpmArticle">
<id column="business_id" jdbcType="INTEGER" property="businessId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="content" jdbcType="VARCHAR" property="content"/>
<result column="picture_id" jdbcType="INTEGER" property="pictureId"/>
<result column="comment_count" jdbcType="VARCHAR" property="commentCount"/>
<result column="like_count" jdbcType="VARCHAR" property="likeCount"/>
<result column="topic_id" jdbcType="INTEGER" property="topicId"/>
<result column="exam_status" jdbcType="VARCHAR" property="examStatus"/>
<result column="is_article" jdbcType="VARCHAR" property="isArticle"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<select id="queryOpmArticle" resultMap="BaseResultMap">
select opa.*,oi.path,sot.topic_name as topic,mi.mem_code as memCode
from opm_article opa
left join oss_info oi on opa.picture_id = oi.business_id
left join opm_topic sot on opa.topic_id = sot.business_id
left join mem_info mi on opa.create_by = mi.user_id
where 1=1
and opa.del_flag = '0'
<if test="entity.flag !=null and entity.flag != '' ">
and opa.flag = #{entity.flag}
</if>
<if test="entity.isArticle !=null and entity.isArticle != '' ">
and opa.is_article = #{entity.isArticle}
</if>
<if test="entity.topicId !=null and entity.topicId != '' ">
and opa.topic_id = #{entity.topicId}
</if>
<if test="entity.businessId !=null and entity.businessId != '' ">
and opa.business_id = #{entity.businessId}
</if>
<if test="entity.examStatus !=null and entity.examStatus != '' ">
and opa.exam_status = #{entity.examStatus}
</if>
<if test="entity.content !=null and entity.content != '' ">
and opa.content like concat('%',#{entity.content},'%')
</if>
<if test="entity.topic !=null and entity.topic != '' ">
and sot.topic_name like concat('%',#{entity.topic},'%')
</if>
<if test="entity.pictureId !=null and entity.pictureId != '' ">
and opa.picture_id = #{entity.pictureId}
</if>
<if test="entity.createBy !=null and entity.createBy != '' ">
and opa.create_by = #{entity.createBy}
</if>
<if test="entity.beginTime !=null and entity.beginTime != '' ">
and opa.create_date &gt;= #{entity.beginTime}
</if>
<if test="entity.endTime !=null and entity.endTime != '' ">
and opa.create_date &lt;= #{entity.endTime}
</if>
<if test="entity.updateBy !=null and entity.updateBy != '' ">
and opa.update_by = #{entity.updateBy}
</if>
<if test="entity.likeCount !=null and entity.likeCount != '' ">
and opa.like_count &gt;= #{entity.likeCount}
</if>
<if test="entity.commentCount !=null and entity.commentCount != '' ">
and opa.comment_count &gt;= #{entity.commentCount}
</if>
ORDER BY opa.business_id DESC
</select>
<select id="queryOpmArticlePaged" resultMap="BaseResultMap">
select opa.*,oi.path,sot.topic_name as topic,mi.mem_code as memCode
from opm_article opa
left join oss_info oi on opa.picture_id = oi.business_id
left join opm_topic sot on opa.topic_id = sot.business_id
left join mem_info mi on opa.create_by = mi.user_id
where 1=1
and opa.del_flag = '0'
<if test="entity.flag !=null and entity.flag != '' ">
and opa.flag = #{entity.flag}
</if>
<if test="entity.isArticle !=null and entity.isArticle != '' ">
and opa.is_article = #{entity.isArticle}
</if>
<if test="entity.topicId !=null and entity.topicId != '' ">
and opa.topic_id = #{entity.topicId}
</if>
<if test="entity.businessId !=null and entity.businessId != '' ">
and opa.business_id = #{entity.businessId}
</if>
<if test="entity.examStatus !=null and entity.examStatus != '' ">
and opa.exam_status = #{entity.examStatus}
</if>
<if test="entity.content !=null and entity.content != '' ">
and opa.content like concat('%',#{entity.content},'%')
</if>
<if test="entity.topic !=null and entity.topic != '' ">
and sot.topic_name like concat('%',#{entity.topic},'%')
</if>
<if test="entity.pictureId !=null and entity.pictureId != '' ">
and opa.picture_id = #{entity.pictureId}
</if>
<if test="entity.createBy !=null and entity.createBy != '' ">
and opa.create_by = #{entity.createBy}
</if>
<if test="entity.beginTime !=null and entity.beginTime != '' ">
and opa.create_date &gt;= #{entity.beginTime}
</if>
<if test="entity.endTime !=null and entity.endTime != '' ">
and opa.create_date &lt;= #{entity.endTime}
</if>
<if test="entity.updateBy !=null and entity.updateBy != '' ">
and opa.update_by = #{entity.updateBy}
</if>
<if test="entity.likeCount !=null and entity.likeCount != '' ">
and opa.like_count &gt;= #{entity.likeCount}
</if>
<if test="entity.commentCount !=null and entity.commentCount != '' ">
and opa.comment_count &gt;= #{entity.commentCount}
</if>
ORDER BY opa.business_id DESC
</select>
<select id="selectByIdWithUrl" resultType="org.rcisoft.business.opmArticle.entity.OpmArticle">
SELECT opa.*,
oi.path
from opm_article opa
LEFT JOIN oss_info oi ON oi.business_id = opa.picture_id
where 1 = 1
and opa.del_flag = '0'
and opa.business_id = #{businessId}
</select>
<select id="SelectArticleComment" resultType="org.rcisoft.business.opmArticle.entity.ArticleCommentDTO">
SELECT opc.*,
mi.mem_code as memCode,
oi.url as path
FROM opm_article_comment opc
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
left join oss_info oi on oi.business_id = mi.avatar
WHERE 1 = 1
AND opc.del_flag = '0'
AND opc.article_id = #{articleId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment