|
@@ -1,9 +1,6 @@
|
1
|
1
|
package com.yunzhi.marketing.xlk.controller;
|
2
|
2
|
|
3
|
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
|
4
|
import com.yunzhi.marketing.base.BaseController;
|
8
|
5
|
import com.yunzhi.marketing.base.ResponseBean;
|
9
|
6
|
import com.yunzhi.marketing.xlk.dto.BuildingChannelDTO;
|
|
@@ -21,6 +18,7 @@ import javax.servlet.http.HttpServletRequest;
|
21
|
18
|
import java.time.LocalDateTime;
|
22
|
19
|
import java.util.ArrayList;
|
23
|
20
|
import java.util.List;
|
|
21
|
+import java.util.stream.Collectors;
|
24
|
22
|
|
25
|
23
|
/**
|
26
|
24
|
* <p>
|
|
@@ -40,7 +38,6 @@ public class BuildingChannelController extends BaseController {
|
40
|
38
|
@Autowired
|
41
|
39
|
public IBuildingChannelService iBuildingChannelService;
|
42
|
40
|
|
43
|
|
-
|
44
|
41
|
/**
|
45
|
42
|
* 保存对象
|
46
|
43
|
* @param buildingChannelDTO 实体对象
|
|
@@ -53,18 +50,7 @@ public class BuildingChannelController extends BaseController {
|
53
|
50
|
HttpServletRequest request){
|
54
|
51
|
ResponseBean responseBean = new ResponseBean();
|
55
|
52
|
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)){
|
|
53
|
+ if (saveData(buildingChannelDTO, getOrgId(request))){
|
68
|
54
|
responseBean.addSuccess("添加成功");
|
69
|
55
|
}else {
|
70
|
56
|
responseBean.addError("fail");
|
|
@@ -93,18 +79,7 @@ public class BuildingChannelController extends BaseController {
|
93
|
79
|
iBuildingChannelService.remove(new LambdaQueryWrapper<BuildingChannel>().eq(BuildingChannel::getBuildingId,buildingChannelDTO.getBuildingId()));
|
94
|
80
|
|
95
|
81
|
// 重新添加
|
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)){
|
|
82
|
+ if (saveData(buildingChannelDTO, getOrgId(request))){
|
108
|
83
|
responseBean.addSuccess("修改成功");
|
109
|
84
|
}else {
|
110
|
85
|
responseBean.addError("fail");
|
|
@@ -117,6 +92,24 @@ public class BuildingChannelController extends BaseController {
|
117
|
92
|
return responseBean;
|
118
|
93
|
}
|
119
|
94
|
|
|
95
|
+ private boolean saveData(BuildingChannelDTO buildingChannelDTO, Integer orgId) {
|
|
96
|
+ List<BuildingChannel> buildingChannelList = new ArrayList<>();
|
|
97
|
+ List<String> channelIdList = buildingChannelDTO.getChannelIdList();
|
|
98
|
+ channelIdList.forEach(e -> {
|
|
99
|
+ BuildingChannel buildingChannel = new BuildingChannel();
|
|
100
|
+ BeanUtils.copyProperties(e,buildingChannel);
|
|
101
|
+ buildingChannel.setChannelId(e);
|
|
102
|
+ buildingChannel.setBuildingId(buildingChannelDTO.getBuildingId());
|
|
103
|
+ buildingChannel.setExpirationDate(buildingChannelDTO.getExpirationDate());
|
|
104
|
+ buildingChannel.setRemark(buildingChannelDTO.getRemark());
|
|
105
|
+ buildingChannel.setCreateDate(LocalDateTime.now());
|
|
106
|
+ buildingChannel.setOrgId(orgId);
|
|
107
|
+ buildingChannelList.add(buildingChannel);
|
|
108
|
+ });
|
|
109
|
+
|
|
110
|
+ return iBuildingChannelService.saveBatch(buildingChannelList);
|
|
111
|
+ }
|
|
112
|
+
|
120
|
113
|
/**
|
121
|
114
|
* 根据id查询对象
|
122
|
115
|
* @param
|
|
@@ -129,7 +122,17 @@ public class BuildingChannelController extends BaseController {
|
129
|
122
|
LambdaQueryWrapper<BuildingChannel> queryWrapper = new LambdaQueryWrapper<>();
|
130
|
123
|
queryWrapper.eq(BuildingChannel::getBuildingId,buildingId);
|
131
|
124
|
List<BuildingChannel> list = iBuildingChannelService.list(queryWrapper);
|
132
|
|
- responseBean.addSuccess(list);
|
|
125
|
+
|
|
126
|
+ BuildingChannelDTO buildingChannelDTO = null;
|
|
127
|
+ if (list != null && list.size() > 0) {
|
|
128
|
+ buildingChannelDTO = new BuildingChannelDTO();
|
|
129
|
+ buildingChannelDTO.setChannelIdList(list.stream().map(x -> x.getChannelId()).collect(Collectors.toList()));
|
|
130
|
+ buildingChannelDTO.setBuildingId(buildingId);
|
|
131
|
+ buildingChannelDTO.setExpirationDate(list.get(0).getExpirationDate());
|
|
132
|
+ buildingChannelDTO.setRemark(list.get(0).getRemark());
|
|
133
|
+ }
|
|
134
|
+
|
|
135
|
+ responseBean.addSuccess(buildingChannelDTO);
|
133
|
136
|
}catch (Exception e){
|
134
|
137
|
e.printStackTrace();
|
135
|
138
|
logger.error("buildingChannelDelete -=- {}",e.toString());
|