校验用户是否存在

This commit is contained in:
yanglei 2026-01-15 17:41:08 +08:00
parent fb2a782f23
commit 513e0e45fc
3 changed files with 23 additions and 0 deletions

View File

@ -216,4 +216,15 @@ public class EbikeUserController {
} }
return JsonResult.success(jsonResult.getData()); return JsonResult.success(jsonResult.getData());
} }
/**
* 校验用户是否存在
* @param userId 用户id
* @return true 存在 false 不存在
*/
@GetMapping("checkUserExit")
public JsonResult<?> checkUserExit(@RequestParam("userId") Long userId) {
boolean result = ebikeUserService.checkUserExit(userId);
return JsonResult.success(result);
}
} }

View File

@ -51,4 +51,11 @@ public interface EbikeUserService extends IService<EbikeUser> {
void updateUserInfo(String decryptedData, String openId); void updateUserInfo(String decryptedData, String openId);
EbikeUserVo getUserInfoByUserId(Long userId); EbikeUserVo getUserInfoByUserId(Long userId);
/**
* 校验用户是否存在
* @param userId 用户id
* @return true 存在 false 不存在
*/
boolean checkUserExit(Long userId);
} }

View File

@ -126,6 +126,11 @@ public class EbikeUserServiceImpl extends ServiceImpl<EbikeUserMapper, EbikeUser
return getOneAs(query, EbikeUserVo.class); return getOneAs(query, EbikeUserVo.class);
} }
@Override
public boolean checkUserExit(Long userId) {
return getOne(buildBaseUserQuery().where(EBIKE_USER.USER_ID.eq(userId))) != null;
}
private String getSafeText(JsonNode node, String fieldName) { private String getSafeText(JsonNode node, String fieldName) {
return node.has(fieldName) && !node.get(fieldName).isNull() return node.has(fieldName) && !node.get(fieldName).isNull()