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,65 +55,65 @@ 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 {
@Autowired
private CmsContentMapper cmsContentMapper;
@Autowired
private CmsContentMapper cmsContentMapper;
@Autowired
private CmsIsReadMapper cmsIsReadMapper;
@Autowired
private CmsIsReadMapper cmsIsReadMapper;
// @Autowired
// private CmsAnnouncementMapper cmsAnnouncementMapper;
/**
* 查询所有讯息
*/
@GetMapping(value = "/hqqyxx")
@ApiOperation(value = "获取企业讯息", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CmsContent>> getQyxx(@CurrentUser UserBean userBean) {
if (userBean.getOrgCode() != null) {
Integer orgCode = userBean.getOrgCode();
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", orgCode);
List<CmsContent> qynr = CmsContent.builder().build().selectList(queryWrapper);
return ResultUtil.data(qynr, "查询成功!");
}
return ResultUtil.error("请登录!");
}
/**
* 查询最新讯息,获取标题和发布时间
*/
@GetMapping(value = "/zxqyxx")
@ApiOperation(value = "获取最新讯息的标题、发布时间", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CmsContent>> groupbyTime(@CurrentUser UserBean userBean) {
Integer orgCode = userBean.getOrgCode();
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.title", "t.author", "t.releasetime", "t.fmtpath")
.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())))
.eq("t.organization_id", orgCode)
.groupBy("t.id")
.orderByDesc("t.releasetime").last("limit 6");
List<CmsContent> qynr = CmsContent.builder().build().selectList(queryWrapper);
return ResultUtil.data(qynr, "查询分类成功!");
}
/**
* 分类,获取标题和发布时间
*
*/
/**
* 查询所有讯息
*/
@GetMapping(value = "/hqqyxx")
@ApiOperation(value = "获取企业讯息", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CmsContent>> getQyxx(@CurrentUser UserBean userBean) {
if (userBean.getOrgCode() != null) {
Integer orgCode = userBean.getOrgCode();
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", orgCode);
List<CmsContent> qynr = CmsContent.builder().build().selectList(queryWrapper);
return ResultUtil.data(qynr, "查询成功!");
}
return ResultUtil.error("请登录!");
}
/**
* 查询最新讯息,获取标题和发布时间
*/
@GetMapping(value = "/zxqyxx")
@ApiOperation(value = "获取最新讯息的标题、发布时间", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CmsContent>> groupbyTime(@CurrentUser UserBean userBean) {
Integer orgCode = userBean.getOrgCode();
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.title", "t.author", "t.releasetime", "t.fmtpath")
.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())))
.eq("t.organization_id", orgCode)
.groupBy("t.id")
.orderByDesc("t.releasetime").last("limit 6");
List<CmsContent> qynr = CmsContent.builder().build().selectList(queryWrapper);
return ResultUtil.data(qynr, "查询分类成功!");
}
/**
* 分类,获取标题和发布时间
*
*/
// @GetMapping(value = "/flhqqyxx")
// @ApiOperation(value = "获取首页分类讯息标题、发布时间", httpMethod = "GET", notes = "接口发布说明")
// public Result<List<List<CmsContent>>> groupbyTpye(@CurrentUser UserBean userBean) {
......@@ -142,625 +143,646 @@ public class CmsController {
// return ResultUtil.data(cmsContentList, "查询成功!");
// }
/**
* 分类内容获取
*
*/
@GetMapping(value = "/getType")
@ApiOperation(value = "分类内容获取", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getType(@CurrentUser UserBean userBean) {
// 分类模块信息
List<CmsContentModular> list = CmsContentModular.builder().build()
.selectList(new QueryWrapper<CmsContentModular>().eq("is_open", 0) // 是否开启
/**
* 分类内容获取
*/
@GetMapping(value = "/getType")
@ApiOperation(value = "分类内容获取", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getType(@CurrentUser UserBean userBean) {
// 分类模块信息
List<CmsContentModular> list = CmsContentModular.builder().build()
.selectList(new QueryWrapper<CmsContentModular>().eq("is_open", 0) // 是否开启
// .eq("organization_id", userBean.getOrgCode())
);
List<List<CmsContent>> o = new ArrayList<List<CmsContent>>();
for (CmsContentModular cmsContentModular : list) {
// 分类模块id
Integer id = cmsContentModular.getId();
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.modularid", "t.title", "t.author", "t.releasetime")
.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())))
.eq("t.organization_id", userBean.getOrgCode()).eq("t.modularid", id)
.groupBy("t.id")
.orderByDesc("t.releasetime")
.last("limit 5");
List<CmsContent> qynrs = CmsContent.builder().build().selectList(queryWrapper);
o.add(qynrs);
}
return ResultUtil.data(o, "查询成功!");
}
/**
* 获取分类
*
*/
@GetMapping(value = "/xxfl")
@ApiOperation(value = "获取分类", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getxxfl(@CurrentUser UserBean userBean) {
return ResultUtil.data(CmsContentModular.builder().build().selectList(new QueryWrapper<CmsContentModular>()
);
List<List<CmsContent>> o = new ArrayList<List<CmsContent>>();
for (CmsContentModular cmsContentModular : list) {
// 分类模块id
Integer id = cmsContentModular.getId();
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.modularid", "t.title", "t.author", "t.releasetime")
.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())))
.eq("t.organization_id", userBean.getOrgCode()).eq("t.modularid", id)
.groupBy("t.id")
.orderByDesc("t.releasetime")
.last("limit 5");
List<CmsContent> qynrs = CmsContent.builder().build().selectList(queryWrapper);
o.add(qynrs);
}
return ResultUtil.data(o, "查询成功!");
}
/**
* 获取分类
*/
@GetMapping(value = "/xxfl")
@ApiOperation(value = "获取分类", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getxxfl(@CurrentUser UserBean userBean) {
return ResultUtil.data(CmsContentModular.builder().build().selectList(new QueryWrapper<CmsContentModular>()
// .eq("organization_id", userBean.getOrgCode())
.eq("is_open", 0)
.orderByAsc("sort")), "查询分类成功!");
}
.eq("is_open", 0)
.orderByAsc("sort")), "查询分类成功!");
}
/**
* 新增/修改企业OA讯息
*/
@PostMapping(value = "/updateqyxx")
@ApiOperation(value = "添加/修改企业OA讯息", httpMethod = "POST", notes = "接口发布说明")
public Result<CmsContent> updateqyxx(@CurrentUser UserBean userBean, @RequestBody CmsContentDto cmsContentDto) {
/**
* 新增/修改企业OA讯息
*/
@PostMapping(value = "/updateqyxx")
@ApiOperation(value = "添加/修改企业OA讯息", httpMethod = "POST", notes = "接口发布说明")
public Result<CmsContent> updateqyxx(@CurrentUser UserBean userBean, @RequestBody CmsContentDto cmsContentDto) {
Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
// String str = StringUtils.join(cmsContentDto.getFilepath(), ","); // 数组转字符串(逗号分隔)(推荐)
CmsContent qynr = new CmsContent();
BeanUtil.copyProperties(cmsContentDto, qynr);
CmsContent qynr = new CmsContent();
BeanUtil.copyProperties(cmsContentDto, qynr);
// qynr.setFilepath(str);
// Integer i = 10000;
// qynr.setXxbh("XX" + i++);
Boolean a = qynr.getId() == null;
if(a){
qynr.setUserid(empNum);
}
if (a && qynr.getPublisher() == null)
qynr.setPublisher(empNum);
qynr.setOrganizationId(orgCode);
Long now = new Date().getTime();
// 录入时间
qynr.setAddeddate(now);
// 发布方式:1,审核通过后立即发布,2定时发布,3手动发布,4立即发布
Integer fbfs = qynr.getReleasetype();
// 定时
if (fbfs != null && fbfs == 2) {
qynr.setReleasetime(qynr.getReleasetime());
}
qynr.setPublisherName(YgglMainEmp.builder().build().selectOne(new LambdaQueryWrapper<YgglMainEmp>()
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum)).getName());
qynr.setReleasetype(fbfs);
qynr.setStatus(0);
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() ) {
entity.setCmsContentId(qynr.getId());
entity.setOrgCode(orgCode);
entity.setReadStatus(0);
entity.setDeleteFlag(0);
entity.insert();
}
}
}
if (a){
String msg = fbfs==4?"提交成功":"提交成功、等待管理员审核";
return ResultUtil.data(qynr, msg);
} else {
return ResultUtil.data(qynr, "修改成功");
}
}
/**
* 删除企业OA讯息
*/
@DeleteMapping(value = "/deleteqyxx")
@ApiOperation(value = "删除企业OA讯息", httpMethod = "DELETE", notes = "接口发布说明")
public Result<CmsContent> deleteqyxx(@CurrentUser UserBean userBean, @RequestBody List<CmsContent> ids) {
if (ids != null) {
cmsContentMapper.deleteBatchIds(ids);
return ResultUtil.success("删除成功");
}
return ResultUtil.error("没这个id");
}
/**
* 审核企业OA讯息
*/
@PostMapping(value = "/shqyxx")
@ApiOperation(value = "审核企业OA讯息", httpMethod = "POST", notes = "接口发布说明")
public Result<CmsContent> shqyxx(@CurrentUser UserBean userBean, @RequestBody CmsContent qynr) {
Long now = new Date().getTime();
Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum));
if (ygglMainEmp != null) {
qynr.setAuditor(ygglMainEmp.getName());// 审核人
}
qynr.setAudittime(now.toString());// 审核时间
qynr.setAuditopinion(qynr.getAuditopinion());// 审核意见
// 如果通过审核
if (qynr.getStatus() == 1) {
if (qynr.getReleasetype() != null && qynr.getReleasetype() == 1) { // 发布方式为审核通过立即发布,设置发布时间为now
qynr.setReleasetime(now.toString());
// 已发布
qynr.setReleasestate(0);
} else if (qynr.getReleasetype() == 2) { // 定时发布
QueryWrapper<CmsContent> q = new QueryWrapper<CmsContent>();
q.select("id", "releasetime").eq("id", qynr.getId());
CmsContent c = CmsContent.builder().build().selectOne(q);
// 发布时间
Long fbsj = Long.parseLong(c.getReleasetime());
Date date = DateUtil.date(fbsj);
// 设置为定时发布中
qynr.setReleasestate(3);
qynr.updateById();
// 设置开始定时发布
Long deley = fbsj - now;
if (deley >= 0) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
qynr.setReleasestate(0);
qynr.updateById();
timer.cancel();
}
}, date);
} else {
qynr.setReleasestate(0);
}
} else if (qynr.getReleasetype() == 3) { // 手动发布
// 未发布
qynr.setReleasestate(1);
}
}
qynr.updateById();
return ResultUtil.data(qynr, "审核完成");
}
/**
* 企业OA讯息查询
*/
@PostMapping(value = "/qyxxquery")
@ApiOperation(value = "搜索OA讯息记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> qyxxquery(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer t = qyxxQueryDto.getModularid();
Integer r = qyxxQueryDto.getReleasestate();
String q = qyxxQueryDto.getQuery();
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
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.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",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("t.userid", q).or().like("t.author", q).or().like("title", q))
.groupBy("t.id")
.orderByDesc("t.addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
cmsContentPage.getPages();
cmsContentPage.getTotal();
cmsContentPage.getSize();
return ResultUtil.data(cmsContentPage, cmsContents, "企业OA讯息搜索成功");
}
/**
* 企业OA讯息查询
*/
@PostMapping(value = "/oaalllist")
@ApiOperation(value = "搜索OA讯息记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> oaAllList(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer t = qyxxQueryDto.getModularid();
Integer r = qyxxQueryDto.getReleasestate();
String q = qyxxQueryDto.getQuery();
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode())
.eq(t != null && t > -1, "modularid", t).eq(r != null && r > -1, "releasestate", r)
.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(!StrUtil.hasBlank(q), wq -> wq.like("userid", q).or().like("author", q).or().like("title", q))
.orderByDesc("addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
cmsContentPage.getPages();
cmsContentPage.getTotal();
cmsContentPage.getSize();
return ResultUtil.data(cmsContentPage, cmsContents, "企业OA讯息搜索成功");
}
@PostMapping(value = "/oaCirculate")
@ApiOperation(value = "搜索OA文件传阅记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> oaCirculate(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer r = qyxxQueryDto.getReleasestate();
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode())
.eq("modularid", 7).eq(r != null && r > -1, "releasestate", r)
.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()))
.orderByDesc("addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
cmsContentPage.getPages();
cmsContentPage.getTotal();
cmsContentPage.getSize();
return ResultUtil.data(cmsContentPage, cmsContents, "企业OA讯息搜索成功");
}
/**
* 根据id查讯息
*
* @param id
* @return
*/
@GetMapping(value = "/returnpath")
@ApiOperation(value = "根据id查讯息", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> returnPath(@CurrentUser UserBean userBean, @RequestParam Integer id) {
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", id);
CmsContent cmsContent = CmsContent.builder().build().selectOne(queryWrapper);
Boolean a = qynr.getId() == null;
if (a) {
qynr.setUserid(empNum);
}
if (a && qynr.getPublisher() == null)
qynr.setPublisher(empNum);
qynr.setOrganizationId(orgCode);
Long now = new Date().getTime();
// 录入时间
qynr.setAddeddate(now);
// 发布方式:1,审核通过后立即发布,2定时发布,3手动发布,4立即发布
Integer fbfs = qynr.getReleasetype();
// 定时
if (fbfs != null && fbfs == 2) {
qynr.setReleasetime(qynr.getReleasetime());
}
qynr.setPublisherName(YgglMainEmp.builder().build().selectOne(new LambdaQueryWrapper<YgglMainEmp>()
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum)).getName());
qynr.setReleasetype(fbfs);
qynr.setStatus(0);
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()) {
entity.setCmsContentId(qynr.getId());
entity.setOrgCode(orgCode);
entity.setReadStatus(0);
entity.setDeleteFlag(0);
entity.insert();
}
}
}
if (a) {
String msg = fbfs == 4 ? "提交成功" : "提交成功、等待管理员审核";
return ResultUtil.data(qynr, msg);
} else {
return ResultUtil.data(qynr, "修改成功");
}
}
/**
* 删除企业OA讯息
*/
@DeleteMapping(value = "/deleteqyxx")
@ApiOperation(value = "删除企业OA讯息", httpMethod = "DELETE", notes = "接口发布说明")
public Result<CmsContent> deleteqyxx(@CurrentUser UserBean userBean, @RequestBody List<CmsContent> ids) {
if (ids != null) {
cmsContentMapper.deleteBatchIds(ids);
return ResultUtil.success("删除成功");
}
return ResultUtil.error("没这个id");
}
/**
* 审核企业OA讯息
*/
@PostMapping(value = "/shqyxx")
@ApiOperation(value = "审核企业OA讯息", httpMethod = "POST", notes = "接口发布说明")
public Result<CmsContent> shqyxx(@CurrentUser UserBean userBean, @RequestBody CmsContent qynr) {
Long now = new Date().getTime();
Integer orgCode = userBean.getOrgCode();
Integer empNum = userBean.getEmpNum();
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum));
if (ygglMainEmp != null) {
qynr.setAuditor(ygglMainEmp.getName());// 审核人
}
qynr.setAudittime(now.toString());// 审核时间
qynr.setAuditopinion(qynr.getAuditopinion());// 审核意见
// 如果通过审核
if (qynr.getStatus() == 1) {
if (qynr.getReleasetype() != null && qynr.getReleasetype() == 1) { // 发布方式为审核通过立即发布,设置发布时间为now
qynr.setReleasetime(now.toString());
// 已发布
qynr.setReleasestate(0);
} else if (qynr.getReleasetype() == 2) { // 定时发布
QueryWrapper<CmsContent> q = new QueryWrapper<CmsContent>();
q.select("id", "releasetime").eq("id", qynr.getId());
CmsContent c = CmsContent.builder().build().selectOne(q);
// 发布时间
Long fbsj = Long.parseLong(c.getReleasetime());
Date date = DateUtil.date(fbsj);
// 设置为定时发布中
qynr.setReleasestate(3);
qynr.updateById();
// 设置开始定时发布
Long deley = fbsj - now;
if (deley >= 0) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
qynr.setReleasestate(0);
qynr.updateById();
timer.cancel();
}
}, date);
} else {
qynr.setReleasestate(0);
}
} else if (qynr.getReleasetype() == 3) { // 手动发布
// 未发布
qynr.setReleasestate(1);
}
}
qynr.updateById();
return ResultUtil.data(qynr, "审核完成");
}
/**
* 企业OA讯息查询
*/
@PostMapping(value = "/qyxxquery")
@ApiOperation(value = "搜索OA讯息记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> qyxxquery(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer t = qyxxQueryDto.getModularid();
Integer r = qyxxQueryDto.getReleasestate();
String q = qyxxQueryDto.getQuery();
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
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.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",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("t.userid", q).or().like("t.author", q).or().like("title", q))
.groupBy("t.id")
.orderByDesc("t.addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
cmsContentPage.getPages();
cmsContentPage.getTotal();
cmsContentPage.getSize();
return ResultUtil.data(cmsContentPage, cmsContents, "企业OA讯息搜索成功");
}
/**
* 企业OA讯息查询
*/
@PostMapping(value = "/oaalllist")
@ApiOperation(value = "搜索OA讯息记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> oaAllList(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer t = qyxxQueryDto.getModularid();
Integer r = qyxxQueryDto.getReleasestate();
String q = qyxxQueryDto.getQuery();
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode())
.eq(t != null && t > -1, "modularid", t).eq(r != null && r > -1, "releasestate", r)
.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(!StrUtil.hasBlank(q), wq -> wq.like("userid", q).or().like("author", q).or().like("title", q))
.orderByDesc("addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
cmsContentPage.getPages();
cmsContentPage.getTotal();
cmsContentPage.getSize();
return ResultUtil.data(cmsContentPage, cmsContents, "企业OA讯息搜索成功");
}
@PostMapping(value = "/oaCirculate")
@ApiOperation(value = "搜索OA文件传阅记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> oaCirculate(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer r = qyxxQueryDto.getReleasestate();
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode())
.eq("modularid", 7).eq(r != null && r > -1, "releasestate", r)
.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()))
.orderByDesc("addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
cmsContentPage.getPages();
cmsContentPage.getTotal();
cmsContentPage.getSize();
return ResultUtil.data(cmsContentPage, cmsContents, "企业OA讯息搜索成功");
}
/**
* 根据id查讯息
*
* @param id
* @return
*/
@GetMapping(value = "/returnpath")
@ApiOperation(value = "根据id查讯息", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> returnPath(@CurrentUser UserBean userBean, @RequestParam Integer id) {
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", id);
CmsContent cmsContent = CmsContent.builder().build().selectOne(queryWrapper);
// String[] f = null;
// if (cmsContent != null && cmsContent.getFilepath() != null) {
// f = cmsContent.getFilepath().split(",");
// }
CmsContentDto cmsContentDto = new CmsContentDto();
BeanUtil.copyProperties(cmsContent, cmsContentDto);
CmsContentDto cmsContentDto = new CmsContentDto();
BeanUtil.copyProperties(cmsContent, cmsContentDto);
// cmsContentDto.setFilepath(f);
return ResultUtil.data(cmsContentDto);
}
/**
* OA审核讯息查询搜索
*/
@PostMapping(value = "/shxxquery")
@ApiOperation(value = "搜索OA讯息审核记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> shxxquery(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer t = qyxxQueryDto.getModularid();
String q = qyxxQueryDto.getQuery();
// 分页
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
// 查询条件
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")
.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",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("userid", q).or().like("author", q).or().like("title", q))
.orderByDesc("addeddate");
IPage<CmsContent> CmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> CmsContents = CmsContentPage.getRecords();
CmsContentPage.getCurrent();
CmsContentPage.getPages();
CmsContentPage.getTotal();
CmsContentPage.getSize();
return ResultUtil.data(CmsContentPage, CmsContents, "企业OA讯息审核情况搜索成功");
}
/**
* 讯息发布
*
* @param id
*/
@GetMapping(value = "/qyxxsdfb/{id}")
@ApiOperation(value = "OA讯息手动发布", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> qyxxsdfb(@CurrentUser UserBean userBean, @PathVariable Integer id) {
// 根据id将状态设为发布
CmsContent q = new CmsContent();
UpdateWrapper<CmsContent> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
Long now = new Date().getTime();// 时间毫秒数
q = CmsContent.builder().organizationId(userBean.getOrgCode()).id(id).releasestate(0)
.releasetime(now.toString()).build();
cmsContentMapper.update(q, updateWrapper);
return ResultUtil.success("发布成功");
}
/**
* 讯息收回
*
* @param id
*/
@GetMapping(value = "/qyxxtb/{id}")
@ApiOperation(value = "OA讯息发布收回", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> takeBack(@CurrentUser UserBean userBean, @PathVariable Integer id) {
// 根据id将状态设为收回
CmsContent q = new CmsContent();
UpdateWrapper<CmsContent> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
Date now = new Date();
q = CmsContent.builder().organizationId(userBean.getOrgCode()).id(id).releasestate(2)
.takeBack(userBean.getEmpNum()).takeBackTime(now.toString()).build();
cmsContentMapper.update(q, updateWrapper);
return ResultUtil.success("收回成功");
}
/**
* 添加已读
*
* @param userBean
* @return
*/
@GetMapping(value = "/isread")
@ApiOperation(value = "添加已读人", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> isRead(@CurrentUser UserBean userBean, Integer mid) {
Integer empNum = userBean.getEmpNum();
QueryWrapper<CmsIsRead> q = new QueryWrapper<CmsIsRead>();
q.eq("mid", mid).eq("uid", empNum);
CmsIsRead cmsIsRead = CmsIsRead.builder().build().selectOne(q);
if (!q.equals(null)) {
cmsIsRead.setMid(mid);
cmsIsRead.setUid(empNum);
cmsIsRead.setReadTime(new Date());
cmsIsRead.insert();
return ResultUtil.success("添加成功");
}
return ResultUtil.success("已存在");
}
/**
* 查询已读人
*
* @param userBean
* @param mid
* @return
*/
@PostMapping(value = "/qisread")
@ApiOperation(value = "查询讯息已读人", httpMethod = "POST", notes = "接口发布说明")
public Result<QyxxIsReadDto> queryIsRead(@CurrentUser UserBean userBean, @RequestBody Integer mid) {
QyxxIsReadDto q = cmsIsReadMapper.queryIsReadEmp(userBean.getOrgCode(), mid);
return ResultUtil.data(q, "查询成功");
}
/******************* 以下轮播信息 ************************/
/**
* 新增/修改轮播信息
*/
@PostMapping(value = "/addCarousel")
@ApiOperation(value = "新增轮播信息", httpMethod = "POST", notes = "接口发布说明")
public Result<CmsAnnouncement> addCarousel(@CurrentUser UserBean userBean,
@RequestBody CmsAnnouncement cmsAnnouncement) {
cmsAnnouncement.setFbrid(userBean.getEmpNum());
cmsAnnouncement.setFbtime(new Date());
cmsAnnouncement.setOrgCode(userBean.getOrgCode());
cmsAnnouncement.insertOrUpdate();
return ResultUtil.data(cmsAnnouncement, "新增/修改成功");
}
/**
* 删除轮播信息
*/
@DeleteMapping(value = "/delCarousel/{id}")
@ApiOperation(value = "删除轮播信息", httpMethod = "DELETE", notes = "接口发布说明")
public Result<Object> delCarousel(@CurrentUser UserBean userBean, @PathVariable Integer id) {
Integer orgCode = userBean.getOrgCode();
return ResultUtil.data(CmsAnnouncement.builder().build()
.delete(new QueryWrapper<CmsAnnouncement>().eq("org_code", orgCode).eq("id", id)), "删除成功");
}
/**
* 查询轮播信息列表
*/
@PostMapping(value = "/queryCarousel")
@ApiOperation(value = "查询轮播信息", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> delCarousel(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
String q = qyxxQueryDto.getQuery();
Page<CmsAnnouncement> page = new Page<CmsAnnouncement>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsAnnouncement> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("org_code", userBean.getOrgCode());
queryWrapper.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "fbtime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00", !StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("title", q).or().like("fbnr", q)).orderByDesc("fbtime");
IPage<CmsAnnouncement> cmsAnnouncementPage = CmsAnnouncement.builder().build().selectPage(page, queryWrapper);
List<CmsAnnouncement> cmsAnnouncements = cmsAnnouncementPage.getRecords();
cmsAnnouncementPage.getCurrent();
cmsAnnouncementPage.getPages();
cmsAnnouncementPage.getTotal();
cmsAnnouncementPage.getSize();
return ResultUtil.data(cmsAnnouncementPage, cmsAnnouncements, "查询成功");
}
/**
* 查询默认轮播信息
*/
@GetMapping(value = "/defaultCarousel")
@ApiOperation(value = "查询轮播信息(默认)", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> defaultCarousel(@CurrentUser UserBean userBean) {
return ResultUtil.data(
CmsAnnouncement.builder().build().selectOne(
new QueryWrapper<CmsAnnouncement>().eq("is_default", 1).eq("org_code", userBean.getOrgCode())),
"查询成功");
}
/**
* 设置默认
*/
@GetMapping(value = "/default/{id}")
@ApiOperation(value = "设置默认轮播信息", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> setDefault(@CurrentUser UserBean userBean, @PathVariable("id") Integer id) {
// 将所有设为非默认
boolean cmsAnnouncement = CmsAnnouncement.builder().isDefault(0).build().update(
new LambdaQueryWrapper<CmsAnnouncement>().eq(CmsAnnouncement::getOrgCode, userBean.getOrgCode()));
// 根据id设为默认
if (cmsAnnouncement) {
if (CmsAnnouncement.builder().id(id).isDefault(1).build().updateById())
return ResultUtil.success("设置成功");
else
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()).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();
}
/**
* 根据讯息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");
//用户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());
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
) {
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()));
}
return ResultUtil.data(cmsContentDto);
}
/**
* OA审核讯息查询搜索
*/
@PostMapping(value = "/shxxquery")
@ApiOperation(value = "搜索OA讯息审核记录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> shxxquery(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
Integer t = qyxxQueryDto.getModularid();
String q = qyxxQueryDto.getQuery();
// 分页
Page<CmsContent> page = new Page<CmsContent>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
// 查询条件
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")
.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",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("userid", q).or().like("author", q).or().like("title", q))
.orderByDesc("addeddate");
IPage<CmsContent> CmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> CmsContents = CmsContentPage.getRecords();
CmsContentPage.getCurrent();
CmsContentPage.getPages();
CmsContentPage.getTotal();
CmsContentPage.getSize();
return ResultUtil.data(CmsContentPage, CmsContents, "企业OA讯息审核情况搜索成功");
}
/**
* 讯息发布
*
* @param id
*/
@GetMapping(value = "/qyxxsdfb/{id}")
@ApiOperation(value = "OA讯息手动发布", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> qyxxsdfb(@CurrentUser UserBean userBean, @PathVariable Integer id) {
// 根据id将状态设为发布
CmsContent q = new CmsContent();
UpdateWrapper<CmsContent> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
Long now = new Date().getTime();// 时间毫秒数
q = CmsContent.builder().organizationId(userBean.getOrgCode()).id(id).releasestate(0)
.releasetime(now.toString()).build();
cmsContentMapper.update(q, updateWrapper);
return ResultUtil.success("发布成功");
}
/**
* 讯息收回
*
* @param id
*/
@GetMapping(value = "/qyxxtb/{id}")
@ApiOperation(value = "OA讯息发布收回", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> takeBack(@CurrentUser UserBean userBean, @PathVariable Integer id) {
// 根据id将状态设为收回
CmsContent q = new CmsContent();
UpdateWrapper<CmsContent> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
Date now = new Date();
q = CmsContent.builder().organizationId(userBean.getOrgCode()).id(id).releasestate(2)
.takeBack(userBean.getEmpNum()).takeBackTime(now.toString()).build();
cmsContentMapper.update(q, updateWrapper);
return ResultUtil.success("收回成功");
}
/**
* 添加已读
*
* @param userBean
* @return
*/
@GetMapping(value = "/isread")
@ApiOperation(value = "添加已读人", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> isRead(@CurrentUser UserBean userBean, Integer mid) {
Integer empNum = userBean.getEmpNum();
QueryWrapper<CmsIsRead> q = new QueryWrapper<CmsIsRead>();
q.eq("mid", mid).eq("uid", empNum);
CmsIsRead cmsIsRead = CmsIsRead.builder().build().selectOne(q);
if (!q.equals(null)) {
cmsIsRead.setMid(mid);
cmsIsRead.setUid(empNum);
cmsIsRead.setReadTime(new Date());
cmsIsRead.insert();
return ResultUtil.success("添加成功");
}
return ResultUtil.success("已存在");
}
/**
* 查询已读人
*
* @param userBean
* @param mid
* @return
*/
@PostMapping(value = "/qisread")
@ApiOperation(value = "查询讯息已读人", httpMethod = "POST", notes = "接口发布说明")
public Result<QyxxIsReadDto> queryIsRead(@CurrentUser UserBean userBean, @RequestBody Integer mid) {
QyxxIsReadDto q = cmsIsReadMapper.queryIsReadEmp(userBean.getOrgCode(), mid);
return ResultUtil.data(q, "查询成功");
}
/******************* 以下轮播信息 ************************/
/**
* 新增/修改轮播信息
*/
@PostMapping(value = "/addCarousel")
@ApiOperation(value = "新增轮播信息", httpMethod = "POST", notes = "接口发布说明")
public Result<CmsAnnouncement> addCarousel(@CurrentUser UserBean userBean,
@RequestBody CmsAnnouncement cmsAnnouncement) {
cmsAnnouncement.setFbrid(userBean.getEmpNum());
cmsAnnouncement.setFbtime(new Date());
cmsAnnouncement.setOrgCode(userBean.getOrgCode());
cmsAnnouncement.insertOrUpdate();
return ResultUtil.data(cmsAnnouncement, "新增/修改成功");
}
/**
* 删除轮播信息
*/
@DeleteMapping(value = "/delCarousel/{id}")
@ApiOperation(value = "删除轮播信息", httpMethod = "DELETE", notes = "接口发布说明")
public Result<Object> delCarousel(@CurrentUser UserBean userBean, @PathVariable Integer id) {
Integer orgCode = userBean.getOrgCode();
return ResultUtil.data(CmsAnnouncement.builder().build()
.delete(new QueryWrapper<CmsAnnouncement>().eq("org_code", orgCode).eq("id", id)), "删除成功");
}
/**
* 查询轮播信息列表
*/
@PostMapping(value = "/queryCarousel")
@ApiOperation(value = "查询轮播信息", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> delCarousel(@CurrentUser UserBean userBean, @RequestBody QyxxQueryDto qyxxQueryDto) {
String s = qyxxQueryDto.getStartTime();
String e = qyxxQueryDto.getEndTime();
String q = qyxxQueryDto.getQuery();
Page<CmsAnnouncement> page = new Page<CmsAnnouncement>(
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsAnnouncement> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("org_code", userBean.getOrgCode());
queryWrapper.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "fbtime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00", !StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("title", q).or().like("fbnr", q)).orderByDesc("fbtime");
IPage<CmsAnnouncement> cmsAnnouncementPage = CmsAnnouncement.builder().build().selectPage(page, queryWrapper);
List<CmsAnnouncement> cmsAnnouncements = cmsAnnouncementPage.getRecords();
cmsAnnouncementPage.getCurrent();
cmsAnnouncementPage.getPages();
cmsAnnouncementPage.getTotal();
cmsAnnouncementPage.getSize();
return ResultUtil.data(cmsAnnouncementPage, cmsAnnouncements, "查询成功");
}
/**
* 查询默认轮播信息
*/
@GetMapping(value = "/defaultCarousel")
@ApiOperation(value = "查询轮播信息(默认)", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> defaultCarousel(@CurrentUser UserBean userBean) {
return ResultUtil.data(
CmsAnnouncement.builder().build().selectOne(
new QueryWrapper<CmsAnnouncement>().eq("is_default", 1).eq("org_code", userBean.getOrgCode())),
"查询成功");
}
/**
* 设置默认
*/
@GetMapping(value = "/default/{id}")
@ApiOperation(value = "设置默认轮播信息", httpMethod = "GET", notes = "接口发布说明")
public Result<Void> setDefault(@CurrentUser UserBean userBean, @PathVariable("id") Integer id) {
// 将所有设为非默认
boolean cmsAnnouncement = CmsAnnouncement.builder().isDefault(0).build().update(
new LambdaQueryWrapper<CmsAnnouncement>().eq(CmsAnnouncement::getOrgCode, userBean.getOrgCode()));
// 根据id设为默认
if (cmsAnnouncement) {
if (CmsAnnouncement.builder().id(id).isDefault(1).build().updateById())
return ResultUtil.success("设置成功");
else
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()).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();
}
/**
* 根据讯息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");
//用户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());
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
) {
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