CommentsServiceImpl.java
3.26 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
package com.cnlive.shenhe.serviceImpl;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.entity.ShyComments;
import com.cnlive.shenhe.entity.ShySites;
import com.cnlive.shenhe.mapper.ShyCommentsMapper;
import com.cnlive.shenhe.mapper.ShySitesMapper;
import com.cnlive.shenhe.utils.CommonUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* @Auther: chenhao
* @Date: 2018/12/4 17:30
* @Description:
*/
@Service
public class CommentsServiceImpl {
@Autowired
ShyCommentsMapper shyCommentsMapper ;
@Autowired
ShySitesMapper shySitesMapper;
public List<ShySites> getBusiness (ShySites shySites ) {
List<ShySites> sitesList = shySitesMapper.select(shySites);
return sitesList;
}
public int impotComments(ShyComments shyComments){
int result = shyCommentsMapper.insert(shyComments);
return result;
}
public int updateComment(JSONObject json,Integer id,String auditor_id){
ShyComments shyComments = new ShyComments();
shyComments.setId(id);
shyComments.setAuditor_id(auditor_id);
shyComments.setActivity_id(json.getString("activity_id"));
shyComments.setState(json.getInteger("state"));
shyComments.setMsg(json.getString("msg"));
int result = shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
return result;
}
public PageInfo<ShyComments> getListComments(String activity_id,String content,Integer is_hot,String start_date,String end_date,Integer state,String auditor,Integer page,Integer pageSize,String orderByClause,Integer spid){
Example example = new Example(ShyComments.class);
Example.Criteria criteria = example.createCriteria();
if (CommonUtils.isNotEmpty(orderByClause)) {
example.setOrderByClause(orderByClause);
}
if (CommonUtils.isNotEmpty(start_date)&&CommonUtils.isNotEmpty(end_date)) {
criteria.andGreaterThanOrEqualTo("comment_time",start_date);
criteria.andLessThanOrEqualTo("comment_time",end_date);
}
if (CommonUtils.isNotEmpty(content)){
criteria.andLike("comment_content", "%" + content + "%");
}
if (CommonUtils.isNotEmpty(auditor)){
criteria.andEqualTo("auditor", auditor );
}
if (CommonUtils.isNotNull(spid)){
criteria.andEqualTo("spid", spid );
}
if (CommonUtils.isNotNull(is_hot)){
criteria.andEqualTo("is_hot", is_hot );
}
if (CommonUtils.isNotEmpty(activity_id)){
criteria.andEqualTo("activity_id", activity_id);
}
//默认按上传时间倒序排序
example.setOrderByClause("comment_time desc");
PageHelper.startPage(page, pageSize, true);
List<ShyComments> commentsList = shyCommentsMapper.selectByExample(example);
PageInfo<ShyComments> pageInfo = new PageInfo<>(commentsList);
return pageInfo;
}
public Object getDetailsComment(Integer id){
ShyComments comment = shyCommentsMapper.selectByPrimaryKey(id);
return comment;
}
}