Commit 1030299c by 龙于生

新增资讯已阅、评论意见反馈接口

parent 2171f0dd
...@@ -7,7 +7,9 @@ import java.util.Timer; ...@@ -7,7 +7,9 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import cn.timer.api.bean.qyxx.*; import cn.timer.api.bean.qyxx.*;
import cn.timer.api.dto.qyxx.CmsContentReadDto;
import cn.timer.api.utils.redis.RedisUtil; import cn.timer.api.utils.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -50,6 +52,7 @@ import javax.annotation.Resource; ...@@ -50,6 +52,7 @@ import javax.annotation.Resource;
@Api(tags = "5.0企业讯息") @Api(tags = "5.0企业讯息")
@Transactional @Transactional
@RequestMapping(value = "/qyxx", produces = { "application/json" }) @RequestMapping(value = "/qyxx", produces = { "application/json" })
@Slf4j
public class CmsController { public class CmsController {
@Autowired @Autowired
...@@ -591,4 +594,84 @@ public class CmsController { ...@@ -591,4 +594,84 @@ public class CmsController {
return ResultUtil.success("设置失败"); return ResultUtil.success("设置失败");
} }
/**
* 查询传阅列表
* @return
*/
@PostMapping(value = "/getCmsContentReads")
@ApiOperation(value = "查询传阅列表", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> getCmsContentReads(@CurrentUser UserBean userBean, @RequestBody CmsContentReadDto cmsContentReadDto) {
Page<CmsContentRead> page = new Page<CmsContentRead>(cmsContentReadDto.getCurrentPage(), cmsContentReadDto.getTotalPage());
//查询传阅列表
IPage<CmsContentRead> cmsContentReads = CmsContentRead.builder().build()
.selectPage(page, new QueryWrapper<CmsContentRead>()
.lambda().eq(CmsContentRead::getCmsContentId, cmsContentReadDto.getCmsContentId())
.eq(CmsContentRead::getOrgCode,userBean.getOrgCode())
.eq(CmsContentRead::getUserId,userBean.getEmpNum())
.orderByDesc(CmsContentRead::getReviewTime));
return ResultUtil.data(cmsContentReads);
}
/**
* 标记已阅
*/
@GetMapping(value = "/haveRead/{id}")
@ApiOperation(value = "标记已阅", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> haveRead(@CurrentUser UserBean userBean, @PathVariable("id") Integer id) {
//用户id查询传阅消息
CmsContentRead cmsContentRead = CmsContentRead.builder().build()
.selectOne(new QueryWrapper<CmsContentRead>().lambda()
.eq(CmsContentRead::getUserId, userBean.getEmpNum())
.eq(CmsContentRead::getOrgCode, userBean.getOrgCode())
.eq(CmsContentRead::getCmsContentId,id));
if(cmsContentRead == null){
cmsContentRead = new CmsContentRead();
cmsContentRead.setUserId(userBean.getEmpNum());
cmsContentRead.setUserName(userBean.getUserInfo().getName());
cmsContentRead.setOrgCode(userBean.getOrgCode());
cmsContentRead.setCmsContentId(id);
}else {
//已阅 直接返回
if(cmsContentRead.getReadStatus() == 1){
return ResultUtil.data(1);
}
}
try {
cmsContentRead.setReadStatus(1);
cmsContentRead.setReviewTime(new Date());
cmsContentRead.insertOrUpdate();
}catch (Exception e){
log.error("=============已阅操作失败, " + e);
return ResultUtil.error(e);
}
return ResultUtil.success();
}
/**
* 根据讯息id查传阅列表
* @return
*/
@PostMapping(value = "/comment")
@ApiOperation(value = "评论意见反馈", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> comment(@CurrentUser UserBean userBean, @RequestBody CmsContentReadDto cmsContentReadDto) {
//用户id查询传阅消息
CmsContentRead cmsContentRead = CmsContentRead.builder().build()
.selectOne(new QueryWrapper<CmsContentRead>().lambda()
.eq(CmsContentRead::getUserId, userBean.getEmpNum())
.eq(CmsContentRead::getOrgCode, userBean.getOrgCode())
.eq(CmsContentRead::getCmsContentId,cmsContentReadDto.getCmsContentId()));
try {
cmsContentRead.setReviewContent(cmsContentReadDto.getReviewContent());
cmsContentRead.insertOrUpdate();
}catch (Exception e){
log.error("=============评论失败, " + e);
return ResultUtil.error(e);
}
return ResultUtil.success();
}
} }
package cn.timer.api.dto.qyxx;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CmsContentReadDto extends Page implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "编号", example = "1")
private Integer id;
@ApiModelProperty(value = "企业讯息主表ID", example = "101")
private Integer cmsContentId;
@ApiModelProperty(value = "留言/意见反馈", example = "")
private String reviewContent;
@ApiModelProperty(value = "留言/意见反馈时间", example = "")
private Date reviewTime;
@ApiModelProperty(value = "组织机构代码", example = "1")
private Integer orgCode;
@ApiModelProperty(value = "用户ID", example = "1")
private Integer userId;
@ApiModelProperty(value = "用户姓名", example = "张三")
private String userName;
@ApiModelProperty(value = "阅读标记0.未读 1.已读", example = "0")
private Integer readStatus;
@ApiModelProperty(value = "逻辑删除标记0.未删除 1.删除", example = "0")
private Integer deleteFlag;
@ApiModelProperty(value = "创建时间", example = "")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "")
private Date updateTime;
}
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