ChannelControllerApi.java
4.85 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.cnlive.shenhe.api;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.entity.ShyChannel;
import com.cnlive.shenhe.serviceImpl.ChannelServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/api/channel")
public class ChannelControllerApi {
private static Logger logger = LoggerFactory.getLogger(ChannelControllerApi.class);
@Value("${spring.localhost.url}")
private String localhost_url;//本机地址
@Autowired
AuditPass Pass;
@Autowired
ChannelServiceImpl channelService;
/**
* @Auther: liwei
* @Date: 2019/08/17 11:17
* @Description: 频道送审接口
*/
@PostMapping("/import")
@ResponseBody
public ResponseBean impotChannel(String param) {
logger.info("频道入库,param=====" + param);
JSONObject json = JSONObject.parseObject(param);
//判断是否存在
ShyChannel shyChannel = new ShyChannel();
shyChannel.setChannel_id(json.getString("channelId"));
List<ShyChannel> channelList = channelService.findshyChannel(shyChannel);
Integer sp_id=null;
try {
sp_id=json.getInteger("spId");
} catch (Exception e) {
sp_id=null;
}
//存在则更新
if (channelList.size() > 0) {
ShyChannel shyChannel1 = channelList.get(0);
shyChannel1.setShenhe_status(CommonConst.AUDIT_INTT);
shyChannel1.setChannel_name(json.getString("channelName"));
shyChannel1.setChannel_img(json.getString("face"));
shyChannel1.setCallback(json.getString("callback"));
shyChannel1.setSp_id(sp_id);
// shyChannel1.setAuditor(null);
// shyChannel1.setUpdater(null);
shyChannel1.setOffline(0);//是否下线 0表示正常 1表示下线
shyChannel1.setUpdated_at(CommonUtils.getCurrentTime());
channelService.getShenheType(shyChannel1);
boolean YorN = channelService.updateshyChannel(shyChannel1);
if (YorN == true) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(),"审核请求收到成功");
} else {
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(),"审核请求收到失败(更新)");
}
}
//如果不存在直接插入
shyChannel.setShenhe_status(CommonConst.AUDIT_INTT);
shyChannel.setChannel_name(json.getString("channelName"));
shyChannel.setChannel_img(json.getString("face"));
shyChannel.setCallback(json.getString("callback"));
shyChannel.setSp_id(sp_id);
shyChannel.setOffline(0);//是否下线 0表示正常 1表示下线
shyChannel.setCreated_at(CommonUtils.getCurrentTime());
shyChannel.setUpdated_at(CommonUtils.getCurrentTime());
channelService.getShenheType(shyChannel);
boolean YorN = channelService.impotChannel(shyChannel);
if (YorN == true) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(),"审核请求收到成功");
} else {
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(),"审核请求收到失败(新增)");
}
}
/**
* @Auther: liwei
* @Date: 2019/08/17 11:17
* @Description: 频道前台通知接口
*/
@GetMapping("/channelNotice")
@ResponseBody
public Map<String,Object> channelNotice() {
Map<String,Object> map=new HashMap<>();
ShyChannel shyChannel = new ShyChannel();
shyChannel.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 审核类型为人工审
shyChannel.setShenhe_status(CommonConst.AUDIT_INTT);
List<ShyChannel> channelList = channelService.findshyChannel(shyChannel);
if (channelList.size() > 0) {
logger.info("您有"+channelList.size()+"条新的频道审核申请,请注意查看!");
map.put("id", "1");//第一个提示框,避免冲突
map.put("title", "新频道审核通知");
map.put("content","您有"+channelList.size()+"条新的频道审核申请,请注意查看!" );
map.put("url",localhost_url+"/channel/page?shenhe_status=0&receive=0" );
return map;
}
return null;
}
}