licailing hace 4 años
padre
commit
74ef657441

+ 2 - 0
src/main/java/com/izouma/wenlvju/repo/PerformanceScoreRepo.java

@@ -16,4 +16,6 @@ public interface PerformanceScoreRepo extends JpaRepository<PerformanceScore, Lo
     void softDelete(Long id);
 
     List<PerformanceScore> findAllByPerformanceApplyId(Long performanceApplyId);
+
+    PerformanceScore findByPerformanceApplyIdAndUserId(Long performanceApplyId,Long userId);
 }

+ 14 - 10
src/main/java/com/izouma/wenlvju/service/PerformanceApplyService.java

@@ -156,9 +156,9 @@ public class PerformanceApplyService {
 //        });
     }
 
-    /*
-    签到
-    由管理人员先登陆,进行签到
+    /**
+     *签到
+     *由管理人员先登陆,进行签到
      */
     public PerformanceApply signIn(Long id, Long userId) {
         PerformanceApply performanceApply = performanceApplyRepo.findById(id)
@@ -174,8 +174,8 @@ public class PerformanceApplyService {
         return performanceApplyRepo.save(performanceApply);
     }
 
-    /*
-    扫描作品二维码,通过手机号获取身份
+    /**
+     *扫描作品二维码,通过手机号获取身份
      */
     public Map<String, String> getAuth(Long id, String phone) {
         PerformanceApply performanceApply = performanceApplyRepo.findById(id)
@@ -190,7 +190,7 @@ public class PerformanceApplyService {
 
         List<String> phones = personRepo.findAllByPerformanceApplyId(id)
                 .stream()
-                .map(Person::getName)
+                .map(Person::getPhone)
                 .collect(Collectors.toList());
         if (phones.contains(phone)) {
             map.put("phone", phone);
@@ -210,8 +210,8 @@ public class PerformanceApplyService {
         return map;
     }
 
-    /*
-    评分
+    /**
+     *评分
      */
     public void score(Long id, double score, Long userId) {
         PerformanceApply apply = performanceApplyRepo.findById(id).orElseThrow(new BusinessException("无此表演"));
@@ -224,6 +224,10 @@ public class PerformanceApplyService {
         if (LocalDateTime.now().isBefore(apply.getShowStartTime())) {
             throw new BusinessException("节目暂未开始");
         }
+        PerformanceScore score1 = performanceScoreRepo.findByPerformanceApplyIdAndUserId(id, userId);
+        if (ObjectUtil.isNotNull(score1)){
+            throw new BusinessException("已打分");
+        }
 
         PerformanceScore performanceScore = PerformanceScore.builder()
                 .performanceApplyId(id)
@@ -243,8 +247,8 @@ public class PerformanceApplyService {
         performanceApplyRepo.save(apply);
     }
 
-    /*
-    获取相关
+    /**
+     *获取相关
      */
     public List<PerformanceApply> related(Long id) {
         PerformanceApply apply = performanceApplyRepo.findById(id).orElseThrow(new BusinessException("无记录"));

+ 6 - 1
src/test/java/com/izouma/wenlvju/service/PerformanceApplyServiceTest.java

@@ -18,7 +18,12 @@ public class PerformanceApplyServiceTest extends ApplicationTests {
 
     @Test
     public void test1() {
-        performanceApplyService.score(14L, 79,1L );
+        performanceApplyService.score(14L, 79, 1L);
+    }
+
+    @Test
+    public void test2() {
+        System.out.println(performanceApplyService.getAuth(895L, "13011112222"));
     }
 
 }