修复留言板错误处理逻辑

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);
/**
* 删除指定租户列表中的指定用户
*
* @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.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<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
//如果没有数据则返回空实体类对象
QueryUserMassageResponse response = new QueryUserMassageResponse();
if (aMonthRecords.size() == 0) {
if (aMonthRecords.isEmpty()) {
return response;
}
List<Long> 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<XhpcMessageBoardReceiveUser> userList = xhpcMessageBoardReceiveUserMapper.findAllBy(param);
if (userList.size() == 0) {
if (userList.isEmpty()) {
return queryUserListResponse;
}
List<QueryUserListResponse.DataDTO> dataDtoList = new ArrayList<>();
@ -315,7 +321,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
//查询用户是否有数据即查询该用户的所有时间记录有时间记录表示该用户发送过信息
List<XhpcMessageBoard> 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<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
//如果没有数据则返回空实体类对象
QueryUserMassageResponse response = new QueryUserMassageResponse();
if (aMonthRecords.size() == 0) {
if (aMonthRecords.isEmpty()) {
return response;
}
List<Long> 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);
}

View File

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