Browse Source

优化抽奖

lighter 1 year ago
parent
commit
8fcad75561

+ 0 - 51
src/main/java/thyyxxk/webserver/controller/singlepage/LotteryController.java

@@ -1,10 +1,8 @@
 package thyyxxk.webserver.controller.singlepage;
 
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.singlepage.LotteryDao;
@@ -14,9 +12,6 @@ import thyyxxk.webserver.entity.singlepage.lottery.LotteryUser;
 import thyyxxk.webserver.entity.singlepage.lottery.StartLotteryRequest;
 import thyyxxk.webserver.utils.ResultVoUtil;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.List;
 
 @Slf4j
@@ -30,49 +25,6 @@ public class LotteryController {
         this.dao = dao;
     }
 
-    @PassToken
-    @PostMapping("/uploadLotteryUsers")
-    public ResultVo<List<LotteryUser>> uploadLotteryUsers(@RequestBody MultipartFile file) throws IOException {
-        List<LotteryUser> userList = new ArrayList<>();
-        dao.truncateTable();
-        Workbook workbook;
-        InputStream is = file.getInputStream();
-        workbook = WorkbookFactory.create(is);
-        // 获取第一个活页数据
-        Sheet sheet = workbook.getSheetAt(0);
-        // 第几行开始解析
-        for (int i = 1; i <= sheet.getLastRowNum(); i++) {
-            Row row = sheet.getRow(i);
-            if(null == row.getCell(0)){
-                continue;
-            }
-            // 获取行所有单元格数据
-            LotteryUser user = new LotteryUser();
-            user.setCodeRs(getCellValue(row.getCell(0)));
-            user.setName(getCellValue(row.getCell(1)));
-            userList.add(user);
-            if (userList.size() == 100) {
-                dao.insertUsers(userList);
-                userList.clear();
-            }
-        }
-        workbook.close();
-        is.close();
-
-        if (!userList.isEmpty()) {
-            dao.insertUsers(userList);
-        }
-
-        return selectLotteryUsers();
-    }
-
-    private String getCellValue(Cell cell) {
-        if (cell.getCellType() == CellType.NUMERIC) {
-            return String.valueOf((int) cell.getNumericCellValue());
-        }
-        return cell.getRichStringCellValue().getString();
-    }
-
     @PassToken
     @GetMapping("/selectLotteryUsers")
     public ResultVo<List<LotteryUser>> selectLotteryUsers() {
@@ -103,9 +55,6 @@ public class LotteryController {
     @GetMapping("/selectWonUsers")
     public ResultVo<List<LotteryUser>> selectWonUsers() {
         List<LotteryUser> wonUsers = dao.selectWonUsers();
-        if (wonUsers.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "尚未有人中奖。");
-        }
         return ResultVoUtil.success(wonUsers);
     }
 }

+ 0 - 11
src/main/java/thyyxxk/webserver/dao/his/singlepage/LotteryDao.java

@@ -9,17 +9,6 @@ import java.util.List;
 @Mapper
 public interface LotteryDao {
 
-    @Delete("truncate table t_lottery_user")
-    void truncateTable();
-
-    @Insert("<script>" +
-            "insert into t_lottery_user (code_rs, name) values " +
-            "<foreach collection='list' item='item' separator=','>" +
-            "(#{item.codeRs},#{item.name})" +
-            "</foreach>" +
-            "</script>")
-    void insertUsers(List<LotteryUser> list);
-
     @Select("select * from t_lottery_user where won=-1 ")
     List<LotteryUser> selectLotteryUsers();
 

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/casefrontsheet/request/LendOutRequest.java

@@ -0,0 +1,2 @@
+package thyyxxk.webserver.entity.casefrontsheet.request;public class LendOut {
+}

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/casefrontsheet/response/LendOutSheet.java

@@ -0,0 +1,2 @@
+package thyyxxk.webserver.entity.casefrontsheet.response;public class LendOutSheet {
+}