根据用户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) {
|
||||
JsonNode result = verifyUtil.wechatAuthority(code);
|
||||
if (result == null) {
|
||||
return JsonResult.failed("微信登录失败");
|
||||
throw new EbikeException("微信登录失败");
|
||||
}
|
||||
if (result.has("errcode")) {
|
||||
return JsonResult.failed(String.format("微信登录失败 %s", result.get("errmsg").asText()));
|
||||
@ -137,7 +137,7 @@ public class EbikeUserController {
|
||||
// 需要检测用户是否还有未支付的订单,如果有则不能注销
|
||||
EbikeOrder unPayed = ebikeOrderTransactionService.checkHistoryOrder(ebikeUser.getUserId());
|
||||
if (unPayed != null) {
|
||||
return JsonResult.failed("用户还有未完成的订单,不能注销", unPayed);
|
||||
throw new EbikeException("用户还有未完成的订单,不能注销");
|
||||
}
|
||||
// 注销用户信息
|
||||
ebikeUserService.deRegister(ebikeUser);
|
||||
@ -162,9 +162,9 @@ public class EbikeUserController {
|
||||
* @param userId 用户信息主键
|
||||
* @return 用户信息详情
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public JsonResult<?> getInfo(@RequestParam(name = "userId") Long userId) {
|
||||
EbikeUser user = ebikeUserService.getById(userId);
|
||||
@GetMapping("getInfoByUserId")
|
||||
public JsonResult<?> getInfoByUserId(@RequestParam(name = "userId") Long userId) {
|
||||
EbikeUserVo user = ebikeUserService.getUserInfoByUserId(userId);
|
||||
return JsonResult.success(user);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.user.service.impl;
|
||||
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.user.enums.UserStatus;
|
||||
import com.cdzy.user.mapper.EbikeUserMapper;
|
||||
import com.cdzy.user.model.dto.EbikeUserPageDto;
|
||||
@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
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.EbikeUserTableDef.EBIKE_USER;
|
||||
@ -104,14 +106,10 @@ public class EbikeUserServiceImpl extends ServiceImpl<EbikeUserMapper, EbikeUser
|
||||
QueryWrapper query = QueryWrapper.create();
|
||||
query.and(EBIKE_USER.OPEN_ID.eq(openId));
|
||||
EbikeUser ebikeUser = this.mapper.selectOneByQuery(query);
|
||||
ebikeUser.setMobile(getSafeText(profile, "phoneNumber"));
|
||||
|
||||
ebikeUser.setNickname(getSafeText(profile, "nickName"));
|
||||
ebikeUser.setAvatar(getSafeText(profile, "avatarUrl"));
|
||||
ebikeUser.setGender(getSafeInt(profile, "gender"));
|
||||
ebikeUser.setCountry(getSafeText(profile, "country"));
|
||||
ebikeUser.setProvince(getSafeText(profile, "province"));
|
||||
ebikeUser.setCity(getSafeText(profile, "city"));
|
||||
if (Objects.isNull(ebikeUser)) {
|
||||
throw new EbikeException("当前用户不存在");
|
||||
}
|
||||
ebikeUser.setMobile(getSafeText(profile, "purePhoneNumber"));
|
||||
ebikeUser.setUpdateTime(LocalDateTime.now());
|
||||
this.mapper.update(ebikeUser);
|
||||
} 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