|
@@ -6,10 +6,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
6
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7
|
7
|
import com.huiju.estateagents.base.BaseController;
|
8
|
8
|
import com.huiju.estateagents.base.ResponseBean;
|
|
9
|
+
|
|
10
|
+import com.huiju.estateagents.common.JWTUtils;
|
|
11
|
+import com.huiju.estateagents.common.StringUtils;
|
9
|
12
|
import com.huiju.estateagents.entity.TaChannel;
|
10
|
13
|
import com.huiju.estateagents.entity.TaPerson;
|
|
14
|
+import com.huiju.estateagents.mapper.TaChannelMapper;
|
11
|
15
|
import com.huiju.estateagents.service.ITaPersonService;
|
12
|
16
|
import com.huiju.estateagents.service.TaChannelService;
|
|
17
|
+import org.apache.http.HttpRequest;
|
13
|
18
|
import org.slf4j.Logger;
|
14
|
19
|
import org.slf4j.LoggerFactory;
|
15
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +26,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
21
|
26
|
import org.springframework.web.bind.annotation.ResponseBody;
|
22
|
27
|
import org.springframework.web.bind.annotation.RestController;
|
23
|
28
|
|
|
29
|
+import javax.servlet.http.HttpServletRequest;
|
|
30
|
+import java.util.HashMap;
|
|
31
|
+import java.util.List;
|
|
32
|
+
|
24
|
33
|
|
25
|
34
|
/**
|
26
|
35
|
* <p>
|
|
@@ -42,6 +51,9 @@ public class TaChannelController extends BaseController {
|
42
|
51
|
@Autowired
|
43
|
52
|
public ITaPersonService taPersonService;
|
44
|
53
|
|
|
54
|
+ @Autowired
|
|
55
|
+ public TaChannelMapper taChannelMapper;
|
|
56
|
+
|
45
|
57
|
|
46
|
58
|
/**
|
47
|
59
|
* 分页查询列表
|
|
@@ -51,16 +63,25 @@ public class TaChannelController extends BaseController {
|
51
|
63
|
*/
|
52
|
64
|
@RequestMapping(value="/admin/channel",method= RequestMethod.GET)
|
53
|
65
|
public ResponseBean channelList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
54
|
|
- @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
66
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
67
|
+ @RequestParam(value ="channelId",required = false) Integer channelId,
|
|
68
|
+ HttpServletRequest request){
|
55
|
69
|
ResponseBean responseBean = new ResponseBean();
|
|
70
|
+ String orgid = JWTUtils.getSubject(request);
|
56
|
71
|
try {
|
57
|
72
|
//使用分页插件
|
58
|
73
|
IPage<TaChannel> pg = new Page<>(pageNum, pageSize);
|
59
|
74
|
QueryWrapper<TaChannel> queryWrapper = new QueryWrapper<>();
|
|
75
|
+ queryWrapper.eq(null != channelId, "channel_id", channelId);
|
60
|
76
|
queryWrapper.orderByDesc("create_date");
|
61
|
77
|
|
62
|
78
|
IPage<TaChannel> result = taChannelService.page(pg, queryWrapper);
|
63
|
|
- responseBean.addSuccess(result);
|
|
79
|
+ HashMap hashMap = new HashMap<>();
|
|
80
|
+ hashMap.put("result",result);
|
|
81
|
+ // 下拉列表的数据 all
|
|
82
|
+ List<TaChannel> taChannelList = taChannelMapper.selectChannelList();
|
|
83
|
+ hashMap.put("channelNmae",taChannelList);
|
|
84
|
+ responseBean.addSuccess(hashMap);
|
64
|
85
|
}catch (Exception e){
|
65
|
86
|
e.printStackTrace();
|
66
|
87
|
logger.error("channelList -=- {}",e.toString());
|
|
@@ -74,10 +95,13 @@ public class TaChannelController extends BaseController {
|
74
|
95
|
* @param channel 实体对象
|
75
|
96
|
* @return
|
76
|
97
|
*/
|
77
|
|
- @RequestMapping(value="/channel",method= RequestMethod.POST)
|
|
98
|
+ @RequestMapping(value="/admin/channel",method= RequestMethod.POST)
|
78
|
99
|
public ResponseBean channelAdd(@RequestBody TaChannel channel){
|
79
|
100
|
ResponseBean responseBean = new ResponseBean();
|
80
|
101
|
try {
|
|
102
|
+ // 生成6位数的渠道码
|
|
103
|
+ int channelCode= taChannelMapper.channelCode();
|
|
104
|
+ channel.setChannelCode(String.valueOf(channelCode));
|
81
|
105
|
if (taChannelService.save(channel)){
|
82
|
106
|
responseBean.addSuccess(channel);
|
83
|
107
|
}else {
|
|
@@ -157,13 +181,11 @@ public class TaChannelController extends BaseController {
|
157
|
181
|
/**
|
158
|
182
|
* 渠道管理下的经纪人
|
159
|
183
|
*/
|
160
|
|
- @RequestMapping(value="/channel/broker",method= RequestMethod.GET)
|
161
|
|
- public ResponseBean channelBrokerList(@RequestBody String Param,
|
|
184
|
+ @RequestMapping(value="/admin/channel/broker",method= RequestMethod.GET)
|
|
185
|
+ public ResponseBean channelBrokerList(@RequestParam(value="name",required = false) String name,
|
|
186
|
+ @RequestParam(value="phone",required = false) String phone,
|
162
|
187
|
@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
163
|
188
|
@RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
164
|
|
- JSONObject jSONObject = JSONObject.parseObject(Param);
|
165
|
|
- String name = jSONObject.getString("name");
|
166
|
|
- String phone = jSONObject.getString("phone");
|
167
|
189
|
ResponseBean taPerson = taPersonService.channelBrokerList(name,phone,pageNum,pageSize);
|
168
|
190
|
return taPerson;
|
169
|
191
|
}
|