|
@@ -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
|
|
@@ -202,16 +214,30 @@ public class TaH5SampleController extends BaseController {
|
202
|
214
|
@RequestMapping(value="/channel/h5Sample/list",method= RequestMethod.GET)
|
203
|
215
|
public ResponseBean geth5SampleList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
204
|
216
|
@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
205
|
|
- String sampleName){
|
|
217
|
+ @RequestParam(value ="sampleName",required = false) String sampleName,
|
|
218
|
+ @RequestParam(value ="tag",required = false) String tag,
|
|
219
|
+ @RequestParam(value ="status",required = false) Integer status,
|
|
220
|
+ @RequestParam(value ="startCreateDate",required = false) String startCreateDate,
|
|
221
|
+ @RequestParam(value ="endCreateDate",required = false) String endCreateDate){
|
206
|
222
|
ResponseBean responseBean = new ResponseBean();
|
207
|
223
|
try {
|
208
|
224
|
//使用分页插件
|
209
|
225
|
IPage<TaH5Sample> pg = new Page<>(pageNum, pageSize);
|
210
|
226
|
QueryWrapper<TaH5Sample> queryWrapper = new QueryWrapper<>();
|
211
|
227
|
queryWrapper.like(!StringUtils.isEmpty(sampleName),"sample_name",sampleName);
|
|
228
|
+ queryWrapper.like(!StringUtils.isEmpty(tag),"tag",tag);
|
|
229
|
+ queryWrapper.eq(null != status,"demand_status",status);
|
|
230
|
+ queryWrapper.ge(!StringUtils.isEmpty(startCreateDate),"date_format(create_date,'%Y-%m-%d')",startCreateDate);
|
|
231
|
+ queryWrapper.le(!StringUtils.isEmpty(endCreateDate),"date_format(create_date,'%Y-%m-%d')",endCreateDate);
|
|
232
|
+ queryWrapper.gt("status", CommConstant.STATUS_DELETE);
|
212
|
233
|
queryWrapper.orderByDesc("order_no","create_date");
|
213
|
234
|
|
214
|
235
|
IPage<TaH5Sample> result = iTaH5SampleService.page(pg, queryWrapper);
|
|
236
|
+ result.getRecords().forEach(e -> {
|
|
237
|
+ if (!StringUtils.isEmpty(e.getTag())){
|
|
238
|
+ e.setTags(Arrays.asList(e.getTag().split(",")));
|
|
239
|
+ }
|
|
240
|
+ });
|
215
|
241
|
responseBean.addSuccess(result);
|
216
|
242
|
}catch (Exception e){
|
217
|
243
|
e.printStackTrace();
|
|
@@ -252,4 +278,107 @@ public class TaH5SampleController extends BaseController {
|
252
|
278
|
}
|
253
|
279
|
return responseBean;
|
254
|
280
|
}
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+ /**
|
|
284
|
+ * 获取详情
|
|
285
|
+ * @param
|
|
286
|
+ * @return
|
|
287
|
+ */
|
|
288
|
+ @RequestMapping(value="/channel/get/h5Sample/{id}",method= RequestMethod.GET)
|
|
289
|
+ public ResponseBean getTaH5Sample(@PathVariable Integer id){
|
|
290
|
+ ResponseBean responseBean = new ResponseBean();
|
|
291
|
+ try {
|
|
292
|
+ TaH5Sample taH5Sample = iTaH5SampleService.getById(id);
|
|
293
|
+ QueryWrapper<TaSampleContact> queryWrapper = new QueryWrapper();
|
|
294
|
+ queryWrapper.eq("sample_id",taH5Sample.getSampleId());
|
|
295
|
+ List<TaSampleContact> sampleContactList = iTaSampleContactService.list(queryWrapper);
|
|
296
|
+ if (sampleContactList.size() > 0){
|
|
297
|
+ List<TaContact> taContactList = taContactService.list(new QueryWrapper<TaContact>().in("contact_id",sampleContactList.stream().map(TaSampleContact::getContactId).collect(Collectors.toList())));
|
|
298
|
+ taH5Sample.setTaContactList(taContactList);
|
|
299
|
+ }
|
|
300
|
+ if (!StringUtils.isEmpty(taH5Sample.getTag())){
|
|
301
|
+ taH5Sample.setTags(Arrays.asList(taH5Sample.getTag().split(",")));
|
|
302
|
+ }
|
|
303
|
+ responseBean.addSuccess(taH5Sample);
|
|
304
|
+ }catch (Exception e){
|
|
305
|
+ e.printStackTrace();
|
|
306
|
+ logger.error("taH5SampleAdd -=- {}",e.toString());
|
|
307
|
+ responseBean.addError(e.getMessage());
|
|
308
|
+ }
|
|
309
|
+ return responseBean;
|
|
310
|
+ }
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+ /**
|
|
315
|
+ * 更新对象
|
|
316
|
+ * @param taH5Sample 实体对象
|
|
317
|
+ * @return
|
|
318
|
+ */
|
|
319
|
+ @RequestMapping(value="/channel/update/h5Sample/{id}",method= RequestMethod.PUT)
|
|
320
|
+ public ResponseBean updateTaH5Sample(@PathVariable Integer id,@RequestBody TaH5Sample taH5Sample){
|
|
321
|
+ ResponseBean responseBean = new ResponseBean();
|
|
322
|
+ try {
|
|
323
|
+ taH5Sample.setSampleId(id);
|
|
324
|
+ List<String> tags = taH5Sample.getTags();
|
|
325
|
+ if (tags.size() > 0){
|
|
326
|
+ taH5Sample.setTag(String.join(",",tags));
|
|
327
|
+ }else{
|
|
328
|
+ taH5Sample.setTag("");
|
|
329
|
+ }
|
|
330
|
+ QueryWrapper<TaSampleContact> taSampleContactQueryWrapper = new QueryWrapper<>();
|
|
331
|
+ taSampleContactQueryWrapper.eq("sample_id",id);
|
|
332
|
+ iTaSampleContactService.remove(taSampleContactQueryWrapper);
|
|
333
|
+ if (iTaH5SampleService.updateById(taH5Sample)){
|
|
334
|
+ List<TaContact> taContactList = taH5Sample.getTaContactList();
|
|
335
|
+ taContactList.forEach(e -> {
|
|
336
|
+ TaSampleContact taSampleContact = new TaSampleContact();
|
|
337
|
+ taSampleContact.setContactId(e.getContactId());
|
|
338
|
+ taSampleContact.setSampleId(taH5Sample.getSampleId());
|
|
339
|
+ iTaSampleContactService.save(taSampleContact);
|
|
340
|
+ });
|
|
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
|
+ }
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+ /**
|
|
355
|
+ * 删除sample
|
|
356
|
+ * @return
|
|
357
|
+ */
|
|
358
|
+ @RequestMapping(value="/channel/put/h5Sample/{id}",method= RequestMethod.PUT)
|
|
359
|
+ public ResponseBean putTaH5Sample(@PathVariable Integer id){
|
|
360
|
+ ResponseBean responseBean = new ResponseBean();
|
|
361
|
+ try {
|
|
362
|
+ //查看是否有关联的需求单
|
|
363
|
+ QueryWrapper<TaH5Demand> queryWrapper = new QueryWrapper<>();
|
|
364
|
+ queryWrapper.eq("sample_id",id);
|
|
365
|
+ queryWrapper.gt("demand_status",CommConstant.STATUS_DELETE);
|
|
366
|
+ List<TaH5Demand> list = iTaH5DemandService.list(queryWrapper);
|
|
367
|
+ if (list.size() > 0){
|
|
368
|
+ return ResponseBean.error("存在关联的需求单,删除失败!",ResponseBean.ERROR_UNAVAILABLE);
|
|
369
|
+ }
|
|
370
|
+ TaH5Sample taH5Sample = iTaH5SampleService.getById(id);
|
|
371
|
+ taH5Sample.setStatus(CommConstant.STATUS_DELETE);
|
|
372
|
+ if (iTaH5SampleService.updateById(taH5Sample)){
|
|
373
|
+ responseBean.addSuccess(taH5Sample);
|
|
374
|
+ }else {
|
|
375
|
+ responseBean.addError("fail");
|
|
376
|
+ }
|
|
377
|
+ }catch (Exception e){
|
|
378
|
+ e.printStackTrace();
|
|
379
|
+ logger.error("taH5SampleAdd -=- {}",e.toString());
|
|
380
|
+ responseBean.addError(e.getMessage());
|
|
381
|
+ }
|
|
382
|
+ return responseBean;
|
|
383
|
+ }
|
255
|
384
|
}
|