Commit 2acffa17 by 翁国栋

华颐————

管理员删除传阅附件
parent 766c3941
......@@ -7,6 +7,7 @@ import java.util.Timer;
import java.util.TimerTask;
import cn.timer.api.bean.qyxx.*;
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
import cn.timer.api.dto.qyxx.CmsContentReadDto;
import cn.timer.api.utils.redis.RedisUtil;
import com.github.yulichang.query.MPJQueryWrapper;
......@@ -54,7 +55,7 @@ import javax.annotation.Resource;
@RestController
@Api(tags = "5.0企业讯息")
@Transactional
@RequestMapping(value = "/qyxx", produces = { "application/json" })
@RequestMapping(value = "/qyxx", produces = {"application/json"})
@Slf4j
public class CmsController {
......@@ -100,8 +101,8 @@ public class CmsController {
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.eq("t.releasestate", 0)
.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1)
.or(true,q -> q.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum()))
.or(true,q -> q.eq("t.open_status", 0).eq("t.userid",userBean.getEmpNum())))
.or(true, q -> q.eq("t.open_status", 0).eq("ccr.user_id", userBean.getEmpNum()))
.or(true, q -> q.eq("t.open_status", 0).eq("t.userid", userBean.getEmpNum())))
.eq("t.organization_id", orgCode)
.groupBy("t.id")
.orderByDesc("t.releasetime").last("limit 6");
......@@ -144,7 +145,6 @@ public class CmsController {
/**
* 分类内容获取
*
*/
@GetMapping(value = "/getType")
@ApiOperation(value = "分类内容获取", httpMethod = "GET", notes = "接口发布说明")
......@@ -163,8 +163,8 @@ public class CmsController {
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.eq("t.releasestate", 0)
.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1)
.or(true,q -> q.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum()))
.or(true,q -> q.eq("t.open_status", 0).eq("t.userid",userBean.getEmpNum())))
.or(true, q -> q.eq("t.open_status", 0).eq("ccr.user_id", userBean.getEmpNum()))
.or(true, q -> q.eq("t.open_status", 0).eq("t.userid", userBean.getEmpNum())))
.eq("t.organization_id", userBean.getOrgCode()).eq("t.modularid", id)
.groupBy("t.id")
.orderByDesc("t.releasetime")
......@@ -177,7 +177,6 @@ public class CmsController {
/**
* 获取分类
*
*/
@GetMapping(value = "/xxfl")
@ApiOperation(value = "获取分类", httpMethod = "GET", notes = "接口发布说明")
......@@ -207,7 +206,7 @@ public class CmsController {
// qynr.setXxbh("XX" + i++);
Boolean a = qynr.getId() == null;
if(a){
if (a) {
qynr.setUserid(empNum);
}
if (a && qynr.getPublisher() == null)
......@@ -228,16 +227,16 @@ public class CmsController {
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum)).getName());
qynr.setReleasetype(fbfs);
qynr.setStatus(0);
if(fbfs != null && fbfs == 4){
if (fbfs != null && fbfs == 4) {
qynr.setReleasestate(0);
qynr.setStatus(1);
qynr.setReleasetime(now.toString());
}
qynr.insertOrUpdate();
// 新增 文件传阅 人员数据
if(a){
if(!CollectionUtils.isEmpty(cmsContentDto.getCmsContentReads())){
for (CmsContentRead entity :cmsContentDto.getCmsContentReads() ) {
if (a) {
if (!CollectionUtils.isEmpty(cmsContentDto.getCmsContentReads())) {
for (CmsContentRead entity : cmsContentDto.getCmsContentReads()) {
entity.setCmsContentId(qynr.getId());
entity.setOrgCode(orgCode);
entity.setReadStatus(0);
......@@ -247,8 +246,8 @@ public class CmsController {
}
}
if (a){
String msg = fbfs==4?"提交成功":"提交成功、等待管理员审核";
if (a) {
String msg = fbfs == 4 ? "提交成功" : "提交成功、等待管理员审核";
return ResultUtil.data(qynr, msg);
} else {
return ResultUtil.data(qynr, "修改成功");
......@@ -350,7 +349,7 @@ public class CmsController {
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.selectAll(CmsContent.class)
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1).or(true,sq -> sq.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum())));
queryWrapper.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1).or(true, sq -> sq.eq("t.open_status", 0).eq("ccr.user_id", userBean.getEmpNum())));
queryWrapper.eq("t.organization_id", userBean.getOrgCode()).eq("t.status", 1).eq("t.releasestate", 0)
.eq(t != null && t > -1, "t.modularid", t).eq(r != null && r > -1, "t.releasestate", r)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "t.releasetime",
......@@ -418,7 +417,7 @@ public class CmsController {
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "releasetime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(wq -> wq.eq("publisher", userBean.getEmpNum()).or().eq("author", userBean.getUserInfo().getName()).or().inSql("id","select cms_content_id from cms_content_read where user_id ="+userBean.getEmpNum()))
.and(wq -> wq.eq("publisher", userBean.getEmpNum()).or().eq("author", userBean.getUserInfo().getName()).or().inSql("id", "select cms_content_id from cms_content_read where user_id =" + userBean.getEmpNum()))
.orderByDesc("addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
......@@ -470,7 +469,7 @@ public class CmsController {
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode())
.select("id", "publisher_name", "auditopinion", "modularid", "status", "title", "releasetime",
"addeddate", "author", "summary", "releasetype", "fmtpath","filepath","open_status")
"addeddate", "author", "summary", "releasetype", "fmtpath", "filepath", "open_status")
.ne("status", 1).eq(t != null && t > -1, "modularid", t)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "releasetime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
......@@ -650,6 +649,7 @@ public class CmsController {
/**
* 查询传阅列表
*
* @return
*/
@PostMapping(value = "/getCmsContentReads")
......@@ -675,17 +675,17 @@ public class CmsController {
.selectOne(new QueryWrapper<CmsContentRead>().lambda()
.eq(CmsContentRead::getUserId, userBean.getEmpNum())
.eq(CmsContentRead::getOrgCode, userBean.getOrgCode())
.eq(CmsContentRead::getCmsContentId,id));
.eq(CmsContentRead::getCmsContentId, id));
if(cmsContentRead == null){
if (cmsContentRead == null) {
cmsContentRead = new CmsContentRead();
cmsContentRead.setUserId(userBean.getEmpNum());
cmsContentRead.setUserName(userBean.getUserInfo().getName());
cmsContentRead.setOrgCode(userBean.getOrgCode());
cmsContentRead.setCmsContentId(id);
}else {
} else {
//已阅 直接返回
if(cmsContentRead.getReadStatus() == 1){
if (cmsContentRead.getReadStatus() == 1) {
return ResultUtil.data(1);
}
}
......@@ -694,7 +694,7 @@ public class CmsController {
cmsContentRead.setReadStatus(1);
cmsContentRead.setReviewTime(new Date());
cmsContentRead.insertOrUpdate();
}catch (Exception e){
} catch (Exception e) {
log.error("=============已阅操作失败, " + e);
return ResultUtil.error(e);
}
......@@ -703,6 +703,7 @@ public class CmsController {
/**
* 根据讯息id查传阅列表
*
* @return
*/
@PostMapping(value = "/comment")
......@@ -713,54 +714,75 @@ public class CmsController {
.selectOne(new QueryWrapper<CmsContentRead>().lambda()
.eq(CmsContentRead::getUserId, userBean.getEmpNum())
.eq(CmsContentRead::getOrgCode, userBean.getOrgCode())
.eq(CmsContentRead::getCmsContentId,cmsContentReadDto.getCmsContentId()));
.eq(CmsContentRead::getCmsContentId, cmsContentReadDto.getCmsContentId()));
try {
cmsContentRead.setReviewContent(cmsContentReadDto.getReviewContent());
cmsContentRead.insertOrUpdate();
}catch (Exception e){
} catch (Exception e) {
log.error("=============评论失败, " + e);
return ResultUtil.error(e);
}
return ResultUtil.success();
}
/**
* 根据讯息id查传阅增加文件
*
* @return
*/
@PostMapping(value = "/cmsAddFile")
@ApiOperation(value = "文件传阅增加文件", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> cmsAddFile(@CurrentUser UserBean userBean, @RequestBody JSONObject request) {
String cmsContentId=request.getString("cmsContentId");
String cmsContentId = request.getString("cmsContentId");
//用户id查询传阅消息
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", cmsContentId);
CmsContent cmsContent = CmsContent.builder().build().selectOne(queryWrapper);
JSONArray addjsonArray=JSONArray.fromObject(request.getString("filepathcms"));
JSONArray resjsonArray=JSONArray.fromObject(cmsContent.getFilepath());
JSONArray addjsonArray = JSONArray.fromObject(request.getString("filepathcms"));
JSONArray resjsonArray = JSONArray.fromObject(cmsContent.getFilepath());
resjsonArray.addAll(addjsonArray);
cmsContent.setFilepath(resjsonArray.toString());
cmsContentMapper.updateById(cmsContent);
return ResultUtil.data(resjsonArray.toString());
}
/**
* 添加传阅人员
*
* @return
*/
@PostMapping(value = "/addReadPersonnel")
@ApiOperation(value = "添加传阅人员", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> addReadPersonnel(@CurrentUser UserBean userBean, @RequestBody List<CmsContentRead> cmsContentReads) {
for (CmsContentRead ccr:cmsContentReads
for (CmsContentRead ccr : cmsContentReads
) {
ccr.insert();
}
return ResultUtil.success();
}
@PostMapping(value = "/getUnreadCmsList")
@ApiOperation(value = "获取当前用户的未读传阅列表", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> shxxquery(@CurrentUser UserBean userBean) {
return ResultUtil.data(cmsIsReadMapper.getUnreadList(userBean.getEmpNum()));
}
@PostMapping(value = "/adminDeleteFile")
@ApiOperation(value = "管理员删除附件", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> adminDeleteFile(@CurrentUser UserBean userBean, @RequestBody CmsContentReadDto cmsContentReadDto) {
QyzxEmpEntAsso ent = QyzxEmpEntAsso.builder().build().selectOne(new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode()).eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum()));
if (ent.getUserType() == 2) {
return ResultUtil.error("当前用户没有权限操作");
}
CmsContent cmsContent = CmsContent.builder().id(cmsContentReadDto.getId()).build().selectById();
JSONArray resjsonArray = JSONArray.fromObject(cmsContent.getFilepath());
/*不转为int会默认使用remove(object)*/
resjsonArray.remove((int)cmsContentReadDto.getFileIndex());
cmsContent.setFilepath(resjsonArray.toString());
cmsContent.updateById();
return ResultUtil.success("删除附件成功");
}
}
......@@ -4,6 +4,7 @@ import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -53,4 +54,7 @@ public class CmsContentReadDto extends Page implements Serializable {
@ApiModelProperty(value = "更新时间", example = "")
private Date updateTime;
@ApiModelProperty(value = "附件索引", example = "")
private Integer fileIndex;
}
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