根据用户id获取详细信息
This commit is contained in:
parent
1fbe70ea73
commit
8479eff9ea
@ -62,7 +62,7 @@ public class EbikeUserController {
|
|||||||
public JsonResult<?> silentLogin(@RequestParam(name = "js_code") String code) {
|
public JsonResult<?> silentLogin(@RequestParam(name = "js_code") String code) {
|
||||||
JsonNode result = verifyUtil.wechatAuthority(code);
|
JsonNode result = verifyUtil.wechatAuthority(code);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return JsonResult.failed("微信登录失败");
|
throw new EbikeException("微信登录失败");
|
||||||
}
|
}
|
||||||
if (result.has("errcode")) {
|
if (result.has("errcode")) {
|
||||||
return JsonResult.failed(String.format("微信登录失败 %s", result.get("errmsg").asText()));
|
return JsonResult.failed(String.format("微信登录失败 %s", result.get("errmsg").asText()));
|
||||||
@ -137,7 +137,7 @@ public class EbikeUserController {
|
|||||||
// 需要检测用户是否还有未支付的订单,如果有则不能注销
|
// 需要检测用户是否还有未支付的订单,如果有则不能注销
|
||||||
EbikeOrder unPayed = ebikeOrderTransactionService.checkHistoryOrder(ebikeUser.getUserId());
|
EbikeOrder unPayed = ebikeOrderTransactionService.checkHistoryOrder(ebikeUser.getUserId());
|
||||||
if (unPayed != null) {
|
if (unPayed != null) {
|
||||||
return JsonResult.failed("用户还有未完成的订单,不能注销", unPayed);
|
throw new EbikeException("用户还有未完成的订单,不能注销");
|
||||||
}
|
}
|
||||||
// 注销用户信息
|
// 注销用户信息
|
||||||
ebikeUserService.deRegister(ebikeUser);
|
ebikeUserService.deRegister(ebikeUser);
|
||||||
@ -162,9 +162,9 @@ public class EbikeUserController {
|
|||||||
* @param userId 用户信息主键
|
* @param userId 用户信息主键
|
||||||
* @return 用户信息详情
|
* @return 用户信息详情
|
||||||
*/
|
*/
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfoByUserId")
|
||||||
public JsonResult<?> getInfo(@RequestParam(name = "userId") Long userId) {
|
public JsonResult<?> getInfoByUserId(@RequestParam(name = "userId") Long userId) {
|
||||||
EbikeUser user = ebikeUserService.getById(userId);
|
EbikeUserVo user = ebikeUserService.getUserInfoByUserId(userId);
|
||||||
return JsonResult.success(user);
|
return JsonResult.success(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.cdzy.user.service.impl;
|
package com.cdzy.user.service.impl;
|
||||||
|
|
||||||
|
import com.cdzy.common.ex.EbikeException;
|
||||||
import com.cdzy.user.enums.UserStatus;
|
import com.cdzy.user.enums.UserStatus;
|
||||||
import com.cdzy.user.mapper.EbikeUserMapper;
|
import com.cdzy.user.mapper.EbikeUserMapper;
|
||||||
import com.cdzy.user.model.dto.EbikeUserPageDto;
|
import com.cdzy.user.model.dto.EbikeUserPageDto;
|
||||||
@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.cdzy.user.model.entity.table.EbikeUserRealInfoTableDef.EBIKE_USER_REAL_INFO;
|
import static com.cdzy.user.model.entity.table.EbikeUserRealInfoTableDef.EBIKE_USER_REAL_INFO;
|
||||||
import static com.cdzy.user.model.entity.table.EbikeUserTableDef.EBIKE_USER;
|
import static com.cdzy.user.model.entity.table.EbikeUserTableDef.EBIKE_USER;
|
||||||
@ -104,14 +106,10 @@ public class EbikeUserServiceImpl extends ServiceImpl<EbikeUserMapper, EbikeUser
|
|||||||
QueryWrapper query = QueryWrapper.create();
|
QueryWrapper query = QueryWrapper.create();
|
||||||
query.and(EBIKE_USER.OPEN_ID.eq(openId));
|
query.and(EBIKE_USER.OPEN_ID.eq(openId));
|
||||||
EbikeUser ebikeUser = this.mapper.selectOneByQuery(query);
|
EbikeUser ebikeUser = this.mapper.selectOneByQuery(query);
|
||||||
ebikeUser.setMobile(getSafeText(profile, "phoneNumber"));
|
if (Objects.isNull(ebikeUser)) {
|
||||||
|
throw new EbikeException("当前用户不存在");
|
||||||
ebikeUser.setNickname(getSafeText(profile, "nickName"));
|
}
|
||||||
ebikeUser.setAvatar(getSafeText(profile, "avatarUrl"));
|
ebikeUser.setMobile(getSafeText(profile, "purePhoneNumber"));
|
||||||
ebikeUser.setGender(getSafeInt(profile, "gender"));
|
|
||||||
ebikeUser.setCountry(getSafeText(profile, "country"));
|
|
||||||
ebikeUser.setProvince(getSafeText(profile, "province"));
|
|
||||||
ebikeUser.setCity(getSafeText(profile, "city"));
|
|
||||||
ebikeUser.setUpdateTime(LocalDateTime.now());
|
ebikeUser.setUpdateTime(LocalDateTime.now());
|
||||||
this.mapper.update(ebikeUser);
|
this.mapper.update(ebikeUser);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@ -135,15 +133,6 @@ public class EbikeUserServiceImpl extends ServiceImpl<EbikeUserMapper, EbikeUser
|
|||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全获取整数字段值
|
|
||||||
*/
|
|
||||||
private Integer getSafeInt(JsonNode node, String fieldName) {
|
|
||||||
return node.has(fieldName) && !node.get(fieldName).isNull()
|
|
||||||
? node.get(fieldName).asInt()
|
|
||||||
: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户基础信息查询
|
* 用户基础信息查询
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user