Ver código fonte

抽奖优化

lighter 1 ano atrás
pai
commit
94e68617ae

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>12.1.1</version>
+    <version>12.1.8</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 12 - 3
src/main/java/thyyxxk/webserver/controller/singlepage/LotteryController.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.controller.singlepage;
 
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -52,9 +53,17 @@ public class LotteryController {
     }
 
     @PassToken
-    @GetMapping("/selectWonUsers")
-    public ResultVo<List<LotteryUser>> selectWonUsers() {
-        List<LotteryUser> wonUsers = dao.selectWonUsers();
+    @PostMapping("/selectWonUsers")
+    public ResultVo<List<LotteryUser>> selectWonUsers(@RequestBody List<Integer> request) {
+        if (request.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR);
+        }
+        StringBuilder builder = new StringBuilder();
+        for (Integer code : request) {
+            builder.append(",").append(code);
+        }
+        String statement = builder.substring(1);
+        List<LotteryUser> wonUsers = dao.selectWonUsers(statement);
         return ResultVoUtil.success(wonUsers);
     }
 }

+ 3 - 2
src/main/java/thyyxxk/webserver/dao/his/singlepage/LotteryDao.java

@@ -23,6 +23,7 @@ public interface LotteryDao {
             "where code_rs=#{userCodeRs}")
     int updateLotteryResult(LotteryResult result);
 
-    @Select("select code_rs,name,won,won_time from t_lottery_user where won>-1 order by won_time")
-    List<LotteryUser> selectWonUsers();
+    @Select("select code_rs,name,won,won_time from t_lottery_user " +
+            "where won in (${statement}) and won>-1 order by won_time")
+    List<LotteryUser> selectWonUsers(String statement);
 }