修复留言板错误处理逻辑

This commit is contained in:
wen 2022-01-24 11:13:34 +08:00
parent 5cfeaf015e
commit edc81cbad4
3 changed files with 55 additions and 16 deletions

View File

@ -73,4 +73,24 @@ public interface XhpcMessageBoardReceiveUserMapper {
*/ */
void updateHaveNewInfoIsNull(UserQueryCondition userQueryCondition); 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);
} }

View File

@ -9,15 +9,13 @@ import com.xhpc.board.service.XhpcMessageBoardService;
import com.xhpc.common.api.UserTypeService; import com.xhpc.common.api.UserTypeService;
import com.xhpc.common.core.domain.R; import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.DateUtils; 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.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService; import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.DateUtil; import com.xhpc.common.util.DateUtil;
import com.xhpc.common.util.MyPagingUtil; import com.xhpc.common.util.MyPagingUtil;
import com.xhpc.system.api.domain.SysUser; import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser; import com.xhpc.system.api.model.LoginUser;
import org.slf4j.Logger; import org.springframework.beans.BeanUtils;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -43,7 +41,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
@Resource @Resource
UserTypeService userTypeService; UserTypeService userTypeService;
private static final Logger logger = LoggerFactory.getLogger(XhpcMessageBoardServiceImpl.class);
/** /**
* 将用户发送的信息保存到数据库中 * 将用户发送的信息保存到数据库中
* *
@ -88,6 +86,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser); xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser);
} else { } else {
xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage); xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage);
xhpcMessageBoardReceiveUserMapper.setDelFlag(userMessage);
} }
} else { } else {
//reset redis key valid time //reset redis key valid time
@ -113,6 +112,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser); xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser);
} else { } else {
xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage); xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage);
xhpcMessageBoardReceiveUserMapper.setDelFlag(userMessage);
} }
} }
} }
@ -213,7 +213,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
List<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr); List<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
//如果没有数据则返回空实体类对象 //如果没有数据则返回空实体类对象
QueryUserMassageResponse response = new QueryUserMassageResponse(); QueryUserMassageResponse response = new QueryUserMassageResponse();
if (aMonthRecords.size() == 0) { if (aMonthRecords.isEmpty()) {
return response; return response;
} }
List<Long> messageIdList = new ArrayList<>(); List<Long> messageIdList = new ArrayList<>();
@ -250,8 +250,14 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
*/ */
@Override @Override
public String returnPlatformAvatar(String tenantId, Integer tenantType) { 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(); QueryUserListResponse queryUserListResponse = new QueryUserListResponse();
//查询出该租户拥有的所有用户列表 //查询出该租户拥有的所有用户列表
List<XhpcMessageBoardReceiveUser> userList = xhpcMessageBoardReceiveUserMapper.findAllBy(param); List<XhpcMessageBoardReceiveUser> userList = xhpcMessageBoardReceiveUserMapper.findAllBy(param);
if (userList.size() == 0) { if (userList.isEmpty()) {
return queryUserListResponse; return queryUserListResponse;
} }
List<QueryUserListResponse.DataDTO> dataDtoList = new ArrayList<>(); List<QueryUserListResponse.DataDTO> dataDtoList = new ArrayList<>();
@ -315,7 +321,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
//查询用户是否有数据即查询该用户的所有时间记录有时间记录表示该用户发送过信息 //查询用户是否有数据即查询该用户的所有时间记录有时间记录表示该用户发送过信息
List<XhpcMessageBoard> allTimeRecords = messageBoardMapper.selectTimeRecords(userQueryCondition); List<XhpcMessageBoard> allTimeRecords = messageBoardMapper.selectTimeRecords(userQueryCondition);
QueryUserMassageResponse queryUserMassageResponse = new QueryUserMassageResponse(); QueryUserMassageResponse queryUserMassageResponse = new QueryUserMassageResponse();
if (allTimeRecords.size() == 0) { if (allTimeRecords.isEmpty()) {
return queryUserMassageResponse; return queryUserMassageResponse;
} }
//获取最后一个时间记录将其减去一个月放入查询条件中 //获取最后一个时间记录将其减去一个月放入查询条件中
@ -339,7 +345,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
List<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr); List<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
//如果没有数据则返回空实体类对象 //如果没有数据则返回空实体类对象
QueryUserMassageResponse response = new QueryUserMassageResponse(); QueryUserMassageResponse response = new QueryUserMassageResponse();
if (aMonthRecords.size() == 0) { if (aMonthRecords.isEmpty()) {
return response; return response;
} }
List<Long> messageIdList = new ArrayList<>(); List<Long> messageIdList = new ArrayList<>();
@ -361,7 +367,6 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
dataDTOS.add(dataDTO); dataDTOS.add(dataDTO);
} }
//处理下次查询时间 //处理下次查询时间
//todo 截取时间
response.setNextQueryTime(nextTimeStr); response.setNextQueryTime(nextTimeStr);
response.setData(dataDTOS); response.setData(dataDTOS);
return response; return response;
@ -376,7 +381,9 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
userInfo.setTenantType(0); userInfo.setTenantType(0);
UserQueryCondition userQueryCondition = new UserQueryCondition(); UserQueryCondition userQueryCondition = new UserQueryCondition();
BeanUtils.copyProperties(userInfo, userQueryCondition); BeanUtils.copyProperties(userInfo, userQueryCondition);
xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoIsNull(userQueryCondition); userQueryCondition.setSenderType(userInfo.getUserType());
userQueryCondition.setSenderAccount(userInfo.getUserAccount());
xhpcMessageBoardReceiveUserMapper.updateDelFlag(userQueryCondition);
} }

