|
@@ -4,21 +4,34 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
+import org.dromara.common.core.utils.DateUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.domain.complaintSuggestion.ComplaintSuggestion;
|
|
import org.dromara.domain.complaintSuggestion.ComplaintSuggestion;
|
|
import org.dromara.domain.complaintSuggestion.bo.ComplaintSuggestionBo;
|
|
import org.dromara.domain.complaintSuggestion.bo.ComplaintSuggestionBo;
|
|
import org.dromara.domain.complaintSuggestion.vo.ComplaintSuggestionVo;
|
|
import org.dromara.domain.complaintSuggestion.vo.ComplaintSuggestionVo;
|
|
|
|
+import org.dromara.domain.suggestionFj.SuggestionFj;
|
|
|
|
+import org.dromara.domain.suggestionFj.bo.SuggestionFjBo;
|
|
|
|
+import org.dromara.domain.suggestionFj.vo.SuggestionFjVo;
|
|
import org.dromara.mapper.ComplaintSuggestionMapper;
|
|
import org.dromara.mapper.ComplaintSuggestionMapper;
|
|
|
|
+import org.dromara.mapper.SuggestionFjMapper;
|
|
import org.dromara.service.IComplaintSuggestionService;
|
|
import org.dromara.service.IComplaintSuggestionService;
|
|
|
|
+import org.dromara.service.ISuggestionFjService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.redis.cache.RedisCache;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
+import static org.dromara.common.core.constant.Constants.*;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 投诉建议Service业务层处理
|
|
* 投诉建议Service业务层处理
|
|
*
|
|
*
|
|
@@ -31,6 +44,15 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
|
|
|
|
|
|
private final ComplaintSuggestionMapper baseMapper;
|
|
private final ComplaintSuggestionMapper baseMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISuggestionFjService suggestionFjService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SuggestionFjMapper suggestionFjMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询投诉建议
|
|
* 查询投诉建议
|
|
*
|
|
*
|
|
@@ -39,7 +61,31 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ComplaintSuggestionVo queryById(Long suggestionId){
|
|
public ComplaintSuggestionVo queryById(Long suggestionId){
|
|
- return baseMapper.selectVoById(suggestionId);
|
|
|
|
|
|
+ ComplaintSuggestionVo vo = baseMapper.selectVoById(suggestionId);
|
|
|
|
+ SuggestionFjBo fjBo = new SuggestionFjBo();
|
|
|
|
+ fjBo.setSuggestionId(suggestionId);
|
|
|
|
+ List<SuggestionFjVo> suggestionFjVos = suggestionFjService.queryList(fjBo);
|
|
|
|
+ if (suggestionFjVos != null && !suggestionFjVos.isEmpty()){
|
|
|
|
+ vo.setSuggestionFjList(suggestionFjVos);
|
|
|
|
+ }
|
|
|
|
+ //判断是否已读如果是未读设置成已读
|
|
|
|
+ String isRead = vo.getIsRead();
|
|
|
|
+ Long userId = vo.getUserId();
|
|
|
|
+ if (N.equals(isRead) && userId.equals(LoginHelper.getUserId())){
|
|
|
|
+ vo.setIsRead(Y);
|
|
|
|
+ ComplaintSuggestion update = MapstructUtils.convert(vo, ComplaintSuggestion.class);
|
|
|
|
+ baseMapper.updateById(update);
|
|
|
|
+ //app首页统计减少一个数
|
|
|
|
+ String userSuggestionKey = COMPLAINT_SUGGESTION_NO + userId;
|
|
|
|
+ //往redis中新增 个人 投诉建议未回复的数量 app统计使用 回复了这个用户的投诉,这个用户能看到
|
|
|
|
+ Object userNum = RedisUtils.getCacheObject(userSuggestionKey);
|
|
|
|
+ if (ObjectUtils.isNotEmpty(userNum)) {
|
|
|
|
+ RedisUtils.setCacheObject(userSuggestionKey, Math.max((int) userNum - 1, 0));
|
|
|
|
+ }else {
|
|
|
|
+ RedisUtils.setCacheObject(userSuggestionKey,0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return vo;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -94,11 +140,21 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean insertByBo(ComplaintSuggestionBo bo) {
|
|
public Boolean insertByBo(ComplaintSuggestionBo bo) {
|
|
|
|
+ Long userId = LoginHelper.getUserId();
|
|
|
|
+ bo.setCreateTime(DateUtils.getNowDate());
|
|
|
|
+ bo.setUserId(userId);
|
|
ComplaintSuggestion add = MapstructUtils.convert(bo, ComplaintSuggestion.class);
|
|
ComplaintSuggestion add = MapstructUtils.convert(bo, ComplaintSuggestion.class);
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
if (flag) {
|
|
if (flag) {
|
|
bo.setSuggestionId(add.getSuggestionId());
|
|
bo.setSuggestionId(add.getSuggestionId());
|
|
|
|
+ //往redis中新增 总数 投诉建议未回复的数量 app统计使用
|
|
|
|
+ Object allNum = RedisUtils.getCacheObject(COMPLAINT_SUGGESTION_NO_ALL);
|
|
|
|
+ if (ObjectUtils.isNotEmpty(allNum)) {
|
|
|
|
+ RedisUtils.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL, Math.max((int) allNum + 1, 0));
|
|
|
|
+ }else {
|
|
|
|
+ RedisUtils.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL,1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
@@ -111,6 +167,31 @@ public class ComplaintSuggestionServiceImpl implements IComplaintSuggestionServi
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean updateByBo(ComplaintSuggestionBo bo) {
|
|
public Boolean updateByBo(ComplaintSuggestionBo bo) {
|
|
|
|
+ Long userId = bo.getUserId();
|
|
|
|
+ String status = bo.getStatus();
|
|
|
|
+ if (TWO.equals(status)){
|
|
|
|
+ //判断是否有附件
|
|
|
|
+ List<SuggestionFj> suggestionFjList = bo.getSuggestionFjList();
|
|
|
|
+ if (suggestionFjList != null && !suggestionFjList.isEmpty()){
|
|
|
|
+
|
|
|
|
+ suggestionFjMapper.insertBatch(suggestionFjList);
|
|
|
|
+ }
|
|
|
|
+ String userSuggestionKey = COMPLAINT_SUGGESTION_NO + userId;
|
|
|
|
+ //往redis中新增 个人 投诉建议未回复的数量 app统计使用 回复了这个用户的投诉,这个用户能看到
|
|
|
|
+ Object userNum = RedisUtils.getCacheObject(userSuggestionKey);
|
|
|
|
+ if (ObjectUtils.isNotEmpty(userNum)) {
|
|
|
|
+ RedisUtils.setCacheObject(userSuggestionKey, Math.max((int) userNum + 1, 0));
|
|
|
|
+ }else {
|
|
|
|
+ RedisUtils.setCacheObject(userSuggestionKey,1);
|
|
|
|
+ }
|
|
|
|
+ //往redis中新增 总数 投诉建议未回复的数量 app统计使用
|
|
|
|
+ Object allNum = RedisUtils.getCacheObject(COMPLAINT_SUGGESTION_NO_ALL);
|
|
|
|
+ if (ObjectUtils.isNotEmpty(allNum)) {
|
|
|
|
+ RedisUtils.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL, Math.max((int) allNum - 1, 0));
|
|
|
|
+ }else {
|
|
|
|
+ RedisUtils.setCacheObject(COMPLAINT_SUGGESTION_NO_ALL,0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
ComplaintSuggestion update = MapstructUtils.convert(bo, ComplaintSuggestion.class);
|
|
ComplaintSuggestion update = MapstructUtils.convert(bo, ComplaintSuggestion.class);
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|