| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package com.uas.ps.message.api;
- import com.uas.ps.core.page.PageParams;
- import com.uas.ps.httplog.annotation.HttpLog;
- import com.uas.ps.message.domain.Message;
- import com.uas.ps.message.service.MessageService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.domain.Page;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- import java.util.Map;
- /**
- * Created by wangyc on 2018/1/13.
- *
- * @version 2018/1/13 15:36 wangyc
- */
- @RestController
- @RequestMapping(value = "/messages")
- public class MessageController {
- private final MessageService messageService;
- @Autowired
- public MessageController(MessageService messageService) {
- this.messageService = messageService;
- }
- /**
- * 获取消息
- * @param receiverUu 收信人uu
- * @param receiverEnuu 收信人企业uu
- * @param consumerApp 接收app
- * @param pageParams 分页参数
- * @param isRead 读取状态
- * @param type 类型
- * @param keyword 关键词
- * @param pageParams
- * @return
- */
- @HttpLog
- @RequestMapping(method = RequestMethod.GET, produces = "application/json")
- public Page<Message> getMessages(String receiverUu, String receiverEnuu, String consumerApp, String isRead, String type, String keyword, PageParams pageParams) {
- return messageService.getMessages(receiverUu, receiverEnuu, consumerApp, isRead, type, keyword, pageParams);
- }
- /**
- * 获取未读消息数量
- * @param receiverUu 收信人uu
- * @param receiverEnuu 收信人企业uu
- * @param consumerApp 接收app
- * @return
- */
- @RequestMapping(value = "/count/unread", method = RequestMethod.GET, produces = "application/json")
- public Map<String, Object> getUnReadMessageCount(String receiverUu, String receiverEnuu, String consumerApp) {
- return messageService.getUnReadMessageCount(receiverUu, receiverEnuu, consumerApp);
- }
- /**
- * 获取未读消息数量
- * @param receiverUu 收信人uu
- * @param receiverEnuu 收信人企业uu
- * @param consumerApp 接收app
- * @param isRead 阅读状态
- * @return
- */
- @RequestMapping(value = "/count", method = RequestMethod.GET, produces = "application/json")
- public Map<String, Object> getMessageCount(String receiverUu, String receiverEnuu, String consumerApp, @RequestParam(required = false) String isRead) {
- return messageService.getMessageCount(receiverUu, receiverEnuu, consumerApp, isRead);
- }
- /**
- * 保存消息
- * @param messages 消息
- * @return
- */
- @HttpLog
- @RequestMapping(method = RequestMethod.POST, produces = "application/json")
- public List<Message> saveMessages(@RequestBody String messages) {
- // TODO 日志
- return messageService.saveMessages(messages);
- }
- /**
- * 推送消息
- * @param consumerApp 接收消息app
- * @return
- */
- @HttpLog
- @RequestMapping(value = "/send", method = RequestMethod.POST, produces = "application/json")
- public Map<String, Object> sendMessage(@RequestBody String consumerApp) {
- return messageService.sendMessage(consumerApp);
- }
- /**
- * 阅读消息
- * @param cousumer 消息接收者信息
- * @return
- */
- @HttpLog
- @RequestMapping(value = "/read", method = RequestMethod.POST, produces = "application/json")
- public ModelMap read(@RequestBody String cousumer) {
- return messageService.readMessage(cousumer);
- }
- }
|