View File

@ -85,7 +85,6 @@
AND tenant_id = #{tenantId} AND tenant_id = #{tenantId}
AND sender_account = #{senderAccount} AND sender_account = #{senderAccount}
AND sender_type = #{senderType} AND sender_type = #{senderType}
AND del_flag IS NULL;
</update> </update>
<update id="updateHaveNewInfoIsNull"> <update id="updateHaveNewInfoIsNull">
UPDATE xhpc_message_board_receive_user UPDATE xhpc_message_board_receive_user
@ -96,6 +95,22 @@
AND sender_type = #{senderType} AND sender_type = #{senderType}
AND del_flag IS NULL; AND del_flag IS NULL;
</update> </update>
<update id="updateDelFlag">
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>
<update id="setDelFlag">
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}
</update>
<select id="findOneByCondition" resultMap="BaseResultMap"> <select id="findOneByCondition" resultMap="BaseResultMap">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
@ -106,7 +121,6 @@
AND tenant_type = #{tenantType} AND tenant_type = #{tenantType}
AND sender_account = #{senderAccount} AND sender_account = #{senderAccount}
AND sender_type = #{senderType} AND sender_type = #{senderType}
AND del_flag IS NULL
</select> </select>
<select id="findAllBy" resultMap="BaseResultMap"> <select id="findAllBy" resultMap="BaseResultMap">
SELECT SELECT
@ -117,7 +131,6 @@
tenant_id = #{tenantId} tenant_id = #{tenantId}
AND tenant_type = #{tenantType} AND tenant_type = #{tenantType}
AND del_flag IS NULL AND del_flag IS NULL
AND have_new_info = 0
<if test="userType!=null and userType!=''"> <if test="userType!=null and userType!=''">
AND sender_type = #{userType} AND sender_type = #{userType}
</if> </if>
@ -132,7 +145,6 @@
WHERE tenant_id = #{tenantId} WHERE tenant_id = #{tenantId}
AND tenant_type = #{tenantType} AND tenant_type = #{tenantType}
AND del_flag IS NULL AND del_flag IS NULL
AND have_new_info = 0
<if test="userType!=null and userType!=''"> <if test="userType!=null and userType!=''">
AND sender_type = #{userType} AND sender_type = #{userType}
</if> </if>