Showing
12 changed files
with
162 additions
and
76 deletions
... | ... | @@ -58,6 +58,26 @@ public class YtNoticeUserController extends BaseController { |
58 | 58 | if (type != null) { |
59 | 59 | queryMap.put("type", type.name()); |
60 | 60 | } |
61 | + //接收者id,当前所属用户的id | |
62 | + queryMap.put("receiverId",getCurrentUser().getCurrentUserId()); | |
63 | + return sysNoticeUserService.page(queryMap); | |
64 | + } | |
65 | + | |
66 | + @GetMapping( | |
67 | + path = "page/{noticeId}", | |
68 | + params = {PAGE_SIZE, PAGE}) | |
69 | + @ApiOperation("通知用户分页") | |
70 | + public YtPageData<SysNoticeUserDTO> pageByNoticeId ( | |
71 | + @PathVariable("noticeId") String noticeId, | |
72 | + @RequestParam(PAGE_SIZE) int pageSize, | |
73 | + @RequestParam(PAGE) int page, | |
74 | + @RequestParam(value = ORDER_FILED, required = false) String orderBy, | |
75 | + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) throws ThingsboardException{ | |
76 | + Map<String, Object> queryMap = getMap(pageSize, page, orderBy, orderType); | |
77 | + queryMap.put("noticeId",noticeId); | |
78 | + if (orderType != null) { | |
79 | + queryMap.put(ORDER_TYPE, orderType.name()); | |
80 | + } | |
61 | 81 | return sysNoticeUserService.page(queryMap); |
62 | 82 | } |
63 | 83 | |
... | ... | @@ -77,7 +97,7 @@ public class YtNoticeUserController extends BaseController { |
77 | 97 | queryMap.put(PAGE_SIZE, pageSize); |
78 | 98 | queryMap.put(PAGE, page); |
79 | 99 | queryMap.put(ORDER_FILED, orderBy); |
80 | - queryMap.put("tenantId", getCurrentUser().getCurrentUserId()); | |
100 | + queryMap.put("tenantId", getCurrentUser().getCurrentTenantId()); | |
81 | 101 | if (orderType != null) { |
82 | 102 | queryMap.put(ORDER_TYPE, orderType.name()); |
83 | 103 | } | ... | ... |
... | ... | @@ -22,20 +22,25 @@ public class SysNoticeDTO extends TenantDTO { |
22 | 22 | private static final long serialVersionUID = 3466370312762440488L; |
23 | 23 | @ApiModelProperty(value = "通知类型",required = true) |
24 | 24 | private SysNoticeTypeEnum type; |
25 | + | |
25 | 26 | @ApiModelProperty(value = "标题",required = true) |
26 | 27 | private String title; |
28 | + | |
27 | 29 | @ApiModelProperty(value = "内容",required = true) |
28 | 30 | private String content; |
31 | + | |
29 | 32 | @ApiModelProperty(value = "接收者(字典值receiver_type) 0:全部 1:组织 2:部门 3:个人",required = true) |
30 | 33 | private String receiverType; |
31 | - @ApiModelProperty(value = "根据receiverType不同变化,,0:传null,1:组织id,2:部门id,3:用户id",required = true) | |
34 | + | |
35 | + @ApiModelProperty(value = "根据receiverType不同变化,0:传null,1:组织id,2:部门id,3:用户id",required = true) | |
32 | 36 | private List<String> pointId; |
33 | - @ApiModelProperty(value = "接收者ID,用逗号分开") | |
34 | - private String receiverTypeIds; | |
37 | + | |
35 | 38 | @ApiModelProperty(value = "发送状态(字典值draft_status) 0:草稿 1:已发布") |
36 | 39 | private String status; |
40 | + | |
37 | 41 | @ApiModelProperty(value = "发送者") |
38 | 42 | private String senderName; |
43 | + | |
39 | 44 | @ApiModelProperty(value = "发送时间") |
40 | 45 | private LocalDateTime senderDate; |
41 | 46 | } | ... | ... |
... | ... | @@ -18,12 +18,14 @@ public class SysNoticeUserDTO extends TenantDTO { |
18 | 18 | private static final long serialVersionUID = -5421685500963791707L; |
19 | 19 | @ApiModelProperty(value = "接收者ID") |
20 | 20 | private String receiverId; |
21 | + @ApiModelProperty(value = "接收者") | |
22 | + private UserDTO user; | |
21 | 23 | @ApiModelProperty(value = "通知ID") |
22 | - private String NoticeId; | |
24 | + private String noticeId; | |
23 | 25 | @ApiModelProperty(value = "阅读状态 0:未读 1:已读") |
24 | - private String ReadStatus; | |
26 | + private String readStatus; | |
25 | 27 | @ApiModelProperty(value = "阅读时间") |
26 | - private LocalDateTime ReadDate; | |
28 | + private LocalDateTime readDate; | |
27 | 29 | @ApiModelProperty(value = "通知类型") |
28 | 30 | private SysNoticeTypeEnum type; |
29 | 31 | @ApiModelProperty(value = "发送者") | ... | ... |
... | ... | @@ -27,8 +27,6 @@ public class SysNotice extends TenantBaseEntity { |
27 | 27 | private String content; |
28 | 28 | /** 接收者(字典值receiver_type) 0:全部 1:组织 2:部门 3:个人 */ |
29 | 29 | private String receiverType; |
30 | - /** 接收者ID,用逗号分开 */ | |
31 | - private String receiverTypeIds; | |
32 | 30 | /** 发送状态(字典值draft_status) 0:草稿 1:已发布 */ |
33 | 31 | private String status; |
34 | 32 | /** 发送者 */ | ... | ... |
... | ... | @@ -23,18 +23,11 @@ public class SysNoticeUser extends TenantBaseEntity { |
23 | 23 | /** 接收者ID */ |
24 | 24 | private String receiverId; |
25 | 25 | /** 通知ID */ |
26 | - private String NoticeId; | |
26 | + private String noticeId; | |
27 | 27 | /** 阅读状态 0:未读 1:已读 */ |
28 | - private String ReadStatus; | |
28 | + private String readStatus; | |
29 | 29 | /** 阅读时间 */ |
30 | - private LocalDateTime ReadDate; | |
31 | - /** 通知类型 */ | |
32 | - @TableField(exist = false) | |
33 | - private SysNoticeTypeEnum type; | |
34 | - /** 发送者 */ | |
35 | - @TableField(exist = false) | |
36 | - private String senderName; | |
37 | - /** 发送时间 */ | |
38 | - @TableField(exist = false) | |
39 | - private LocalDateTime senderDate; | |
30 | + private LocalDateTime readDate; | |
31 | + /** 通知用户状态: 0 草稿 1已发布 */ | |
32 | + private String status; | |
40 | 33 | } | ... | ... |
... | ... | @@ -4,26 +4,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
5 | 5 | import lombok.RequiredArgsConstructor; |
6 | 6 | import lombok.extern.slf4j.Slf4j; |
7 | -import org.apache.commons.lang3.ObjectUtils; | |
8 | -import org.apache.commons.lang3.StringUtils; | |
9 | 7 | import org.springframework.stereotype.Service; |
10 | 8 | import org.springframework.transaction.annotation.Transactional; |
11 | 9 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
12 | 10 | import org.thingsboard.server.common.data.yunteng.core.exception.EntityCreationException; |
13 | 11 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
14 | 12 | import org.thingsboard.server.common.data.yunteng.dto.SysNoticeDTO; |
13 | +import org.thingsboard.server.common.data.yunteng.dto.SysNoticeUserDTO; | |
15 | 14 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
16 | 15 | import org.thingsboard.server.dao.yunteng.entities.SysNotice; |
17 | -import org.thingsboard.server.dao.yunteng.entities.SysNoticeUser; | |
18 | 16 | import org.thingsboard.server.dao.yunteng.entities.User; |
19 | 17 | import org.thingsboard.server.dao.yunteng.mapper.SysNoticeMapper; |
20 | 18 | import org.thingsboard.server.dao.yunteng.mapper.UserMapper; |
21 | 19 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
22 | 20 | import org.thingsboard.server.dao.yunteng.service.SysNoticeService; |
21 | +import org.thingsboard.server.dao.yunteng.service.SysNoticeUserService; | |
23 | 22 | import org.thingsboard.server.dao.yunteng.service.UserOrganizationMappingService; |
24 | 23 | |
25 | 24 | import java.time.LocalDateTime; |
26 | -import java.util.ArrayList; | |
27 | 25 | import java.util.List; |
28 | 26 | import java.util.Map; |
29 | 27 | import java.util.Set; |
... | ... | @@ -43,6 +41,7 @@ public class SysNoticeServiceImpl extends AbstractBaseService<SysNoticeMapper, S |
43 | 41 | private final SysNoticeUserServiceImpl sysNoticeUserService; |
44 | 42 | private final UserOrganizationMappingService userOrganizationMappingService; |
45 | 43 | private final UserMapper userMapper; |
44 | + private final SysNoticeUserService noticeUserService; | |
46 | 45 | |
47 | 46 | @Override |
48 | 47 | public YtPageData<SysNoticeDTO> page(Map<String, Object> queryMap) { |
... | ... | @@ -70,50 +69,57 @@ public class SysNoticeServiceImpl extends AbstractBaseService<SysNoticeMapper, S |
70 | 69 | SysNotice sysNotice = sysNoticeDTO.getEntity(SysNotice.class); |
71 | 70 | // 设置为草稿 |
72 | 71 | sysNotice.setTenantId(tenantId); |
73 | - // 拼接需要发送的名单 | |
74 | - // ReceiverType为空,getPointId有值,也抛异常 | |
75 | - // ReceiverType,getPointId同时为空,抛异常 | |
76 | - // ReceiverType为其他任何值都抛异常 | |
77 | 72 | if (sysNoticeDTO.getReceiverType() == null |
78 | 73 | || (!sysNoticeDTO.getReceiverType().equals(FastIotConstants.ReceiverType.ALL) |
79 | 74 | && sysNoticeDTO.getPointId() == null)) { |
80 | 75 | throw new EntityCreationException(ErrorMessage.SEND_DESTINATION_NOT_FOUND.name()); |
81 | 76 | } |
82 | - LambdaQueryWrapper<User> wrapper = | |
83 | - new LambdaQueryWrapper<User>().eq(User::getTenantId, sysNotice.getTenantId()); | |
77 | + | |
78 | + List<String> userList; | |
84 | 79 | switch (sysNotice.getReceiverType()) { |
85 | 80 | case FastIotConstants.ReceiverType.ALL: |
86 | - // 全部 | |
87 | - sysNotice.setReceiverTypeIds( | |
88 | - userMapper.selectList(wrapper).stream() | |
81 | + // 获取全部用户ID | |
82 | + userList = | |
83 | + userMapper | |
84 | + .selectList( | |
85 | + new LambdaQueryWrapper<User>().eq(User::getTenantId, sysNotice.getTenantId())) | |
86 | + .stream() | |
89 | 87 | .map(User::getId) |
90 | - .collect(Collectors.joining(","))); | |
88 | + .distinct() | |
89 | + .collect(Collectors.toList()); | |
91 | 90 | break; |
92 | 91 | case FastIotConstants.ReceiverType.ORGANIZATION: |
93 | - // 组织内 | |
94 | - sysNotice.setReceiverTypeIds( | |
95 | - String.join(",", userOrganizationMappingService | |
96 | - .getUserIdByOrganizationIds( | |
97 | - tenantId, sysNoticeDTO.getPointId().toArray(String[]::new)))); | |
98 | - break; | |
99 | - case FastIotConstants.ReceiverType.PERSONAL: | |
100 | - // 个人 | |
101 | - sysNotice.setReceiverTypeIds( | |
102 | - String.join(",", sysNoticeDTO.getPointId())); | |
92 | + // 判断传入的集合id是否为空 | |
93 | + if (sysNoticeDTO.getPointId() == null || sysNoticeDTO.getPointId().size() == 0) { | |
94 | + throw new EntityCreationException(ErrorMessage.GET_CURRENT_USER_EXCEPTION.name()); | |
95 | + } | |
96 | + // 获取当前组织下的所有用户 | |
97 | + userList = | |
98 | + userOrganizationMappingService.getUserIdByOrganizationIds( | |
99 | + tenantId, sysNoticeDTO.getPointId().toArray(String[]::new)); | |
103 | 100 | break; |
104 | 101 | default: |
105 | 102 | throw new EntityCreationException(ErrorMessage.SEND_DESTINATION_NOT_FOUND.name()); |
106 | 103 | } |
107 | - if (StringUtils.isEmpty(sysNotice.getReceiverTypeIds())) { | |
104 | + if (userList.isEmpty()) { | |
108 | 105 | throw new EntityCreationException(ErrorMessage.SEND_DESTINATION_NOT_FOUND.name()); |
109 | 106 | } |
110 | 107 | // 如果为空,则新增 |
111 | 108 | if (sysNotice.getId() == null) { |
112 | 109 | baseMapper.insert(sysNotice); |
110 | + // 保存用户通知表 | |
111 | + noticeUserService.saveSysNoticeUser( | |
112 | + userList, tenantId, sysNotice.getId(), sysNoticeDTO.getStatus()); | |
113 | + sysNotice.copyToDTO(sysNoticeDTO); | |
113 | 114 | } else { |
115 | + List<String> sysNoticeUserList = noticeUserService.getSysNoticeUserIdsByNoticeId(sysNotice.getId()); | |
116 | + //更改通知用户的状态 | |
117 | + if(null == sysNoticeUserList || sysNoticeUserList.size()<1){ | |
118 | + throw new EntityCreationException(ErrorMessage.SEND_DESTINATION_NOT_FOUND.name()); | |
119 | + } | |
120 | + noticeUserService.updateSysNoticeUsersStatusByNoticeId(sysNotice.getId(),sysNotice.getStatus()); | |
114 | 121 | baseMapper.updateById(sysNotice); |
115 | 122 | } |
116 | - sysNotice.copyToDTO(sysNoticeDTO); | |
117 | 123 | return sysNoticeDTO; |
118 | 124 | } |
119 | 125 | |
... | ... | @@ -134,25 +140,6 @@ public class SysNoticeServiceImpl extends AbstractBaseService<SysNoticeMapper, S |
134 | 140 | new LambdaQueryWrapper<SysNotice>() |
135 | 141 | .eq(SysNotice::getId, sysNoticeDTO.getId()) |
136 | 142 | .eq(SysNotice::getTenantId, tenantId)); |
137 | - | |
138 | - if (update > 0) { | |
139 | - // 发送消息 | |
140 | - String[] split = sysNotice.getReceiverTypeIds().split(","); | |
141 | - List<SysNoticeUser> list = new ArrayList<>(split.length); | |
142 | - for (String s : split) { | |
143 | - SysNoticeUser sysNoticeUser = new SysNoticeUser(); | |
144 | - sysNoticeUser.setReceiverId(s); | |
145 | - sysNoticeUser.setNoticeId(sysNotice.getId()); | |
146 | - sysNoticeUser.setTenantId(sysNotice.getTenantId()); | |
147 | - sysNoticeUser.setReadStatus(FastIotConstants.ReadState.UNREAD); | |
148 | - list.add(sysNoticeUser); | |
149 | - } | |
150 | - if (ObjectUtils.isEmpty(list) || !sysNoticeUserService.insertBatch(list, 100)) { | |
151 | - // 通知失败 | |
152 | - throw new EntityCreationException(ErrorMessage.SEND_DESTINATION_NOT_FOUND.name()); | |
153 | - } | |
154 | - } | |
155 | - sysNotice.copyToDTO(SysNoticeDTO.class); | |
156 | - return sysNoticeDTO; | |
143 | + return sysNotice.getDTO(SysNoticeDTO.class); | |
157 | 144 | } |
158 | 145 | } | ... | ... |
1 | 1 | package org.thingsboard.server.dao.yunteng.impl; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
3 | 4 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
4 | 5 | import com.baomidou.mybatisplus.core.metadata.IPage; |
6 | +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; | |
7 | +import org.apache.commons.lang3.StringUtils; | |
5 | 8 | import org.springframework.stereotype.Service; |
6 | 9 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
10 | +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | |
11 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | |
7 | 12 | import org.thingsboard.server.common.data.yunteng.dto.SysNoticeUserDTO; |
8 | 13 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
9 | 14 | import org.thingsboard.server.dao.yunteng.entities.SysNoticeUser; |
15 | +import org.thingsboard.server.dao.yunteng.entities.User; | |
10 | 16 | import org.thingsboard.server.dao.yunteng.mapper.SysNoticeUserMapper; |
11 | 17 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
12 | 18 | import org.thingsboard.server.dao.yunteng.service.SysNoticeUserService; |
13 | 19 | |
14 | 20 | import java.time.LocalDateTime; |
21 | +import java.util.ArrayList; | |
22 | +import java.util.List; | |
15 | 23 | import java.util.Map; |
24 | +import java.util.stream.Collectors; | |
16 | 25 | |
17 | 26 | /** |
18 | 27 | * @author: 徐浩然 |
... | ... | @@ -30,16 +39,21 @@ public class SysNoticeUserServiceImpl |
30 | 39 | } |
31 | 40 | |
32 | 41 | @Override |
42 | + public YtPageData<SysNoticeUserDTO> pageByNoticeId(Map<String, Object> queryMap) { | |
43 | + return getPage(queryMap); | |
44 | + } | |
45 | + | |
46 | + @Override | |
33 | 47 | public YtPageData<SysNoticeUserDTO> read(Map<String, Object> queryMap, String currentUserId) { |
34 | 48 | queryMap.put("creator", currentUserId); |
35 | 49 | return getPage(queryMap); |
36 | 50 | } |
37 | 51 | |
38 | 52 | @Override |
39 | - public SysNoticeUserDTO get(String id,String tenantId) { | |
40 | - SysNoticeUser sysNoticeUser = | |
41 | - baseMapper.get(id, tenantId).getEntity(SysNoticeUser.class); | |
42 | - if (!FastIotConstants.ReadState.READ.equals(sysNoticeUser.getReadStatus()) || sysNoticeUser.getReadDate() == null) { | |
53 | + public SysNoticeUserDTO get(String id, String tenantId) { | |
54 | + SysNoticeUser sysNoticeUser = baseMapper.get(id, tenantId).getEntity(SysNoticeUser.class); | |
55 | + if (!FastIotConstants.ReadState.READ.equals(sysNoticeUser.getReadStatus()) | |
56 | + || sysNoticeUser.getReadDate() == null) { | |
43 | 57 | // 设置已读 |
44 | 58 | sysNoticeUser.setReadStatus(FastIotConstants.ReadState.READ); |
45 | 59 | sysNoticeUser.setReadDate(LocalDateTime.now()); |
... | ... | @@ -53,6 +67,43 @@ public class SysNoticeUserServiceImpl |
53 | 67 | return sysNoticeUser.getDTO(SysNoticeUserDTO.class); |
54 | 68 | } |
55 | 69 | |
70 | + @Override | |
71 | + public void saveSysNoticeUser( | |
72 | + List<String> userIds, String tenantId, String noticeId, String status) { | |
73 | + List<SysNoticeUser> sysNoticeUserList = new ArrayList<>(); | |
74 | + userIds.forEach(userId ->{ | |
75 | + SysNoticeUser sysNoticeUser = new SysNoticeUser(); | |
76 | + sysNoticeUser.setNoticeId(noticeId); | |
77 | + sysNoticeUser.setStatus(status); | |
78 | + sysNoticeUser.setTenantId(tenantId); | |
79 | + sysNoticeUser.setReadStatus(FastIotConstants.ReadState.UNREAD); | |
80 | + sysNoticeUser.setReceiverId(userId); | |
81 | + sysNoticeUserList.add(sysNoticeUser); | |
82 | + }); | |
83 | + insertBatch(sysNoticeUserList,sysNoticeUserList.size()); | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + public List<String> getSysNoticeUserIdsByNoticeId(String noticeId) { | |
88 | + if (StringUtils.isAllEmpty(noticeId)) { | |
89 | + throw new YtDataValidationException(ErrorMessage.INTERNAL_ERROR.name()); | |
90 | + } | |
91 | + return baseMapper | |
92 | + .selectList( | |
93 | + new LambdaQueryWrapper<SysNoticeUser>().eq(SysNoticeUser::getNoticeId, noticeId)) | |
94 | + .stream() | |
95 | + .map(SysNoticeUser::getId) | |
96 | + .collect(Collectors.toList()); | |
97 | + } | |
98 | + | |
99 | + @Override | |
100 | + public boolean updateSysNoticeUsersStatusByNoticeId(String id, String status) { | |
101 | + if (StringUtils.isAllEmpty(id) || StringUtils.isAllEmpty(status)) { | |
102 | + throw new YtDataValidationException(ErrorMessage.INTERNAL_ERROR.name()); | |
103 | + } | |
104 | + return baseMapper.updateSysNoticeUsersStatusByNoticeId(id, status); | |
105 | + } | |
106 | + | |
56 | 107 | private YtPageData<SysNoticeUserDTO> getPage(Map<String, Object> queryMap) { |
57 | 108 | IPage<SysNoticeUser> page = getPage(queryMap, FastIotConstants.DefaultOrder.CREATE_TIME, true); |
58 | 109 | IPage<SysNoticeUserDTO> pageDto = baseMapper.page(page, queryMap); | ... | ... |
... | ... | @@ -47,6 +47,7 @@ public class UserOrganizationMappingServiceImpl implements UserOrganizationMappi |
47 | 47 | new LambdaQueryWrapper<UserOrganizationMapping>() |
48 | 48 | .in(UserOrganizationMapping::getOrganizationId, collect)) |
49 | 49 | .stream() |
50 | + .distinct() | |
50 | 51 | .map(UserOrganizationMapping::getUserId) |
51 | 52 | .collect(Collectors.toList()); |
52 | 53 | } | ... | ... |
... | ... | @@ -29,4 +29,6 @@ public interface SysNoticeUserMapper extends BaseMapper<SysNoticeUser> { |
29 | 29 | * @return |
30 | 30 | */ |
31 | 31 | SysNoticeUserDTO get(@Param("id") String id, @Param("tenantId") String tenantId); |
32 | + | |
33 | + boolean updateSysNoticeUsersStatusByNoticeId(@Param("noticeId")String noticeId, @Param("status")String status); | |
32 | 34 | } | ... | ... |
... | ... | @@ -3,6 +3,7 @@ package org.thingsboard.server.dao.yunteng.service; |
3 | 3 | import org.thingsboard.server.common.data.yunteng.dto.SysNoticeUserDTO; |
4 | 4 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
5 | 5 | |
6 | +import java.util.List; | |
6 | 7 | import java.util.Map; |
7 | 8 | |
8 | 9 | /** |
... | ... | @@ -13,7 +14,15 @@ import java.util.Map; |
13 | 14 | public interface SysNoticeUserService { |
14 | 15 | YtPageData<SysNoticeUserDTO> page(Map<String, Object> queryMap); |
15 | 16 | |
17 | + YtPageData<SysNoticeUserDTO> pageByNoticeId(Map<String, Object> queryMap); | |
18 | + | |
16 | 19 | YtPageData<SysNoticeUserDTO> read(Map<String, Object> queryMap, String currentUserId); |
17 | 20 | |
18 | 21 | SysNoticeUserDTO get(String id,String tenantId); |
22 | + | |
23 | + void saveSysNoticeUser (List<String> userIds, String tenantId,String noticeId,String status); | |
24 | + | |
25 | + List<String> getSysNoticeUserIdsByNoticeId(String noticeId); | |
26 | + | |
27 | + boolean updateSysNoticeUsersStatusByNoticeId(String noticeId, String status); | |
19 | 28 | } | ... | ... |
... | ... | @@ -8,7 +8,6 @@ |
8 | 8 | <result property="title" column="title"/> |
9 | 9 | <result property="content" column="content"/> |
10 | 10 | <result property="receiverType" column="receiver_type"/> |
11 | - <result property="receiverTypeIds" column="receiver_type_ids"/> | |
12 | 11 | <result property="status" column="status"/> |
13 | 12 | <result property="senderName" column="sender_name"/> |
14 | 13 | <result property="senderDate" column="sender_date"/> |
... | ... | @@ -36,7 +35,6 @@ |
36 | 35 | <include refid="dict"/> |
37 | 36 | AND sd.dict_code = 'receiver_type' AND sdi.item_value = sn.receiver_type |
38 | 37 | ) receiver_type, |
39 | - sn.receiver_type_ids receiver_type_ids, | |
40 | 38 | ( |
41 | 39 | <include refid="dict"/> |
42 | 40 | AND sd.dict_code = 'draft_status' AND sdi.item_value = sn.status | ... | ... |
... | ... | @@ -13,7 +13,13 @@ |
13 | 13 | <result property="updateTime" column="update_time"/> |
14 | 14 | <result property="tenantId" column="tenant_id"/> |
15 | 15 | <result property="id" column="id"/> |
16 | - <association property="sysNotice" javaType="org.thingsboard.server.common.data.yunteng.dto.SysNoticeDTO"> | |
16 | + <association property="user" column="receiver_id" | |
17 | + javaType="org.thingsboard.server.common.data.yunteng.dto.UserDTO"> | |
18 | + <result property="realName" column="real_name"/> | |
19 | + </association> | |
20 | + <association property="sysNotice" column="notice_id" | |
21 | + javaType="org.thingsboard.server.common.data.yunteng.dto.SysNoticeDTO"> | |
22 | + <result property="id" column="id"/> | |
17 | 23 | <result property="type" column="type" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> |
18 | 24 | <result property="senderName" column="sender_name"/> |
19 | 25 | <result property="senderDate" column="sender_date"/> |
... | ... | @@ -36,13 +42,16 @@ |
36 | 42 | snu.updater updater, |
37 | 43 | snu.create_time create_time, |
38 | 44 | snu.update_time update_time, |
39 | - snu.tenant_id tenant_id, | |
45 | + snu.tenant_id tenant_id, | |
46 | + su.real_name real_name, | |
40 | 47 | snu.id id, |
41 | 48 | sn.type AS type, |
42 | 49 | sn.sender_name sender_name, |
43 | - sn.sender_date sender_date | |
50 | + sn.sender_date sender_date, | |
51 | + sn.id AS id | |
44 | 52 | FROM sys_notice_user snu |
45 | 53 | LEFT JOIN sys_notice sn ON sn.id = snu.notice_id |
54 | + LEFT JOIN sys_user su ON snu.receiver_id = su.id | |
46 | 55 | </sql> |
47 | 56 | <select id="page" resultMap="sysNoticeUser"> |
48 | 57 | <include refid="columns"/> |
... | ... | @@ -54,6 +63,12 @@ |
54 | 63 | <if test="queryMap.creator != null"> |
55 | 64 | AND sn.creator = #{queryMap.creator} |
56 | 65 | </if> |
66 | + <if test="queryMap.receiverId != null"> | |
67 | + AND snu.receiver_id = #{queryMap.receiverId} | |
68 | + </if> | |
69 | + <if test="queryMap.noticeId != null"> | |
70 | + AND snu.notice_id = #{queryMap.noticeId} | |
71 | + </if> | |
57 | 72 | </select> |
58 | 73 | <select id="get" resultMap="sysNoticeUser"> |
59 | 74 | <include refid="columns"/> |
... | ... | @@ -61,4 +76,9 @@ |
61 | 76 | snu.tenant_id = #{tenantId} |
62 | 77 | AND snu.id = #{id} |
63 | 78 | </select> |
79 | + <update id="updateSysNoticeUsersStatusByNoticeId"> | |
80 | + UPDATE sys_notice_user | |
81 | + SET status =#{status} | |
82 | + WHERE notice_id = #{noticeId} | |
83 | + </update> | |
64 | 84 | </mapper> | ... | ... |