|
|
@@ -10,6 +10,8 @@ import com.izouma.zhirongip.dto.PageQuery;
|
|
|
import com.izouma.zhirongip.dto.UserRegister;
|
|
|
import com.izouma.zhirongip.enums.AuthorityName;
|
|
|
import com.izouma.zhirongip.exception.BusinessException;
|
|
|
+import com.izouma.zhirongip.repo.InstitutionRepo;
|
|
|
+import com.izouma.zhirongip.repo.PersonalRepo;
|
|
|
import com.izouma.zhirongip.repo.UserRepo;
|
|
|
import com.izouma.zhirongip.security.Authority;
|
|
|
import com.izouma.zhirongip.security.JwtTokenUtil;
|
|
|
@@ -33,19 +35,22 @@ import org.springframework.stereotype.Service;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@AllArgsConstructor
|
|
|
public class UserService {
|
|
|
- private final UserRepo userRepo;
|
|
|
- private final WxMaService wxMaService;
|
|
|
- private final WxMpService wxMpService;
|
|
|
- private final SmsService smsService;
|
|
|
- private final StorageService storageService;
|
|
|
- private final JwtTokenUtil jwtTokenUtil;
|
|
|
- private final CaptchaService captchaService;
|
|
|
+ private final UserRepo userRepo;
|
|
|
+ private final WxMaService wxMaService;
|
|
|
+ private final WxMpService wxMpService;
|
|
|
+ private final SmsService smsService;
|
|
|
+ private final StorageService storageService;
|
|
|
+ private final JwtTokenUtil jwtTokenUtil;
|
|
|
+ private final CaptchaService captchaService;
|
|
|
+ private final PersonalRepo personalRepo;
|
|
|
+ private final InstitutionRepo institutionRepo;
|
|
|
|
|
|
public Page<User> all(PageQuery pageQuery) {
|
|
|
return userRepo.findAll(JpaUtils.toSpecification(pageQuery, User.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -70,6 +75,12 @@ public class UserService {
|
|
|
user.setPhone(user.getPhone() + "###" + RandomStringUtils.randomAlphabetic(8));
|
|
|
}
|
|
|
userRepo.save(user);
|
|
|
+ Set<Authority> authorities = user.getAuthorities();
|
|
|
+ if (authorities.contains(Authority.get(AuthorityName.ROLE_INSTITUTION))) {
|
|
|
+ institutionRepo.softDeleteByUserId(id);
|
|
|
+ } else if (authorities.contains(Authority.get(AuthorityName.ROLE_PERSONAL))) {
|
|
|
+ personalRepo.softDeleteByUserId(id);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public User loginByPhone(String phone) {
|