|
@@ -1,11 +1,9 @@
|
1
|
1
|
package com.yunzhi.gnyy.controller;
|
2
|
2
|
|
3
|
|
-import com.yunzhi.gnyy.common.BaseController;
|
4
|
|
-import com.yunzhi.gnyy.common.Constants;
|
5
|
|
-import com.yunzhi.gnyy.common.ResponseBean;
|
6
|
|
-import com.yunzhi.gnyy.common.StringUtils;
|
|
3
|
+import com.yunzhi.gnyy.common.*;
|
7
|
4
|
import com.yunzhi.gnyy.entity.SysSetting;
|
8
|
5
|
import com.yunzhi.gnyy.entity.TaPerson;
|
|
6
|
+import com.yunzhi.gnyy.entity.WxUser;
|
9
|
7
|
import com.yunzhi.gnyy.service.ISysSettingService;
|
10
|
8
|
import io.swagger.annotations.Api;
|
11
|
9
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -13,11 +11,10 @@ import io.swagger.annotations.ApiParam;
|
13
|
11
|
import org.slf4j.Logger;
|
14
|
12
|
import org.slf4j.LoggerFactory;
|
15
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
17
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
18
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
14
|
+import org.springframework.web.bind.annotation.*;
|
19
|
15
|
import com.yunzhi.gnyy.service.ITaPersonService;
|
20
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
16
|
+
|
|
17
|
+import java.time.LocalDateTime;
|
21
|
18
|
|
22
|
19
|
/**
|
23
|
20
|
* <p>
|
|
@@ -36,7 +33,7 @@ public class TaPersonController extends BaseController {
|
36
|
33
|
private final Logger logger = LoggerFactory.getLogger(TaPersonController.class);
|
37
|
34
|
|
38
|
35
|
@Autowired
|
39
|
|
- public ITaPersonService iTaPersonService;
|
|
36
|
+ public HttpUtils httpUtils;
|
40
|
37
|
|
41
|
38
|
@Autowired
|
42
|
39
|
public ISysSettingService iSysSettingService;
|
|
@@ -91,23 +88,31 @@ public class TaPersonController extends BaseController {
|
91
|
88
|
// }
|
92
|
89
|
// }
|
93
|
90
|
//
|
94
|
|
-// /**
|
95
|
|
-// * 修改对象
|
96
|
|
-// * @param id 实体ID
|
97
|
|
-// * @param taPerson 实体对象
|
98
|
|
-// * @return
|
99
|
|
-// */
|
100
|
|
-// @RequestMapping(value="/taPerson/{id}",method= RequestMethod.PUT)
|
101
|
|
-// @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
102
|
|
-// public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
103
|
|
-// @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
|
104
|
|
-//
|
105
|
|
-// if (iTaPersonService.updateById(taPerson)){
|
106
|
|
-// return ResponseBean.success(iTaPersonService.getById(id));
|
107
|
|
-// }else {
|
108
|
|
-// return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
109
|
|
-// }
|
110
|
|
-// }
|
|
91
|
+ /**
|
|
92
|
+ * 修改对象
|
|
93
|
+ * @param id 实体ID
|
|
94
|
+ * @param taPerson 实体对象
|
|
95
|
+ * @return
|
|
96
|
+ */
|
|
97
|
+ @RequestMapping(value="/wx/{clientId}/person",method= RequestMethod.PUT)
|
|
98
|
+ @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
99
|
+ public ResponseBean taPersonUpdate(@ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
|
|
100
|
+
|
|
101
|
+ // TODO 暂未校验 taPerson 各个必填字段
|
|
102
|
+
|
|
103
|
+ WxUser wxUser = currentWxUser();
|
|
104
|
+ if (StringUtils.isEmpty(wxUser.getPersonId())) {
|
|
105
|
+ taPerson.setPersonId(null);
|
|
106
|
+ iTaPersonService.save(taPerson);
|
|
107
|
+ wxUser.setPersonId(taPerson.getPersonId());
|
|
108
|
+ iWxUserService.updateById(wxUser);
|
|
109
|
+ } else {
|
|
110
|
+ taPerson.setPersonId(wxUser.getPersonId());
|
|
111
|
+ iTaPersonService.updateById(taPerson);
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ return ResponseBean.success(taPerson);
|
|
115
|
+ }
|
111
|
116
|
//
|
112
|
117
|
// /**
|
113
|
118
|
// * 根据id查询对象
|
|
@@ -131,9 +136,14 @@ public class TaPersonController extends BaseController {
|
131
|
136
|
return ResponseBean.error("人员不存在");
|
132
|
137
|
}
|
133
|
138
|
|
|
139
|
+ String today = DateUtils.toString(LocalDateTime.now(), "yyyy-MM-dd");
|
|
140
|
+
|
134
|
141
|
SysSetting sysSetting = iSysSettingService.getById(Constants.SETTING_BARCODE_URL);
|
135
|
|
- String url = sysSetting.getContent() + "?id_no=" + StringUtils.urlEncode(taPerson.getIdNo());
|
|
142
|
+ String url = String.format("%s?createDate=%s&idNo=%s",
|
|
143
|
+ sysSetting.getContent(),
|
|
144
|
+ StringUtils.urlEncode(today),
|
|
145
|
+ StringUtils.urlEncode(taPerson.getIdNo()));
|
136
|
146
|
|
137
|
|
- return ResponseBean.success(iTaPersonService.getById(id));
|
|
147
|
+ return ResponseBean.success(httpUtils.get(url));
|
138
|
148
|
}
|
139
|
149
|
}
|