12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package com.bosshand.virgo.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.bosshand.virgo.core.response.Response;
- import com.bosshand.virgo.message.model.NotificationMessage;
- import com.bosshand.virgo.message.service.MessageService;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping(value = "message")
- public class MessageController {
- @Autowired
- private MessageService messageService;
- @ApiOperation("分页获取消息列表")
- @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
- public Response list(@RequestBody NotificationMessage notificationMessage, @PathVariable int currPage, @PathVariable int pageSize) {
- int totalCount = messageService.getTotalCount(notificationMessage);
- List<NotificationMessage> dataList = messageService.getLimit(notificationMessage, currPage, pageSize);
- Map<String, Object> result = new HashMap<>();
- result.put("dataList", dataList);
- result.put("totalCount", totalCount);
- return Response.ok(result);
- }
- @ApiOperation(value = "个人消息列表", notes = "个人消息列表")
- @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
- public Response getByUserId(@PathVariable long userId) {
- return Response.ok(messageService.getMessageByUserId(userId));
- }
- @ApiOperation(value = "待办事项", notes = "待办事项")
- @RequestMapping(value = "/backlog/{userId}", method = RequestMethod.GET)
- public Response backlog(@PathVariable long userId) {
- return Response.ok(messageService.getMessage(userId, false));
- }
- @ApiOperation(value = "已办事项", notes = "已办事项")
- @RequestMapping(value = "/finishBacklog/{userId}", method = RequestMethod.GET)
- public Response finishBacklog(@PathVariable long userId) {
- return Response.ok(messageService.getMessage(userId, true));
- }
- @ApiOperation(value = "审核消息发送", notes = "审核消息发送")
- @RequestMapping(value = "/", method = RequestMethod.POST)
- public Response pushMesssage(@RequestBody JSONObject parameter) {
- messageService.pushMessage(parameter);
- return Response.ok();
- }
- @ApiOperation(value = "其他消息发送", notes = "其他消息发送")
- @RequestMapping(value = "/{userIds}", method = RequestMethod.POST)
- public Response pushOtherMesssage(@PathVariable String userIds, @RequestBody NotificationMessage message) {
- messageService.pushOtherMesssage(userIds, message);
- return Response.ok();
- }
- @ApiOperation(value = "提醒消息发送", notes = "提醒消息发送")
- @RequestMapping(value = "/reminder", method = RequestMethod.POST)
- public void pushReminderMessage(@RequestBody JSONArray data) {
- messageService.pushReminderMessage(data);
- }
- @ApiOperation(value = "修改", notes = "修改")
- @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
- public Response updateViewed(@PathVariable long id) {
- messageService.updateViewed(id);
- return Response.ok();
- }
- @ApiOperation(value = "详情", notes = "详情")
- @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
- public Response get(@PathVariable long id) {
- return Response.ok(messageService.get(id));
- }
- @ApiOperation(value = "根据type获取消息列表", notes = "根据type获取消息列表")
- @RequestMapping(value = "/messageType/{userId}/{messageType}", method = RequestMethod.GET)
- public Response getByUserId(@PathVariable int messageType, @PathVariable long userId) {
- return Response.ok(messageService.getMessageByUserId(messageType, userId));
- }
- @ApiOperation(value = "统计未读消息数", notes = "统计未读消息数")
- @RequestMapping(value = "/countUnread/messageType/{userId}", method = RequestMethod.GET)
- public Response countUnread(@PathVariable long userId) {
- return Response.ok(messageService.countUnread(userId));
- }
- }
|