|
@@ -4,24 +4,20 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.izouma.wenlvju.config.Constants;
|
|
import com.izouma.wenlvju.config.Constants;
|
|
|
-import com.izouma.wenlvju.domain.ArtType;
|
|
|
|
|
-import com.izouma.wenlvju.domain.Organization;
|
|
|
|
|
-import com.izouma.wenlvju.domain.User;
|
|
|
|
|
|
|
+import com.izouma.wenlvju.domain.*;
|
|
|
import com.izouma.wenlvju.dto.ExpertDTO;
|
|
import com.izouma.wenlvju.dto.ExpertDTO;
|
|
|
import com.izouma.wenlvju.dto.OrganizationRegDTO;
|
|
import com.izouma.wenlvju.dto.OrganizationRegDTO;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.dto.UserRegister;
|
|
import com.izouma.wenlvju.dto.UserRegister;
|
|
|
import com.izouma.wenlvju.enums.AuthorityName;
|
|
import com.izouma.wenlvju.enums.AuthorityName;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
|
-import com.izouma.wenlvju.repo.ArtTypeRepo;
|
|
|
|
|
-import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
|
|
-import com.izouma.wenlvju.repo.UserRepo;
|
|
|
|
|
|
|
+import com.izouma.wenlvju.repo.*;
|
|
|
import com.izouma.wenlvju.security.Authority;
|
|
import com.izouma.wenlvju.security.Authority;
|
|
|
import com.izouma.wenlvju.security.JwtTokenUtil;
|
|
import com.izouma.wenlvju.security.JwtTokenUtil;
|
|
|
import com.izouma.wenlvju.security.JwtUserFactory;
|
|
import com.izouma.wenlvju.security.JwtUserFactory;
|
|
|
-import com.izouma.wenlvju.service.sms.SmsService;
|
|
|
|
|
import com.izouma.wenlvju.service.storage.StorageService;
|
|
import com.izouma.wenlvju.service.storage.StorageService;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
@@ -48,15 +44,17 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class UserService {
|
|
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 ArtTypeRepo artTypeRepo;
|
|
|
|
|
- private final OrganizationRepo organizationRepo;
|
|
|
|
|
|
|
+ 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 ArtTypeRepo artTypeRepo;
|
|
|
|
|
+ private final OrganizationRepo organizationRepo;
|
|
|
|
|
+ private final CollaborateRepo collaborateRepo;
|
|
|
|
|
+ private final GradingOrganizationRepo gradingOrganizationRepo;
|
|
|
|
|
|
|
|
public Page<User> all(PageQuery pageQuery) {
|
|
public Page<User> all(PageQuery pageQuery) {
|
|
|
return userRepo.findAll(JpaUtils.toSpecification(pageQuery, User.class), JpaUtils.toPageRequest(pageQuery));
|
|
return userRepo.findAll(JpaUtils.toSpecification(pageQuery, User.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -197,34 +195,55 @@ public class UserService {
|
|
|
return setPassword(userId, password);
|
|
return setPassword(userId, password);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Page<ExpertDTO> all1(PageQuery pageQuery) {
|
|
|
|
|
|
|
+ public Page<ExpertDTO> all1(PageQuery pageQuery, List<Authority> authorities) {
|
|
|
|
|
+ Map<Long, String> artMap = artTypeRepo.findAll()
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(ArtType::getId, ArtType::getName));
|
|
|
|
|
+ return this.all2(pageQuery, authorities).map(user -> new ExpertDTO(user, artMap.get(user.getArtTypeId())));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Page<ExpertDTO> all3(Long rateId) {
|
|
|
|
|
+ PageQuery pageQuery = new PageQuery();
|
|
|
|
|
+ pageQuery.setSize(1000);
|
|
|
|
|
+ pageQuery.getQuery().put("del", false);
|
|
|
pageQuery.setSort("createdAt,desc");
|
|
pageQuery.setSort("createdAt,desc");
|
|
|
|
|
+
|
|
|
Map<Long, String> artMap = artTypeRepo.findAll()
|
|
Map<Long, String> artMap = artTypeRepo.findAll()
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(ArtType::getId, ArtType::getName));
|
|
.collect(Collectors.toMap(ArtType::getId, ArtType::getName));
|
|
|
|
|
+
|
|
|
|
|
+ Set<Long> goId = collaborateRepo.findAllByRateId(rateId)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(Collaborate::getGradingOrganizationId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+ List<String> names = gradingOrganizationRepo.findAllById(goId)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(GradingOrganization::getName)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
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);
|
|
|
- // 只有专家权限
|
|
|
|
|
|
|
+ // 特定权限
|
|
|
SetJoin<User, Authority> join = root.join(root.getModel()
|
|
SetJoin<User, Authority> join = root.join(root.getModel()
|
|
|
.getSet("authorities", Authority.class), JoinType.LEFT);
|
|
.getSet("authorities", Authority.class), JoinType.LEFT);
|
|
|
- and.add(join.in(Authority.get(AuthorityName.ROLE_EXPERT)));
|
|
|
|
|
|
|
+ and.add(join.in(Authority.get(AuthorityName.ROLE_EXPERT), Authority.get(AuthorityName.ROLE_DISTRICT_STAFF)));
|
|
|
|
|
+ criteriaQuery.distinct(true);
|
|
|
|
|
+ names.forEach(name -> and.add(criteriaBuilder.notLike(root.get("work"), "%" + name + "%")));
|
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
}), JpaUtils.toPageRequest(pageQuery)).map(user -> new ExpertDTO(user, artMap.get(user.getArtTypeId())));
|
|
}), JpaUtils.toPageRequest(pageQuery)).map(user -> new ExpertDTO(user, artMap.get(user.getArtTypeId())));
|
|
|
|
|
+// return this.all2(pageQuery, authorities).map(user -> new ExpertDTO(user, artMap.get(user.getArtTypeId())));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Page<User> all2(PageQuery pageQuery) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public Page<User> all2(PageQuery pageQuery, List<Authority> authorities) {
|
|
|
|
|
+ pageQuery.getQuery().put("del", false);
|
|
|
|
|
+ pageQuery.setSort("createdAt,desc");
|
|
|
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);
|
|
|
- // 只有专家权限
|
|
|
|
|
|
|
+ // 特定权限
|
|
|
SetJoin<User, Authority> join = root.join(root.getModel()
|
|
SetJoin<User, Authority> join = root.join(root.getModel()
|
|
|
.getSet("authorities", Authority.class), JoinType.LEFT);
|
|
.getSet("authorities", Authority.class), JoinType.LEFT);
|
|
|
- and.add(join.in(
|
|
|
|
|
- Authority.get(AuthorityName.ROLE_DISTRICT),
|
|
|
|
|
- Authority.get(AuthorityName.ROLE_ORGANIZER),
|
|
|
|
|
- Authority.get(AuthorityName.ROLE_ADMIN),
|
|
|
|
|
- Authority.get(AuthorityName.ROLE_DEV),
|
|
|
|
|
- Authority.get(AuthorityName.ROLE_SUPERVISOR),
|
|
|
|
|
- Authority.get(AuthorityName.ROLE_USER)));
|
|
|
|
|
|
|
+ and.add(join.in(authorities));
|
|
|
criteriaQuery.distinct(true);
|
|
criteriaQuery.distinct(true);
|
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
}), JpaUtils.toPageRequest(pageQuery));
|
|
}), JpaUtils.toPageRequest(pageQuery));
|