|
@@ -386,16 +386,16 @@ public class UserController {
|
|
|
return RT.ok(userService.resetPassword(dto));
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/bind-openid")
|
|
|
+ @PostMapping("/bind-unionid")
|
|
|
@ApiOperation(value = "绑定微信 UnionId")
|
|
|
- public R bindOpenid(@RequestBody BindOpenidDto dto) {
|
|
|
+ public R bindUnionId(@RequestBody BindOpenidDto dto) {
|
|
|
User user = userService.getOne(Wrappers.<User>query().lambda().select(User::getId, User::getOpenId,User::getUnionId).eq(User::getId, dto.getId()), false);
|
|
|
if (user != null) {
|
|
|
if (StrUtil.isNotBlank(user.getUnionId())) {
|
|
|
return R.error("该用户已经绑定微信!");
|
|
|
}
|
|
|
|
|
|
- long count = userService.count(Wrappers.<User>query().lambda().eq(User::getOpenId, dto.getOpenid()));
|
|
|
+ long count = userService.count(Wrappers.<User>query().lambda().eq(User::getUnionId, dto.getOpenid()));
|
|
|
if(count > 0){
|
|
|
return R.error("该用户已经绑定微信!");
|
|
|
}
|
|
@@ -414,6 +414,33 @@ public class UserController {
|
|
|
return R.error("该用户不存在!");
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/bind-openid")
|
|
|
+ @ApiOperation(value = "绑定微信 Openid")
|
|
|
+ public R bindOpenid(@RequestBody BindOpenidDto dto) {
|
|
|
+ User user = userService.getOne(Wrappers.<User>query().lambda().select(User::getId, User::getOpenId,User::getUnionId).eq(User::getId, dto.getId()), false);
|
|
|
+ if (user != null) {
|
|
|
+ if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
|
+ return R.error("该用户已经绑定微信!");
|
|
|
+ }
|
|
|
+
|
|
|
+ long count = userService.count(Wrappers.<User>query().lambda().eq(User::getOpenId, dto.getOpenid()));
|
|
|
+ if(count > 0){
|
|
|
+ return R.error("该用户已经绑定微信!");
|
|
|
+ }
|
|
|
+
|
|
|
+ User updateUser = new User();
|
|
|
+ updateUser.setId(dto.getId());
|
|
|
+ updateUser.setOpenId(dto.getOpenid());
|
|
|
+ return R.ok(userService.updateById(updateUser));
|
|
|
+ }else{
|
|
|
+ long count = userService.count(Wrappers.<User>query().lambda().eq(User::getOpenId, dto.getOpenid()));
|
|
|
+ if(count > 0){
|
|
|
+ return R.error("该用户已经绑定微信!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.error("该用户不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/unbind-openid")
|
|
|
@ApiOperation(value = "取消绑定微信 UnionId")
|
|
|
public R unbindOpenid(@RequestParam Long id) {
|