|
@@ -1,18 +1,19 @@
|
|
|
package com.keao.edu.auth.web.controller;
|
|
|
|
|
|
+import com.keao.edu.auth.api.client.SysUserFeignService;
|
|
|
import com.keao.edu.auth.api.entity.SysMessageParams;
|
|
|
+import com.keao.edu.auth.api.entity.SysUser;
|
|
|
import com.keao.edu.auth.service.SysMessageService;
|
|
|
+import com.keao.edu.auth.web.controller.queryInfo.SysMessageQueryInfo;
|
|
|
import com.keao.edu.common.controller.BaseController;
|
|
|
-import com.keao.edu.common.enums.MessageTypeEnum;
|
|
|
-import com.keao.edu.thirdparty.message.MessageSenderPluginContext;
|
|
|
+import com.keao.edu.common.entity.SysMessage;
|
|
|
+import com.keao.edu.common.enums.MessageSendMode;
|
|
|
+import com.keao.edu.common.page.PageInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-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 org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
/**
|
|
|
* @Author Joburgess
|
|
@@ -25,6 +26,8 @@ public class SysMessageController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private SysMessageService sysMessageService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
@ApiOperation(value = "发送消息")
|
|
|
@PostMapping(value = "/batchSendMessage")
|
|
@@ -34,4 +37,56 @@ public class SysMessageController extends BaseController {
|
|
|
sysMessageParams.getArgs());
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "删除消息")
|
|
|
+ @PostMapping(value = "/batchDelMessage")
|
|
|
+ public void batchDelMessage(String ids){
|
|
|
+ sysMessageService.batchDelMessage(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询用户未读消息条数")
|
|
|
+ @GetMapping("/queryCountOfUnread")
|
|
|
+ public Object queryCountOfUnread() {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ return succeed(sysMessageService.queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("一键已读")
|
|
|
+ @PostMapping("batchSetRead")
|
|
|
+ public Object batchSetRead() {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ return succeed(sysMessageService.updateStatus(sysUser.getId(), 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("设置已读")
|
|
|
+ @PostMapping("setRead")
|
|
|
+ public Object setRead(Long id) {
|
|
|
+ int status = 1;
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ return succeed(sysMessageService.updateOneStatus(id, status));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取所有消息列表")
|
|
|
+ @GetMapping(value = "list")
|
|
|
+ public Object list(SysMessageQueryInfo queryInfo){
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ if(!sysUser.getIsSuperAdmin()){
|
|
|
+ queryInfo.setUserId(sysUser.getId());
|
|
|
+ }
|
|
|
+ queryInfo.setType(MessageSendMode.SEO.getCode());
|
|
|
+ PageInfo<SysMessage> pageInfo = sysMessageService.queryPage(queryInfo);
|
|
|
+ return succeed(pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|