| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package com.uas.ps.message.api;
- import com.uas.ps.message.domain.Message;
- import com.uas.ps.message.service.MessageService;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- 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;
- /**
- * 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
- private MessageController(MessageService messageService) {
- this.messageService = messageService;
- }
- /**
- * 获取消息
- * @param receiver 收信人
- * @param consumerApp 接收app
- * @return
- */
- @RequestMapping(method = RequestMethod.GET, produces = "application/json")
- public List<Message> getMessages(@RequestParam String receiver, String consumerApp) {
- return messageService.getMessages(receiver, consumerApp);
- }
- /**
- * 保存消息
- * @param messages 消息
- * @return
- */
- @RequestMapping(method = RequestMethod.POST, produces = "application/json")
- public List<Message> saveMessages(@RequestBody String messages) {
- // TODO 日志
- return messageService.saveMessages(messages);
- }
- /**
- * 推送消息
- * @param consumerApp 接收消息app
- * @return
- */
- @RequestMapping(value = "/send", method = RequestMethod.POST, produces = "application/json")
- public Map<String, Object> sendMessage(@RequestBody String consumerApp) {
- return messageService.sendMessage(consumerApp);
- }
- }
|