MessageController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.bosshand.virgo.controller;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.web.bind.annotation.PathVariable;
  4. import org.springframework.web.bind.annotation.RequestBody;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestMethod;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.alibaba.fastjson.JSONObject;
  9. import com.bosshand.virgo.core.response.Response;
  10. import com.bosshand.virgo.message.model.NotificationMessage;
  11. import com.bosshand.virgo.message.service.MessageService;
  12. import io.swagger.annotations.ApiOperation;
  13. @RestController
  14. @RequestMapping(value = "message")
  15. public class MessageController {
  16. @Autowired
  17. private MessageService messageService;
  18. @ApiOperation(value = "个人消息列表", notes = "个人消息列表")
  19. @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
  20. public Response getByUserId(@PathVariable long userId) {
  21. return Response.ok(messageService.getMessageByUserId(userId));
  22. }
  23. @ApiOperation(value = "待办事项", notes = "待办事项")
  24. @RequestMapping(value = "/backlog/{userId}", method = RequestMethod.GET)
  25. public Response backlog(@PathVariable long userId) {
  26. return Response.ok(messageService.getMessage(userId, false));
  27. }
  28. @ApiOperation(value = "已办事项", notes = "已办事项")
  29. @RequestMapping(value = "/finishBacklog/{userId}", method = RequestMethod.GET)
  30. public Response finishBacklog(@PathVariable long userId) {
  31. return Response.ok(messageService.getMessage(userId, true));
  32. }
  33. @ApiOperation(value = "审核消息发送", notes = "审核消息发送")
  34. @RequestMapping(value = "/", method = RequestMethod.POST)
  35. public Response pushMesssage(@RequestBody JSONObject parameter) {
  36. messageService.pushMessage(parameter);
  37. return Response.ok();
  38. }
  39. @ApiOperation(value = "其他消息发送", notes = "其他消息发送")
  40. @RequestMapping(value = "/{userIds}", method = RequestMethod.POST)
  41. public Response pushOtherMesssage(@PathVariable String userIds, @RequestBody NotificationMessage message) {
  42. messageService.pushOtherMesssage(userIds, message);
  43. return Response.ok();
  44. }
  45. @ApiOperation(value = "修改", notes = "修改")
  46. @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
  47. public Response updateViewed(@PathVariable long id) {
  48. messageService.updateViewed(id);
  49. return Response.ok();
  50. }
  51. @ApiOperation(value = "详情", notes = "详情")
  52. @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
  53. public Response get(@PathVariable long id) {
  54. return Response.ok(messageService.get(id));
  55. }
  56. @ApiOperation(value = "根据type获取消息列表", notes = "根据type获取消息列表")
  57. @RequestMapping(value = "/messageType/{userId}/{messageType}", method = RequestMethod.GET)
  58. public Response getByUserId(@PathVariable int messageType, @PathVariable long userId) {
  59. return Response.ok(messageService.getMessageByUserId(messageType, userId));
  60. }
  61. @ApiOperation(value = "根据type统计未读消息", notes = "根据type统计未读消息")
  62. @RequestMapping(value = "/countUnread/messageType/{userId}/{messageType}", method = RequestMethod.GET)
  63. public Response countUnread(@PathVariable int messageType, @PathVariable long userId) {
  64. return Response.ok(messageService.countUnread(messageType, userId));
  65. }
  66. }