|
@@ -6,10 +6,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.huiju.estateagents.base.BaseController;
|
7
|
7
|
import com.huiju.estateagents.base.ResponseBean;
|
8
|
8
|
import com.huiju.estateagents.common.StringUtils;
|
|
9
|
+import com.huiju.estateagents.entity.SysAdvancedConfigRelation;
|
9
|
10
|
import com.huiju.estateagents.sample.entity.TaContact;
|
10
|
11
|
import com.huiju.estateagents.common.CommConstant;
|
|
12
|
+import com.huiju.estateagents.sample.entity.TaH5Demand;
|
11
|
13
|
import com.huiju.estateagents.sample.entity.TaH5Sample;
|
12
|
14
|
import com.huiju.estateagents.sample.entity.TaSampleContact;
|
|
15
|
+import com.huiju.estateagents.sample.service.ITaContactService;
|
|
16
|
+import com.huiju.estateagents.sample.service.ITaH5DemandService;
|
13
|
17
|
import com.huiju.estateagents.sample.service.ITaH5SampleService;
|
14
|
18
|
import com.huiju.estateagents.sample.service.ITaSampleContactService;
|
15
|
19
|
import org.slf4j.Logger;
|
|
@@ -24,7 +28,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
24
|
28
|
import org.springframework.web.bind.annotation.RestController;
|
25
|
29
|
|
26
|
30
|
import java.time.LocalDateTime;
|
|
31
|
+import java.util.Arrays;
|
27
|
32
|
import java.util.List;
|
|
33
|
+import java.util.stream.Collectors;
|
28
|
34
|
|
29
|
35
|
/**
|
30
|
36
|
* <p>
|
|
@@ -46,6 +52,12 @@ public class TaH5SampleController extends BaseController {
|
46
|
52
|
@Autowired
|
47
|
53
|
public ITaSampleContactService iTaSampleContactService;
|
48
|
54
|
|
|
55
|
+ @Autowired
|
|
56
|
+ public ITaContactService taContactService;
|
|
57
|
+
|
|
58
|
+ @Autowired
|
|
59
|
+ public ITaH5DemandService iTaH5DemandService;
|
|
60
|
+
|
49
|
61
|
/**
|
50
|
62
|
* 分页查询列表
|
51
|
63
|
* @param pageNum
|
|
@@ -170,16 +182,30 @@ public class TaH5SampleController extends BaseController {
|
170
|
182
|
@RequestMapping(value="/channel/h5Sample/list",method= RequestMethod.GET)
|
171
|
183
|
public ResponseBean geth5SampleList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
172
|
184
|
@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
173
|
|
- String sampleName){
|
|
185
|
+ @RequestParam(value ="sampleName",required = false) String sampleName,
|
|
186
|
+ @RequestParam(value ="tag",required = false) String tag,
|
|
187
|
+ @RequestParam(value ="status",required = false) Integer status,
|
|
188
|
+ @RequestParam(value ="startCreateDate",required = false) String startCreateDate,
|
|
189
|
+ @RequestParam(value ="endCreateDate",required = false) String endCreateDate){
|
174
|
190
|
ResponseBean responseBean = new ResponseBean();
|
175
|
191
|
try {
|
176
|
192
|
//使用分页插件
|
177
|
193
|
IPage<TaH5Sample> pg = new Page<>(pageNum, pageSize);
|
178
|
194
|
QueryWrapper<TaH5Sample> queryWrapper = new QueryWrapper<>();
|
179
|
195
|
queryWrapper.like(!StringUtils.isEmpty(sampleName),"sample_name",sampleName);
|
|
196
|
+ queryWrapper.like(!StringUtils.isEmpty(tag),"tag",tag);
|
|
197
|
+ queryWrapper.eq(null != status,"demand_status",status);
|
|
198
|
+ queryWrapper.ge(!StringUtils.isEmpty(startCreateDate),"date_format(create_date,'%Y-%m-%d')",startCreateDate);
|
|
199
|
+ queryWrapper.le(!StringUtils.isEmpty(endCreateDate),"date_format(create_date,'%Y-%m-%d')",endCreateDate);
|
|
200
|
+ queryWrapper.gt("status", CommConstant.STATUS_DELETE);
|
180
|
201
|
queryWrapper.orderByDesc("order_no","create_date");
|
181
|
202
|
|
182
|
203
|
IPage<TaH5Sample> result = iTaH5SampleService.page(pg, queryWrapper);
|
|
204
|
+ result.getRecords().forEach(e -> {
|
|
205
|
+ if (!StringUtils.isEmpty(e.getTag())){
|
|
206
|
+ e.setTags(Arrays.asList(e.getTag().split(",")));
|
|
207
|
+ }
|
|
208
|
+ });
|
183
|
209
|
responseBean.addSuccess(result);
|
184
|
210
|
}catch (Exception e){
|
185
|
211
|
e.printStackTrace();
|
|
@@ -220,4 +246,107 @@ public class TaH5SampleController extends BaseController {
|
220
|
246
|
}
|
221
|
247
|
return responseBean;
|
222
|
248
|
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+ /**
|
|
252
|
+ * 获取详情
|
|
253
|
+ * @param
|
|
254
|
+ * @return
|
|
255
|
+ */
|
|
256
|
+ @RequestMapping(value="/channel/get/h5Sample/{id}",method= RequestMethod.GET)
|
|
257
|
+ public ResponseBean getTaH5Sample(@PathVariable Integer id){
|
|
258
|
+ ResponseBean responseBean = new ResponseBean();
|
|
259
|
+ try {
|
|
260
|
+ TaH5Sample taH5Sample = iTaH5SampleService.getById(id);
|
|
261
|
+ QueryWrapper<TaSampleContact> queryWrapper = new QueryWrapper();
|
|
262
|
+ queryWrapper.eq("sample_id",taH5Sample.getSampleId());
|
|
263
|
+ List<TaSampleContact> sampleContactList = iTaSampleContactService.list(queryWrapper);
|
|
264
|
+ if (sampleContactList.size() > 0){
|
|
265
|
+ List<TaContact> taContactList = taContactService.list(new QueryWrapper<TaContact>().in("contact_id",sampleContactList.stream().map(TaSampleContact::getContactId).collect(Collectors.toList())));
|
|
266
|
+ taH5Sample.setTaContactList(taContactList);
|
|
267
|
+ }
|
|
268
|
+ if (!StringUtils.isEmpty(taH5Sample.getTag())){
|
|
269
|
+ taH5Sample.setTags(Arrays.asList(taH5Sample.getTag().split(",")));
|
|
270
|
+ }
|
|
271
|
+ responseBean.addSuccess(taH5Sample);
|
|
272
|
+ }catch (Exception e){
|
|
273
|
+ e.printStackTrace();
|
|
274
|
+ logger.error("taH5SampleAdd -=- {}",e.toString());
|
|
275
|
+ responseBean.addError(e.getMessage());
|
|
276
|
+ }
|
|
277
|
+ return responseBean;
|
|
278
|
+ }
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+ /**
|
|
283
|
+ * 更新对象
|
|
284
|
+ * @param taH5Sample 实体对象
|
|
285
|
+ * @return
|
|
286
|
+ */
|
|
287
|
+ @RequestMapping(value="/channel/update/h5Sample/{id}",method= RequestMethod.PUT)
|
|
288
|
+ public ResponseBean updateTaH5Sample(@PathVariable Integer id,@RequestBody TaH5Sample taH5Sample){
|
|
289
|
+ ResponseBean responseBean = new ResponseBean();
|
|
290
|
+ try {
|
|
291
|
+ taH5Sample.setSampleId(id);
|
|
292
|
+ List<String> tags = taH5Sample.getTags();
|
|
293
|
+ if (tags.size() > 0){
|
|
294
|
+ taH5Sample.setTag(String.join(",",tags));
|
|
295
|
+ }else{
|
|
296
|
+ taH5Sample.setTag("");
|
|
297
|
+ }
|
|
298
|
+ QueryWrapper<TaSampleContact> taSampleContactQueryWrapper = new QueryWrapper<>();
|
|
299
|
+ taSampleContactQueryWrapper.eq("sample_id",id);
|
|
300
|
+ iTaSampleContactService.remove(taSampleContactQueryWrapper);
|
|
301
|
+ if (iTaH5SampleService.updateById(taH5Sample)){
|
|
302
|
+ List<TaContact> taContactList = taH5Sample.getTaContactList();
|
|
303
|
+ taContactList.forEach(e -> {
|
|
304
|
+ TaSampleContact taSampleContact = new TaSampleContact();
|
|
305
|
+ taSampleContact.setContactId(e.getContactId());
|
|
306
|
+ taSampleContact.setSampleId(taH5Sample.getSampleId());
|
|
307
|
+ iTaSampleContactService.save(taSampleContact);
|
|
308
|
+ });
|
|
309
|
+ responseBean.addSuccess(taH5Sample);
|
|
310
|
+ }else {
|
|
311
|
+ responseBean.addError("fail");
|
|
312
|
+ }
|
|
313
|
+ }catch (Exception e){
|
|
314
|
+ e.printStackTrace();
|
|
315
|
+ logger.error("taH5SampleAdd -=- {}",e.toString());
|
|
316
|
+ responseBean.addError(e.getMessage());
|
|
317
|
+ }
|
|
318
|
+ return responseBean;
|
|
319
|
+ }
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+ /**
|
|
323
|
+ * 删除sample
|
|
324
|
+ * @return
|
|
325
|
+ */
|
|
326
|
+ @RequestMapping(value="/channel/put/h5Sample/{id}",method= RequestMethod.PUT)
|
|
327
|
+ public ResponseBean putTaH5Sample(@PathVariable Integer id){
|
|
328
|
+ ResponseBean responseBean = new ResponseBean();
|
|
329
|
+ try {
|
|
330
|
+ //查看是否有关联的需求单
|
|
331
|
+ QueryWrapper<TaH5Demand> queryWrapper = new QueryWrapper<>();
|
|
332
|
+ queryWrapper.eq("sample_id",id);
|
|
333
|
+ queryWrapper.gt("demand_status",CommConstant.STATUS_DELETE);
|
|
334
|
+ List<TaH5Demand> list = iTaH5DemandService.list(queryWrapper);
|
|
335
|
+ if (list.size() > 0){
|
|
336
|
+ return ResponseBean.error("存在关联的需求单,删除失败!",ResponseBean.ERROR_UNAVAILABLE);
|
|
337
|
+ }
|
|
338
|
+ TaH5Sample taH5Sample = iTaH5SampleService.getById(id);
|
|
339
|
+ taH5Sample.setStatus(CommConstant.STATUS_DELETE);
|
|
340
|
+ if (iTaH5SampleService.updateById(taH5Sample)){
|
|
341
|
+ responseBean.addSuccess(taH5Sample);
|
|
342
|
+ }else {
|
|
343
|
+ responseBean.addError("fail");
|
|
344
|
+ }
|
|
345
|
+ }catch (Exception e){
|
|
346
|
+ e.printStackTrace();
|
|
347
|
+ logger.error("taH5SampleAdd -=- {}",e.toString());
|
|
348
|
+ responseBean.addError(e.getMessage());
|
|
349
|
+ }
|
|
350
|
+ return responseBean;
|
|
351
|
+ }
|
223
|
352
|
}
|