LiveApplyControllerApi.java
8.21 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
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 impotVideo(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");//直播主题
Integer businessModel = Integer.parseInt(json.getString("businessModel"));//商务模式:0免费 1收费
Integer contentProperty = Integer.parseInt(json.getString("contentProperty"));//内容属性:1商业类活动 0非商业活动
String simpleContent = json.getString("simpleContent");//内容简述
String live_type = json.getString("liveType");//直播类型
String keys = json.getString("keys").equals("")?"无":json.getString("keys");//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
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");//拉流来源
String platforms = json.getString("platforms");//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
String startTime = json.getString("preStartTime");//预计开始时间
Date timestamp_start =null;
if (CommonUtils.isNotEmpty(startTime)) {
timestamp_start = new Timestamp(Long.valueOf(startTime));
}
String endTime = json.getString("preEndTime");//预计结束时间
Date timestamp_end =null;
if (CommonUtils.isNotEmpty(endTime)) {
timestamp_end = 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);
//封装数据入库
shyliveApply.setSp_id(spId);//设置spid
shyliveApply.setSender(sender);//设置发送者
shyliveApply.setMobile(mobile);//设置联系方式
shyliveApply.setOrganization(organization);//设置直播发起单位
shyliveApply.setTheme(theme);//直播主题
shyliveApply.setLive_type(live_type);//直播类型
shyliveApply.setPre_start_time(timestamp_start);//预计开始时间
shyliveApply.setPre_end_time(timestamp_end);//预计结束时间
shyliveApply.setBusiness_model(businessModel);//商务模式:0免费 1收费
shyliveApply.setContent_property(contentProperty);//内容属性:1商业类活动 0非商业活动
shyliveApply.setSimple_content(simpleContent);//内容简述
shyliveApply.setPoint_key(keys);//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
shyliveApply.setLive_place(livePlace);//直播地点
shyliveApply.setPush_url(pushUrl);//推流地址
shyliveApply.setPull_url(pullUrl);//拉流地址
shyliveApply.setPull_source(pullSource);//拉流来源
shyliveApply.setPlatforms(platforms);//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
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{
//查了,没有,直接插入数据库
shyliveApply1.setChannel_id(channelId);//设置频道id
shyliveApply1.setSp_id(spId);//设置spid
shyliveApply1.setSender(sender);//设置发送者
shyliveApply1.setMobile(mobile);//设置联系方式
shyliveApply1.setOrganization(organization);//设置直播发起单位
shyliveApply1.setTheme(theme);//直播主题
shyliveApply1.setLive_type(live_type);//直播类型
shyliveApply1.setPre_start_time(timestamp_start);//预计开始时间
shyliveApply1.setPre_end_time(timestamp_end);//预计结束时间
shyliveApply1.setBusiness_model(businessModel);//商务模式:0免费 1收费
shyliveApply1.setContent_property(contentProperty);//内容属性:1商业类活动 0非商业活动
shyliveApply1.setSimple_content(simpleContent);//内容简述
shyliveApply1.setPoint_key(keys);//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
shyliveApply1.setLive_place(livePlace);//直播地点
shyliveApply1.setPush_url(pushUrl);//推流地址
shyliveApply1.setPull_url(pullUrl);//拉流地址
shyliveApply1.setPull_source(pullSource);//拉流来源
shyliveApply1.setPlatforms(platforms);//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
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 == true) {
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;
}
}