|
@@ -1,9 +1,98 @@
|
|
package com.jpsoft.picc.modules.auth.controller;
|
|
package com.jpsoft.picc.modules.auth.controller;
|
|
|
|
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
+import com.jpsoft.picc.modules.base.entity.Message;
|
|
|
|
+import com.jpsoft.picc.modules.base.service.MessageService;
|
|
|
|
+import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
|
|
+import com.jpsoft.picc.modules.common.dto.Sort;
|
|
|
|
+import com.jpsoft.picc.modules.common.utils.PojoUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-@Api(description="消息管理")
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@Api(description="消息列表")
|
|
@RestController
|
|
@RestController
|
|
public class MessageController {
|
|
public class MessageController {
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MessageService messageService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="消息列表")
|
|
|
|
+ @RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "senderId",value = "发件人ID", required = false, paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "recipientId",value = "收件人ID", required = false, paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "status",value = "状态(未读/已读)", required = false, paramType = "form",dataType = "Boolean")
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<Map> list(@RequestParam(value="senderId",defaultValue="") String senderId,
|
|
|
|
+ @RequestParam(value="recipientId",defaultValue="") String recipientId,
|
|
|
|
+ @RequestParam(value="status",defaultValue="") Boolean status){
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
+ searchParams.put("delFlag",false);
|
|
|
|
+
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(senderId)) {
|
|
|
|
+ searchParams.put("senderId",senderId);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(recipientId)) {
|
|
|
|
+ searchParams.put("recipientId",recipientId);
|
|
|
|
+ }
|
|
|
|
+ if (status != null) {
|
|
|
|
+ searchParams.put("status",status);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<Message> page = messageService.pageSearch(searchParams,1,1000,sortList);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="消息设为已读")
|
|
|
|
+ @PostMapping("read")
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "id",value = "编号", required = true, paramType = "form",dataType = "String")
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<Integer> read(@RequestParam(value="id",defaultValue="") String id){
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Message message = messageService.get(id);
|
|
|
|
+ message.setStatus(true);
|
|
|
|
+// companyMember.setUpdateBy(subject);
|
|
|
|
+ message.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = messageService.update(message);
|
|
|
|
+
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(affectCount);
|
|
|
|
+ } else {
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
}
|
|
}
|