mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
删除非推荐类消息
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
package com.xboe.system.user.api;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
@@ -24,8 +11,14 @@ import com.xboe.system.user.entity.Message;
|
||||
import com.xboe.system.user.service.IMessageService;
|
||||
import com.xboe.system.user.service.MessageSender;
|
||||
import com.xboe.system.user.vo.BatchMessage;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -227,6 +220,23 @@ public class MessageApi extends ApiBaseController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/clearMessageNotCase")
|
||||
public JsonResponse<Integer> clearMessageNotCase(){
|
||||
|
||||
String aid=getCurrent().getAccountId();
|
||||
if(StringUtils.isBlank(aid)) {
|
||||
return badRequest("获取用户信息异常");
|
||||
}
|
||||
try {
|
||||
Integer type = service.clearMessageNotCase(aid);
|
||||
return success(type);
|
||||
} catch (Exception e) {
|
||||
log.error("清空消息错误",e);
|
||||
return error("清空消息失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移动端
|
||||
* 消息页面,按用户分组返回 暂时不用
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.xboe.system.user.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.system.user.entity.Message;
|
||||
import com.xboe.system.user.vo.BatchMessage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息接口
|
||||
@@ -61,6 +60,13 @@ public interface IMessageService {
|
||||
* @return
|
||||
*/
|
||||
void cleanByAcceptId(String aid);
|
||||
|
||||
/**
|
||||
* 清楚消息排除推荐消息
|
||||
* @param aid
|
||||
* @return
|
||||
*/
|
||||
Integer clearMessageNotCase(String aid);
|
||||
|
||||
/**
|
||||
* 批量设置已读
|
||||
|
||||
@@ -166,15 +166,21 @@ public class MessageServiceImpl implements IMessageService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void cleanByAcceptId(String aid) {
|
||||
List<Message> list = dao.findList(FieldFilters.eq("acceptId", aid), FieldFilters.ne("refType", "99"));
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
throw new RuntimeException("此类消息不支持删除");
|
||||
}
|
||||
dao.deleteByFilter(FieldFilters.eq("acceptId", aid), FieldFilters.ne("refType", "99"));
|
||||
// dao.deleteByField("acceptId", aid);
|
||||
dao.deleteByField("acceptId", aid);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer clearMessageNotCase(String aid) {
|
||||
List<Message> list = dao.findList(FieldFilters.eq("acceptId", aid), FieldFilters.ne("refType", "99"));
|
||||
dao.deleteByFilter(FieldFilters.eq("acceptId", aid), FieldFilters.ne("refType", "99"));
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchSave(List<Message> list) {
|
||||
|
||||
Reference in New Issue
Block a user