|
@@ -19,6 +19,7 @@ import com.izouma.jiashanxia.repo.OrderInfoRepo;
|
|
|
import com.izouma.jiashanxia.repo.UserRepo;
|
|
import com.izouma.jiashanxia.repo.UserRepo;
|
|
|
import com.izouma.jiashanxia.security.Authority;
|
|
import com.izouma.jiashanxia.security.Authority;
|
|
|
import com.izouma.jiashanxia.security.JwtTokenUtil;
|
|
import com.izouma.jiashanxia.security.JwtTokenUtil;
|
|
|
|
|
+import com.izouma.jiashanxia.security.JwtUser;
|
|
|
import com.izouma.jiashanxia.security.JwtUserFactory;
|
|
import com.izouma.jiashanxia.security.JwtUserFactory;
|
|
|
import com.izouma.jiashanxia.service.sms.SmsService;
|
|
import com.izouma.jiashanxia.service.sms.SmsService;
|
|
|
import com.izouma.jiashanxia.service.storage.StorageService;
|
|
import com.izouma.jiashanxia.service.storage.StorageService;
|
|
@@ -202,14 +203,19 @@ public class UserService {
|
|
|
return user;
|
|
return user;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public User getMaPhone(String sessionKey, String encryptedData, String iv) {
|
|
|
|
|
|
|
+ public Map<String, Object> getMaPhone(String sessionKey, String encryptedData, String iv) {
|
|
|
// 解密用户信息
|
|
// 解密用户信息
|
|
|
WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
|
|
WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
|
|
|
User user = userRepo.findById(SecurityUtils.getAuthenticatedUser().getId())
|
|
User user = userRepo.findById(SecurityUtils.getAuthenticatedUser().getId())
|
|
|
.orElseThrow(new BusinessException("用户不存在"));
|
|
.orElseThrow(new BusinessException("用户不存在"));
|
|
|
user.setPhone(phoneNoInfo.getPhoneNumber());
|
|
user.setPhone(phoneNoInfo.getPhoneNumber());
|
|
|
user.setUsername(phoneNoInfo.getPhoneNumber());
|
|
user.setUsername(phoneNoInfo.getPhoneNumber());
|
|
|
- return userRepo.save(user);
|
|
|
|
|
|
|
+ user = userRepo.save(user);
|
|
|
|
|
+ String token = jwtTokenUtil.generateToken(JwtUserFactory.create(user));
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("user", user);
|
|
|
|
|
+ map.put("token", token);
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String setPassword(Long userId, String password) {
|
|
public String setPassword(Long userId, String password) {
|
|
@@ -276,7 +282,8 @@ public class UserService {
|
|
|
List<User> employees = userRepo.findAllByCompanyIdAndDelFalse(parent.getCompanyId());
|
|
List<User> employees = userRepo.findAllByCompanyIdAndDelFalse(parent.getCompanyId());
|
|
|
Map<Long, User> userMap = employees.stream().collect(Collectors.toMap(User::getId, user -> user));
|
|
Map<Long, User> userMap = employees.stream().collect(Collectors.toMap(User::getId, user -> user));
|
|
|
return userRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
return userRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
- List<Predicate> and = JpaUtils.toPredicates(pageQuery, User.class, root, criteriaQuery, criteriaBuilder);
|
|
|
|
|
|
|
+ List<Predicate> and = JpaUtils
|
|
|
|
|
+ .toPredicates(pageQuery, User.class, root, criteriaQuery, criteriaBuilder);
|
|
|
and.add(root.get("parent").in(userMap.keySet()));
|
|
and.add(root.get("parent").in(userMap.keySet()));
|
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
}), JpaUtils.toPageRequest(pageQuery)).map(user -> {
|
|
}), JpaUtils.toPageRequest(pageQuery)).map(user -> {
|