LiveApplyControllerApi.java
9.16 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package com.cnlive.shenhe.api;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.entity.ShyLiveapply;
import com.cnlive.shenhe.serviceImpl.LiveApplyServiceImpl;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
/**
* @author Administrator
*/
@Controller
@RequestMapping("/api/liveApply")
public class LiveApplyControllerApi {
private static Logger logger = LoggerFactory.getLogger(LiveApplyControllerApi.class);
@Autowired
LiveApplyServiceImpl liveApplyServiceImpl;
@PostMapping("/import")
@ResponseBody
public JSONObject impotLiveApply(String param) {
JSONObject map = new JSONObject();
JSONObject result = new JSONObject();
//初始化一个请求数据库返回结果
boolean yorN = true;
logger.info("直播申请入库,param=====" + param);
JSONObject json = JSONObject.parseObject(param);
//获取所有参数
//直播活动id
String activityId = json.getString("activityId");
//直播频道id
String channelId = json.getString("channelId");
Integer spId = null;
try {
spId = json.getInteger("spId");
} catch (Exception e) {
spId = null;
}
//直播发起人
String sender = json.getString("sender");
//联系方式
String mobile = json.getString("mobile");
//回调地址
String callback = json.getString("callback");
//直播发起单位
String organization = json.getString("organization");
//直播主题
String theme = json.getString("theme");
//商务模式:0免费 1收费
Integer businessModel = json.getInteger("businessModel");
//内容属性:1商业类活动 0非商业活动
Integer contentProperty = json.getInteger("contentProperty");
//内容简述
String simpleContent = json.getString("simpleContent");
//直播类型
String liveType = json.getString("liveType");
//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
String keys = json.getString("keys").equals("") ? "无" : json.getString("keys");
//直播地点
String livePlace = json.getString("livePlace");
//推流地址
String pushUrl = json.getString("pushUrl");
//拉流地址
String pullUrl = json.getString("pullUrl").equals("") ? "无拉流地址" : json.getString("pullUrl");
//拉流来源
String pullSource = json.getString("pullSource").equals("") ? "无来源" : json.getString("pullSource");
//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
String platforms = json.getString("platforms");
//预计开始时间
String startTime = json.getString("preStartTime");
Date timestampStart = null;
if (CommonUtils.isNotEmpty(startTime)) {
timestampStart = new Timestamp(Long.valueOf(startTime));
}
//预计结束时间
String endTime = json.getString("preEndTime");
Date timestampEnd = null;
if (CommonUtils.isNotEmpty(endTime)) {
timestampEnd = new Timestamp(Long.valueOf(endTime));
}
ShyLiveapply shyliveApply1 = new ShyLiveapply();
//得到直播活动id去查询是否已有
shyliveApply1.setActivity_id(activityId);
//查询一下 存在,更新 没有,插入
List<ShyLiveapply> listshyLiveApply = liveApplyServiceImpl.findshyLiveApply(shyliveApply1);
if (listshyLiveApply.size() > 0) {
ShyLiveapply shyliveApply = listshyLiveApply.get(0);
//封装数据入库
//设置spid
shyliveApply.setSp_id(spId);
//设置发送者
shyliveApply.setSender(sender);
//设置联系方式
shyliveApply.setMobile(mobile);
//设置直播发起单位
shyliveApply.setOrganization(organization);
//直播主题
shyliveApply.setTheme(theme);
//直播类型
shyliveApply.setLive_type(liveType);
//预计开始时间
shyliveApply.setPre_start_time(timestampStart);
//预计结束时间
shyliveApply.setPre_end_time(timestampEnd);
//商务模式:0免费 1收费
shyliveApply.setBusiness_model(businessModel);
//内容属性:1商业类活动 0非商业活动
shyliveApply.setContent_property(contentProperty);
//内容简述
shyliveApply.setSimple_content(simpleContent);
//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
shyliveApply.setPoint_key(keys);
//直播地点
shyliveApply.setLive_place(livePlace);
//推流地址
shyliveApply.setPush_url(pushUrl);
//拉流地址
shyliveApply.setPull_url(pullUrl);
//拉流来源
shyliveApply.setPull_source(pullSource);
//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
shyliveApply.setPlatforms(platforms);
//设置回调地址
shyliveApply.setCallback(callback);
shyliveApply.setReceive(CommonConst.RECEIVE_BEFORE);
shyliveApply.setShenhe_state(CommonConst.AUDIT_INTT);
shyliveApply.setEmail_notice_state(CommonConst.NOTICE_INTT);
shyliveApply.setUpdater(null);
shyliveApply.setAuditor(null);
//更新时间
shyliveApply.setUpdated_at(CommonUtils.getCurrentTime());
//获取审核类型
liveApplyServiceImpl.getShenheType(shyliveApply);
yorN = liveApplyServiceImpl.updateshyLiveApply(shyliveApply);
} else {
//查了,没有,直接插入数据库
//设置频道id
shyliveApply1.setChannel_id(channelId);
//设置spid
shyliveApply1.setSp_id(spId);
//设置发送者
shyliveApply1.setSender(sender);
//设置联系方式
shyliveApply1.setMobile(mobile);
//设置直播发起单位
shyliveApply1.setOrganization(organization);
//直播主题
shyliveApply1.setTheme(theme);
//直播类型
shyliveApply1.setLive_type(liveType);
//预计开始时间
shyliveApply1.setPre_start_time(timestampStart);
//预计结束时间
shyliveApply1.setPre_end_time(timestampEnd);
//商务模式:0免费 1收费
shyliveApply1.setBusiness_model(businessModel);
//内容属性:1商业类活动 0非商业活动
shyliveApply1.setContent_property(contentProperty);
//内容简述
shyliveApply1.setSimple_content(simpleContent);
//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
shyliveApply1.setPoint_key(keys);
//直播地点
shyliveApply1.setLive_place(livePlace);
//推流地址
shyliveApply1.setPush_url(pushUrl);
//拉流地址
shyliveApply1.setPull_url(pullUrl);
//拉流来源
shyliveApply1.setPull_source(pullSource);
//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
shyliveApply1.setPlatforms(platforms);
//设置回调地址
shyliveApply1.setCallback(callback);
//获取审核类型
liveApplyServiceImpl.getShenheType(shyliveApply1);
shyliveApply1.setReceive(CommonConst.RECEIVE_BEFORE);
shyliveApply1.setShenhe_state(CommonConst.AUDIT_INTT);
shyliveApply1.setEmail_notice_state(CommonConst.NOTICE_INTT);
shyliveApply1.setUpdater(null);
shyliveApply1.setAuditor(null);
shyliveApply1.setShenhe_msg(null);
shyliveApply1.setEmail_notice_msg("");
//创建时间
shyliveApply1.setCreated_at(CommonUtils.getCurrentTime());
//更新时间
shyliveApply1.setUpdated_at(CommonUtils.getCurrentTime());
yorN = liveApplyServiceImpl.impotLiveApply(shyliveApply1);
}
if (yorN) {
result.put("errorCode", "0");
result.put("errorMessage", "直播申请审核请求收到成功");
map.put("statusCode", "200");
map.put("result", result);
} else {
result.put("errorCode", "-1");
result.put("errorMessage", "直播申请审核入库失败");
map.put("statusCode", "300");
map.put("result", result);
}
return map;
}
}