通知公告中新增被通知人是否已经查看该通知的功能(类似浙政钉的已读),不好实现的话让接收人那里加个【已阅】的按钮,发布人那里能看到谁点了
This commit is contained in:
parent
7745db197c
commit
6a04a56f18
|
@ -27,7 +27,7 @@ public class Generator {
|
|||
|
||||
public static void main(String[] args) {
|
||||
//表名
|
||||
String tableName = "t_integrated_meeting_user";
|
||||
String tableName = "t_integrated_notice_user";
|
||||
//表前缀
|
||||
String tablePrefix = "t_integrated_";
|
||||
//作者—
|
||||
|
|
|
@ -8,7 +8,9 @@ import com.ydool.common.base.BaseController;
|
|||
import com.ydool.common.constant.UrlConstant;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.integrated.dto.DocumentDto;
|
||||
import com.ydool.integrated.dto.NoticeDto;
|
||||
import com.ydool.integrated.service.NoticeService;
|
||||
import com.ydool.integrated.service.NoticeUserService;
|
||||
import com.ydool.integrated.vo.IdsVo;
|
||||
import com.ydool.integrated.vo.NoticeVo;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -27,6 +29,9 @@ public class NoticeController extends BaseController {
|
|||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Autowired
|
||||
private NoticeUserService noticeUserService;
|
||||
|
||||
/**
|
||||
* 保存通知
|
||||
*
|
||||
|
@ -95,7 +100,7 @@ public class NoticeController extends BaseController {
|
|||
@ApiOperation(value = "详情")
|
||||
@ApiOperationSupport(
|
||||
responses = @DynamicResponseParameters(properties = {
|
||||
@DynamicParameter(name = "data", dataTypeClass = DocumentDto.class)
|
||||
@DynamicParameter(name = "data", dataTypeClass = NoticeDto.class)
|
||||
}), order = 5
|
||||
)
|
||||
public AjaxResult noticeDetails(String id) {
|
||||
|
@ -123,11 +128,25 @@ public class NoticeController extends BaseController {
|
|||
})
|
||||
@ApiOperationSupport(
|
||||
responses = @DynamicResponseParameters(properties = {
|
||||
@DynamicParameter(name = "data", dataTypeClass = DocumentDto.class)
|
||||
@DynamicParameter(name = "data", dataTypeClass = NoticeDto.class)
|
||||
}),
|
||||
order = 6
|
||||
)
|
||||
public AjaxResult noticePages(String value, String column, String orderBy, String type,Boolean isUrgent) {
|
||||
return noticeService.noticePages(getPage(), value, column, orderBy,type,isUrgent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 已阅
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "read")
|
||||
@ApiOperation(value = "已阅")
|
||||
@ApiImplicitParam(name = "id", value = "Id")
|
||||
@ApiOperationSupport(order = 7)
|
||||
public AjaxResult readNotice(String id) {
|
||||
return noticeUserService.readNotice(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class NoticeDto extends Notice {
|
||||
|
@ -16,4 +18,13 @@ public class NoticeDto extends Notice {
|
|||
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updatedName;
|
||||
|
||||
@ApiModelProperty(value = "已读人员")
|
||||
private List<NoticeUserDto> readUserList;
|
||||
|
||||
@ApiModelProperty(value = "是否已阅")
|
||||
private Boolean isRead;
|
||||
|
||||
@ApiModelProperty(value = "是否创建人")
|
||||
private Boolean isCreated;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.ydool.integrated.dto;
|
||||
|
||||
import com.ydool.integrated.entity.NoticeUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class NoticeUserDto extends NoticeUser {
|
||||
@ApiModelProperty(value = "接收人")
|
||||
private String userName;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.ydool.integrated.entity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ydool.common.base.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
/**
|
||||
* <p>
|
||||
* 通知管理阅读人员表
|
||||
* </p>
|
||||
*
|
||||
* @author zhouyuan
|
||||
* @since 2023-10-23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_integrated_notice_user")
|
||||
@ApiModel(value="NoticeUser对象", description="通知管理阅读人员表")
|
||||
public class NoticeUser extends BaseEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "接收人")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "通知管理id")
|
||||
private String noticeId;
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.ydool.integrated.mapper;
|
||||
|
||||
import com.ydool.integrated.entity.NoticeUser;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通知管理阅读人员表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zhouyuan
|
||||
* @since 2023-10-23
|
||||
*/
|
||||
@Mapper
|
||||
public interface NoticeUserMapper extends MPJBaseMapper<NoticeUser> {
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.ydool.integrated.service;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydool.common.base.BaseService;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.integrated.entity.NoticeUser;
|
||||
import com.ydool.integrated.mapper.NoticeUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通知管理阅读人员表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zhouyuan
|
||||
* @since 2023-10-23
|
||||
*/
|
||||
@Service
|
||||
public class NoticeUserService extends BaseService<NoticeUserMapper, NoticeUser> {
|
||||
|
||||
public AjaxResult readNotice(String id) {
|
||||
|
||||
int count = count(new QueryWrapper<NoticeUser>()
|
||||
.lambda()
|
||||
.eq(NoticeUser::getNoticeId, id)
|
||||
.eq(NoticeUser::getUserId, StpUtil.getLoginIdAsString())
|
||||
);
|
||||
if (count > 0) {
|
||||
return AjaxResult.fail("已经阅读过了");
|
||||
}
|
||||
NoticeUser noticeUser = new NoticeUser();
|
||||
noticeUser.setNoticeId(id);
|
||||
noticeUser.setUserId(StpUtil.getLoginIdAsString());
|
||||
save(noticeUser);
|
||||
return AjaxResult.ok().msg("阅读成功");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.ydool.integrated.wrapper;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.ydool.common.base.BaseWrapper;
|
||||
import com.ydool.integrated.dto.NoticeUserDto;
|
||||
|
||||
import com.ydool.integrated.entity.NoticeUser;
|
||||
import com.ydool.system.entity.User;
|
||||
import com.ydool.system.service.impl.UserServiceImpl;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface NoticeUserWrapper extends BaseWrapper<NoticeUser, NoticeUserDto> {
|
||||
|
||||
NoticeUserWrapper INSTANCE = Mappers.getMapper(NoticeUserWrapper.class);
|
||||
|
||||
|
||||
@AfterMapping
|
||||
default void setOtherField(@Param("obj") NoticeUser obj, @MappingTarget @Param("dto") NoticeUserDto dto) {
|
||||
UserServiceImpl userService = SpringUtil.getBean(UserServiceImpl.class);
|
||||
User user = userService.getById(obj.getUserId());
|
||||
if(ObjUtil.isNotNull(user)){
|
||||
dto.setUserName(user.getUserName());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,16 @@
|
|||
package com.ydool.integrated.wrapper;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydool.common.base.BaseWrapper;
|
||||
import com.ydool.integrated.dto.NoticeDto;
|
||||
import com.ydool.integrated.entity.Notice;
|
||||
import com.ydool.integrated.entity.NoticeUser;
|
||||
import com.ydool.integrated.service.NoticeUserService;
|
||||
import com.ydool.system.entity.User;
|
||||
import com.ydool.system.service.impl.UserServiceImpl;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -40,6 +44,27 @@ public interface NoticeWrapper extends BaseWrapper<Notice, NoticeDto> {
|
|||
dto.setUserList(JSONUtil.toJsonStr(users));
|
||||
}
|
||||
}
|
||||
|
||||
NoticeUserService noticeUserService = SpringUtil.getBean(NoticeUserService.class);
|
||||
List<NoticeUser> noticeUsers = noticeUserService.list(new QueryWrapper<NoticeUser>()
|
||||
.lambda()
|
||||
.eq(NoticeUser::getNoticeId, obj.getId())
|
||||
);
|
||||
|
||||
if (CollUtil.isNotEmpty(noticeUsers)) {
|
||||
if (noticeUsers.stream().anyMatch(noticeUser -> noticeUser.getUserId().equals(StpUtil.getLoginIdAsString()))) {
|
||||
dto.setIsRead(true);
|
||||
}
|
||||
dto.setReadUserList(NoticeUserWrapper.INSTANCE.toDto(noticeUsers));
|
||||
}else {
|
||||
dto.setIsRead(false);
|
||||
dto.setReadUserList(null);
|
||||
}
|
||||
|
||||
if (obj.getCreatedId().equals(StpUtil.getLoginIdAsString())) {
|
||||
dto.setIsCreated(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,8 @@ spring:
|
|||
thymeleaf:
|
||||
prefix: classpath:/html/
|
||||
suffix: .html
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
# jackson:
|
||||
# default-property-inclusion: non_null
|
||||
main:
|
||||
allow-circular-references: true
|
||||
|
||||
|
|
Loading…
Reference in New Issue