TopicControllerApi.java
4.29 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
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.ShyTopic;
import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl;
import com.cnlive.shenhe.serviceImpl.TopicServiceImpl;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/api/topic")
public class TopicControllerApi {
private static Logger logger = LoggerFactory.getLogger(TopicControllerApi.class);
@Autowired
AuditPass Pass;
@Autowired
CommentsServiceImpl commentsService;
@Autowired
TopicServiceImpl topicService;
/**
* @author liwei
* @Date: 2019/12/13 15:17
* @Description: 话题送审接口
*/
@PostMapping("/import")
@ResponseBody
public ResponseBean impotTopic(@RequestBody String param) {
logger.info("话题入库,param=====" + param);
JSONObject json = JSONObject.parseObject(param);
//获取所有参数
String topic_id = json.getString("topic_id");//话题id
Integer spId = Integer.parseInt(json.getString("spId"));//spId
String topicTitle = json.getString("topicTitle");//话题标题
String topicPic = json.getString("topicPic");//话题图片
String topic_text = json.getString("topic_text");//话题内容
String topic_tag = json.getString("topic_tag");//话题标签
String topic_url = json.getString("topic_url");//话题url
String topic_time = json.getString("createTime");//话题创建时间
//判断是否存在
ShyTopic shyTopic=new ShyTopic();
shyTopic.setTopic_id(topic_id);
List<ShyTopic> topicList = topicService.findshyTopic(shyTopic);
//获取审核类型
Integer shenheType = topicService.getShenheType(spId);
//存在则更新
if (topicList.size() > 0) {
ShyTopic shyTopic1 = topicList.get(0);
shyTopic1.setTitle(topicTitle);//话题标题
shyTopic1.setTopic_image(topicPic);//话题图片
shyTopic1.setShenhe_type(shenheType);//审核类型
shyTopic1.setTopic_text(topic_text);//话题内容
shyTopic1.setTopic_tag(topic_tag);//话题标签
shyTopic1.setTopic_url(topic_url);//话题url
shyTopic1.setTopic_time(topic_time);//话题创建时间
shyTopic1.setSp_id(spId);//spid
shyTopic1.setShenhe_status(CommonConst.AUDIT_INTT);;//当前话题的审核状态
shyTopic1.setUpdate_date(CommonUtils.getCurrentTime());//最后一次更新时间
boolean YorN = topicService.updateshyTopic(shyTopic1);
if (YorN == true) {
return new ResponseBean(ErrorEnum.ERROR);
} else {
return new ResponseBean(ErrorEnum.SUCCESS);
}
}
//如果不存在直接插入
shyTopic.setTitle(topicTitle);//话题标题
shyTopic.setTopic_image(topicPic);//话题图片
shyTopic.setShenhe_type(shenheType);//审核类型
shyTopic.setTopic_text(topic_text);//话题内容
shyTopic.setTopic_tag(topic_tag);//话题标签
shyTopic.setTopic_url(topic_url);//话题url
shyTopic.setTopic_time(topic_time);//话题创建时间
shyTopic.setSp_id(spId);//spid
shyTopic.setShenhe_status(CommonConst.AUDIT_INTT);;//当前话题的审核状态
shyTopic.setUpdate_date(CommonUtils.getCurrentTime());//最后一次更新时间
shyTopic.setCreate_date(CommonUtils.getCurrentTime());//送审时间
boolean YorN = topicService.impotshyTopic(shyTopic);
if (YorN == true) {
return new ResponseBean(ErrorEnum.ERROR);
} else {
return new ResponseBean(ErrorEnum.SUCCESS);
}
}
}