1.update avatar path in cms getUserById

main
Gary 12 months ago
parent 15cebc3e42
commit aeaa2a5a0d

@ -3,7 +3,6 @@ package com.luoo.user.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
@ -59,7 +58,7 @@ public class CMSUserController {
@ApiOperation(value = "根据ID查询")
@GetMapping("/{id}")
public Result<UserInfo> findById(@PathVariable String id) {
return Result.success(userInfoService.findById(id));
return Result.success(userInfoService.cmsFindById(id));
}
@ApiOperation(value = "分页+多条件查询")
@ -106,6 +105,6 @@ public class CMSUserController {
@GetMapping("/ids/{ids}")
public Result<List<UserInfo>> orderByField(@PathVariable @VerifyParam(required = true) String ids) {
List<String> idList = Arrays.stream(ids.split(",")).map(String::trim).collect(Collectors.toList());
return Result.success(userInfoService.orderByField(idList));
return Result.success(userInfoService.cmsOrderByField(idList));
}
}

@ -2,6 +2,7 @@ package com.luoo.user.service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
@ -93,7 +94,6 @@ public class UserInfoService {
return userInfoDao.getById(id);
}
/**
*
*
@ -117,7 +117,6 @@ public class UserInfoService {
userInfoDao.deleteById(id);
}
public void sendSms(String deviceId, String mobile) {
// 生成6位数字随机数
String checkcode = RandomStringUtils.randomNumeric(6);
@ -186,7 +185,8 @@ public class UserInfoService {
userInfo.setLastUseDeviceId(deviceId);
userInfo.setLastUseDeviceBrand(deviceBrand);
userInfoDao.save(userInfo);
return Constants.TOKEN_PREFIX+jwtUtil.createJWT(userLoginDto.getUserId(), userInfo.getNickName(), userLoginDto.getRoles(),userLoginDto.getAvatar());
return Constants.TOKEN_PREFIX + jwtUtil.createJWT(userLoginDto.getUserId(), userInfo.getNickName(),
userLoginDto.getRoles(), userLoginDto.getAvatar());
}
public long countByNickName(String nickName) {
@ -211,13 +211,18 @@ public class UserInfoService {
}
user.setLastLoginTime(new Date());
userInfoDao.save(user);
return Constants.TOKEN_PREFIX+jwtUtil.createJWT(user.getId(),user.getNickName(),Constants.TOKEN_ROLE_APP_USER,user.getAvatar());
return Constants.TOKEN_PREFIX
+ jwtUtil.createJWT(user.getId(), user.getNickName(), Constants.TOKEN_ROLE_APP_USER, user.getAvatar());
}
public List<UserInfo> orderByField(List<String> idList) {
return userInfoDao.orderByField(idList);
}
public List<UserInfo> cmsOrderByField(List<String> idList) {
return orderByField(idList).stream().map(this::updateAvatarPath).collect(Collectors.toList());
}
public List<SimpleUser> getSimpleUserOrderByField(List<String> idList) {
return userInfoDao.getSimpleUserOrderByField(idList);
}
@ -230,16 +235,18 @@ public class UserInfoService {
}
private UserInfo updateAvatarPath(UserInfo userInfo) {
if (null != userInfo.getAvatar()) {
if (null != userInfo && null != userInfo.getAvatar()) {
userInfo.setAvatar(Constants.RESOURCE_PREFIX + userInfo.getAvatar());
}
return userInfo;
}
public Page<UserInfo> findSearch(UserQueryReq queryReq, int page, int size) {
Specification<UserInfo> specification = createUserInfoSpecification(queryReq);
PageRequest pageRequest = PageRequest.of(page - 1, size);
return userInfoDao.findAll(specification, pageRequest);
}
private Specification<UserInfo> createUserInfoSpecification(UserQueryReq queryReq) {
return (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<>();
@ -277,5 +284,8 @@ public class UserInfoService {
};
}
public UserInfo cmsFindById(String id) {
return updateAvatarPath(userInfoDao.getById(id));
}
}

Loading…
Cancel
Save