Commit 7a4d4c0e authored by unset's avatar unset

添加通知信息

parent e53f8b90
......@@ -16,4 +16,6 @@ public class NoticeInfoDto extends PageParam {
Integer read;
String ids;
}
......@@ -2,8 +2,10 @@ package com.upyuns.platform.rs.website.biz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.upyuns.platform.rs.website.dto.NoticeInfoDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.upyuns.platform.rs.website.entity.NoticeInfo;
......@@ -12,6 +14,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -47,4 +50,70 @@ public class NoticeInfoBiz extends BaseBiz<NoticeInfoMapper,NoticeInfo> {
return ObjectRestResponse.succ(pageDataVO);
}
public ObjectRestResponse deleteOne(Integer id) {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
NoticeInfo noticeInfo = selectById(id);
if (noticeInfo == null || noticeInfo.getIsDel() == 1) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
}
noticeInfo.setIsDel(1);
updateSelectiveByIdRe(noticeInfo);
return ObjectRestResponse.succ();
}
/**
* 设置为已读
* @param id
* @return
*/
public ObjectRestResponse updateRead(Integer id) {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
NoticeInfo noticeInfo = selectById(id);
if (noticeInfo == null || noticeInfo.getIsDel() == 1) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
}
noticeInfo.setIsRead(2);
updateSelectiveByIdRe(noticeInfo);
return ObjectRestResponse.succ();
}
/**
* 设置为已读
* @param ids
* @return
*/
public ObjectRestResponse updateAllRead(String ids) {
if (StringUtils.isBlank(ids)) {
return ObjectRestResponse.paramIsEmpty();
}
String[] arr = ids.split(",");
if (arr == null) {
return ObjectRestResponse.paramIsEmpty();
}
for (String id : arr) {
updateRead(Integer.parseInt(id));
}
return ObjectRestResponse.succ();
}
public ObjectRestResponse updateAll(NoticeInfoDto noticeInfoDto) {
Example example = new Example(NoticeInfo.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isRead", 1);
criteria.andEqualTo("userId", noticeInfoDto.getUserId());
List<NoticeInfo> list = mapper.selectByExample(example);
if (list != null && list.size() > 0) {
list.parallelStream().forEach(noticeInfo -> {
noticeInfo.setIsRead(2);
updateSelectiveByIdRe(noticeInfo);
});
}
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
......@@ -8,9 +8,7 @@ import com.upyuns.platform.rs.website.biz.NoticeInfoBiz;
import com.upyuns.platform.rs.website.dto.NoticeInfoDto;
import com.upyuns.platform.rs.website.entity.NoticeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("noticeInfo/web")
......@@ -29,4 +27,25 @@ public class NoticeInfoWebController extends BaseController<NoticeInfoBiz,Notice
noticeInfoDto.setUserId(Integer.parseInt(getCurrentUserId()));
return baseBiz.getByUserId(noticeInfoDto);
}
@DeleteMapping(value = "deleteOne")
public ObjectRestResponse deleteOne(Integer id) {
return baseBiz.deleteOne(id);
}
@PostMapping(value = "updateRead")
public ObjectRestResponse updateRead(NoticeInfo noticeInfo) {
return baseBiz.updateRead(noticeInfo.getId());
}
@PostMapping(value = "updateAllRead")
public ObjectRestResponse updateAllRead(@RequestBody NoticeInfoDto noticeInfoDto) {
return baseBiz.updateAllRead(noticeInfoDto.getIds());
}
@PostMapping(value = "updateAll")
public ObjectRestResponse updateAll(@RequestBody NoticeInfoDto noticeInfoDto) {
noticeInfoDto.setUserId(Integer.parseInt(getCurrentUserId()));
return baseBiz.updateAll(noticeInfoDto);
}
}
\ No newline at end of file
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