|
@@ -0,0 +1,172 @@
|
|
1
|
+package com.huiju.estateagents.center.taUser.controller;
|
|
2
|
+
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
5
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
6
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
7
|
+import com.huiju.estateagents.base.BaseController;
|
|
8
|
+import com.huiju.estateagents.base.ResponseBean;
|
|
9
|
+import com.huiju.estateagents.center.taUser.entity.TpLifeConsultantEvaluate;
|
|
10
|
+import com.huiju.estateagents.center.taUser.service.ITpLifeConsultantEvaluateService;
|
|
11
|
+import io.swagger.annotations.Api;
|
|
12
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
13
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
14
|
+import io.swagger.annotations.ApiOperation;
|
|
15
|
+import org.slf4j.Logger;
|
|
16
|
+import org.slf4j.LoggerFactory;
|
|
17
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
18
|
+import org.springframework.web.bind.annotation.*;
|
|
19
|
+
|
|
20
|
+import javax.servlet.http.HttpServletRequest;
|
|
21
|
+import java.text.SimpleDateFormat;
|
|
22
|
+import java.time.LocalDateTime;
|
|
23
|
+import java.util.Date;
|
|
24
|
+import java.util.List;
|
|
25
|
+
|
|
26
|
+/**
|
|
27
|
+ * <p>
|
|
28
|
+ * 生活顾问评价表 前端控制器
|
|
29
|
+ * </p>
|
|
30
|
+ *
|
|
31
|
+ * @author jobob
|
|
32
|
+ * @since 2020-12-17
|
|
33
|
+ */
|
|
34
|
+@RestController
|
|
35
|
+@RequestMapping("/api")
|
|
36
|
+@Api(value = "生活顾问评分 API", description = "生活顾问评分 API")
|
|
37
|
+public class TpLifeConsultantEvaluateController extends BaseController {
|
|
38
|
+
|
|
39
|
+ private final Logger logger = LoggerFactory.getLogger(TpLifeConsultantEvaluateController.class);
|
|
40
|
+
|
|
41
|
+ @Autowired
|
|
42
|
+ public ITpLifeConsultantEvaluateService iTpLifeConsultantEvaluateService;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ /**
|
|
46
|
+ * 分页查询列表
|
|
47
|
+ * @param pageNum
|
|
48
|
+ * @param pageSize
|
|
49
|
+ * @return
|
|
50
|
+ */
|
|
51
|
+ @RequestMapping(value="/tpLifeConsultantEvaluate",method= RequestMethod.GET)
|
|
52
|
+ public ResponseBean tpLifeConsultantEvaluateList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
53
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
54
|
+ ResponseBean responseBean = new ResponseBean();
|
|
55
|
+ try {
|
|
56
|
+ //使用分页插件
|
|
57
|
+ IPage<TpLifeConsultantEvaluate> pg = new Page<>(pageNum, pageSize);
|
|
58
|
+ QueryWrapper<TpLifeConsultantEvaluate> queryWrapper = new QueryWrapper<>();
|
|
59
|
+ queryWrapper.orderByDesc("create_date");
|
|
60
|
+
|
|
61
|
+ IPage<TpLifeConsultantEvaluate> result = iTpLifeConsultantEvaluateService.page(pg, queryWrapper);
|
|
62
|
+ responseBean.addSuccess(result);
|
|
63
|
+ }catch (Exception e){
|
|
64
|
+ e.printStackTrace();
|
|
65
|
+ logger.error("tpLifeConsultantEvaluateList -=- {}",e.toString());
|
|
66
|
+ responseBean.addError(e.getMessage());
|
|
67
|
+ }
|
|
68
|
+ return responseBean;
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ /**
|
|
72
|
+ * 保存对象
|
|
73
|
+ * @param tpLifeConsultantEvaluate 实体对象
|
|
74
|
+ * @return
|
|
75
|
+ */
|
|
76
|
+ @ApiOperation(value = "生活顾问打分", notes = "生活顾问打分")
|
|
77
|
+ @ApiImplicitParams({
|
|
78
|
+ @ApiImplicitParam(paramType = "body",dataType = "TpLifeConsultantEvaluate",name = "tpLifeConsultantEvaluate",value = "")
|
|
79
|
+ })
|
|
80
|
+ @RequestMapping(value="/wx/tpLifeConsultantEvaluate",method= RequestMethod.POST)
|
|
81
|
+ public ResponseBean tpLifeConsultantEvaluateAdd(@RequestBody TpLifeConsultantEvaluate tpLifeConsultantEvaluate, HttpServletRequest request){
|
|
82
|
+ ResponseBean responseBean = new ResponseBean();
|
|
83
|
+ try {
|
|
84
|
+ tpLifeConsultantEvaluate.setOrgId(getOrgId(request));
|
|
85
|
+ tpLifeConsultantEvaluate.setPersonId(getPersonId(request));
|
|
86
|
+ tpLifeConsultantEvaluate.setCreateDate(LocalDateTime.now());
|
|
87
|
+ tpLifeConsultantEvaluate.setEvaluateTime(new SimpleDateFormat("yyyyMMdd").format(new Date()));
|
|
88
|
+ LambdaQueryWrapper<TpLifeConsultantEvaluate> queryWrapper = new LambdaQueryWrapper<>();
|
|
89
|
+ queryWrapper.eq(TpLifeConsultantEvaluate::getOrgId,tpLifeConsultantEvaluate.getOrgId());
|
|
90
|
+ queryWrapper.eq(TpLifeConsultantEvaluate::getPersonId,tpLifeConsultantEvaluate.getPersonId());
|
|
91
|
+ queryWrapper.eq(TpLifeConsultantEvaluate::getEvaluateTime,tpLifeConsultantEvaluate.getEvaluateTime());
|
|
92
|
+ List<TpLifeConsultantEvaluate> list = iTpLifeConsultantEvaluateService.list(queryWrapper);
|
|
93
|
+ if (list.size() > 0){
|
|
94
|
+ responseBean.addError("你当月已经投票了");
|
|
95
|
+ return responseBean;
|
|
96
|
+ }
|
|
97
|
+ if (iTpLifeConsultantEvaluateService.save(tpLifeConsultantEvaluate)){
|
|
98
|
+ responseBean.addSuccess(tpLifeConsultantEvaluate);
|
|
99
|
+ }else {
|
|
100
|
+ responseBean.addError("fail");
|
|
101
|
+ }
|
|
102
|
+ }catch (Exception e){
|
|
103
|
+ e.printStackTrace();
|
|
104
|
+ logger.error("tpLifeConsultantEvaluateAdd -=- {}",e.toString());
|
|
105
|
+ responseBean.addError(e.getMessage());
|
|
106
|
+ }
|
|
107
|
+ return responseBean;
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ /**
|
|
111
|
+ * 根据id删除对象
|
|
112
|
+ * @param id 实体ID
|
|
113
|
+ */
|
|
114
|
+ @ResponseBody
|
|
115
|
+ @RequestMapping(value="/tpLifeConsultantEvaluate/{id}", method= RequestMethod.DELETE)
|
|
116
|
+ public ResponseBean tpLifeConsultantEvaluateDelete(@PathVariable Integer id){
|
|
117
|
+ ResponseBean responseBean = new ResponseBean();
|
|
118
|
+ try {
|
|
119
|
+ if(iTpLifeConsultantEvaluateService.removeById(id)){
|
|
120
|
+ responseBean.addSuccess("success");
|
|
121
|
+ }else {
|
|
122
|
+ responseBean.addError("fail");
|
|
123
|
+ }
|
|
124
|
+ }catch (Exception e){
|
|
125
|
+ e.printStackTrace();
|
|
126
|
+ logger.error("tpLifeConsultantEvaluateDelete -=- {}",e.toString());
|
|
127
|
+ responseBean.addError(e.getMessage());
|
|
128
|
+ }
|
|
129
|
+ return responseBean;
|
|
130
|
+ }
|
|
131
|
+
|
|
132
|
+ /**
|
|
133
|
+ * 修改对象
|
|
134
|
+ * @param id 实体ID
|
|
135
|
+ * @param tpLifeConsultantEvaluate 实体对象
|
|
136
|
+ * @return
|
|
137
|
+ */
|
|
138
|
+ @RequestMapping(value="/tpLifeConsultantEvaluate/{id}",method= RequestMethod.PUT)
|
|
139
|
+ public ResponseBean tpLifeConsultantEvaluateUpdate(@PathVariable Integer id,
|
|
140
|
+ @RequestBody TpLifeConsultantEvaluate tpLifeConsultantEvaluate){
|
|
141
|
+ ResponseBean responseBean = new ResponseBean();
|
|
142
|
+ try {
|
|
143
|
+ if (iTpLifeConsultantEvaluateService.updateById(tpLifeConsultantEvaluate)){
|
|
144
|
+ responseBean.addSuccess(tpLifeConsultantEvaluate);
|
|
145
|
+ }else {
|
|
146
|
+ responseBean.addError("fail");
|
|
147
|
+ }
|
|
148
|
+ }catch (Exception e){
|
|
149
|
+ e.printStackTrace();
|
|
150
|
+ logger.error("tpLifeConsultantEvaluateUpdate -=- {}",e.toString());
|
|
151
|
+ responseBean.addError(e.getMessage());
|
|
152
|
+ }
|
|
153
|
+ return responseBean;
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ /**
|
|
157
|
+ * 根据id查询对象
|
|
158
|
+ * @param id 实体ID
|
|
159
|
+ */
|
|
160
|
+ @RequestMapping(value="/tpLifeConsultantEvaluate/{id}",method= RequestMethod.GET)
|
|
161
|
+ public ResponseBean tpLifeConsultantEvaluateGet(@PathVariable Integer id){
|
|
162
|
+ ResponseBean responseBean = new ResponseBean();
|
|
163
|
+ try {
|
|
164
|
+ responseBean.addSuccess(iTpLifeConsultantEvaluateService.getById(id));
|
|
165
|
+ }catch (Exception e){
|
|
166
|
+ e.printStackTrace();
|
|
167
|
+ logger.error("tpLifeConsultantEvaluateDelete -=- {}",e.toString());
|
|
168
|
+ responseBean.addError(e.getMessage());
|
|
169
|
+ }
|
|
170
|
+ return responseBean;
|
|
171
|
+ }
|
|
172
|
+}
|