InBoxController.java
3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.yohoufo.user.controller.inbox;
import com.alibaba.fastjson.JSONArray;
import com.yoho.core.common.restbean.ResponseBean;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.user.dal.model.InBox;
import com.yohoufo.user.requestVO.InboxReqVO;
import com.yohoufo.user.requestVO.ListInboxTypeInfoReqVO;
import com.yohoufo.user.requestVO.ListNewInboxReqVO;
import com.yohoufo.user.responseVO.PageResponseVO;
import com.yohoufo.user.service.IInBoxService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* Created by shengguo.cai on 2018/9/11.
*/
@RestController
@RequestMapping("/inbox")
public class InBoxController {
private static Logger logger = LoggerFactory.getLogger(InBoxController.class);
@Resource
private IInBoxService inBoxService;
/**
* 查询消息类型以及每个类型下的未读消息
* @param reqBO
*/
@RequestMapping("/listInboxTypeInfo")
public ResponseBean listInboxTypeInfo(@RequestBody ListInboxTypeInfoReqVO reqBO){
logger.info("enter listInboxTypeInfo param is {}", reqBO);
// (1)判断用户id是否存在
if (null == reqBO || reqBO.getUid() < 1) {
logger.warn("Uid is null or 0.");
throw new ServiceException(ServiceError.SMS_INBOX_UID_NULL);
}
JSONArray allTabs = inBoxService.listInboxTypeInfo(reqBO);
ResponseBean responseBean = new ResponseBean();
responseBean.setCode("200");
responseBean.setData(allTabs);
responseBean.setMessage("listInboxTypeInfo success");
return responseBean;
}
/**
* 查看某个消息类型下的未读消息列表
* @param reqVO
* reqVO.type 为 null,查询最新未读消息;
* reqVO.type 不为null,根据type查询未读消息
* @return
*/
@RequestMapping("/listNewInboxs")
public ResponseBean listNewInboxs(@RequestBody ListNewInboxReqVO reqVO){
logger.info("enter listNewInboxByTypes param is {}", reqVO);
ResponseBean responseBean = new ResponseBean();
PageResponseVO<InBox> pageList = inBoxService.listNewInboxByTypes(reqVO);
responseBean.setCode("200");
responseBean.setMessage("success");
responseBean.setData(pageList);
logger.info("listNewInboxByTypes success with param is {}, count is {}", reqVO, pageList.getTotal());
return responseBean;
}
/**
* 新增消息
*/
@RequestMapping("/addInbox")
public ResponseBean addInbox(@RequestBody InboxReqVO reqVO){
logger.info("addInbox with param is {}", reqVO);
inBoxService.addInbox(reqVO);
ResponseBean responseBean = new ResponseBean();
responseBean.setCode("200");
responseBean.setMessage("保存成功");
return responseBean;
}
}