TopicServiceImpl.java
9.22 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
package com.cnlive.shenhe.serviceImpl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.dto.TopicDTO;
import com.cnlive.shenhe.entity.ShyComments;
import com.cnlive.shenhe.entity.ShyContent;
import com.cnlive.shenhe.entity.ShyTopic;
import com.cnlive.shenhe.mapper.ShyCommentsMapper;
import com.cnlive.shenhe.mapper.ShySitesMapper;
import com.cnlive.shenhe.mapper.ShyTopicMapper;
import com.cnlive.shenhe.mapper.ShyUsersMapper;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import com.cnlive.shenhe.utils.TransitServiceUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.session.RowBounds;
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.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
/**
* @Auther: liwei
* @Date: 2019/5/20 17:30
* @Description:
*/
@Service
public class TopicServiceImpl {
private static Logger logger = LoggerFactory.getLogger(TopicServiceImpl.class);
@Autowired
ShyCommentsMapper shyCommentsMapper;
@Autowired
ShyTopicMapper shyTopicMapper;
@Autowired
ShySitesMapper shySitesMapper;
@Autowired
ShyUsersMapper shyUsersMapper;
@Autowired
TransitServiceUtils transitServiceUtils;
@Autowired
SitesServiceImpl sitesService;
@Autowired
VideosServiceImpl videosService;
@Autowired
VideofilterServiceImpl videofilterServiceImpl;
@Value("${spring.localhost.url}")
String localhost_url;
public ShyTopic getShyTopic(ShyTopic shyTopic) {
List<ShyTopic> shyTopicList = shyTopicMapper.select(shyTopic);
if (CommonUtils.isNotNull(shyTopicList) && shyTopicList.size() > 0) {
return shyTopicList.get(0);
}
return new ShyTopic();
}
//**************************************
public List<ShyTopic> findshyTopic(ShyTopic shyTopic) {
return shyTopicMapper.selectByRowBounds(shyTopic, new RowBounds(0, 100));
}
//***************************
public boolean updateshyTopic(ShyTopic shyTopic) {
int result = shyTopicMapper.updateByPrimaryKey(shyTopic);
if (result == 0) {
return false;
}
return true;
}
//***************************
public boolean impotshyTopic(ShyTopic shyTopic) {
int result = shyTopicMapper.insertSelective(shyTopic);
if (result == 0) {
return false;
}
return true;
}
public int updateComment(Integer id, Integer state, String msg) {
ShyComments shyComments = shyCommentsMapper.selectByPrimaryKey(id);
shyComments.setState(state);
shyComments.setMsg(msg);
return shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
}
public PageInfo<ShyTopic> getPage(TopicDTO topicDTO) {
logger.info("接受参数列表为,TopicDTO:{}", JSON.toJSONString(topicDTO));
Example example = new Example(ShyTopic.class);
Example.Criteria criteria = example.createCriteria();
if (CommonUtils.isNotEmpty(topicDTO.getOrderByClause())) {
example.setOrderByClause(topicDTO.getOrderByClause());
} else {
example.setOrderByClause("create_date desc");
}
if (CommonUtils.isNotEmpty(topicDTO.getStart_date())) {
criteria.andGreaterThanOrEqualTo("create_date", topicDTO.getStart_date());
}
if (CommonUtils.isNotEmpty(topicDTO.getEnd_date())) {
criteria.andLessThanOrEqualTo("create_date", topicDTO.getEnd_date());
}
if (CommonUtils.isNotEmpty(topicDTO.getTopic_name())) {
criteria.andLike("title", "%" + topicDTO.getTopic_name() + "%");
}
if (CommonUtils.isNotEmpty(topicDTO.getUpdater())) {
criteria.andEqualTo("updater", topicDTO.getUpdater());
}
if (CommonUtils.isNotEmpty(topicDTO.getTopic_tag())) {
criteria.andEqualTo("topic_tag", topicDTO.getTopic_tag());
}
if (CommonUtils.isNotNull(topicDTO.getSpid())) {
criteria.andEqualTo("sp_id", topicDTO.getSpid());
}
if (CommonUtils.isNotEmpty(topicDTO.getTopic_id())) {
criteria.andEqualTo("topic_id", topicDTO.getTopic_id());
}
if (CommonUtils.isNotNull(topicDTO.getReceive()) && topicDTO.getReceive().equals(CommonConst.RECEIVE_AFTER)) {
criteria.andEqualTo("auditor_id", topicDTO.getUserId());
}
//不是 我的已审 进来的,只查一种状态
if (CommonUtils.isNotNull(topicDTO.getShenhe_status()) && topicDTO.getShenhe_status() != 3) {
criteria.andEqualTo("shenhe_status", topicDTO.getShenhe_status());
//是 我的已审,查通过和拒绝的两种状态
} else if (CommonUtils.isNotNull(topicDTO.getShenhe_status()) && topicDTO.getShenhe_status() == 3) {
Example.Criteria criteria1 = example.createCriteria();
criteria1.orEqualTo("shenhe_status", 1);
criteria1.orEqualTo("shenhe_status", 2);
example.and(criteria1);
}
PageHelper.startPage(topicDTO.getPage(), topicDTO.getPageSize(), true);
List<ShyTopic> topicList = shyTopicMapper.selectByExample(example);
PageInfo<ShyTopic> pageInfo = new PageInfo<>(topicList);
return pageInfo;
}
/**
* 根据条件导出数据excel
*
* @return
*/
public List<ShyTopic> findByCondition(String title, String content_tag, String contentId, Date start_date,
Date end_date, Integer receive_status, Integer page,
Integer pageSize, String orderByClause, Integer spid) {
Example example = new Example(ShyContent.class);
Example.Criteria criteria = example.createCriteria();
if (CommonUtils.isNotEmpty(orderByClause)) {
example.setOrderByClause(orderByClause);
} else {
example.setOrderByClause("create_date desc");
}
if (CommonUtils.isNotNull(start_date)) {
criteria.andGreaterThanOrEqualTo("create_date", start_date);
}
if (CommonUtils.isNotNull(end_date)) {
criteria.andLessThanOrEqualTo("create_date", end_date);
}
if (CommonUtils.isNotEmpty(title)) {
criteria.andLike("title", "%" + title + "%");
}
if (CommonUtils.isNotNull(spid)) {
criteria.andEqualTo("sp_id", spid);
}
if (CommonUtils.isNotEmpty(contentId)) {
criteria.andEqualTo("content_id", contentId);
}
if (CommonUtils.isNotEmpty(content_tag)) {
criteria.andEqualTo("content_tag", content_tag);
}
if (CommonUtils.isNotNull(receive_status)) {
criteria.andEqualTo("receive_status", receive_status);
}
List<ShyTopic> shyContentList = shyTopicMapper.selectByExample(example);
return shyContentList;
}
//**********************
public boolean callback(String id, String msg, Integer state, String userId, String updater) {
boolean success = true;
ShyTopic topic = shyTopicMapper.selectByPrimaryKey(Integer.parseInt(id));
JSONObject params = new JSONObject();
params.put("topic_id", topic.getTopic_id());
params.put("status", state + 1);
params.put("msg", msg);
success = transitServiceUtils.send("cms", "updateTopicStatus", true, params);
if (!success) {
logger.error("话题审核回调失败,话题表id:{}", topic.getId());
return success;
}
topic.setShenhe_status(state);// 设置话题状态为审核后的状态
topic.setShenhe_msg(msg);// 设置审核消息
if (CommonUtils.isNotEmpty(userId)) {
topic.setAuditor_id(userId);
topic.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 设置审核类型为人工
} else {
topic.setUpdater(updater);//设置更新人
}
topic.setUpdate_date(CommonUtils.getCurrentTime());
int i = shyTopicMapper.updateByPrimaryKeySelective(topic);
if (i != 1) {
success = false;
}
return success;
}
//**************************************
public ShyTopic selectByPrimaryKey(Integer id) {
ShyTopic shyTopic = shyTopicMapper.selectByPrimaryKey(id);
return shyTopic;
}
public int updateByPrimaryKeySelective(ShyTopic topic) {
return shyTopicMapper.updateByPrimaryKeySelective(topic);
}
/**
* 获得审核类型
*
* @param spId
*/
public Integer getShenheType(Integer spId) {
//获取图文免审sp
List<Integer> sites = sitesService.getBusinessList(CommonConst.BUSINESS_TOPIC);
//初始化一个审核状态
Integer shenheType = 3;//审核类型,1:免审,2:机审,3:人工审
//如果当前sp是免审sp
if (sites.contains(spId)) {
shenheType = 1;//免审
} else {
shenheType = 3;//人工审
}
return shenheType;
}
}