InBoxController.java
2.76 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
package com.yohoufo.user.controller.inbox;
import com.alibaba.fastjson.JSONArray;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.dal.user.model.InBox;
import com.yohoufo.user.requestVO.ListInboxReqVO;
import com.yohoufo.user.requestVO.ListInboxTypeInfoReqVO;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* Created by shengguo.cai on 2018/9/11.
*/
@RestController
public class InBoxController {
private static Logger logger = LoggerFactory.getLogger(InBoxController.class);
@Resource
private IInBoxService inBoxService;
/**
* 查询消息类型以及每个类型下的未读消息
* @param reqBO
*/
@RequestMapping(params = "method=ufo.users.listInboxTypeInfo")
public ApiResponse listInboxTypeInfo(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);
return new ApiResponse(200,"操作成功",allTabs);
}
/**
* 查询消息列表
* @param reqVO
* reqVO.type 为 null,查询最新消息;
* reqVO.type 不为null,根据type查询消息
* @return
*/
@RequestMapping(params = "method=ufo.users.listInboxs")
public ApiResponse listInboxs(ListInboxReqVO reqVO){
logger.info("enter listInboxByTypes param is {}", reqVO);
PageResponseVO<InBox> pageList = inBoxService.listInboxByTypes(reqVO);
return new ApiResponse(200,"操作成功",pageList);
}
/**
* 新增消息
*/
@RequestMapping(params = "method=ufo.users.addInbox")
public ApiResponse addInbox(@RequestParam(name = "uid") int uid,
@RequestParam(name = "type") Integer type,
@RequestParam(name = "businessType") Integer businessType,
@RequestParam(name = "params",required = false) String params){
logger.info("addInbox with param :uid is {},type is {},businessType is {},params is {}", uid,type,businessType,params);
inBoxService.addInbox(uid,type,businessType,params);
return new ApiResponse(200,"保存成功",null);
}
}