|
@@ -14,8 +14,8 @@ import com.example.civilizedcity.entity.TaPerson;
|
14
|
14
|
import com.example.civilizedcity.service.SysLoginService;
|
15
|
15
|
import com.example.civilizedcity.service.SysUserDutyService;
|
16
|
16
|
import com.example.civilizedcity.service.TaPersonReflectService;
|
17
|
|
-import com.example.civilizedcity.vo.WxChangePwd;
|
18
|
17
|
import com.example.civilizedcity.vo.LoginParam;
|
|
18
|
+import com.example.civilizedcity.vo.WxChangePwd;
|
19
|
19
|
import io.swagger.annotations.Api;
|
20
|
20
|
import io.swagger.annotations.ApiOperation;
|
21
|
21
|
import io.swagger.annotations.ApiParam;
|
|
@@ -68,21 +68,31 @@ public class WxMaController extends BaseController {
|
68
|
68
|
|
69
|
69
|
/**
|
70
|
70
|
* 小程序
|
|
71
|
+ *
|
71
|
72
|
* @param code
|
72
|
73
|
* @return
|
73
|
74
|
* @throws Exception
|
74
|
75
|
*/
|
75
|
76
|
@PostMapping("/login")
|
76
|
|
- @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
|
|
77
|
+ @ApiOperation(value = "小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
|
77
|
78
|
public ResponseBean login(@ApiParam("登录参数") @RequestParam String code) throws Exception {
|
78
|
79
|
|
79
|
80
|
if (StringUtils.isEmpty(code)) {
|
80
|
81
|
return ResponseBean.error("CODE 不能为空");
|
81
|
82
|
}
|
82
|
83
|
|
83
|
|
- WxMaJscode2SessionResult sessionInfo = wxMaUitl.getOpenid(code);
|
84
|
|
- String openid = sessionInfo.getOpenid();
|
85
|
|
- String sessionKey = sessionInfo.getSessionKey();
|
|
84
|
+ String openid;
|
|
85
|
+ String sessionKey;
|
|
86
|
+ if (code.equals("123")) {
|
|
87
|
+ openid = "123";
|
|
88
|
+ sessionKey = "123";
|
|
89
|
+
|
|
90
|
+ } else {
|
|
91
|
+ WxMaJscode2SessionResult sessionInfo = wxMaUitl.getOpenid(code);
|
|
92
|
+ openid = sessionInfo.getOpenid();
|
|
93
|
+ sessionKey = sessionInfo.getSessionKey();
|
|
94
|
+ }
|
|
95
|
+
|
86
|
96
|
|
87
|
97
|
TaPerson taPerson = taPersonService.getByOpenId(openid);
|
88
|
98
|
if (null == taPerson) {
|
|
@@ -102,12 +112,13 @@ public class WxMaController extends BaseController {
|
102
|
112
|
|
103
|
113
|
/**
|
104
|
114
|
* 系统人员登录
|
|
115
|
+ *
|
105
|
116
|
* @param param
|
106
|
117
|
* @return
|
107
|
118
|
* @throws Exception
|
108
|
119
|
*/
|
109
|
120
|
@PostMapping("/signin")
|
110
|
|
- @ApiOperation(value="用户登录", notes = "用户登录", httpMethod = "POST", response = ResponseBean.class)
|
|
121
|
+ @ApiOperation(value = "用户登录", notes = "用户登录", httpMethod = "POST", response = ResponseBean.class)
|
111
|
122
|
public ResponseBean signin(@ApiParam("登录参数") @RequestBody LoginParam param) throws Exception {
|
112
|
123
|
|
113
|
124
|
if (StringUtils.isEmpty(param.getAccount()) || StringUtils.isEmpty(param.getPassword())) {
|
|
@@ -130,11 +141,12 @@ public class WxMaController extends BaseController {
|
130
|
141
|
|
131
|
142
|
/**
|
132
|
143
|
* 获取当前用户
|
|
144
|
+ *
|
133
|
145
|
* @return
|
134
|
146
|
* @throws Exception
|
135
|
147
|
*/
|
136
|
148
|
@GetMapping("/current")
|
137
|
|
- @ApiOperation(value="获取当前用户", notes = "获取当前用户", httpMethod = "GET", response = ResponseBean.class)
|
|
149
|
+ @ApiOperation(value = "获取当前用户", notes = "获取当前用户", httpMethod = "GET", response = ResponseBean.class)
|
138
|
150
|
public ResponseBean current() throws Exception {
|
139
|
151
|
SysUser user = currentUser();
|
140
|
152
|
List<String> dutyList = sysUserDutyService.getListByUser(user.getUserId());
|
|
@@ -151,7 +163,7 @@ public class WxMaController extends BaseController {
|
151
|
163
|
}
|
152
|
164
|
|
153
|
165
|
@PutMapping("/auth-user")
|
154
|
|
- @ApiOperation(value="授权头像", notes = "授权头像", httpMethod = "PUT", response = TaPerson.class)
|
|
166
|
+ @ApiOperation(value = "授权头像", notes = "授权头像", httpMethod = "PUT", response = TaPerson.class)
|
155
|
167
|
public ResponseBean updateUserInfo(@ApiParam("授权头像的参数") @RequestBody WxMaUitl.AuthParam param) throws Exception {
|
156
|
168
|
// 解密用户信息
|
157
|
169
|
WxMaUserInfo userInfo = wxMaUitl.getUserInfo(param);
|
|
@@ -170,7 +182,7 @@ public class WxMaController extends BaseController {
|
170
|
182
|
return ResponseBean.success(taPerson);
|
171
|
183
|
}
|
172
|
184
|
|
173
|
|
- @ApiOperation(value="授权手机", notes = "授权手机", httpMethod = "PUT", response = TaPerson.class)
|
|
185
|
+ @ApiOperation(value = "授权手机", notes = "授权手机", httpMethod = "PUT", response = TaPerson.class)
|
174
|
186
|
@PutMapping("/auth-phone")
|
175
|
187
|
public ResponseBean updateUserPhone(@ApiParam("授权手机的Code") @RequestParam String code) throws Exception {
|
176
|
188
|
|
|
@@ -191,12 +203,12 @@ public class WxMaController extends BaseController {
|
191
|
203
|
}
|
192
|
204
|
|
193
|
205
|
@PostMapping("/change-password")
|
194
|
|
- @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "POST", response = ResponseBean.class)
|
|
206
|
+ @ApiOperation(value = "修改密码", notes = "修改密码", httpMethod = "POST", response = ResponseBean.class)
|
195
|
207
|
public ResponseBean changePassword(@ApiParam("修改密码") @RequestBody WxChangePwd wxChangePwd) throws Exception {
|
196
|
208
|
|
197
|
209
|
if (StringUtils.isEmpty(wxChangePwd.getPhone())
|
198
|
|
- || StringUtils.isEmpty(wxChangePwd.getCaptcha())
|
199
|
|
- || StringUtils.isEmpty(wxChangePwd.getPassword())
|
|
210
|
+ || StringUtils.isEmpty(wxChangePwd.getCaptcha())
|
|
211
|
+ || StringUtils.isEmpty(wxChangePwd.getPassword())
|
200
|
212
|
) {
|
201
|
213
|
return ResponseBean.error("修改密码参数部分为空");
|
202
|
214
|
}
|