|
@@ -0,0 +1,140 @@
|
|
1
|
+package com.yunzhi.marketing.xlk.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.yunzhi.marketing.base.BaseController;
|
|
8
|
+import com.yunzhi.marketing.base.ResponseBean;
|
|
9
|
+import com.yunzhi.marketing.xlk.dto.BuildingChannelDTO;
|
|
10
|
+import com.yunzhi.marketing.xlk.entity.BuildingChannel;
|
|
11
|
+import com.yunzhi.marketing.xlk.service.IBuildingChannelService;
|
|
12
|
+import io.swagger.annotations.Api;
|
|
13
|
+import io.swagger.annotations.ApiOperation;
|
|
14
|
+import org.slf4j.Logger;
|
|
15
|
+import org.slf4j.LoggerFactory;
|
|
16
|
+import org.springframework.beans.BeanUtils;
|
|
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.time.LocalDateTime;
|
|
22
|
+import java.util.ArrayList;
|
|
23
|
+import java.util.List;
|
|
24
|
+
|
|
25
|
+/**
|
|
26
|
+ * <p>
|
|
27
|
+ * 楼盘渠道表 前端控制器
|
|
28
|
+ * </p>
|
|
29
|
+ *
|
|
30
|
+ * @author jobob
|
|
31
|
+ * @since 2021-07-18
|
|
32
|
+ */
|
|
33
|
+@RestController
|
|
34
|
+@RequestMapping("/api")
|
|
35
|
+@Api(value = "楼盘渠道表", tags = "xlk-楼盘渠道表")
|
|
36
|
+public class BuildingChannelController extends BaseController {
|
|
37
|
+
|
|
38
|
+ private final Logger logger = LoggerFactory.getLogger(BuildingChannelController.class);
|
|
39
|
+
|
|
40
|
+ @Autowired
|
|
41
|
+ public IBuildingChannelService iBuildingChannelService;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+ /**
|
|
45
|
+ * 保存对象
|
|
46
|
+ * @param buildingChannelDTO 实体对象
|
|
47
|
+ * @return
|
|
48
|
+ */
|
|
49
|
+ @ApiOperation(value = "admin-保存楼盘渠道接口", notes = "admin-保存楼盘渠道接口")
|
|
50
|
+ @RequestMapping(value="/admin/buildingChannel",method= RequestMethod.POST)
|
|
51
|
+ public ResponseBean buildingChannelAdd(@RequestHeader("authorization") String token,
|
|
52
|
+ @RequestBody BuildingChannelDTO buildingChannelDTO,
|
|
53
|
+ HttpServletRequest request){
|
|
54
|
+ ResponseBean responseBean = new ResponseBean();
|
|
55
|
+ try {
|
|
56
|
+ Integer orgId = getOrgId(request);
|
|
57
|
+ List<BuildingChannel> buildingChannelList = new ArrayList<>();
|
|
58
|
+ List<String> channelIdList = buildingChannelDTO.getChannelIdList();
|
|
59
|
+ channelIdList.forEach(e -> {
|
|
60
|
+ BuildingChannel buildingChannel = new BuildingChannel();
|
|
61
|
+ BeanUtils.copyProperties(e,buildingChannel);
|
|
62
|
+ buildingChannel.setChannelId(e);
|
|
63
|
+ buildingChannel.setCreateDate(LocalDateTime.now());
|
|
64
|
+ buildingChannel.setOrgId(orgId);
|
|
65
|
+ buildingChannelList.add(buildingChannel);
|
|
66
|
+ });
|
|
67
|
+ if (iBuildingChannelService.saveBatch(buildingChannelList)){
|
|
68
|
+ responseBean.addSuccess("添加成功");
|
|
69
|
+ }else {
|
|
70
|
+ responseBean.addError("fail");
|
|
71
|
+ }
|
|
72
|
+ }catch (Exception e){
|
|
73
|
+ e.printStackTrace();
|
|
74
|
+ logger.error("buildingChannelAdd -=- {}",e.toString());
|
|
75
|
+ responseBean.addError(e.getMessage());
|
|
76
|
+ }
|
|
77
|
+ return responseBean;
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ /**
|
|
81
|
+ * 修改对象
|
|
82
|
+ *
|
|
83
|
+ * @return
|
|
84
|
+ */
|
|
85
|
+ @ApiOperation(value = "admin-修改楼盘渠道接口", notes = "admin-修改楼盘渠道接口")
|
|
86
|
+ @RequestMapping(value="/admin/buildingChannel",method= RequestMethod.PUT)
|
|
87
|
+ public ResponseBean buildingChannelUpdate(@RequestHeader("authorization") String token,
|
|
88
|
+ @RequestBody BuildingChannelDTO buildingChannelDTO,
|
|
89
|
+ HttpServletRequest request){
|
|
90
|
+ ResponseBean responseBean = new ResponseBean();
|
|
91
|
+ try {
|
|
92
|
+ // 先把此楼盘的渠道全部删除
|
|
93
|
+ iBuildingChannelService.remove(new LambdaQueryWrapper<BuildingChannel>().eq(BuildingChannel::getBuildingId,buildingChannelDTO.getBuildingId()));
|
|
94
|
+
|
|
95
|
+ // 重新添加
|
|
96
|
+ Integer orgId = getOrgId(request);
|
|
97
|
+ List<BuildingChannel> buildingChannelList = new ArrayList<>();
|
|
98
|
+ List<String> channelIdList = buildingChannelDTO.getChannelIdList();
|
|
99
|
+ channelIdList.forEach(e -> {
|
|
100
|
+ BuildingChannel buildingChannel = new BuildingChannel();
|
|
101
|
+ BeanUtils.copyProperties(e,buildingChannel);
|
|
102
|
+ buildingChannel.setChannelId(e);
|
|
103
|
+ buildingChannel.setCreateDate(LocalDateTime.now());
|
|
104
|
+ buildingChannel.setOrgId(orgId);
|
|
105
|
+ buildingChannelList.add(buildingChannel);
|
|
106
|
+ });
|
|
107
|
+ if (iBuildingChannelService.saveBatch(buildingChannelList)){
|
|
108
|
+ responseBean.addSuccess("修改成功");
|
|
109
|
+ }else {
|
|
110
|
+ responseBean.addError("fail");
|
|
111
|
+ }
|
|
112
|
+ }catch (Exception e){
|
|
113
|
+ e.printStackTrace();
|
|
114
|
+ logger.error("buildingChannelUpdate -=- {}",e.toString());
|
|
115
|
+ responseBean.addError(e.getMessage());
|
|
116
|
+ }
|
|
117
|
+ return responseBean;
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+ /**
|
|
121
|
+ * 根据id查询对象
|
|
122
|
+ * @param
|
|
123
|
+ */
|
|
124
|
+ @ApiOperation(value = "admin-获取楼盘渠道详情接口", notes = "admin-获取楼盘渠道详情接口")
|
|
125
|
+ @RequestMapping(value="/admin/buildingChannel/{buildingId}",method= RequestMethod.GET)
|
|
126
|
+ public ResponseBean buildingChannelGet(@PathVariable String buildingId){
|
|
127
|
+ ResponseBean responseBean = new ResponseBean();
|
|
128
|
+ try {
|
|
129
|
+ LambdaQueryWrapper<BuildingChannel> queryWrapper = new LambdaQueryWrapper<>();
|
|
130
|
+ queryWrapper.eq(BuildingChannel::getBuildingId,buildingId);
|
|
131
|
+ List<BuildingChannel> list = iBuildingChannelService.list(queryWrapper);
|
|
132
|
+ responseBean.addSuccess(list);
|
|
133
|
+ }catch (Exception e){
|
|
134
|
+ e.printStackTrace();
|
|
135
|
+ logger.error("buildingChannelDelete -=- {}",e.toString());
|
|
136
|
+ responseBean.addError(e.getMessage());
|
|
137
|
+ }
|
|
138
|
+ return responseBean;
|
|
139
|
+ }
|
|
140
|
+}
|