Compare commits

..

2 Commits

Author SHA1 Message Date
wangliwen e12f4f0a62 标识为已读支持批量 2022-06-22 11:23:25 +08:00
wangliwen f2ec0b118d 站内信来源标注为 其它 2022-06-22 11:14:20 +08:00
2 changed files with 19 additions and 3 deletions

View File

@ -17,11 +17,15 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Arrays;
import java.util.Map;
@ -34,6 +38,7 @@ import java.util.Map;
@RequestMapping("sys/notice")
@Api(tags = "通知管理")
public class SysNoticeController {
private static Logger logger = LoggerFactory.getLogger(SysNoticeController.class);
@Autowired
private SysNoticeService sysNoticeService;
@Autowired
@ -89,9 +94,19 @@ public class SysNoticeController {
@PutMapping("mynotice/read/{noticeId}")
@ApiOperation("标记我的通知为已读")
public Result read(@PathVariable("noticeId") Long noticeId) {
sysNoticeUserService.updateReadStatus(SecurityUser.getUserId(), noticeId);
public Result read(@PathVariable("noticeId") String noticeId) {
if (StringUtils.isNotEmpty(noticeId) && noticeId.contains(";")) {
String[] noticeIds = noticeId.split(";");
Arrays.asList(noticeIds).stream().distinct().forEach(index -> {
try {
sysNoticeUserService.updateReadStatus(SecurityUser.getUserId(), Long.valueOf(index));
} catch (Exception exception) {
logger.error("标识已读失败", exception);
}
});
} else {
sysNoticeUserService.updateReadStatus(SecurityUser.getUserId(), Long.valueOf(noticeId));
}
return new Result();
}

View File

@ -86,6 +86,7 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
@Transactional(rollbackFor = Exception.class)
public void save(SysNoticeDTO dto) {
SysNoticeEntity entity = ConvertUtils.sourceToTarget(dto, SysNoticeEntity.class);
entity.setFrom("其它"); // 站内信通知来源 (通知评论其它)
//更新发送者信息
if (dto.getStatus() == NoticeStatusEnum.SEND.value() && StringUtils.isEmpty(dto.getSenderName())) {