浏览代码

Merge branch 'Regulation' of http://git.izouma.com/licailing/wenlvju into Regulation

xuqiang 4 年之前
父节点
当前提交
a705e01ce0

+ 2 - 2
src/main/h5/src/views/loginHome.vue

@@ -75,9 +75,9 @@ export default {
         forbidClick: true
       });
       this.$http
-        .post("/performanceApply/getAuth", {
+        .post("/programme/getAuth", {
           phone: this.ruleForm.phone,
-          id: this.$route.query.performanceApplyId
+          id: this.$route.query.programmeId
         })
         .then(res => {
           window.localStorage.setItem("loginPhone", res.phone);

+ 1 - 1
src/main/java/com/izouma/wenlvju/domain/RecordSpecialty.java

@@ -25,7 +25,7 @@ public class RecordSpecialty extends BaseEntity {
     private String code;
 
     @ApiModelProperty(value = "总级数")
-    private int level;
+    private String level;
 
     @ApiModelProperty(value = "考场数量")
     private int numOfExam;

+ 4 - 0
src/main/java/com/izouma/wenlvju/domain/performance/Programme.java

@@ -125,6 +125,10 @@ public class Programme extends BaseEntity {
     @ApiModelProperty(value = "奖项")
     private Long awardId;
 
+    @Transient
+    private String specialty;
+
+
     public Programme(ProgrammeDTO dto) {
         BeanUtil.copyProperties(dto, this);
     }

+ 2 - 0
src/main/java/com/izouma/wenlvju/security/WebSecurityConfig.java

@@ -71,6 +71,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/district/NJ").permitAll()
                 .antMatchers("/setting/byFlag").permitAll()
                 .antMatchers("/programme/getShow/**").permitAll()
+                .antMatchers("/programme/getAuth").permitAll()
+                .antMatchers("/programme/getScore").permitAll()
                 .antMatchers("/upload/**").permitAll()
                 .antMatchers("/files/**").permitAll()
                 .antMatchers("/static/**").permitAll()

+ 44 - 1
src/main/java/com/izouma/wenlvju/service/UserService.java

@@ -8,6 +8,8 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.izouma.wenlvju.config.Constants;
 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.OrganizationRegDTO;
 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.exception.BusinessException;
 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.JwtTokenUtil;
 import com.izouma.wenlvju.security.JwtUserFactory;
@@ -57,6 +61,8 @@ public class UserService {
     private final RateRepo                rateRepo;
     private final OrganizationService     organizationService;
     private final SettingRepo             settingRepo;
+    private final ParticipantRepo         participantRepo;
+    private final ProgrammeRepo           programmeRepo;
 
     public Page<User> all(PageQuery 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()
                 .stream()
                 .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;
     }
+
+    /**
+     * 扫描作品二维码,通过手机号获取身份
+     */
+    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;
+    }
 }

+ 2 - 0
src/main/java/com/izouma/wenlvju/web/AuthenticationController.java

@@ -3,6 +3,7 @@ package com.izouma.wenlvju.web;
 import com.izouma.wenlvju.domain.User;
 import com.izouma.wenlvju.enums.AuthorityName;
 import com.izouma.wenlvju.exception.AuthenticationException;
+import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.security.JwtTokenUtil;
 import com.izouma.wenlvju.security.JwtUser;
 import com.izouma.wenlvju.security.JwtUserFactory;
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Map;
 import java.util.Objects;
 
 @Slf4j

+ 24 - 0
src/main/java/com/izouma/wenlvju/web/performance/ProgrammeController.java

@@ -1,10 +1,14 @@
 package com.izouma.wenlvju.web.performance;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.izouma.wenlvju.domain.ArtType;
 import com.izouma.wenlvju.domain.performance.Programme;
 import com.izouma.wenlvju.dto.*;
 import com.izouma.wenlvju.enums.SignedIn;
 import com.izouma.wenlvju.exception.BusinessException;
+import com.izouma.wenlvju.repo.ArtTypeRepo;
 import com.izouma.wenlvju.repo.performance.ProgrammeRepo;
+import com.izouma.wenlvju.service.UserService;
 import com.izouma.wenlvju.service.performance.ProgrammeService;
 import com.izouma.wenlvju.utils.ObjUtils;
 import com.izouma.wenlvju.utils.SecurityUtils;
@@ -20,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @RestController
@@ -28,6 +33,8 @@ import java.util.List;
 public class ProgrammeController extends BaseController {
     private ProgrammeService programmeService;
     private ProgrammeRepo    programmeRepo;
+    private ArtTypeRepo      artTypeRepo;
+    private UserService      userService;
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
@@ -149,5 +156,22 @@ public class ProgrammeController extends BaseController {
         return programmeService.showByGO(id);
     }
 
+    @ApiOperation("获取手机号/token")
+    @PostMapping("/getAuth")
+    public Map<String, String> getAuth(@RequestParam Long id, @RequestParam String phone) {
+        Programme apply = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        return userService.getAuth(id, phone, apply.getPhone());
+    }
+
+    @GetMapping("/getScore/{id}")
+    public Programme get(@PathVariable Long id, String phone) {
+        Programme apply = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        if (ObjectUtil.isNotNull(apply.getSpecialtyId())) {
+            ArtType artType = artTypeRepo.findById(apply.getSpecialtyId()).orElseThrow(new BusinessException("无此专业"));
+            apply.setSpecialty(artType.getName());
+        }
+        userService.getAuth(id, phone, apply.getPhone());
+        return apply;
+    }
 }
 

+ 1 - 4
src/main/vue/src/views/performance/ProgrammeList.vue

@@ -570,10 +570,7 @@ export default {
         showCode(row) {
             this.dialogCode = true;
             this.dialogUrl =
-                'http://wljtest.izouma.com/h5/home?performanceId=' +
-                row.performanceId +
-                '&performanceApplyId=' +
-                row.id;
+                'http://wljtest.izouma.com/h5/home?performanceId=' + row.performanceId + '&programmeId=' + row.id;
         },
         clearSearch() {
             // this.competitionGroup = '';