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:
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -123,6 +124,46 @@ public class MessageApi extends ApiBaseController {
|
||||
return error("设置已读失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置已读
|
||||
* */
|
||||
|
||||
//@AutoLog(module = "消息",action = "未的全部设置为已读")
|
||||
@GetMapping("/readall")
|
||||
public JsonResponse<Boolean> readAll(){
|
||||
|
||||
String aid=getCurrent().getAccountId();
|
||||
if(StringUtils.isBlank(aid)) {
|
||||
return badRequest("获取用户信息异常");
|
||||
}
|
||||
|
||||
try {
|
||||
service.cleanByAcceptId(aid);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("设置已读失败",e);
|
||||
return error("设置已读失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/clearall")
|
||||
public JsonResponse<Boolean> clearAll(){
|
||||
|
||||
String aid=getCurrent().getAccountId();
|
||||
if(StringUtils.isBlank(aid)) {
|
||||
return badRequest("获取用户信息异常");
|
||||
}
|
||||
|
||||
try {
|
||||
service.cleanByAcceptId(aid);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("清空消息错误",e);
|
||||
return error("清空消息失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移动端
|
||||
|
||||
@@ -46,6 +46,10 @@ public class Message extends IdEntity {
|
||||
@Column(name = "send_name",nullable = true)
|
||||
private String sendName;
|
||||
|
||||
/**发送人id*/
|
||||
@Column(name = "send_aid",nullable = true,length=20)
|
||||
private String sendAid;
|
||||
|
||||
/**
|
||||
* 发送方式,1直接消息,邮件,短信
|
||||
* */
|
||||
|
||||
@@ -35,6 +35,21 @@ public interface IMessageService {
|
||||
* 未读消息条数
|
||||
* */
|
||||
Integer isRead(String aid);
|
||||
|
||||
/**
|
||||
* 设置全部未读消息为已读
|
||||
* @param aid
|
||||
* @return
|
||||
*/
|
||||
Integer setReadByAcceptId(String aid);
|
||||
|
||||
/**
|
||||
* 清空所有的消息,按接收人
|
||||
* @param aid
|
||||
* @return
|
||||
*/
|
||||
void cleanByAcceptId(String aid);
|
||||
|
||||
/**
|
||||
* 批量设置已读
|
||||
* */
|
||||
|
||||
@@ -108,4 +108,16 @@ public class MessageServiceImpl implements IMessageService {
|
||||
List<Message> list = dao.findList(builder.builder());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer setReadByAcceptId(String aid) {
|
||||
int n=dao.deleteByField("acceptId", aid);
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanByAcceptId(String aid) {
|
||||
dao.update("Update "+Message.class.getSimpleName()+" set isRead=?1 where acceptId=?2 and isRead=?3", true,aid,false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user