From edc81cbad4d7ee27ab2c64f5f52c7b546e8eed91 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Mon, 24 Jan 2022 11:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=95=99=E8=A8=80=E6=9D=BF?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XhpcMessageBoardReceiveUserMapper.java | 20 ++++++++++++ .../impl/XhpcMessageBoardServiceImpl.java | 31 ++++++++++++------- .../XhpcMessageBoardReceiveUserMapper.xml | 20 +++++++++--- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java index 5ea339f4..f77476c2 100644 --- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java +++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/mapper/XhpcMessageBoardReceiveUserMapper.java @@ -73,4 +73,24 @@ public interface XhpcMessageBoardReceiveUserMapper { */ void updateHaveNewInfoIsNull(UserQueryCondition userQueryCondition); + /** + * 删除指定租户列表中的指定用户 + * + * @param userQueryCondition 用户信息 + * @author WH + * @date 2022/1/24 10:32 + * @since version-1.0 + */ + void updateDelFlag(UserQueryCondition userQueryCondition); + + /** + * 设置指定用户从租户列表中恢复 + * + * @param userMessage 用户信息 + * @author WH + * @date 2022/1/24 10:37 + * @since version-1.0 + */ + void setDelFlag(SendMessageToPlatformRequest userMessage); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java index cb900446..900af764 100644 --- a/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java +++ b/xhpc-modules/xhpc-message-board/src/main/java/com/xhpc/board/service/impl/XhpcMessageBoardServiceImpl.java @@ -9,15 +9,13 @@ import com.xhpc.board.service.XhpcMessageBoardService; import com.xhpc.common.api.UserTypeService; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.DateUtils; -import com.xhpc.common.core.utils.bean.BeanUtils; import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.DateUtil; import com.xhpc.common.util.MyPagingUtil; import com.xhpc.system.api.domain.SysUser; import com.xhpc.system.api.model.LoginUser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -43,7 +41,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { @Resource UserTypeService userTypeService; - private static final Logger logger = LoggerFactory.getLogger(XhpcMessageBoardServiceImpl.class); + /** * 将用户发送的信息保存到数据库中 * @@ -88,6 +86,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser); } else { xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage); + xhpcMessageBoardReceiveUserMapper.setDelFlag(userMessage); } } else { //reset redis key valid time @@ -113,6 +112,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser); } else { xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage); + xhpcMessageBoardReceiveUserMapper.setDelFlag(userMessage); } } } @@ -213,7 +213,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { List aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr); //如果没有数据,则返回空实体类对象 QueryUserMassageResponse response = new QueryUserMassageResponse(); - if (aMonthRecords.size() == 0) { + if (aMonthRecords.isEmpty()) { return response; } List messageIdList = new ArrayList<>(); @@ -250,8 +250,14 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { */ @Override public String returnPlatformAvatar(String tenantId, Integer tenantType) { - //todo 查询数据库 - return "https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png"; + + SysUser sysUser = tokenService.getLoginUser().getSysUser(); + String avatar = sysUser.getAvatar(); + if (avatar == null) { + return "https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png"; + } else { + return avatar; + } } /** @@ -275,7 +281,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { QueryUserListResponse queryUserListResponse = new QueryUserListResponse(); //查询出该租户拥有的所有用户列表 List userList = xhpcMessageBoardReceiveUserMapper.findAllBy(param); - if (userList.size() == 0) { + if (userList.isEmpty()) { return queryUserListResponse; } List dataDtoList = new ArrayList<>(); @@ -315,7 +321,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { //查询用户是否有数据,即查询该用户的所有时间记录(有时间记录表示该用户发送过信息) List allTimeRecords = messageBoardMapper.selectTimeRecords(userQueryCondition); QueryUserMassageResponse queryUserMassageResponse = new QueryUserMassageResponse(); - if (allTimeRecords.size() == 0) { + if (allTimeRecords.isEmpty()) { return queryUserMassageResponse; } //获取最后一个时间记录,将其减去一个月,放入查询条件中 @@ -339,7 +345,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { List aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr); //如果没有数据,则返回空实体类对象 QueryUserMassageResponse response = new QueryUserMassageResponse(); - if (aMonthRecords.size() == 0) { + if (aMonthRecords.isEmpty()) { return response; } List messageIdList = new ArrayList<>(); @@ -361,7 +367,6 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { dataDTOS.add(dataDTO); } //处理下次查询时间 - //todo 截取时间 response.setNextQueryTime(nextTimeStr); response.setData(dataDTOS); return response; @@ -376,7 +381,9 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService { userInfo.setTenantType(0); UserQueryCondition userQueryCondition = new UserQueryCondition(); BeanUtils.copyProperties(userInfo, userQueryCondition); - xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoIsNull(userQueryCondition); + userQueryCondition.setSenderType(userInfo.getUserType()); + userQueryCondition.setSenderAccount(userInfo.getUserAccount()); + xhpcMessageBoardReceiveUserMapper.updateDelFlag(userQueryCondition); } diff --git a/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml b/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml index 838a91ba..ba98eaec 100644 --- a/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml +++ b/xhpc-modules/xhpc-message-board/src/main/resources/mapper/XhpcMessageBoardReceiveUserMapper.xml @@ -85,7 +85,6 @@ AND tenant_id = #{tenantId} AND sender_account = #{senderAccount} AND sender_type = #{senderType} - AND del_flag IS NULL; UPDATE xhpc_message_board_receive_user @@ -96,6 +95,22 @@ AND sender_type = #{senderType} AND del_flag IS NULL; + + UPDATE xhpc_message_board_receive_user + SET del_flag = 0 + WHERE tenant_type = #{tenantType} + AND tenant_id = #{tenantId} + AND sender_account = #{senderAccount} + AND sender_type = #{senderType} + + + UPDATE xhpc_message_board_receive_user + SET del_flag = null + WHERE tenant_type = #{tenantType} + AND tenant_id = #{tenantId} + AND sender_account = #{senderAccount} + AND sender_type = #{senderType} +