夏文涛 1 year ago
parent
commit
383941bb50

+ 3 - 0
src/main/java/com/template/api/WelcomeStudentControllerAPI.java

@@ -77,4 +77,7 @@ public interface WelcomeStudentControllerAPI {
     @ApiOperation(value = "学生住宿情况", notes = "学生住宿情况", httpMethod = "GET")
     @ApiOperation(value = "学生住宿情况", notes = "学生住宿情况", httpMethod = "GET")
     CommonResult studentStay();
     CommonResult studentStay();
 
 
+    @GetMapping(value = "/queryStudentByToken")
+    @ApiOperation(value = "学生住宿情况", notes = "学生住宿情况", httpMethod = "GET")
+    CommonResult queryStudentByToken(@RequestAttribute String userId);
 }
 }

+ 1 - 1
src/main/java/com/template/common/utils/JWTUtil.java

@@ -50,7 +50,7 @@ public class JWTUtil {
                 .withHeader(map) // header
                 .withHeader(map) // header
 //                .withClaim("identityType", ms.getIdentityType()) // 认证类型
 //                .withClaim("identityType", ms.getIdentityType()) // 认证类型
 //                .withClaim("identifier", ms.getIdentifier()) // 登录标识
 //                .withClaim("identifier", ms.getIdentifier()) // 登录标识
-                .withClaim("userId",userId)
+                .withClaim("userId",String.valueOf( userId))
                 .withClaim("studentCard",studentCard)
                 .withClaim("studentCard",studentCard)
                 .withExpiresAt(expireTime) // 设置过期时间。过期时间要大于签发时间
                 .withExpiresAt(expireTime) // 设置过期时间。过期时间要大于签发时间
                 .withIssuedAt(iatDate) // 设置签发时间
                 .withIssuedAt(iatDate) // 设置签发时间

+ 17 - 16
src/main/java/com/template/controller/WelcomeDormitoryController.java

@@ -149,10 +149,24 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
 //        动态修改床位
 //        动态修改床位
         List<WelcomeBed> list = welcomeBedService.listWelcomeBed(welcomeDormitory.getId());
         List<WelcomeBed> list = welcomeBedService.listWelcomeBed(welcomeDormitory.getId());
         if(list != null && list.size() > 0){
         if(list != null && list.size() > 0){
-            int i = 1;
             ArrayList<WelcomeBed> welcomeBeds = new ArrayList<>();
             ArrayList<WelcomeBed> welcomeBeds = new ArrayList<>();
-            for (WelcomeBed welcomeBed : list) {
-                if(welcomeBed.getNumber().intValue() != i){
+            //动态生成床位
+            Integer bedNumber = welcomeDormitory.getBedNumber();
+            for (int i = 1; i <= bedNumber; i++) {
+                int intData = i;
+                Optional<WelcomeBed> oBed = list.stream().filter(e -> e.getNumber().intValue() == intData).findFirst();
+                if(oBed != null && oBed.isPresent()){
+                    WelcomeBed wb = new WelcomeBed();
+                    wb = oBed.get();
+                    wb.setSchool(welcomeDormitory.getSchool());
+                    wb.setSchoolId(welcomeDormitory.getSchoolId());
+                    wb.setBuild(welcomeDormitory.getBuild());
+                    wb.setBuildId(welcomeDormitory.getBuildId());
+                    wb.setDormitory(welcomeDormitory.getDormitory());
+                    wb.setDormitoryId(welcomeDormitory.getId());
+                    wb.setSex(welcomeDormitory.getSex());
+                    welcomeBeds.add(wb);
+                }else{
                     WelcomeBed welcomeInsert = new WelcomeBed();
                     WelcomeBed welcomeInsert = new WelcomeBed();
                     welcomeInsert.setNumber(i);
                     welcomeInsert.setNumber(i);
                     welcomeInsert.setSchool(welcomeDormitory.getSchool());
                     welcomeInsert.setSchool(welcomeDormitory.getSchool());
@@ -165,19 +179,6 @@ public class WelcomeDormitoryController implements WelcomeDormitoryControllerAPI
                     welcomeInsert.setIsCheck(0);
                     welcomeInsert.setIsCheck(0);
                     welcomeBeds.add(welcomeInsert);
                     welcomeBeds.add(welcomeInsert);
                 }
                 }
-                welcomeBed.setSchool(welcomeDormitory.getSchool());
-                welcomeBed.setSchoolId(welcomeDormitory.getSchoolId());
-                welcomeBed.setBuild(welcomeDormitory.getBuild());
-                welcomeBed.setBuildId(welcomeDormitory.getBuildId());
-                welcomeBed.setDormitory(welcomeDormitory.getDormitory());
-                welcomeBed.setDormitoryId(welcomeDormitory.getId());
-                welcomeBed.setSex(welcomeDormitory.getSex());
-                welcomeBeds.add(welcomeBed);
-                i++;
-            }
-            boolean updateResult = welcomeBedService.saveOrUpdateBatch(welcomeBeds);
-            if(!updateResult){
-                return CommonResult.fail("编辑失败");
             }
             }
         }else {
         }else {
             //动态生成床位
             //动态生成床位

+ 34 - 20
src/main/java/com/template/controller/WelcomeStudentController.java

@@ -2,12 +2,15 @@ package com.template.controller;
 
 
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.auth0.jwt.interfaces.Claim;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.api.R;
 import com.baomidou.mybatisplus.extension.api.R;
+import com.template.annotation.PassToken;
 import com.template.api.WelcomeStudentControllerAPI;
 import com.template.api.WelcomeStudentControllerAPI;
 import com.template.common.utils.ExcelUtils;
 import com.template.common.utils.ExcelUtils;
+import com.template.common.utils.JWTUtil;
 import com.template.common.utils.paramUtils;
 import com.template.common.utils.paramUtils;
 import com.template.model.enumModel.eFileType;
 import com.template.model.enumModel.eFileType;
 import com.template.model.enumModel.eProjectType;
 import com.template.model.enumModel.eProjectType;
@@ -44,10 +47,7 @@ import java.io.InputStream;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -924,6 +924,9 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         WelcomeStudent studentData = new WelcomeStudent();
                         WelcomeStudent studentData = new WelcomeStudent();
 
 
                         String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
                         String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
+                        if(!StringUtils.hasText(assNum)){
+                            break;
+                        }
                         studentData.setAdmissNum(assNum);
                         studentData.setAdmissNum(assNum);
                         String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
                         String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
                         studentData.setName(name);
                         studentData.setName(name);
@@ -990,7 +993,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setOprovince(addressDatas[0]);
                                     studentData.setOprovince(addressDatas[0]);
                                     studentData.setOprovinceId(oProvince.get().getId());
                                     studentData.setOprovinceId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressDatas != null && addressDatas.length >= 2) {
                             if (addressDatas != null && addressDatas.length >= 2) {
@@ -999,7 +1002,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setOcity(addressDatas[1]);
                                     studentData.setOcity(addressDatas[1]);
                                     studentData.setOcityId(oProvince.get().getId());
                                     studentData.setOcityId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressDatas != null && addressDatas.length >= 3) {
                             if (addressDatas != null && addressDatas.length >= 3) {
@@ -1008,7 +1011,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setOdistrict(addressDatas[2]);
                                     studentData.setOdistrict(addressDatas[2]);
                                     studentData.setOdistrictId(oProvince.get().getId());
                                     studentData.setOdistrictId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                         }
                         }
@@ -1020,14 +1023,14 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         if (citys != null && citys.size() > 0) {
                         if (citys != null && citys.size() > 0) {
                             if (addressPlaces != null && addressPlaces.length >= 1) {
                             if (addressPlaces != null && addressPlaces.length >= 1) {
                                 if (!addressPlaces[0].contains("省")) {
                                 if (!addressPlaces[0].contains("省")) {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                                 Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
                                 Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
                                 if (oProvince != null && oProvince.isPresent()) {
                                 if (oProvince != null && oProvince.isPresent()) {
                                     studentData.setProvince(addressPlaces[0]);
                                     studentData.setProvince(addressPlaces[0]);
                                     studentData.setProvinceId(oProvince.get().getId());
                                     studentData.setProvinceId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressPlaces != null && addressPlaces.length >= 2) {
                             if (addressPlaces != null && addressPlaces.length >= 2) {
@@ -1036,7 +1039,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setCity(addressPlaces[1]);
                                     studentData.setCity(addressPlaces[1]);
                                     studentData.setCityId(oProvince.get().getId());
                                     studentData.setCityId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressPlaces != null && addressPlaces.length >= 3) {
                             if (addressPlaces != null && addressPlaces.length >= 3) {
@@ -1045,7 +1048,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setDistrict(addressPlaces[2]);
                                     studentData.setDistrict(addressPlaces[2]);
                                     studentData.setDistrictId(oProvince.get().getId());
                                     studentData.setDistrictId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                         }
                         }
@@ -1056,6 +1059,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
 
 
                         String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
                         String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
                         studentData.setZipCode(zipCode);
                         studentData.setZipCode(zipCode);
+                        studentData.setIdenType(1);
 
 
                         result.add(studentData);
                         result.add(studentData);
                     }
                     }
@@ -1181,6 +1185,10 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         WelcomeStudent studentData = new WelcomeStudent();
                         WelcomeStudent studentData = new WelcomeStudent();
 
 
                         String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
                         String assNum = dataFormatter.formatCellValue(row.getCell(1));//录取号
+
+                        if(!StringUtils.hasText(assNum)){
+                            break;
+                        }
                         studentData.setAdmissNum(assNum);
                         studentData.setAdmissNum(assNum);
                         String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
                         String name = dataFormatter.formatCellValue(row.getCell(2));//姓名
                         studentData.setName(name);
                         studentData.setName(name);
@@ -1240,14 +1248,14 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         if (citys != null && citys.size() > 0) {
                         if (citys != null && citys.size() > 0) {
                             if (addressDatas != null && addressDatas.length >= 1) {
                             if (addressDatas != null && addressDatas.length >= 1) {
                                 if (!addressDatas[0].contains("省")) {
                                 if (!addressDatas[0].contains("省")) {
-                                    return CommonResult.fail("录取编号为\" + assNum + \"的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为\" + assNum + \"的籍贯格式应该是 省/市/县");
                                 }
                                 }
                                 Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[0])).findFirst();
                                 Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressDatas[0])).findFirst();
                                 if (oProvince != null && oProvince.isPresent()) {
                                 if (oProvince != null && oProvince.isPresent()) {
                                     studentData.setOprovince(addressDatas[0]);
                                     studentData.setOprovince(addressDatas[0]);
                                     studentData.setOprovinceId(oProvince.get().getId());
                                     studentData.setOprovinceId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressDatas != null && addressDatas.length >= 2) {
                             if (addressDatas != null && addressDatas.length >= 2) {
@@ -1256,7 +1264,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setOcity(addressDatas[1]);
                                     studentData.setOcity(addressDatas[1]);
                                     studentData.setOcityId(oProvince.get().getId());
                                     studentData.setOcityId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressDatas != null && addressDatas.length >= 3) {
                             if (addressDatas != null && addressDatas.length >= 3) {
@@ -1265,7 +1273,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setOdistrict(addressDatas[2]);
                                     studentData.setOdistrict(addressDatas[2]);
                                     studentData.setOdistrictId(oProvince.get().getId());
                                     studentData.setOdistrictId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的籍贯格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                         }
                         }
@@ -1277,14 +1285,14 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                         if (citys != null && citys.size() > 0) {
                         if (citys != null && citys.size() > 0) {
                             if (addressPlaces != null && addressPlaces.length >= 1) {
                             if (addressPlaces != null && addressPlaces.length >= 1) {
                                 if (!addressPlaces[0].contains("省")) {
                                 if (!addressPlaces[0].contains("省")) {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                                 Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
                                 Optional<WelcomeCity> oProvince = citys.stream().filter(e -> e.getDistrictZh().equals(addressPlaces[0])).findFirst();
                                 if (oProvince != null && oProvince.isPresent()) {
                                 if (oProvince != null && oProvince.isPresent()) {
                                     studentData.setProvince(addressPlaces[0]);
                                     studentData.setProvince(addressPlaces[0]);
                                     studentData.setProvinceId(oProvince.get().getId());
                                     studentData.setProvinceId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressPlaces != null && addressPlaces.length >= 2) {
                             if (addressPlaces != null && addressPlaces.length >= 2) {
@@ -1293,7 +1301,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setCity(addressPlaces[1]);
                                     studentData.setCity(addressPlaces[1]);
                                     studentData.setCityId(oProvince.get().getId());
                                     studentData.setCityId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                             if (addressPlaces != null && addressPlaces.length >= 3) {
                             if (addressPlaces != null && addressPlaces.length >= 3) {
@@ -1302,7 +1310,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
                                     studentData.setDistrict(addressPlaces[2]);
                                     studentData.setDistrict(addressPlaces[2]);
                                     studentData.setDistrictId(oProvince.get().getId());
                                     studentData.setDistrictId(oProvince.get().getId());
                                 } else {
                                 } else {
-                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
+                                    return CommonResult.fail("录取编号为" + assNum + "的家庭住址格式应该是 省/市/县");
                                 }
                                 }
                             }
                             }
                         }
                         }
@@ -1313,7 +1321,7 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
 
 
                         String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
                         String zipCode = dataFormatter.formatCellValue(row.getCell(18));//邮编
                         studentData.setZipCode(zipCode);
                         studentData.setZipCode(zipCode);
-
+                        studentData.setIdenType(1);
                         result.add(studentData);
                         result.add(studentData);
                     }
                     }
                 }
                 }
@@ -1464,5 +1472,11 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
 
 
         return CommonResult.ok(vos);
         return CommonResult.ok(vos);
     }
     }
+
+    @Override
+    public CommonResult queryStudentByToken( String userId) {
+        WelcomeStudent student = welcomeStudentService.getManageById(Integer.valueOf(userId));
+        return CommonResult.ok(student);
+    }
 }
 }
 
 

+ 2 - 1
src/main/java/com/template/core/JwtAuthenticationInterceptor.java

@@ -94,8 +94,9 @@ public class JwtAuthenticationInterceptor implements HandlerInterceptor {
                 //endregion
                 //endregion
                 return false;
                 return false;
             }
             }
-            request.setAttribute("userId", stringClaimMap.get("userId").asString());
+
             request.setAttribute("studentCard", stringClaimMap.get("studentCard").asString());
             request.setAttribute("studentCard", stringClaimMap.get("studentCard").asString());
+            request.setAttribute("userId", stringClaimMap.get("userId").asString());
             return true;
             return true;
         }
         }
         System.out.println("8");
         System.out.println("8");