|
@@ -8,6 +8,8 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.wenlvju.config.Constants;
|
|
import com.izouma.wenlvju.config.Constants;
|
|
|
import com.izouma.wenlvju.domain.*;
|
|
import com.izouma.wenlvju.domain.*;
|
|
|
|
|
+import com.izouma.wenlvju.domain.performance.Participant;
|
|
|
|
|
+import com.izouma.wenlvju.domain.performance.Programme;
|
|
|
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;
|
|
@@ -15,6 +17,8 @@ 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.*;
|
|
import com.izouma.wenlvju.repo.*;
|
|
|
|
|
+import com.izouma.wenlvju.repo.performance.ParticipantRepo;
|
|
|
|
|
+import com.izouma.wenlvju.repo.performance.ProgrammeRepo;
|
|
|
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;
|
|
@@ -57,6 +61,8 @@ public class UserService {
|
|
|
private final RateRepo rateRepo;
|
|
private final RateRepo rateRepo;
|
|
|
private final OrganizationService organizationService;
|
|
private final OrganizationService organizationService;
|
|
|
private final SettingRepo settingRepo;
|
|
private final SettingRepo settingRepo;
|
|
|
|
|
+ private final ParticipantRepo participantRepo;
|
|
|
|
|
+ private final ProgrammeRepo programmeRepo;
|
|
|
|
|
|
|
|
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));
|
|
@@ -222,7 +228,8 @@ public class UserService {
|
|
|
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));
|
|
|
- return this.byAuthority(pageQuery, authorities).map(user -> new ExpertDTO(user, artMap.get(user.getArtTypeId())));
|
|
|
|
|
|
|
+ return this.byAuthority(pageQuery, authorities)
|
|
|
|
|
+ .map(user -> new ExpertDTO(user, artMap.get(user.getArtTypeId())));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 等级评定分配专家列表
|
|
// 等级评定分配专家列表
|
|
@@ -326,4 +333,40 @@ public class UserService {
|
|
|
|
|
|
|
|
return user;
|
|
return user;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 扫描作品二维码,通过手机号获取身份
|
|
|
|
|
+ */
|
|
|
|
|
+ public Map<String, String> getAuth(Long id, String phone,String proPhone) {
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotNull(id)){
|
|
|
|
|
+ if (phone.equals(proPhone)) {
|
|
|
|
|
+ map.put("phone", phone);
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<String> phones = participantRepo.findAllByProgrammeId(id)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(Participant::getPhone)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (phones.contains(phone)) {
|
|
|
|
|
+ map.put("phone", phone);
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ User user = userRepo.findByPhoneAndDelFalse(phone);
|
|
|
|
|
+ if (ObjectUtil.isNull(user)) {
|
|
|
|
|
+ throw new BusinessException("手机号错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!user.getAuthorities().contains(Authority.get(AuthorityName.ROLE_ADMIN))) {
|
|
|
|
|
+ throw new BusinessException("无权限");
|
|
|
|
|
+ }
|
|
|
|
|
+ String token = jwtTokenUtil.generateToken(JwtUserFactory.create(user));
|
|
|
|
|
+ map.put("phone", phone);
|
|
|
|
|
+ map.put("token", token);
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|