├── .gitignore ├── LICENSE ├── README.md ├── downsourceanddoc.bat ├── package.bat ├── pic ├── image │ ├── functional-structure-diagram.png │ └── schematic-diagram-of-system-operation.png ├── 学生信息导入模板.xlsx └── 班级信息导入模板.xlsx ├── smp-admin-server ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpadminserver │ │ │ ├── SecurityConfig.java │ │ │ └── SmpAdminServerApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpadminserver │ └── SmpAdminServerApplicationTests.java ├── smp-class ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── com │ │ │ ├── lzw │ │ │ │ └── face │ │ │ │ │ ├── FaceHelper.java │ │ │ │ │ ├── SeetafaceBuilder.java │ │ │ │ │ ├── bean │ │ │ │ │ └── FaceIndex.java │ │ │ │ │ └── utils │ │ │ │ │ └── ImageUtils.java │ │ │ └── seetaface2 │ │ │ │ ├── SeetaFace2JNI.java │ │ │ │ └── model │ │ │ │ ├── FaceLandmark.java │ │ │ │ ├── RecognizeResult.java │ │ │ │ ├── SeetaImageData.java │ │ │ │ ├── SeetaPointF.java │ │ │ │ └── SeetaRect.java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpclass │ │ │ ├── SmpClassApplication.java │ │ │ ├── cache │ │ │ └── FaceImgCache.java │ │ │ ├── client │ │ │ ├── InfoClient.java │ │ │ ├── LeaveClient.java │ │ │ └── entity │ │ │ │ ├── LeaveDTO.java │ │ │ │ └── LeaveType.java │ │ │ ├── config │ │ │ ├── CustomProperties.java │ │ │ └── HttpTraceActuatorConfiguration.java │ │ │ ├── controller │ │ │ ├── ClassCheckController.java │ │ │ └── ClassUserController.java │ │ │ ├── dao │ │ │ ├── StudentClassCheckDao.java │ │ │ ├── StudentClassCheckMetaDataDao.java │ │ │ ├── StudentClassDao.java │ │ │ └── StudentClassUserDao.java │ │ │ ├── dto │ │ │ ├── ClassComingDTO.java │ │ │ ├── StudentClassCheckDTO.java │ │ │ └── StudentClassDTO.java │ │ │ ├── entity │ │ │ ├── Apartment.java │ │ │ ├── Face.java │ │ │ ├── RestModel.java │ │ │ ├── Role.java │ │ │ ├── StudentClass.java │ │ │ ├── StudentClassCheck.java │ │ │ ├── StudentClassCheckMetaData.java │ │ │ ├── StudentClassUser.java │ │ │ ├── StudentGroupPrimaryKey.java │ │ │ ├── StudentUser.java │ │ │ └── User.java │ │ │ ├── exception │ │ │ ├── BaseException.java │ │ │ ├── ExceptionResolver.java │ │ │ ├── FileException.java │ │ │ ├── GpsException.java │ │ │ ├── NullFiledException.java │ │ │ ├── SecurityException.java │ │ │ └── UnexpectedException.java │ │ │ ├── repository │ │ │ ├── AbstractFaceRepository.java │ │ │ ├── DefaultFaceRepository.java │ │ │ └── FaceRepository.java │ │ │ ├── security │ │ │ ├── LoginUser.java │ │ │ ├── MustCounselorLogin.java │ │ │ ├── MustLogin.java │ │ │ ├── MustStudentLogin.java │ │ │ ├── MustTeacherLogin.java │ │ │ ├── SecurityArgumentResolversWebMvcConfig.java │ │ │ └── SecurityHandlerMethodArgumentResolver.java │ │ │ ├── service │ │ │ ├── ClassCheckService.java │ │ │ ├── ClassUserService.java │ │ │ └── impl │ │ │ │ ├── ClassCheckServiceImpl.java │ │ │ │ └── ClassUserServiceImpl.java │ │ │ └── util │ │ │ ├── DateUtils.java │ │ │ ├── GpsUtils.java │ │ │ └── OrikaUtils.java │ └── resources │ │ ├── bootstrap.properties │ │ └── seetaface.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpclass │ ├── SmpClassApplicationTests.java │ └── service │ └── ClassUserServiceTest.java ├── smp-config ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpconfig │ │ │ └── SmpConfigApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpconfig │ └── SmpConfigApplicationTests.java ├── smp-eureka ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpeureka │ │ │ └── SmpEurekaApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpeureka │ └── SmpEurekaApplicationTests.java ├── smp-gateway ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpgateway │ │ │ ├── SmpGatewayApplication.java │ │ │ ├── config │ │ │ └── CustomWebMvcConfig.java │ │ │ ├── entity │ │ │ ├── LoginUser.java │ │ │ └── Role.java │ │ │ ├── exception │ │ │ ├── BaseException.java │ │ │ └── TokenException.java │ │ │ ├── filter │ │ │ ├── AuthorizationHeaderFilter.java │ │ │ ├── CorsFilter.java │ │ │ └── ErrorFilter.java │ │ │ ├── handler │ │ │ └── ErrorHandler.java │ │ │ └── util │ │ │ └── JwtUtils.java │ └── resources │ │ └── bootstrap.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpgateway │ └── SmpGatewayApplicationTests.java ├── smp-hystrix-dashboard ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smphystrixdashboard │ │ │ └── SmpHystrixDashboardApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smphystrixdashboard │ └── SmpHystrixDashboardApplicationTests.java ├── smp-info ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpinfo │ │ │ ├── SmpInfoApplication.java │ │ │ ├── client │ │ │ ├── ClassClient.java │ │ │ ├── LeaveClient.java │ │ │ └── RoomClient.java │ │ │ ├── config │ │ │ └── HttpTraceActuatorConfiguration.java │ │ │ ├── controller │ │ │ ├── ApartmentController.java │ │ │ └── UserController.java │ │ │ ├── dao │ │ │ ├── ApartmentDao.java │ │ │ ├── RoleDao.java │ │ │ ├── StudentUserDao.java │ │ │ └── UserDao.java │ │ │ ├── dto │ │ │ ├── ApartmentDTO.java │ │ │ ├── StudentUserDTO.java │ │ │ └── UpFileDTO.java │ │ │ ├── entity │ │ │ ├── Apartment.java │ │ │ ├── RestModel.java │ │ │ ├── Role.java │ │ │ ├── StudentUser.java │ │ │ └── User.java │ │ │ ├── exception │ │ │ ├── BaseException.java │ │ │ ├── ExceptionResolver.java │ │ │ ├── FileException.java │ │ │ ├── NotInLineWithBusinessLogicException.java │ │ │ ├── NullFiledException.java │ │ │ └── SecurityException.java │ │ │ ├── security │ │ │ ├── LoginUser.java │ │ │ ├── MustCounselorLogin.java │ │ │ ├── MustLogin.java │ │ │ ├── MustStudentLogin.java │ │ │ ├── MustTeacherLogin.java │ │ │ ├── SecurityArgumentResolversWebMvcConfig.java │ │ │ └── SecurityHandlerMethodArgumentResolver.java │ │ │ ├── service │ │ │ ├── ApartmentService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ ├── ApartmentServiceImpl.java │ │ │ │ ├── UserServiceImpl.java │ │ │ │ └── excel │ │ │ │ ├── AbstractExcelHandlerHelper.java │ │ │ │ ├── AbstractReadExcel2Save.java │ │ │ │ ├── ExcelData.java │ │ │ │ └── ExcelHandlerHelper.java │ │ │ └── util │ │ │ ├── IdCardUtils.java │ │ │ └── OrikaUtils.java │ └── resources │ │ └── bootstrap.properties │ └── test │ ├── java │ └── top │ │ └── itning │ │ └── smp │ │ └── smpinfo │ │ ├── RandomValue.java │ │ ├── SmpInfoApplicationTests.java │ │ ├── dao │ │ ├── StudentUserDaoTest.java │ │ └── UserDaoTest.java │ │ └── service │ │ ├── ApartmentServiceTest.java │ │ └── UserServiceTest.java │ └── resources │ ├── test.xlsx │ └── test2.xlsx ├── smp-leave ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpleave │ │ │ ├── SmpLeaveApplication.java │ │ │ ├── client │ │ │ ├── InfoClient.java │ │ │ └── entity │ │ │ │ ├── Apartment.java │ │ │ │ └── StudentUser.java │ │ │ ├── config │ │ │ └── HttpTraceActuatorConfiguration.java │ │ │ ├── controller │ │ │ └── LeaveController.java │ │ │ ├── dao │ │ │ ├── LeaveDao.java │ │ │ └── LeaveReasonDao.java │ │ │ ├── dto │ │ │ ├── LeaveDTO.java │ │ │ └── SearchDTO.java │ │ │ ├── entity │ │ │ ├── Apartment.java │ │ │ ├── Leave.java │ │ │ ├── LeaveReason.java │ │ │ ├── LeaveType.java │ │ │ ├── RestModel.java │ │ │ ├── Role.java │ │ │ ├── StudentUser.java │ │ │ └── User.java │ │ │ ├── exception │ │ │ ├── BaseException.java │ │ │ ├── DateRangeException.java │ │ │ ├── ExceptionResolver.java │ │ │ ├── NullFiledException.java │ │ │ ├── SecurityException.java │ │ │ └── UnexpectedException.java │ │ │ ├── security │ │ │ ├── LoginUser.java │ │ │ ├── MustCounselorLogin.java │ │ │ ├── MustLogin.java │ │ │ ├── MustStudentLogin.java │ │ │ ├── MustTeacherLogin.java │ │ │ ├── SecurityArgumentResolversWebMvcConfig.java │ │ │ └── SecurityHandlerMethodArgumentResolver.java │ │ │ ├── service │ │ │ ├── LeaveService.java │ │ │ └── impl │ │ │ │ └── LeaveServiceImpl.java │ │ │ └── util │ │ │ ├── DateUtils.java │ │ │ └── OrikaUtils.java │ └── resources │ │ └── bootstrap.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpleave │ └── SmpLeaveApplicationTests.java ├── smp-room ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── com │ │ │ ├── lzw │ │ │ │ └── face │ │ │ │ │ ├── FaceHelper.java │ │ │ │ │ ├── SeetafaceBuilder.java │ │ │ │ │ ├── bean │ │ │ │ │ └── FaceIndex.java │ │ │ │ │ └── utils │ │ │ │ │ └── ImageUtils.java │ │ │ └── seetaface2 │ │ │ │ ├── SeetaFace2JNI.java │ │ │ │ └── model │ │ │ │ ├── FaceLandmark.java │ │ │ │ ├── RecognizeResult.java │ │ │ │ ├── SeetaImageData.java │ │ │ │ ├── SeetaPointF.java │ │ │ │ └── SeetaRect.java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smproom │ │ │ ├── SmpRoomApplication.java │ │ │ ├── cache │ │ │ └── FaceImgCache.java │ │ │ ├── client │ │ │ ├── InfoClient.java │ │ │ ├── LeaveClient.java │ │ │ └── entity │ │ │ │ ├── LeaveDTO.java │ │ │ │ ├── LeaveReason.java │ │ │ │ ├── LeaveType.java │ │ │ │ └── StudentUserDTO.java │ │ │ ├── config │ │ │ ├── CustomProperties.java │ │ │ ├── CustomWebMvcConfig.java │ │ │ └── HttpTraceActuatorConfiguration.java │ │ │ ├── controller │ │ │ └── RoomController.java │ │ │ ├── dao │ │ │ ├── StudentRoomCheckDao.java │ │ │ └── StudentRoomCheckMetaDataDao.java │ │ │ ├── entity │ │ │ ├── Apartment.java │ │ │ ├── Face.java │ │ │ ├── RestModel.java │ │ │ ├── Role.java │ │ │ ├── StudentRoomCheck.java │ │ │ ├── StudentRoomCheckMetaData.java │ │ │ ├── StudentRoomCheckMetaDataPrimaryKey.java │ │ │ ├── StudentUser.java │ │ │ └── User.java │ │ │ ├── exception │ │ │ ├── AppMetaException.java │ │ │ ├── BaseException.java │ │ │ ├── ExceptionResolver.java │ │ │ ├── FileNotFoundException.java │ │ │ ├── GpsException.java │ │ │ ├── IllegalCheckException.java │ │ │ ├── SavedException.java │ │ │ ├── SecurityException.java │ │ │ └── UserNameDoesNotExistException.java │ │ │ ├── repository │ │ │ ├── AbstractFaceRepository.java │ │ │ ├── DefaultFaceRepository.java │ │ │ └── FaceRepository.java │ │ │ ├── security │ │ │ ├── LoginUser.java │ │ │ ├── MustCounselorLogin.java │ │ │ ├── MustLogin.java │ │ │ ├── MustStudentLogin.java │ │ │ ├── MustTeacherLogin.java │ │ │ ├── SecurityArgumentResolversWebMvcConfig.java │ │ │ └── SecurityHandlerMethodArgumentResolver.java │ │ │ ├── service │ │ │ ├── RoomCheckMetaDataService.java │ │ │ ├── RoomService.java │ │ │ └── impl │ │ │ │ ├── RoomCheckMetaDataServiceImpl.java │ │ │ │ └── RoomServiceImpl.java │ │ │ └── util │ │ │ ├── DateUtils.java │ │ │ └── GpsUtils.java │ └── resources │ │ ├── bootstrap.properties │ │ └── seetaface.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smproom │ └── SmpRoomApplicationTests.java ├── smp-security ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── top │ │ │ └── itning │ │ │ └── smp │ │ │ └── smpsecurity │ │ │ ├── SmpSecurityApplication.java │ │ │ ├── client │ │ │ ├── InfoClient.java │ │ │ └── entity │ │ │ │ ├── Role.java │ │ │ │ ├── StudentUserDTO.java │ │ │ │ └── User.java │ │ │ ├── config │ │ │ └── HttpTraceActuatorConfiguration.java │ │ │ ├── controller │ │ │ └── SecurityController.java │ │ │ ├── entity │ │ │ ├── LoginUser.java │ │ │ ├── RestModel.java │ │ │ └── Role.java │ │ │ ├── exception │ │ │ ├── BaseException.java │ │ │ ├── ExceptionResolver.java │ │ │ ├── TokenException.java │ │ │ ├── UserNameDoesNotExistException.java │ │ │ └── UserPasswordException.java │ │ │ ├── security │ │ │ ├── LoginUser.java │ │ │ ├── MustCounselorLogin.java │ │ │ ├── MustLogin.java │ │ │ ├── MustStudentLogin.java │ │ │ ├── MustTeacherLogin.java │ │ │ ├── SecurityArgumentResolversWebMvcConfig.java │ │ │ └── SecurityHandlerMethodArgumentResolver.java │ │ │ ├── service │ │ │ ├── SecurityService.java │ │ │ └── impl │ │ │ │ └── SecurityServiceImpl.java │ │ │ └── util │ │ │ ├── JwtUtils.java │ │ │ └── OrikaUtils.java │ └── resources │ │ └── bootstrap.properties │ └── test │ └── java │ └── top │ └── itning │ └── smp │ └── smpsecurity │ └── SmpSecurityApplicationTests.java └── smp-statistics ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── top │ │ └── itning │ │ └── smp │ │ └── smpstatistics │ │ ├── SmpStatisticsApplication.java │ │ ├── aop │ │ └── CacheAop.java │ │ ├── client │ │ ├── ClassClient.java │ │ ├── InfoClient.java │ │ ├── LeaveClient.java │ │ ├── RoomClient.java │ │ └── entity │ │ │ └── User.java │ │ ├── config │ │ └── HttpTraceActuatorConfiguration.java │ │ ├── controller │ │ └── StatisticsController.java │ │ ├── entity │ │ ├── AllCounselor.java │ │ ├── ApartmentStatistics.java │ │ ├── ClassComing.java │ │ ├── HomeComing.java │ │ ├── Leave.java │ │ ├── RestModel.java │ │ └── Role.java │ │ ├── exception │ │ ├── BaseException.java │ │ ├── ExceptionResolver.java │ │ └── SecurityException.java │ │ ├── security │ │ ├── LoginUser.java │ │ ├── MustCounselorLogin.java │ │ ├── MustLogin.java │ │ ├── MustStudentLogin.java │ │ ├── MustTeacherLogin.java │ │ ├── SecurityArgumentResolversWebMvcConfig.java │ │ └── SecurityHandlerMethodArgumentResolver.java │ │ ├── service │ │ ├── StatisticsService.java │ │ └── impl │ │ │ └── StatisticsServiceImpl.java │ │ └── util │ │ └── DateUtils.java └── resources │ └── bootstrap.properties └── test └── java └── top └── itning └── smp └── smpstatistics └── SmpStatisticsApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | target/ 4 | .mvn/ 5 | config-dir/ 6 | release/ -------------------------------------------------------------------------------- /downsourceanddoc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | CHCP 65001 3 | echo author itning 4 | set ROOT_DIR=%~dp0 5 | set PROJECT_NAMES=smp-admin-server,smp-class,smp-config,smp-eureka,smp-gateway,smp-hystrix-dashboard,smp-info,smp-leave,smp-room,smp-security 6 | 7 | echo --------------------------------------------- 8 | echo start bat 9 | echo --------------------------------------------- 10 | for %%i in (%PROJECT_NAMES%) do call:work_func %%i 11 | echo --------------------------------------------- 12 | echo end bat 13 | echo --------------------------------------------- 14 | pause 15 | exit 16 | 17 | ::-------------------------------------------------------- 18 | ::-- This function will execute mvn clean and mvn package 19 | ::-- command without unit test and it will copy jar to dir. 20 | ::-------------------------------------------------------- 21 | :work_func 22 | set PROJECT_NAME=%~1 23 | echo Start %PROJECT_NAME% project 24 | cd /d %ROOT_DIR%%PROJECT_NAME% 25 | call mvn dependency:sources 26 | call mvn dependency:resolve -Dclassifier=javadoc 27 | echo End %PROJECT_NAME% project 28 | goto:eof -------------------------------------------------------------------------------- /package.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | CHCP 65001 3 | echo author itning 4 | set ROOT_DIR=%~dp0 5 | set RELEASE_VERSION=1.0.0.RELEASE 6 | set COPY_TARGET_DIR=%ROOT_DIR%release\ 7 | set PROJECT_NAMES=smp-admin-server,smp-class,smp-config,smp-eureka,smp-gateway,smp-hystrix-dashboard,smp-info,smp-leave,smp-room,smp-security,smp-statistics 8 | 9 | if not exist %COPY_TARGET_DIR% md %COPY_TARGET_DIR% 10 | 11 | echo --------------------------------------------- 12 | echo start bat 13 | echo --------------------------------------------- 14 | for %%i in (%PROJECT_NAMES%) do call:work_func %%i 15 | echo --------------------------------------------- 16 | echo end bat 17 | echo --------------------------------------------- 18 | exit 19 | 20 | ::-------------------------------------------------------- 21 | ::-- This function will execute mvn clean and mvn package 22 | ::-- command without unit test and it will copy jar to dir. 23 | ::-------------------------------------------------------- 24 | :work_func 25 | set PROJECT_NAME=%~1 26 | echo Start %PROJECT_NAME% project 27 | cd /d %ROOT_DIR%%PROJECT_NAME% 28 | call mvn clean 29 | call mvn package -DskipTests 30 | copy /y %ROOT_DIR%%PROJECT_NAME%\target\%PROJECT_NAME%-%RELEASE_VERSION%.jar %COPY_TARGET_DIR% 31 | echo End %PROJECT_NAME% project 32 | goto:eof -------------------------------------------------------------------------------- /pic/image/functional-structure-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/pic/image/functional-structure-diagram.png -------------------------------------------------------------------------------- /pic/image/schematic-diagram-of-system-operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/pic/image/schematic-diagram-of-system-operation.png -------------------------------------------------------------------------------- /pic/学生信息导入模板.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/pic/学生信息导入模板.xlsx -------------------------------------------------------------------------------- /pic/班级信息导入模板.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/pic/班级信息导入模板.xlsx -------------------------------------------------------------------------------- /smp-admin-server/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/** 4 | !**/src/test/** 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | build/ 28 | 29 | ### VS Code ### 30 | .vscode/ 31 | -------------------------------------------------------------------------------- /smp-admin-server/src/main/java/top/itning/smp/smpadminserver/SmpAdminServerApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpadminserver; 2 | 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @SpringBootApplication 12 | @EnableAdminServer 13 | @EnableEurekaClient 14 | public class SmpAdminServerApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(SmpAdminServerApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /smp-admin-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-admin-server/src/main/resources/application.properties -------------------------------------------------------------------------------- /smp-admin-server/src/test/java/top/itning/smp/smpadminserver/SmpAdminServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpadminserver; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpAdminServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-class/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-class/src/main/java/com/lzw/face/bean/FaceIndex.java: -------------------------------------------------------------------------------- 1 | package com.lzw.face.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | public class FaceIndex implements Serializable { 7 | private String key; 8 | 9 | private int index; 10 | 11 | private byte[] imgData; 12 | private int width; 13 | private int height; 14 | private int channel; 15 | 16 | public String getKey() { 17 | return key; 18 | } 19 | 20 | public void setKey(String key) { 21 | this.key = key; 22 | } 23 | 24 | public int getIndex() { 25 | return index; 26 | } 27 | 28 | public void setIndex(int index) { 29 | this.index = index; 30 | } 31 | 32 | public byte[] getImgData() { 33 | return imgData; 34 | } 35 | 36 | public void setImgData(byte[] imgData) { 37 | this.imgData = imgData; 38 | } 39 | 40 | public int getWidth() { 41 | return width; 42 | } 43 | 44 | public void setWidth(int width) { 45 | this.width = width; 46 | } 47 | 48 | public int getHeight() { 49 | return height; 50 | } 51 | 52 | public void setHeight(int height) { 53 | this.height = height; 54 | } 55 | 56 | public int getChannel() { 57 | return channel; 58 | } 59 | 60 | public void setChannel(int channel) { 61 | this.channel = channel; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /smp-class/src/main/java/com/seetaface2/model/FaceLandmark.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class FaceLandmark { 4 | public SeetaRect[] rects; 5 | public SeetaPointF[] points; 6 | } 7 | -------------------------------------------------------------------------------- /smp-class/src/main/java/com/seetaface2/model/RecognizeResult.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | /** 4 | * 人脸搜索结果 下标 显示度 5 | */ 6 | public class RecognizeResult { 7 | public int index; 8 | public float similar; 9 | } 10 | -------------------------------------------------------------------------------- /smp-class/src/main/java/com/seetaface2/model/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData() { 5 | 6 | } 7 | 8 | public SeetaImageData(int width, int height, int channels) { 9 | this.data = new byte[width * height * channels]; 10 | this.width = width; 11 | this.height = height; 12 | this.channels = channels; 13 | } 14 | 15 | public SeetaImageData(int width, int height) { 16 | this(width, height, 3); 17 | } 18 | 19 | public byte[] data; 20 | public int width; 21 | public int height; 22 | public int channels; 23 | } 24 | -------------------------------------------------------------------------------- /smp-class/src/main/java/com/seetaface2/model/SeetaPointF.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class SeetaPointF { 4 | public double x; 5 | public double y; 6 | } 7 | -------------------------------------------------------------------------------- /smp-class/src/main/java/com/seetaface2/model/SeetaRect.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class SeetaRect { 4 | public int x; 5 | public int y; 6 | public int width; 7 | public int height; 8 | } 9 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/SmpClassApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.cloud.client.SpringCloudApplication; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @SpringCloudApplication 13 | @EnableFeignClients 14 | public class SmpClassApplication { 15 | static { 16 | Logger logger = LoggerFactory.getLogger(SmpClassApplication.class); 17 | try { 18 | com.lzw.face.SeetafaceBuilder.build(); 19 | logger.info("Face Recognition Init Success"); 20 | } catch (Throwable e) { 21 | logger.error("Face Recognition Init Fail", e); 22 | } 23 | } 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(SmpClassApplication.class, args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/client/InfoClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import top.itning.smp.smpclass.entity.StudentUser; 8 | import top.itning.smp.smpclass.entity.User; 9 | 10 | import java.util.Optional; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @FeignClient(name = "info") 16 | @Component 17 | public interface InfoClient { 18 | /** 19 | * 根据用户名获取用户信息 20 | * 21 | * @param username 用户名 22 | * @return 用户 23 | */ 24 | @GetMapping("/internal/user/{username}") 25 | Optional getUserInfoByUserName(@PathVariable String username); 26 | 27 | /** 28 | * 根据用户名获取用户信息 29 | * 30 | * @param username 用户名 31 | * @return 用户 32 | */ 33 | @GetMapping("/internal/student_user/{username}") 34 | Optional getStudentUserInfoByUserName(@PathVariable String username); 35 | 36 | /** 37 | * 获取学生信息根据学号 38 | * 39 | * @param studentId 学号 40 | * @return 用户 41 | */ 42 | @GetMapping("/internal/student_user_id/{studentId}") 43 | User getStudentUserDtoByStudentId(@PathVariable String studentId); 44 | } 45 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/client/LeaveClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import top.itning.smp.smpclass.client.entity.LeaveDTO; 8 | import top.itning.smp.smpclass.client.entity.LeaveType; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @FeignClient(name = "leave") 16 | @Component 17 | public interface LeaveClient { 18 | /** 19 | * 获取请假信息(包括课假和寝室假) 20 | * 21 | * @param whereDay 哪天 22 | * @return 所有请假信息 23 | */ 24 | @GetMapping("/internal/leaves") 25 | List getAllLeave(@RequestParam("whereDay") String whereDay); 26 | 27 | /** 28 | * 学生今天是否请假了 29 | * 30 | * @param userName 学生 31 | * @param leaveType 请假类型 只能传课假或寝室假,默认包括全部假 32 | * @return 今天请假了返回true 33 | */ 34 | @GetMapping("/internal/isLeave") 35 | boolean isLeave(@RequestParam("userName") String userName, @RequestParam("leaveType") LeaveType leaveType); 36 | } 37 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/client/entity/LeaveDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.client.entity; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpclass.entity.StudentUser; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | public class LeaveDTO implements Serializable { 14 | /** 15 | * ID 16 | */ 17 | private String id; 18 | /** 19 | * 学生 20 | */ 21 | private StudentUser studentUser; 22 | /** 23 | * 请假开始时间 24 | */ 25 | private Date startTime; 26 | /** 27 | * 请假结束时间 28 | */ 29 | private Date endTime; 30 | /** 31 | * 请假类型 32 | */ 33 | private LeaveType leaveType; 34 | /** 35 | * 请假原因 36 | */ 37 | private String reason; 38 | /** 39 | * 审核状态(true 通过;false 未通过) 40 | */ 41 | private Boolean status; 42 | /** 43 | * 创建时间 44 | */ 45 | private Date gmtCreate; 46 | /** 47 | * 更新时间 48 | */ 49 | private Date gmtModified; 50 | } 51 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/client/entity/LeaveType.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.client.entity; 2 | 3 | /** 4 | * 请假类型(课假;寝室假;课假+寝室假) 5 | * 6 | * @author itning 7 | */ 8 | public enum LeaveType { 9 | /** 10 | * 课假 11 | */ 12 | CLASS_LEAVE, 13 | /** 14 | * 寝室假 15 | */ 16 | ROOM_LEAVE, 17 | /** 18 | * 课假+寝室假 19 | */ 20 | ALL_LEAVE 21 | } 22 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/config/CustomProperties.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.io.File; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @ConfigurationProperties(prefix = "app") 12 | @Component 13 | public class CustomProperties { 14 | /** 15 | * 学生注册的人脸存储路径 16 | */ 17 | private String faceLocation; 18 | /** 19 | * 人脸对比精度阈值 20 | */ 21 | private float contrastAccuracyThreshold = 0.5f; 22 | 23 | public String getFaceLocation() { 24 | return faceLocation; 25 | } 26 | 27 | public void setFaceLocation(String faceLocation) { 28 | if (!faceLocation.endsWith(File.separator)) { 29 | faceLocation += File.separator; 30 | } 31 | this.faceLocation = faceLocation; 32 | } 33 | 34 | public float getContrastAccuracyThreshold() { 35 | return contrastAccuracyThreshold; 36 | } 37 | 38 | public void setContrastAccuracyThreshold(float contrastAccuracyThreshold) { 39 | if (contrastAccuracyThreshold > 1) { 40 | contrastAccuracyThreshold = 1f; 41 | } 42 | if (contrastAccuracyThreshold < 0) { 43 | contrastAccuracyThreshold = 0; 44 | } 45 | this.contrastAccuracyThreshold = contrastAccuracyThreshold; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/config/HttpTraceActuatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.config; 2 | 3 | import org.springframework.boot.actuate.trace.http.HttpTraceRepository; 4 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Configuration 12 | public class HttpTraceActuatorConfiguration { 13 | @Bean 14 | public HttpTraceRepository httpTraceRepository() { 15 | return new InMemoryHttpTraceRepository(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/dao/StudentClassCheckMetaDataDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.dao; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 | import top.itning.smp.smpclass.entity.StudentClass; 8 | import top.itning.smp.smpclass.entity.StudentClassCheckMetaData; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | public interface StudentClassCheckMetaDataDao extends JpaRepository, JpaSpecificationExecutor { 16 | /** 17 | * 查找最新的教师发起的签到信息 18 | * 19 | * @param studentClass 班级 20 | * @return 最新签到信息 21 | */ 22 | StudentClassCheckMetaData findTopByStudentClassOrderByGmtCreateDesc(StudentClass studentClass); 23 | 24 | /** 25 | * 根据班级删除元数据 26 | * 27 | * @param studentClass 班级 28 | */ 29 | void deleteAllByStudentClass(StudentClass studentClass); 30 | 31 | /** 32 | * 查找所有签到元数据 33 | * 34 | * @param studentClass 班级 35 | * @param pageable 分页 36 | * @return 所有签到元数据 37 | */ 38 | Page findAllByStudentClass(StudentClass studentClass, Pageable pageable); 39 | 40 | /** 41 | * 查找所有签到元数据 42 | * 43 | * @param studentClass 班级 44 | * @return 所有签到元数据 45 | */ 46 | List findAllByStudentClass(StudentClass studentClass); 47 | } 48 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/dao/StudentClassDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.dao; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import top.itning.smp.smpclass.entity.StudentClass; 7 | import top.itning.smp.smpclass.entity.User; 8 | 9 | import java.util.Optional; 10 | 11 | 12 | /** 13 | * @author itning 14 | */ 15 | public interface StudentClassDao extends JpaRepository { 16 | /** 17 | * 根据班号获取班级 18 | * 19 | * @param classNum 班号 20 | * @return 班级 21 | */ 22 | Optional findByClassNum(String classNum); 23 | 24 | /** 25 | * 根据教师查找创建的班级 26 | * 27 | * @param user 用户 28 | * @param pageable 分页 29 | * @return 教师所有创建的班级 30 | */ 31 | Page findByUser(User user, Pageable pageable); 32 | } 33 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/dto/ClassComingDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class ClassComingDTO implements Serializable { 12 | private Long sum; 13 | private Long coming; 14 | } 15 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/dto/StudentClassCheckDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.dto; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpclass.entity.StudentClass; 5 | import top.itning.smp.smpclass.entity.User; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author itning 12 | */ 13 | @Data 14 | public class StudentClassCheckDTO implements Serializable { 15 | /** 16 | * 学生 ID 17 | */ 18 | private User user; 19 | /** 20 | * 班级 ID 21 | */ 22 | private StudentClass studentClass; 23 | /** 24 | * 该学生是否签到了 true已签 false未签 null请假 25 | */ 26 | private Boolean check; 27 | /** 28 | * 签到时间 29 | */ 30 | private Date checkTime; 31 | /** 32 | * 创建时间 33 | */ 34 | private Date gmtCreate; 35 | /** 36 | * 更新时间 37 | */ 38 | private Date gmtModified; 39 | } 40 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/dto/StudentClassDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.dto; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpclass.entity.StudentClassUser; 5 | import top.itning.smp.smpclass.entity.User; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * @author itning 13 | */ 14 | @Data 15 | public class StudentClassDTO implements Serializable { 16 | /** 17 | * ID 18 | */ 19 | private String id; 20 | /** 21 | * 群组名 22 | */ 23 | private String name; 24 | /** 25 | * 班号(创建时教师指定,唯一;学生加入用此) 26 | */ 27 | private String classNum; 28 | /** 29 | * 加入该班级的学生 30 | */ 31 | private List studentClassUserList; 32 | /** 33 | * 所属教师 34 | */ 35 | private User user; 36 | /** 37 | * 创建时间 38 | */ 39 | private Date gmtCreate; 40 | /** 41 | * 更新时间 42 | */ 43 | private Date gmtModified; 44 | } 45 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/Apartment.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 公寓信息 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "apartment") 22 | public class Apartment implements Serializable { 23 | /** 24 | * ID 25 | */ 26 | @Id 27 | @GeneratedValue(generator = "idGenerator") 28 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 29 | @Column(length = 36, columnDefinition = "char(36)") 30 | private String id; 31 | /** 32 | * 公寓名 33 | */ 34 | @Column(nullable = false, unique = true) 35 | private String name; 36 | /** 37 | * 创建时间 38 | */ 39 | @Column(nullable = false) 40 | @CreationTimestamp 41 | private Date gmtCreate; 42 | /** 43 | * 更新时间 44 | */ 45 | @Column(nullable = false) 46 | @UpdateTimestamp 47 | private Date gmtModified; 48 | } 49 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/Face.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.awt.image.BufferedImage; 6 | import java.io.InputStream; 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | public class Face implements Serializable { 14 | private String id; 15 | private BufferedImage bufferedImage; 16 | private InputStream inputStream; 17 | } 18 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Rest 返回消息 10 | * 11 | * @author itning 12 | */ 13 | public class RestModel implements Serializable { 14 | private int code; 15 | private String msg; 16 | private T data; 17 | 18 | public RestModel() { 19 | 20 | } 21 | 22 | private RestModel(HttpStatus status, String msg, T data) { 23 | this(status.value(), msg, data); 24 | } 25 | 26 | private RestModel(int code, String msg, T data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public static ResponseEntity> ok(T data) { 33 | return ResponseEntity.ok(new RestModel<>(HttpStatus.OK, "查询成功", data)); 34 | } 35 | 36 | public static ResponseEntity> created() { 37 | return ResponseEntity.status(HttpStatus.CREATED).build(); 38 | } 39 | 40 | public static ResponseEntity> created(T data) { 41 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, "创建成功", data)); 42 | } 43 | 44 | public static ResponseEntity noContent() { 45 | return ResponseEntity.noContent().build(); 46 | } 47 | 48 | public int getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(int code) { 53 | this.code = code; 54 | } 55 | 56 | public String getMsg() { 57 | return msg; 58 | } 59 | 60 | public void setMsg(String msg) { 61 | this.msg = msg; 62 | } 63 | 64 | public T getData() { 65 | return data; 66 | } 67 | 68 | public void setData(T data) { 69 | this.data = data; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 角色 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "role") 22 | public class Role implements Serializable { 23 | public static final String STUDENT_ROLE_ID = "1"; 24 | public static final String STUDENT_ROLE_ID_STR = "学生"; 25 | public static final String TEACHER_ROLE_ID = "2"; 26 | public static final String TEACHER_ROLE_ID_STR = "教师"; 27 | public static final String COUNSELOR_ROLE_ID = "3"; 28 | public static final String COUNSELOR_ROLE_ID_STR = "辅导员"; 29 | 30 | public static Role withStudentUser() { 31 | Role role = new Role(); 32 | role.setId("1"); 33 | return role; 34 | } 35 | 36 | /** 37 | * 角色ID 38 | */ 39 | @Id 40 | @GeneratedValue(generator = "idGenerator") 41 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 42 | @Column(length = 36, columnDefinition = "char(36)") 43 | private String id; 44 | /** 45 | * 角色名 46 | */ 47 | @Column(length = 50, unique = true, nullable = false) 48 | private String name; 49 | /** 50 | * 创建时间 51 | */ 52 | @Column(nullable = false) 53 | @CreationTimestamp 54 | private Date gmtCreate; 55 | /** 56 | * 更新时间 57 | */ 58 | @Column(nullable = false) 59 | @UpdateTimestamp 60 | private Date gmtModified; 61 | } 62 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/StudentClass.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 学生班级,由老师创建 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "student_class") 19 | public class StudentClass implements Serializable { 20 | /** 21 | * ID 22 | */ 23 | @Id 24 | @GeneratedValue(generator = "idGenerator") 25 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 26 | @Column(length = 36, columnDefinition = "char(36)") 27 | private String id; 28 | /** 29 | * 群组名 30 | */ 31 | @Column(nullable = false) 32 | private String name; 33 | /** 34 | * 班号(创建时教师指定,唯一;学生加入用此) 35 | */ 36 | @Column(nullable = false, unique = true) 37 | private String classNum; 38 | /** 39 | * 所属教师 40 | */ 41 | @ManyToOne(optional = false) 42 | @JoinColumn(name = "teacherUserId") 43 | private User user; 44 | /** 45 | * 创建时间 46 | */ 47 | @Column(nullable = false) 48 | @CreationTimestamp 49 | private Date gmtCreate; 50 | /** 51 | * 更新时间 52 | */ 53 | @Column(nullable = false) 54 | @UpdateTimestamp 55 | private Date gmtModified; 56 | } 57 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/StudentClassCheck.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 学生课堂签到 14 | * 每个群组的签到信息 15 | * 16 | * @author itning 17 | */ 18 | @Data 19 | @Entity(name = "student_class_check") 20 | public class StudentClassCheck implements Serializable { 21 | /** 22 | * ID 23 | */ 24 | @Id 25 | @GeneratedValue(generator = "idGenerator") 26 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 27 | @Column(length = 36, columnDefinition = "char(36)") 28 | private String id; 29 | /** 30 | * 学生信息 31 | */ 32 | @ManyToOne(optional = false) 33 | @JoinColumn(name = "userId") 34 | private User user; 35 | /** 36 | * 所属班级 37 | */ 38 | @ManyToOne(optional = false) 39 | @JoinColumn(name = "studentClassId") 40 | private StudentClass studentClass; 41 | /** 42 | * 签到时间 43 | */ 44 | @Column(nullable = false) 45 | private Date checkTime; 46 | /** 47 | * 经度 48 | */ 49 | @Column(nullable = false) 50 | private double longitude; 51 | /** 52 | * 纬度 53 | */ 54 | @Column(nullable = false) 55 | private double latitude; 56 | /** 57 | * 本次签到所对应的元数据 58 | */ 59 | @ManyToOne(optional = false) 60 | @JoinColumn(name = "studentClassCheckMetaDataId") 61 | private StudentClassCheckMetaData studentClassCheckMetaData; 62 | /** 63 | * 创建时间 64 | */ 65 | @Column(nullable = false) 66 | @CreationTimestamp 67 | private Date gmtCreate; 68 | /** 69 | * 更新时间 70 | */ 71 | @Column(nullable = false) 72 | @UpdateTimestamp 73 | private Date gmtModified; 74 | } 75 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/StudentClassCheckMetaData.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @Data 16 | @Entity(name = "student_class_check_meta_data") 17 | public class StudentClassCheckMetaData implements Serializable { 18 | /** 19 | * 元数据ID 20 | */ 21 | @Id 22 | @GeneratedValue(generator = "idGenerator") 23 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 24 | @Column(length = 36, columnDefinition = "char(36)") 25 | private String id; 26 | /** 27 | * 签到开始时间 28 | */ 29 | @Column(nullable = false) 30 | private Date startTime; 31 | /** 32 | * 签到结束时间 33 | */ 34 | @Column(nullable = false) 35 | private Date endTime; 36 | /** 37 | * 经度 38 | */ 39 | @Column(nullable = false) 40 | private double longitude; 41 | /** 42 | * 纬度 43 | */ 44 | @Column(nullable = false) 45 | private double latitude; 46 | /** 47 | * 签到者距离教师经纬度最大距离 48 | */ 49 | @Column(nullable = false) 50 | private float m; 51 | /** 52 | * 元数据所对应的班级 53 | */ 54 | @ManyToOne(optional = false) 55 | @JoinColumn(name = "studentClassId") 56 | private StudentClass studentClass; 57 | /** 58 | * 创建时间 59 | */ 60 | @Column(nullable = false) 61 | @CreationTimestamp 62 | private Date gmtCreate; 63 | /** 64 | * 更新时间 65 | */ 66 | @Column(nullable = false) 67 | @UpdateTimestamp 68 | private Date gmtModified; 69 | } 70 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/StudentClassUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.UpdateTimestamp; 6 | 7 | import javax.persistence.*; 8 | import java.io.Serializable; 9 | import java.util.Date; 10 | 11 | /** 12 | * 学生班级学生 13 | * 管理学生班级与学生之间的关系 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "student_class_user") 19 | @IdClass(StudentGroupPrimaryKey.class) 20 | public class StudentClassUser implements Serializable { 21 | /** 22 | * 学生 ID 23 | */ 24 | @Id 25 | @ManyToOne(optional = false) 26 | @JoinColumn(name = "studentId", columnDefinition = "char(36)") 27 | private User user; 28 | /** 29 | * 班级 ID 30 | */ 31 | @Id 32 | @ManyToOne(optional = false) 33 | @JoinColumn(name = "studentClassId", columnDefinition = "char(36)") 34 | private StudentClass studentClass; 35 | /** 36 | * 创建时间 37 | */ 38 | @Column(nullable = false) 39 | @CreationTimestamp 40 | private Date gmtCreate; 41 | /** 42 | * 更新时间 43 | */ 44 | @Column(nullable = false) 45 | @UpdateTimestamp 46 | private Date gmtModified; 47 | } 48 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/StudentGroupPrimaryKey.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class StudentGroupPrimaryKey implements Serializable { 12 | /** 13 | * StudentClassUser ID 14 | */ 15 | private String user; 16 | /** 17 | * studentClass ID 18 | */ 19 | private String studentClass; 20 | } 21 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/entity/User.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 用户 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "user") 19 | public class User implements Serializable { 20 | /** 21 | * 用户ID 22 | */ 23 | @Id 24 | @GeneratedValue(generator = "idGenerator") 25 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 26 | @Column(length = 36, columnDefinition = "char(36)") 27 | private String id; 28 | /** 29 | * 用户姓名 30 | */ 31 | @Column(nullable = false) 32 | private String name; 33 | /** 34 | * 电话 35 | */ 36 | @Column(length = 11, columnDefinition = "char(11)") 37 | private String tel; 38 | /** 39 | * 邮箱 40 | */ 41 | private String email; 42 | /** 43 | * 用户名 44 | */ 45 | @Column(nullable = false, unique = true) 46 | private String username; 47 | /** 48 | * 角色 49 | */ 50 | @ManyToOne(optional = false) 51 | @JoinColumn(name = "roleId") 52 | private Role role; 53 | /** 54 | * 所对应的学生 55 | */ 56 | @OneToOne 57 | @PrimaryKeyJoinColumn 58 | private StudentUser studentUser; 59 | /** 60 | * 创建时间 61 | */ 62 | @Column(nullable = false) 63 | @CreationTimestamp 64 | private Date gmtCreate; 65 | /** 66 | * 更新时间 67 | */ 68 | @Column(nullable = false) 69 | @UpdateTimestamp 70 | private Date gmtModified; 71 | } 72 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/exception/FileException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class FileException extends BaseException { 9 | public FileException(String msg, HttpStatus httpStatus) { 10 | super(msg, httpStatus); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/exception/GpsException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class GpsException extends BaseException { 9 | public GpsException(double longitude, double latitude) { 10 | super("GPS错误:" + longitude + ";" + latitude, HttpStatus.BAD_REQUEST); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/exception/NullFiledException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 空属性异常 7 | * 8 | * @author itning 9 | */ 10 | public class NullFiledException extends BaseException { 11 | public NullFiledException(String msg, HttpStatus code) { 12 | super(msg, code); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/exception/SecurityException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class SecurityException extends BaseException { 9 | public SecurityException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/exception/UnexpectedException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class UnexpectedException extends BaseException { 9 | public UnexpectedException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/repository/DefaultFaceRepository.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.repository; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.lang.NonNull; 5 | import org.springframework.stereotype.Repository; 6 | import top.itning.smp.smpclass.cache.FaceImgCache; 7 | import top.itning.smp.smpclass.config.CustomProperties; 8 | import top.itning.smp.smpclass.entity.Face; 9 | 10 | import java.io.File; 11 | import java.util.Optional; 12 | 13 | /** 14 | * @author itning 15 | */ 16 | @Repository 17 | public class DefaultFaceRepository extends AbstractFaceRepository { 18 | 19 | @Autowired 20 | public DefaultFaceRepository(CustomProperties customProperties, FaceImgCache faceImgCache) { 21 | super(customProperties, faceImgCache); 22 | } 23 | 24 | @NonNull 25 | @Override 26 | public Optional findById(@NonNull String id) { 27 | File file = new File(customProperties.getFaceLocation() + id); 28 | if (file.exists()) { 29 | Face face = new Face(); 30 | face.setId(file.getName()); 31 | face.setBufferedImage(faceImgCache.getBufferedImageFromStudentId(id)); 32 | return Optional.of(face); 33 | } 34 | return Optional.empty(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/repository/FaceRepository.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.repository; 2 | 3 | 4 | import java.util.Optional; 5 | 6 | /** 7 | * 人脸仓库 8 | * 9 | * @author itning 10 | */ 11 | public interface FaceRepository { 12 | /** 13 | * Retrieves an entity by its id. 14 | * 15 | * @param id must not be {@literal null}. 16 | * @return the entity with the given id or {@literal Optional#empty()} if none found. 17 | * @throws IllegalArgumentException if {@literal id} is {@literal null}. 18 | */ 19 | Optional findById(ID id); 20 | 21 | /** 22 | * Returns whether an entity with the given id exists. 23 | * 24 | * @param id must not be {@literal null}. 25 | * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. 26 | * @throws IllegalArgumentException if {@literal id} is {@literal null}. 27 | */ 28 | boolean existsById(ID id); 29 | 30 | /** 31 | * Returns all instances of the type. 32 | * 33 | * @return all entities 34 | */ 35 | Iterable findAll(); 36 | 37 | /** 38 | * Returns all instances of the type {@code T} with the given IDs. 39 | *

40 | * If some or all ids are not found, no entities are returned for these IDs. 41 | *

42 | * Note that the order of elements in the result is not guaranteed. 43 | * 44 | * @param ids must not be {@literal null} nor contain any {@literal null} values. 45 | * @return guaranteed to be not {@literal null}. The size can be equal or less than the number of given 46 | * {@literal ids}. 47 | * @throws IllegalArgumentException in case the given {@link Iterable ids} or one of its items is {@literal null}. 48 | */ 49 | Iterable findAllById(Iterable ids); 50 | 51 | /** 52 | * Returns the number of entities available. 53 | * 54 | * @return the number of entities. 55 | */ 56 | long count(); 57 | } 58 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/security/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.security; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private String roleId; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/security/MustCounselorLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.COUNSELOR) 12 | public @interface MustCounselorLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/security/MustLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target({ElementType.PARAMETER, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @Inherited 12 | public @interface MustLogin { 13 | /** 14 | * 登录角色 15 | * 16 | * @return 角色数组 17 | */ 18 | ROLE[] role(); 19 | 20 | enum ROLE { 21 | /** 22 | * 学生 23 | */ 24 | STUDENT("1", "学生"), 25 | /** 26 | * 教师 27 | */ 28 | TEACHER("2", "教师"), 29 | /** 30 | * 辅导员 31 | */ 32 | COUNSELOR("3", "辅导员"); 33 | 34 | private String id; 35 | private String name; 36 | 37 | ROLE(String id, String name) { 38 | this.id = id; 39 | this.name = name; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ROLE{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/security/MustStudentLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.STUDENT) 12 | public @interface MustStudentLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/security/MustTeacherLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.TEACHER) 12 | public @interface MustTeacherLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/security/SecurityArgumentResolversWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * MVC参数配置 12 | * 13 | * @author itning 14 | */ 15 | @Configuration 16 | public class SecurityArgumentResolversWebMvcConfig implements WebMvcConfigurer { 17 | private final SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver; 18 | 19 | @Autowired 20 | public SecurityArgumentResolversWebMvcConfig(SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver) { 21 | this.securityHandlerMethodArgumentResolver = securityHandlerMethodArgumentResolver; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(securityHandlerMethodArgumentResolver); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /smp-class/src/main/java/top/itning/smp/smpclass/util/OrikaUtils.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.util; 2 | 3 | import ma.glasnost.orika.MapperFactory; 4 | import ma.glasnost.orika.impl.DefaultMapperFactory; 5 | import org.springframework.lang.NonNull; 6 | import org.springframework.lang.Nullable; 7 | 8 | /** 9 | * 实体映射工具类 10 | * 11 | * @author itning 12 | */ 13 | public class OrikaUtils { 14 | private static final MapperFactory MAPPER_FACTORY = new DefaultMapperFactory.Builder().build(); 15 | 16 | /** 17 | * 将两个实体合并为一个DTO 18 | * input1,input2 不能全为 {@code null} 19 | * 20 | * @param input1 第一个输入实体 21 | * @param input2 第二个输入实体 22 | * @param result DTO类型 23 | * @param DTO 24 | * @param ENTITY 25 | * @param ENTITY 26 | * @return DTO类型 27 | */ 28 | @NonNull 29 | public static R doubleEntity2Dto(@Nullable A input1, @Nullable B input2, @NonNull Class result) { 30 | if (input1 != null && input2 != null) { 31 | R r = MAPPER_FACTORY.getMapperFacade().map(input1, result); 32 | MAPPER_FACTORY.getMapperFacade().map(input2, r); 33 | return r; 34 | } else if (input1 != null) { 35 | return MAPPER_FACTORY.getMapperFacade().map(input1, result); 36 | } else { 37 | return MAPPER_FACTORY.getMapperFacade().map(input2, result); 38 | } 39 | } 40 | 41 | /** 42 | * A 实体 转换 B 实体 43 | * 44 | * @param a A实例 45 | * @param bClass B类型 46 | * @param A 47 | * @param B 48 | * @return B 实例 49 | */ 50 | public static B a2b(A a, Class bClass) { 51 | return MAPPER_FACTORY.getMapperFacade().map(a, bClass); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /smp-class/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-class/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-class/src/main/resources/seetaface.properties: -------------------------------------------------------------------------------- 1 | #依赖的lib名称,注意依赖关系顺序,用逗号隔开 2 | #linux os 3 | #libs=holiday,SeetaFaceDetector200,SeetaPointDetector200,SeetaFaceRecognizer200,SeetaFaceCropper200,SeetaFace2JNI 4 | #windows os 5 | libs=libgcc_s_sjlj-1,libeay32,libquadmath-0,ssleay32,libgfortran-3,libopenblas,holiday,SeetaFaceDetector200,SeetaPointDetector200,SeetaFaceRecognizer200,SeetaFaceCropper200,SeetaFace2JNI 6 | 7 | #依赖的lib存放目录, 等同于-Djava.library.path= 8 | #linux os 9 | #libs.path=/Users/apple/Documents/seetaface/lib 10 | #windows os 11 | libs.path=G:\\seetafaceJNI\\doc\\lib-win-x64\\lib 12 | 13 | #seetaface model目录 14 | #linux os 15 | #bindata.dir=/Users/apple/Documents/seetaface/bindata 16 | #windows os 17 | bindata.dir=G:\\seetafaceJNI\\bindata -------------------------------------------------------------------------------- /smp-class/src/test/java/top/itning/smp/smpclass/SmpClassApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpClassApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-class/src/test/java/top/itning/smp/smpclass/service/ClassUserServiceTest.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpclass.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.data.domain.PageRequest; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.domain.Sort; 9 | import top.itning.smp.smpclass.security.LoginUser; 10 | 11 | @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") 12 | @SpringBootTest 13 | class ClassUserServiceTest { 14 | @Autowired 15 | private ClassUserService classUserService; 16 | 17 | @Test 18 | void getAllStudentClassUsers() { 19 | LoginUser loginUser = new LoginUser(); 20 | loginUser.setUsername(""); 21 | Pageable pageable = PageRequest.of(0, 1, Sort.by(Sort.Direction.DESC, "gmtModified")); 22 | classUserService.getAllStudentClassUsers(loginUser, pageable); 23 | } 24 | 25 | @Test 26 | void joinClass() { 27 | } 28 | 29 | @Test 30 | void newClass() { 31 | } 32 | 33 | @Test 34 | void quitClass() { 35 | } 36 | 37 | @Test 38 | void delClass() { 39 | } 40 | 41 | @Test 42 | void getAllStudentClass() { 43 | } 44 | 45 | @Test 46 | void getAllStudentClassCheckMetaData() { 47 | } 48 | 49 | @Test 50 | void getStudentClassLeave() { 51 | } 52 | 53 | @Test 54 | void delStudent() { 55 | } 56 | } -------------------------------------------------------------------------------- /smp-config/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/** 4 | !**/src/test/** 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | build/ 28 | 29 | ### VS Code ### 30 | .vscode/ 31 | -------------------------------------------------------------------------------- /smp-config/src/main/java/top/itning/smp/smpconfig/SmpConfigApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpconfig; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.config.server.EnableConfigServer; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @EnableConfigServer 14 | public class SmpConfigApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(SmpConfigApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /smp-config/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-config/src/main/resources/application.properties -------------------------------------------------------------------------------- /smp-config/src/test/java/top/itning/smp/smpconfig/SmpConfigApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpconfig; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpConfigApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-eureka/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-eureka/src/main/java/top/itning/smp/smpeureka/SmpEurekaApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpeureka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @SpringBootApplication 11 | @EnableEurekaServer 12 | public class SmpEurekaApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SmpEurekaApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /smp-eureka/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-eureka/src/main/resources/application.properties -------------------------------------------------------------------------------- /smp-eureka/src/test/java/top/itning/smp/smpeureka/SmpEurekaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpeureka; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpEurekaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/SmpGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @SpringBootApplication 12 | @EnableEurekaClient 13 | @EnableZuulProxy 14 | public class SmpGatewayApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(SmpGatewayApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/config/CustomWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * MVC参数配置 9 | * 10 | * @author itning 11 | */ 12 | @Configuration 13 | public class CustomWebMvcConfig implements WebMvcConfigurer { 14 | @Override 15 | public void addCorsMappings(CorsRegistry registry) { 16 | registry.addMapping("/**") 17 | .allowedOrigins("*") 18 | .allowCredentials(true) 19 | .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH") 20 | .maxAge(86400); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/entity/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private Role role; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 角色 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class Role implements Serializable { 15 | /** 16 | * 角色ID 17 | */ 18 | private String id; 19 | /** 20 | * 角色名 21 | */ 22 | private String name; 23 | /** 24 | * 创建时间 25 | */ 26 | private Date gmtCreate; 27 | /** 28 | * 更新时间 29 | */ 30 | private Date gmtModified; 31 | } 32 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/exception/TokenException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class TokenException extends BaseException { 9 | public TokenException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-gateway/src/main/java/top/itning/smp/smpgateway/handler/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway.handler; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.web.servlet.error.ErrorAttributes; 5 | import org.springframework.boot.web.servlet.error.ErrorController; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import org.springframework.web.context.request.ServletWebRequest; 10 | import org.springframework.web.context.request.WebRequest; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import java.util.Map; 14 | 15 | /** 16 | * 错误处理器 17 | * 18 | * @author itning 19 | */ 20 | @RestController 21 | public class ErrorHandler implements ErrorController { 22 | private final ErrorAttributes errorAttributes; 23 | 24 | @Autowired 25 | public ErrorHandler(ErrorAttributes errorAttributes) { 26 | this.errorAttributes = errorAttributes; 27 | } 28 | 29 | @Override 30 | public String getErrorPath() { 31 | return "/error"; 32 | } 33 | 34 | @RequestMapping(value = "/error", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) 35 | public String error(HttpServletRequest request) { 36 | WebRequest webRequest = new ServletWebRequest(request); 37 | Map errorAttributes = this.errorAttributes.getErrorAttributes(webRequest, true); 38 | String msg = errorAttributes.getOrDefault("error", "not found").toString(); 39 | String code = errorAttributes.getOrDefault("status", 404).toString(); 40 | return "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":\"\"}"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /smp-gateway/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-gateway/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-gateway/src/test/java/top/itning/smp/smpgateway/SmpGatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpgateway; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpGatewayApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-hystrix-dashboard/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/** 4 | !**/src/test/** 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | build/ 28 | 29 | ### VS Code ### 30 | .vscode/ 31 | -------------------------------------------------------------------------------- /smp-hystrix-dashboard/src/main/java/top/itning/smp/smphystrixdashboard/SmpHystrixDashboardApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smphystrixdashboard; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 6 | import org.springframework.cloud.netflix.turbine.EnableTurbine; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @SpringBootApplication 12 | @EnableHystrixDashboard 13 | @EnableTurbine 14 | public class SmpHystrixDashboardApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(SmpHystrixDashboardApplication.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /smp-hystrix-dashboard/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-hystrix-dashboard/src/main/resources/application.properties -------------------------------------------------------------------------------- /smp-hystrix-dashboard/src/test/java/top/itning/smp/smphystrixdashboard/SmpHystrixDashboardApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smphystrixdashboard; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpHystrixDashboardApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-info/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/SmpInfoApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @SpringCloudApplication 11 | @EnableFeignClients 12 | public class SmpInfoApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SmpInfoApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/client/ClassClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @FeignClient(name = "class") 12 | @Component 13 | public interface ClassClient { 14 | /** 15 | * 删除某学生加入的班级信息 16 | * 17 | * @param counselorUsername 辅导员用户名 18 | * @param studentUserName 学生用户名 19 | */ 20 | @PostMapping("/internal/delete") 21 | void delClassUserInfo(@RequestParam String counselorUsername, @RequestParam String studentUserName); 22 | } 23 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/client/LeaveClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @FeignClient(name = "leave") 12 | @Component 13 | public interface LeaveClient { 14 | /** 15 | * 删除学生请假信息 16 | * 17 | * @param counselorUsername 导员用户名 18 | * @param studentUserName 学生用户名 19 | */ 20 | @PostMapping("/internal/delete") 21 | void delLeaveInfo(@RequestParam String counselorUsername, @RequestParam String studentUserName); 22 | } 23 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/client/RoomClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @FeignClient(name = "room") 12 | @Component 13 | public interface RoomClient { 14 | /** 15 | * 删除寝室打卡信息 16 | * 17 | * @param counselorUsername 导员用户名 18 | * @param studentUserName 学生用户名 19 | */ 20 | @PostMapping("/internal/delete") 21 | void delRoomInfo(@RequestParam String counselorUsername, @RequestParam String studentUserName); 22 | } 23 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/config/HttpTraceActuatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.config; 2 | 3 | import org.springframework.boot.actuate.trace.http.HttpTraceRepository; 4 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Configuration 12 | public class HttpTraceActuatorConfiguration { 13 | @Bean 14 | public HttpTraceRepository httpTraceRepository() { 15 | return new InMemoryHttpTraceRepository(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/dao/ApartmentDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import top.itning.smp.smpinfo.entity.Apartment; 5 | 6 | /** 7 | * @author itning 8 | */ 9 | public interface ApartmentDao extends JpaRepository { 10 | /** 11 | * 根据公寓名查询ID 12 | * 13 | * @param name 公寓名 14 | * @return ID 15 | */ 16 | Apartment findByName(String name); 17 | } 18 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import top.itning.smp.smpinfo.entity.Role; 5 | 6 | /** 7 | * @author itning 8 | */ 9 | public interface RoleDao extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 | import top.itning.smp.smpinfo.entity.Role; 6 | import top.itning.smp.smpinfo.entity.User; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author itning 12 | */ 13 | public interface UserDao extends JpaRepository, JpaSpecificationExecutor { 14 | /** 15 | * 根据用户名获取用户 16 | * 17 | * @param username 用户名 18 | * @return 用户 19 | */ 20 | User findByUsername(String username); 21 | 22 | /** 23 | * 根据角色查找 24 | * 25 | * @param role 角色 26 | * @return 用户 27 | */ 28 | List findByRole(Role role); 29 | } 30 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/dto/ApartmentDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class ApartmentDTO implements Serializable { 12 | /** 13 | * 公寓名 14 | */ 15 | private String name; 16 | /** 17 | * 人数 18 | */ 19 | private Long people; 20 | } 21 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/dto/StudentUserDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.dto; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpinfo.entity.Apartment; 5 | import top.itning.smp.smpinfo.entity.Role; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * 学生信息DTO 12 | * 13 | * @author itning 14 | */ 15 | @Data 16 | public class StudentUserDTO implements Serializable { 17 | /** 18 | * 用户ID 19 | */ 20 | private String id; 21 | /** 22 | * 用户姓名 23 | */ 24 | private String name; 25 | /** 26 | * 电话 27 | */ 28 | private String tel; 29 | /** 30 | * 邮箱 31 | */ 32 | private String email; 33 | /** 34 | * 用户名 35 | */ 36 | private String username; 37 | /** 38 | * 角色 39 | */ 40 | private Role role; 41 | /** 42 | * 出生日期 43 | */ 44 | private Date birthday; 45 | /** 46 | * 性别(true 男; false 女) 47 | */ 48 | private Boolean sex; 49 | /** 50 | * 年龄 51 | */ 52 | private Integer age; 53 | /** 54 | * 学号 55 | */ 56 | private String studentId; 57 | /** 58 | * 该学生所属辅导员的ID 59 | */ 60 | private String belongCounselorId; 61 | /** 62 | * 身份证号 63 | */ 64 | private String idCard; 65 | /** 66 | * 政治面貌 67 | */ 68 | private String politicalStatus; 69 | /** 70 | * 民族 71 | */ 72 | private String ethnic; 73 | /** 74 | * 公寓信息 75 | */ 76 | private Apartment apartment; 77 | /** 78 | * 寝室号 79 | */ 80 | private String roomNum; 81 | /** 82 | * 床号 83 | */ 84 | private String bedNum; 85 | /** 86 | * 家庭地址 87 | */ 88 | private String address; 89 | /** 90 | * 创建时间 91 | */ 92 | private Date gmtCreate; 93 | /** 94 | * 更新时间 95 | */ 96 | private Date gmtModified; 97 | } 98 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/dto/UpFileDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | public class UpFileDTO implements Serializable { 15 | private Long now; 16 | private Long total; 17 | private List error; 18 | } 19 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/entity/Apartment.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 公寓信息 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "apartment") 22 | public class Apartment implements Serializable { 23 | /** 24 | * ID 25 | */ 26 | @Id 27 | @GeneratedValue(generator = "idGenerator") 28 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 29 | @Column(length = 36, columnDefinition = "char(36)") 30 | private String id; 31 | /** 32 | * 公寓名 33 | */ 34 | @Column(nullable = false, unique = true) 35 | private String name; 36 | /** 37 | * 创建时间 38 | */ 39 | @Column(nullable = false) 40 | @CreationTimestamp 41 | private Date gmtCreate; 42 | /** 43 | * 更新时间 44 | */ 45 | @Column(nullable = false) 46 | @UpdateTimestamp 47 | private Date gmtModified; 48 | } 49 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/entity/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.entity; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Rest 返回消息 10 | * 11 | * @author itning 12 | */ 13 | public class RestModel implements Serializable { 14 | private int code; 15 | private String msg; 16 | private T data; 17 | 18 | public RestModel() { 19 | 20 | } 21 | 22 | private RestModel(HttpStatus status, String msg, T data) { 23 | this(status.value(), msg, data); 24 | } 25 | 26 | private RestModel(int code, String msg, T data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public static ResponseEntity> ok(T data) { 33 | return ResponseEntity.ok(new RestModel<>(HttpStatus.OK, "查询成功", data)); 34 | } 35 | 36 | public static ResponseEntity> created() { 37 | return ResponseEntity.status(HttpStatus.CREATED).build(); 38 | } 39 | 40 | public static ResponseEntity> created(T data) { 41 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, "创建成功", data)); 42 | } 43 | 44 | public static ResponseEntity noContent() { 45 | return ResponseEntity.noContent().build(); 46 | } 47 | 48 | public int getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(int code) { 53 | this.code = code; 54 | } 55 | 56 | public String getMsg() { 57 | return msg; 58 | } 59 | 60 | public void setMsg(String msg) { 61 | this.msg = msg; 62 | } 63 | 64 | public T getData() { 65 | return data; 66 | } 67 | 68 | public void setData(T data) { 69 | this.data = data; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.UpdateTimestamp; 6 | 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.Id; 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * 角色 15 | * 16 | * @author itning 17 | */ 18 | @Data 19 | @Entity(name = "role") 20 | public class Role implements Serializable { 21 | public static final String STUDENT_ROLE_ID = "1"; 22 | public static final String STUDENT_ROLE_ID_STR = "学生"; 23 | public static final String TEACHER_ROLE_ID = "2"; 24 | public static final String TEACHER_ROLE_ID_STR = "教师"; 25 | public static final String COUNSELOR_ROLE_ID = "3"; 26 | public static final String COUNSELOR_ROLE_ID_STR = "辅导员"; 27 | 28 | public static Role withStudentUser() { 29 | Role role = new Role(); 30 | role.setId(STUDENT_ROLE_ID); 31 | return role; 32 | } 33 | 34 | /** 35 | * 角色ID 36 | */ 37 | @Id 38 | @Column(length = 36, columnDefinition = "char(36)") 39 | private String id; 40 | /** 41 | * 角色名 42 | */ 43 | @Column(length = 50, unique = true, nullable = false) 44 | private String name; 45 | /** 46 | * 创建时间 47 | */ 48 | @Column(nullable = false) 49 | @CreationTimestamp 50 | private Date gmtCreate; 51 | /** 52 | * 更新时间 53 | */ 54 | @Column(nullable = false) 55 | @UpdateTimestamp 56 | private Date gmtModified; 57 | } 58 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/entity/User.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 用户 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "user") 19 | public class User implements Serializable { 20 | /** 21 | * 用户ID 22 | */ 23 | @Id 24 | @GeneratedValue(generator = "idGenerator") 25 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 26 | @Column(length = 36, columnDefinition = "char(36)") 27 | private String id; 28 | /** 29 | * 用户姓名 30 | */ 31 | @Column(nullable = false) 32 | private String name; 33 | /** 34 | * 电话 35 | */ 36 | @Column(length = 11, columnDefinition = "char(11)") 37 | private String tel; 38 | /** 39 | * 邮箱 40 | */ 41 | private String email; 42 | /** 43 | * 用户名 44 | */ 45 | @Column(nullable = false, unique = true) 46 | private String username; 47 | /** 48 | * 密码 49 | */ 50 | @Column(nullable = false) 51 | private String password; 52 | /** 53 | * 角色 54 | */ 55 | @ManyToOne(optional = false) 56 | @JoinColumn(name = "roleId") 57 | private Role role; 58 | /** 59 | * 所对应的学生 60 | */ 61 | @OneToOne 62 | @PrimaryKeyJoinColumn 63 | private StudentUser studentUser; 64 | /** 65 | * 创建时间 66 | */ 67 | @Column(nullable = false) 68 | @CreationTimestamp 69 | private Date gmtCreate; 70 | /** 71 | * 更新时间 72 | */ 73 | @Column(nullable = false) 74 | @UpdateTimestamp 75 | private Date gmtModified; 76 | } 77 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/exception/FileException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class FileException extends BaseException { 9 | public FileException(String msg, HttpStatus httpStatus) { 10 | super(msg, httpStatus); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/exception/NotInLineWithBusinessLogicException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 不符合业务逻辑 7 | * 8 | * @author itning 9 | */ 10 | public class NotInLineWithBusinessLogicException extends BaseException { 11 | public NotInLineWithBusinessLogicException(String msg, HttpStatus code) { 12 | super(msg, code); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/exception/NullFiledException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 空属性异常 7 | * 8 | * @author itning 9 | */ 10 | public class NullFiledException extends BaseException { 11 | public NullFiledException(String msg, HttpStatus code) { 12 | super(msg, code); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/exception/SecurityException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class SecurityException extends BaseException { 9 | public SecurityException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/security/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.security; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private String roleId; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/security/MustCounselorLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.COUNSELOR) 12 | public @interface MustCounselorLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/security/MustLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target({ElementType.PARAMETER, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @Inherited 12 | public @interface MustLogin { 13 | /** 14 | * 登录角色 15 | * 16 | * @return 角色数组 17 | */ 18 | ROLE[] role(); 19 | 20 | enum ROLE { 21 | /** 22 | * 学生 23 | */ 24 | STUDENT("1", "学生"), 25 | /** 26 | * 教师 27 | */ 28 | TEACHER("2", "教师"), 29 | /** 30 | * 辅导员 31 | */ 32 | COUNSELOR("3", "辅导员"); 33 | 34 | private String id; 35 | private String name; 36 | 37 | ROLE(String id, String name) { 38 | this.id = id; 39 | this.name = name; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ROLE{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/security/MustStudentLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.STUDENT) 12 | public @interface MustStudentLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/security/MustTeacherLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.TEACHER) 12 | public @interface MustTeacherLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/security/SecurityArgumentResolversWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * MVC参数配置 12 | * 13 | * @author itning 14 | */ 15 | @Configuration 16 | public class SecurityArgumentResolversWebMvcConfig implements WebMvcConfigurer { 17 | private final SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver; 18 | 19 | @Autowired 20 | public SecurityArgumentResolversWebMvcConfig(SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver) { 21 | this.securityHandlerMethodArgumentResolver = securityHandlerMethodArgumentResolver; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(securityHandlerMethodArgumentResolver); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/service/ApartmentService.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.service; 2 | 3 | import top.itning.smp.smpinfo.dto.ApartmentDTO; 4 | import top.itning.smp.smpinfo.entity.Apartment; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | public interface ApartmentService { 12 | /** 13 | * 获取所有公寓信息 14 | * 15 | * @return 公寓集合 16 | */ 17 | List getAllApartments(); 18 | 19 | /** 20 | * 更新公寓信息 21 | * 22 | * @param apartment 公寓信息 23 | */ 24 | void updateApartment(Apartment apartment); 25 | 26 | /** 27 | * 删除公寓 28 | * 29 | * @param id 公寓ID 30 | */ 31 | void delApartment(String id); 32 | 33 | /** 34 | * 新增公寓 35 | * 36 | * @param name 公寓 37 | * @return 新增的公寓 38 | */ 39 | Apartment saveApartment(String name); 40 | 41 | /** 42 | * 获取公寓信息 43 | * 44 | * @return 公寓信息 45 | */ 46 | List getAllApartmentsWithPeople(); 47 | } 48 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/util/IdCardUtils.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.util; 2 | 3 | import com.google.common.collect.Maps; 4 | 5 | import java.text.ParseException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Calendar; 8 | import java.util.Date; 9 | import java.util.Map; 10 | 11 | /** 12 | * 身份证工具类 13 | * 14 | * @author itning 15 | */ 16 | public class IdCardUtils { 17 | private static final ThreadLocal SIMPLE_DATE_FORMAT_THREAD_LOCAL = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyyMMdd")); 18 | /** 19 | * CN 大陆第二代身份证号长度 20 | */ 21 | private static final int ID_CARD_LENGTH = 18; 22 | 23 | /** 24 | * 解析身份证号码 25 | * 26 | * @param idCardNum 身份证号 27 | * @return Map 28 | */ 29 | public static Map analysisIdCard(String idCardNum) { 30 | if (idCardNum.length() != ID_CARD_LENGTH) { 31 | throw new IllegalArgumentException("身份证号长度不是18位,请检查"); 32 | } 33 | 34 | Map map = Maps.newHashMapWithExpectedSize(3); 35 | try { 36 | Date birthday = SIMPLE_DATE_FORMAT_THREAD_LOCAL.get().parse(idCardNum.substring(6, 14)); 37 | map.put("birthday", birthday); 38 | boolean sex = Integer.parseInt(idCardNum.substring(16, 17)) % 2 != 0; 39 | map.put("sex", sex); 40 | Calendar cal = Calendar.getInstance(); 41 | int age = cal.get(Calendar.YEAR) - Integer.parseInt(idCardNum.substring(6, 10)); 42 | map.put("age", age); 43 | } catch (ParseException e) { 44 | throw new RuntimeException(e); 45 | } 46 | return map; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /smp-info/src/main/java/top/itning/smp/smpinfo/util/OrikaUtils.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpinfo.util; 2 | 3 | import ma.glasnost.orika.MapperFactory; 4 | import ma.glasnost.orika.impl.DefaultMapperFactory; 5 | import org.springframework.lang.NonNull; 6 | import org.springframework.lang.Nullable; 7 | 8 | /** 9 | * 实体映射工具类 10 | * 11 | * @author itning 12 | */ 13 | public class OrikaUtils { 14 | private static final MapperFactory MAPPER_FACTORY = new DefaultMapperFactory.Builder().build(); 15 | 16 | /** 17 | * 将两个实体合并为一个DTO 18 | * input1,input2 不能全为 {@code null} 19 | * 20 | * @param input1 第一个输入实体 21 | * @param input2 第二个输入实体 22 | * @param result DTO类型 23 | * @param DTO 24 | * @param ENTITY 25 | * @param ENTITY 26 | * @return DTO类型 27 | */ 28 | @NonNull 29 | public static R doubleEntity2Dto(@Nullable A input1, @Nullable B input2, @NonNull Class result) { 30 | if (input1 != null && input2 != null) { 31 | R r = MAPPER_FACTORY.getMapperFacade().map(input1, result); 32 | MAPPER_FACTORY.getMapperFacade().map(input2, r); 33 | return r; 34 | } else if (input1 != null) { 35 | return MAPPER_FACTORY.getMapperFacade().map(input1, result); 36 | } else { 37 | return MAPPER_FACTORY.getMapperFacade().map(input2, result); 38 | } 39 | } 40 | 41 | /** 42 | * A 实体 转换 B 实体 43 | * 44 | * @param a A实例 45 | * @param bClass B类型 46 | * @param A 47 | * @param B 48 | * @return B 实例 49 | */ 50 | public static B a2b(A a, Class bClass) { 51 | return MAPPER_FACTORY.getMapperFacade().map(a, bClass); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /smp-info/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-info/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-info/src/test/resources/test.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-info/src/test/resources/test.xlsx -------------------------------------------------------------------------------- /smp-info/src/test/resources/test2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-info/src/test/resources/test2.xlsx -------------------------------------------------------------------------------- /smp-leave/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/SmpLeaveApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @SpringCloudApplication 11 | @EnableFeignClients 12 | public class SmpLeaveApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SmpLeaveApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/client/InfoClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import top.itning.smp.smpleave.client.entity.StudentUser; 8 | import top.itning.smp.smpleave.entity.User; 9 | 10 | import java.util.Optional; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @FeignClient(name = "info") 16 | @Component 17 | public interface InfoClient { 18 | /** 19 | * 根据用户名获取用户信息 20 | * 21 | * @param username 用户名 22 | * @return 用户 23 | */ 24 | @GetMapping("/internal/user/{username}") 25 | Optional getUserInfoByUserName(@PathVariable String username); 26 | 27 | /** 28 | * 根据用户名获取用户信息 29 | * 30 | * @param username 用户名 31 | * @return 用户 32 | */ 33 | @GetMapping("/internal/student_user/{username}") 34 | Optional getStudentUserInfoByUserName(@PathVariable String username); 35 | } 36 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/client/entity/Apartment.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.client.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 公寓信息 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class Apartment implements Serializable { 15 | /** 16 | * ID 17 | */ 18 | private String id; 19 | /** 20 | * 公寓名 21 | */ 22 | private String name; 23 | /** 24 | * 创建时间 25 | */ 26 | private Date gmtCreate; 27 | /** 28 | * 更新时间 29 | */ 30 | private Date gmtModified; 31 | } 32 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/client/entity/StudentUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.client.entity; 2 | 3 | import lombok.Data; 4 | 5 | import top.itning.smp.smpleave.entity.Role; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * 学生信息DTO 12 | * 13 | * @author itning 14 | */ 15 | @Data 16 | public class StudentUser implements Serializable { 17 | /** 18 | * 用户ID 19 | */ 20 | private String id; 21 | /** 22 | * 用户姓名 23 | */ 24 | private String name; 25 | /** 26 | * 电话 27 | */ 28 | private String tel; 29 | /** 30 | * 邮箱 31 | */ 32 | private String email; 33 | /** 34 | * 用户名 35 | */ 36 | private String username; 37 | /** 38 | * 角色 39 | */ 40 | private Role role; 41 | /** 42 | * 出生日期 43 | */ 44 | private Date birthday; 45 | /** 46 | * 性别(true 男; false 女) 47 | */ 48 | private Boolean sex; 49 | /** 50 | * 年龄 51 | */ 52 | private Integer age; 53 | /** 54 | * 学号 55 | */ 56 | private String studentId; 57 | /** 58 | * 该学生所属辅导员的ID 59 | */ 60 | private String belongCounselorId; 61 | /** 62 | * 身份证号 63 | */ 64 | private String idCard; 65 | /** 66 | * 政治面貌 67 | */ 68 | private String politicalStatus; 69 | /** 70 | * 民族 71 | */ 72 | private String ethnic; 73 | /** 74 | * 公寓信息 75 | */ 76 | private Apartment apartment; 77 | /** 78 | * 寝室号 79 | */ 80 | private String roomNum; 81 | /** 82 | * 床号 83 | */ 84 | private String bedNum; 85 | /** 86 | * 家庭地址 87 | */ 88 | private String address; 89 | /** 90 | * 创建时间 91 | */ 92 | private Date gmtCreate; 93 | /** 94 | * 更新时间 95 | */ 96 | private Date gmtModified; 97 | } 98 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/config/HttpTraceActuatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.config; 2 | 3 | import org.springframework.boot.actuate.trace.http.HttpTraceRepository; 4 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Configuration 12 | public class HttpTraceActuatorConfiguration { 13 | @Bean 14 | public HttpTraceRepository httpTraceRepository() { 15 | return new InMemoryHttpTraceRepository(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/dao/LeaveDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.dao; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 | import top.itning.smp.smpleave.entity.Leave; 8 | import top.itning.smp.smpleave.entity.User; 9 | 10 | import java.util.List; 11 | 12 | 13 | /** 14 | * @author itning 15 | */ 16 | public interface LeaveDao extends JpaRepository, JpaSpecificationExecutor { 17 | /** 18 | * 获取请假信息 19 | * 20 | * @param status 审核状态 21 | * @param pageable 分页 22 | * @return 请假信息 23 | */ 24 | Page findAllByStatus(Boolean status, Pageable pageable); 25 | 26 | /** 27 | * 根据用户寻找请假信息 28 | * 29 | * @param user 用户 30 | * @param pageable 分页 31 | * @return 请假信息 32 | */ 33 | Page findAllByUser(User user, Pageable pageable); 34 | 35 | /** 36 | * 根据用户寻找请假信息 37 | * 38 | * @param user 用户 39 | * @return 请假信息 40 | */ 41 | List findAllByUser(User user); 42 | } -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/dao/LeaveReasonDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import top.itning.smp.smpleave.entity.LeaveReason; 5 | 6 | /** 7 | * @author itning 8 | */ 9 | public interface LeaveReasonDao extends JpaRepository { 10 | } 11 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/dto/LeaveDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.dto; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpleave.client.entity.StudentUser; 5 | import top.itning.smp.smpleave.entity.LeaveReason; 6 | import top.itning.smp.smpleave.entity.LeaveType; 7 | 8 | import java.io.Serializable; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @Data 16 | public class LeaveDTO implements Serializable { 17 | /** 18 | * ID 19 | */ 20 | private String id; 21 | /** 22 | * 学生 23 | */ 24 | private StudentUser studentUser; 25 | /** 26 | * 请假开始时间 27 | */ 28 | private Date startTime; 29 | /** 30 | * 请假结束时间 31 | */ 32 | private Date endTime; 33 | /** 34 | * 请假类型 35 | */ 36 | private LeaveType leaveType; 37 | /** 38 | * 请假原因 39 | */ 40 | private String reason; 41 | /** 42 | * 审核状态(true 通过;false 未通过) 43 | */ 44 | private Boolean status; 45 | /** 46 | * 评论 47 | */ 48 | private List leaveReasonList; 49 | /** 50 | * 创建时间 51 | */ 52 | private Date gmtCreate; 53 | /** 54 | * 更新时间 55 | */ 56 | private Date gmtModified; 57 | } 58 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/dto/SearchDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.dto; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpleave.entity.LeaveType; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | public class SearchDTO implements Serializable { 14 | private String key; 15 | private Boolean effective; 16 | private Date startTime; 17 | private Date endTime; 18 | private LeaveType leaveType; 19 | } 20 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/Apartment.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 公寓信息 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "apartment") 22 | public class Apartment implements Serializable { 23 | /** 24 | * ID 25 | */ 26 | @Id 27 | @GeneratedValue(generator = "idGenerator") 28 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 29 | @Column(length = 36, columnDefinition = "char(36)") 30 | private String id; 31 | /** 32 | * 公寓名 33 | */ 34 | @Column(nullable = false, unique = true) 35 | private String name; 36 | /** 37 | * 创建时间 38 | */ 39 | @Column(nullable = false) 40 | @CreationTimestamp 41 | private Date gmtCreate; 42 | /** 43 | * 更新时间 44 | */ 45 | @Column(nullable = false) 46 | @UpdateTimestamp 47 | private Date gmtModified; 48 | } 49 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/Leave.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * 请假表 15 | * 16 | * @author itning 17 | */ 18 | @Data 19 | @Entity(name = "student_leave") 20 | public class Leave implements Serializable { 21 | /** 22 | * ID 23 | */ 24 | @Id 25 | @GeneratedValue(generator = "idGenerator") 26 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 27 | @Column(length = 36, columnDefinition = "char(36)") 28 | private String id; 29 | /** 30 | * 学生 31 | */ 32 | @ManyToOne(optional = false) 33 | @JoinColumn(name = "userId") 34 | private User user; 35 | /** 36 | * 请假开始时间 37 | */ 38 | @Column(nullable = false) 39 | private Date startTime; 40 | /** 41 | * 请假结束时间 42 | */ 43 | @Column(nullable = false) 44 | private Date endTime; 45 | /** 46 | * 请假类型 47 | */ 48 | @Column(nullable = false) 49 | private LeaveType leaveType; 50 | /** 51 | * 请假原因 52 | */ 53 | @Column(nullable = false, columnDefinition = "text") 54 | private String reason; 55 | /** 56 | * 审核状态(true 通过;false 未通过;null 未审核) 57 | */ 58 | @Column 59 | private Boolean status; 60 | /** 61 | * 评论 62 | */ 63 | @OneToMany 64 | @JoinColumn(name = "leaveId", nullable = false) 65 | private List leaveReasonList; 66 | /** 67 | * 创建时间 68 | */ 69 | @Column(nullable = false) 70 | @CreationTimestamp 71 | private Date gmtCreate; 72 | /** 73 | * 更新时间 74 | */ 75 | @Column(nullable = false) 76 | @UpdateTimestamp 77 | private Date gmtModified; 78 | } 79 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/LeaveReason.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @Data 16 | @Entity(name = "student_leave_reason") 17 | public class LeaveReason implements Serializable { 18 | /** 19 | * ID 20 | */ 21 | @Id 22 | @GeneratedValue(generator = "idGenerator") 23 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 24 | @Column(length = 36, columnDefinition = "char(36)") 25 | private String id; 26 | /** 27 | * 评论用户ID 28 | */ 29 | @OneToOne 30 | @JoinColumn(name = "from_user_id", nullable = false) 31 | private User fromUser; 32 | /** 33 | * 评论 34 | */ 35 | @Column(nullable = false, columnDefinition = "text") 36 | private String comment; 37 | /** 38 | * 创建时间 39 | */ 40 | @Column(nullable = false) 41 | @CreationTimestamp 42 | private Date gmtCreate; 43 | /** 44 | * 更新时间 45 | */ 46 | @Column(nullable = false) 47 | @UpdateTimestamp 48 | private Date gmtModified; 49 | } 50 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/LeaveType.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | /** 4 | * 请假类型(课假;寝室假;课假+寝室假) 5 | * 6 | * @author itning 7 | */ 8 | public enum LeaveType { 9 | /** 10 | * 课假 11 | */ 12 | CLASS_LEAVE, 13 | /** 14 | * 寝室假 15 | */ 16 | ROOM_LEAVE, 17 | /** 18 | * 课假+寝室假 19 | */ 20 | ALL_LEAVE 21 | } 22 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Rest 返回消息 10 | * 11 | * @author itning 12 | */ 13 | public class RestModel implements Serializable { 14 | private int code; 15 | private String msg; 16 | private T data; 17 | 18 | public RestModel() { 19 | 20 | } 21 | 22 | private RestModel(HttpStatus status, String msg, T data) { 23 | this(status.value(), msg, data); 24 | } 25 | 26 | private RestModel(int code, String msg, T data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public static ResponseEntity> ok(T data) { 33 | return ResponseEntity.ok(new RestModel<>(HttpStatus.OK, "查询成功", data)); 34 | } 35 | 36 | public static ResponseEntity> created() { 37 | return ResponseEntity.status(HttpStatus.CREATED).build(); 38 | } 39 | 40 | public static ResponseEntity> created(T data) { 41 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, "创建成功", data)); 42 | } 43 | 44 | public static ResponseEntity noContent() { 45 | return ResponseEntity.noContent().build(); 46 | } 47 | 48 | public int getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(int code) { 53 | this.code = code; 54 | } 55 | 56 | public String getMsg() { 57 | return msg; 58 | } 59 | 60 | public void setMsg(String msg) { 61 | this.msg = msg; 62 | } 63 | 64 | public T getData() { 65 | return data; 66 | } 67 | 68 | public void setData(T data) { 69 | this.data = data; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 角色 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "role") 22 | public class Role implements Serializable { 23 | public static final String STUDENT_ROLE_ID = "1"; 24 | public static final String STUDENT_ROLE_ID_STR = "学生"; 25 | public static final String TEACHER_ROLE_ID = "2"; 26 | public static final String TEACHER_ROLE_ID_STR = "教师"; 27 | public static final String COUNSELOR_ROLE_ID = "3"; 28 | public static final String COUNSELOR_ROLE_ID_STR = "辅导员"; 29 | 30 | /** 31 | * 角色ID 32 | */ 33 | @Id 34 | @GeneratedValue(generator = "idGenerator") 35 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 36 | @Column(length = 36, columnDefinition = "char(36)") 37 | private String id; 38 | /** 39 | * 角色名 40 | */ 41 | @Column(length = 50, unique = true, nullable = false) 42 | private String name; 43 | /** 44 | * 创建时间 45 | */ 46 | @Column(nullable = false) 47 | @CreationTimestamp 48 | private Date gmtCreate; 49 | /** 50 | * 更新时间 51 | */ 52 | @Column(nullable = false) 53 | @UpdateTimestamp 54 | private Date gmtModified; 55 | } 56 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/entity/User.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 用户 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "user") 19 | public class User implements Serializable { 20 | /** 21 | * 用户ID 22 | */ 23 | @Id 24 | @GeneratedValue(generator = "idGenerator") 25 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 26 | @Column(length = 36, columnDefinition = "char(36)") 27 | private String id; 28 | /** 29 | * 用户姓名 30 | */ 31 | @Column(nullable = false) 32 | private String name; 33 | /** 34 | * 电话 35 | */ 36 | @Column(length = 11, columnDefinition = "char(11)") 37 | private String tel; 38 | /** 39 | * 邮箱 40 | */ 41 | private String email; 42 | /** 43 | * 用户名 44 | */ 45 | @Column(nullable = false, unique = true) 46 | private String username; 47 | /** 48 | * 角色 49 | */ 50 | @ManyToOne(optional = false) 51 | @JoinColumn(name = "roleId") 52 | private Role role; 53 | /** 54 | * 所对应的学生 55 | */ 56 | @OneToOne 57 | @PrimaryKeyJoinColumn 58 | private StudentUser studentUser; 59 | /** 60 | * 创建时间 61 | */ 62 | @Column(nullable = false) 63 | @CreationTimestamp 64 | private Date gmtCreate; 65 | /** 66 | * 更新时间 67 | */ 68 | @Column(nullable = false) 69 | @UpdateTimestamp 70 | private Date gmtModified; 71 | } 72 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/exception/DateRangeException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class DateRangeException extends BaseException { 9 | public DateRangeException(String msg) { 10 | super(msg, HttpStatus.BAD_REQUEST); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/exception/NullFiledException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 空属性异常 7 | * 8 | * @author itning 9 | */ 10 | public class NullFiledException extends BaseException { 11 | public NullFiledException(String msg, HttpStatus code) { 12 | super(msg, code); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/exception/SecurityException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class SecurityException extends BaseException { 9 | public SecurityException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/exception/UnexpectedException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class UnexpectedException extends BaseException { 9 | public UnexpectedException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/security/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.security; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private String roleId; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/security/MustCounselorLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.COUNSELOR) 12 | public @interface MustCounselorLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/security/MustLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target({ElementType.PARAMETER, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @Inherited 12 | public @interface MustLogin { 13 | /** 14 | * 登录角色 15 | * 16 | * @return 角色数组 17 | */ 18 | ROLE[] role(); 19 | 20 | enum ROLE { 21 | /** 22 | * 学生 23 | */ 24 | STUDENT("1", "学生"), 25 | /** 26 | * 教师 27 | */ 28 | TEACHER("2", "教师"), 29 | /** 30 | * 辅导员 31 | */ 32 | COUNSELOR("3", "辅导员"); 33 | 34 | private String id; 35 | private String name; 36 | 37 | ROLE(String id, String name) { 38 | this.id = id; 39 | this.name = name; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ROLE{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/security/MustStudentLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.STUDENT) 12 | public @interface MustStudentLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/security/MustTeacherLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.TEACHER) 12 | public @interface MustTeacherLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/security/SecurityArgumentResolversWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * MVC参数配置 12 | * 13 | * @author itning 14 | */ 15 | @Configuration 16 | public class SecurityArgumentResolversWebMvcConfig implements WebMvcConfigurer { 17 | private final SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver; 18 | 19 | @Autowired 20 | public SecurityArgumentResolversWebMvcConfig(SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver) { 21 | this.securityHandlerMethodArgumentResolver = securityHandlerMethodArgumentResolver; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(securityHandlerMethodArgumentResolver); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /smp-leave/src/main/java/top/itning/smp/smpleave/util/OrikaUtils.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave.util; 2 | 3 | import ma.glasnost.orika.MapperFactory; 4 | import ma.glasnost.orika.impl.DefaultMapperFactory; 5 | import org.springframework.lang.NonNull; 6 | import org.springframework.lang.Nullable; 7 | 8 | /** 9 | * 实体映射工具类 10 | * 11 | * @author itning 12 | */ 13 | public class OrikaUtils { 14 | private static final MapperFactory MAPPER_FACTORY = new DefaultMapperFactory.Builder().build(); 15 | 16 | /** 17 | * 将两个实体合并为一个DTO 18 | * input1,input2 不能全为 {@code null} 19 | * 20 | * @param input1 第一个输入实体 21 | * @param input2 第二个输入实体 22 | * @param result DTO类型 23 | * @param DTO 24 | * @param ENTITY 25 | * @param ENTITY 26 | * @return DTO类型 27 | */ 28 | @NonNull 29 | public static R doubleEntity2Dto(@Nullable A input1, @Nullable B input2, @NonNull Class result) { 30 | if (input1 != null && input2 != null) { 31 | R r = MAPPER_FACTORY.getMapperFacade().map(input1, result); 32 | MAPPER_FACTORY.getMapperFacade().map(input2, r); 33 | return r; 34 | } else if (input1 != null) { 35 | return MAPPER_FACTORY.getMapperFacade().map(input1, result); 36 | } else { 37 | return MAPPER_FACTORY.getMapperFacade().map(input2, result); 38 | } 39 | } 40 | 41 | /** 42 | * A 实体 转换 B 实体 43 | * 44 | * @param a A实例 45 | * @param bClass B类型 46 | * @param A 47 | * @param B 48 | * @return B 实例 49 | */ 50 | public static B a2b(A a, Class bClass) { 51 | return MAPPER_FACTORY.getMapperFacade().map(a, bClass); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /smp-leave/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-leave/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-leave/src/test/java/top/itning/smp/smpleave/SmpLeaveApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpleave; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpLeaveApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-room/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-room/src/main/java/com/lzw/face/bean/FaceIndex.java: -------------------------------------------------------------------------------- 1 | package com.lzw.face.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | public class FaceIndex implements Serializable { 7 | private String key; 8 | 9 | private int index; 10 | 11 | private byte[] imgData; 12 | private int width; 13 | private int height; 14 | private int channel; 15 | 16 | public String getKey() { 17 | return key; 18 | } 19 | 20 | public void setKey(String key) { 21 | this.key = key; 22 | } 23 | 24 | public int getIndex() { 25 | return index; 26 | } 27 | 28 | public void setIndex(int index) { 29 | this.index = index; 30 | } 31 | 32 | public byte[] getImgData() { 33 | return imgData; 34 | } 35 | 36 | public void setImgData(byte[] imgData) { 37 | this.imgData = imgData; 38 | } 39 | 40 | public int getWidth() { 41 | return width; 42 | } 43 | 44 | public void setWidth(int width) { 45 | this.width = width; 46 | } 47 | 48 | public int getHeight() { 49 | return height; 50 | } 51 | 52 | public void setHeight(int height) { 53 | this.height = height; 54 | } 55 | 56 | public int getChannel() { 57 | return channel; 58 | } 59 | 60 | public void setChannel(int channel) { 61 | this.channel = channel; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /smp-room/src/main/java/com/seetaface2/model/FaceLandmark.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class FaceLandmark { 4 | public SeetaRect[] rects; 5 | public SeetaPointF[] points; 6 | } 7 | -------------------------------------------------------------------------------- /smp-room/src/main/java/com/seetaface2/model/RecognizeResult.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | /** 4 | * 人脸搜索结果 下标 显示度 5 | */ 6 | public class RecognizeResult { 7 | public int index; 8 | public float similar; 9 | } 10 | -------------------------------------------------------------------------------- /smp-room/src/main/java/com/seetaface2/model/SeetaImageData.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class SeetaImageData { 4 | public SeetaImageData() { 5 | 6 | } 7 | 8 | public SeetaImageData(int width, int height, int channels) { 9 | this.data = new byte[width * height * channels]; 10 | this.width = width; 11 | this.height = height; 12 | this.channels = channels; 13 | } 14 | 15 | public SeetaImageData(int width, int height) { 16 | this(width, height, 3); 17 | } 18 | 19 | public byte[] data; 20 | public int width; 21 | public int height; 22 | public int channels; 23 | } 24 | -------------------------------------------------------------------------------- /smp-room/src/main/java/com/seetaface2/model/SeetaPointF.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class SeetaPointF { 4 | public double x; 5 | public double y; 6 | } 7 | -------------------------------------------------------------------------------- /smp-room/src/main/java/com/seetaface2/model/SeetaRect.java: -------------------------------------------------------------------------------- 1 | package com.seetaface2.model; 2 | 3 | public class SeetaRect { 4 | public int x; 5 | public int y; 6 | public int width; 7 | public int height; 8 | } 9 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/SmpRoomApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.cloud.client.SpringCloudApplication; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @SpringCloudApplication 13 | @EnableFeignClients 14 | public class SmpRoomApplication { 15 | static { 16 | Logger logger = LoggerFactory.getLogger(SmpRoomApplication.class); 17 | try { 18 | com.lzw.face.SeetafaceBuilder.build(); 19 | logger.info("Face Recognition Init Success"); 20 | } catch (Throwable e) { 21 | logger.error("Face Recognition Init Fail", e); 22 | } 23 | } 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(SmpRoomApplication.class, args); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/client/InfoClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import top.itning.smp.smproom.client.entity.StudentUserDTO; 9 | import top.itning.smp.smproom.entity.StudentUser; 10 | import top.itning.smp.smproom.entity.User; 11 | 12 | import java.util.List; 13 | import java.util.Optional; 14 | 15 | /** 16 | * @author itning 17 | */ 18 | @FeignClient(name = "info") 19 | @Component 20 | public interface InfoClient { 21 | /** 22 | * 根据用户名获取用户信息 23 | * 24 | * @param username 用户名 25 | * @return 用户 26 | */ 27 | @GetMapping("/internal/user/{username}") 28 | Optional getUserInfoByUserName(@PathVariable String username); 29 | 30 | /** 31 | * 根据用户名获取用户信息 32 | * 33 | * @param username 用户名 34 | * @return 用户 35 | */ 36 | @GetMapping("/internal/student_user/{username}") 37 | Optional getStudentUserInfoByUserName(@PathVariable String username); 38 | 39 | /** 40 | * 计算学生人数 41 | * 42 | * @param username 导员用户名 43 | * @return 学生数量 44 | */ 45 | @GetMapping("/internal/student_user/count/{username}") 46 | long countStudent(@PathVariable String username); 47 | 48 | /** 49 | * 获取所有学生信息 50 | * 51 | * @param username 导员用户名 52 | * @return 学生信息 53 | */ 54 | @GetMapping("/internal/users") 55 | List getAllUser(@RequestParam String username); 56 | } 57 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/client/LeaveClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import top.itning.smp.smproom.client.entity.LeaveDTO; 8 | import top.itning.smp.smproom.client.entity.LeaveType; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author itning 14 | */ 15 | @FeignClient(name = "leave") 16 | @Component 17 | public interface LeaveClient { 18 | /** 19 | * 获取正在生效的寝室请假信息数量 20 | * 21 | * @param date 哪天开始 22 | * @param username 导员用户名 23 | * @return 正在生效的寝室请假信息数量 24 | */ 25 | @GetMapping("/internal/leaves/roomInEffect/count") 26 | long countInEffectRoomLeaves(@RequestParam("date") String date, @RequestParam("username") String username); 27 | 28 | /** 29 | * 学生今天是否请假了 30 | * 31 | * @param userName 学生 32 | * @param leaveType 请假类型 只能传课假或寝室假,默认包括全部假 33 | * @return 今天请假了返回true 34 | */ 35 | @GetMapping("/internal/isLeave") 36 | boolean isLeave(@RequestParam("userName") String userName, @RequestParam("leaveType") LeaveType leaveType); 37 | 38 | /** 39 | * 获取请假信息(包括课假和寝室假) 40 | * 41 | * @param whereDay 哪天 42 | * @param username 导员用户名 43 | * @return 所有请假信息 44 | */ 45 | @GetMapping("/internal/leaves") 46 | List getAllLeave(@RequestParam("whereDay") String whereDay, @RequestParam String username); 47 | } 48 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/client/entity/LeaveDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.client.entity; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smproom.entity.StudentUser; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | /** 11 | * @author itning 12 | */ 13 | @Data 14 | public class LeaveDTO implements Serializable { 15 | /** 16 | * ID 17 | */ 18 | private String id; 19 | /** 20 | * 学生 21 | */ 22 | private StudentUser studentUser; 23 | /** 24 | * 请假开始时间 25 | */ 26 | private Date startTime; 27 | /** 28 | * 请假结束时间 29 | */ 30 | private Date endTime; 31 | /** 32 | * 请假类型 33 | */ 34 | private LeaveType leaveType; 35 | /** 36 | * 请假原因 37 | */ 38 | private String reason; 39 | /** 40 | * 审核状态(true 通过;false 未通过) 41 | */ 42 | private Boolean status; 43 | /** 44 | * 评论 45 | */ 46 | private List leaveReasonList; 47 | /** 48 | * 创建时间 49 | */ 50 | private Date gmtCreate; 51 | /** 52 | * 更新时间 53 | */ 54 | private Date gmtModified; 55 | } 56 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/client/entity/LeaveReason.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.client.entity; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smproom.entity.User; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | public class LeaveReason implements Serializable { 14 | /** 15 | * ID 16 | */ 17 | private String id; 18 | /** 19 | * 评论用户ID 20 | */ 21 | private User fromUser; 22 | /** 23 | * 评论 24 | */ 25 | private String comment; 26 | /** 27 | * 创建时间 28 | */ 29 | private Date gmtCreate; 30 | /** 31 | * 更新时间 32 | */ 33 | private Date gmtModified; 34 | } 35 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/client/entity/LeaveType.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.client.entity; 2 | 3 | /** 4 | * 请假类型(课假;寝室假;课假+寝室假) 5 | * 6 | * @author itning 7 | */ 8 | public enum LeaveType { 9 | /** 10 | * 课假 11 | */ 12 | CLASS_LEAVE, 13 | /** 14 | * 寝室假 15 | */ 16 | ROOM_LEAVE, 17 | /** 18 | * 课假+寝室假 19 | */ 20 | ALL_LEAVE 21 | } 22 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/client/entity/StudentUserDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.client.entity; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smproom.entity.Apartment; 5 | import top.itning.smp.smproom.entity.Role; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * 学生信息DTO 12 | * 13 | * @author itning 14 | */ 15 | @Data 16 | public class StudentUserDTO implements Serializable { 17 | /** 18 | * 用户ID 19 | */ 20 | private String id; 21 | /** 22 | * 用户姓名 23 | */ 24 | private String name; 25 | /** 26 | * 电话 27 | */ 28 | private String tel; 29 | /** 30 | * 邮箱 31 | */ 32 | private String email; 33 | /** 34 | * 用户名 35 | */ 36 | private String username; 37 | /** 38 | * 角色 39 | */ 40 | private Role role; 41 | /** 42 | * 出生日期 43 | */ 44 | private Date birthday; 45 | /** 46 | * 性别(true 男; false 女) 47 | */ 48 | private Boolean sex; 49 | /** 50 | * 年龄 51 | */ 52 | private Integer age; 53 | /** 54 | * 学号 55 | */ 56 | private String studentId; 57 | /** 58 | * 身份证号 59 | */ 60 | private String idCard; 61 | /** 62 | * 政治面貌 63 | */ 64 | private String politicalStatus; 65 | /** 66 | * 民族 67 | */ 68 | private String ethnic; 69 | /** 70 | * 公寓信息 71 | */ 72 | private Apartment apartment; 73 | /** 74 | * 寝室号 75 | */ 76 | private String roomNum; 77 | /** 78 | * 床号 79 | */ 80 | private String bedNum; 81 | /** 82 | * 家庭地址 83 | */ 84 | private String address; 85 | /** 86 | * 创建时间 87 | */ 88 | private Date gmtCreate; 89 | /** 90 | * 更新时间 91 | */ 92 | private Date gmtModified; 93 | } 94 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/config/CustomProperties.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.io.File; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @ConfigurationProperties(prefix = "app") 12 | @Component 13 | public class CustomProperties { 14 | /** 15 | * 资源映射路径 16 | */ 17 | private String resourceLocation; 18 | /** 19 | * 学生注册的人脸存储路径 20 | */ 21 | private String faceLocation; 22 | /** 23 | * 人脸对比精度阈值 24 | */ 25 | private float contrastAccuracyThreshold = 0.5f; 26 | 27 | public String getResourceLocation() { 28 | return resourceLocation; 29 | } 30 | 31 | public void setResourceLocation(String resourceLocation) { 32 | if (!resourceLocation.endsWith(File.separator)) { 33 | resourceLocation += File.separator; 34 | } 35 | this.resourceLocation = resourceLocation; 36 | } 37 | 38 | public String getFaceLocation() { 39 | return faceLocation; 40 | } 41 | 42 | public void setFaceLocation(String faceLocation) { 43 | if (!faceLocation.endsWith(File.separator)) { 44 | faceLocation += File.separator; 45 | } 46 | this.faceLocation = faceLocation; 47 | } 48 | 49 | public float getContrastAccuracyThreshold() { 50 | return contrastAccuracyThreshold; 51 | } 52 | 53 | public void setContrastAccuracyThreshold(float contrastAccuracyThreshold) { 54 | if (contrastAccuracyThreshold > 1) { 55 | contrastAccuracyThreshold = 1f; 56 | } 57 | if (contrastAccuracyThreshold < 0) { 58 | contrastAccuracyThreshold = 0; 59 | } 60 | this.contrastAccuracyThreshold = contrastAccuracyThreshold; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/config/CustomWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | /** 9 | * MVC参数配置 10 | * 11 | * @author itning 12 | */ 13 | @Configuration 14 | public class CustomWebMvcConfig implements WebMvcConfigurer { 15 | private final CustomProperties customProperties; 16 | 17 | @Autowired 18 | public CustomWebMvcConfig(CustomProperties customProperties) { 19 | this.customProperties = customProperties; 20 | } 21 | 22 | @Override 23 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 24 | registry.addResourceHandler("/check_image/**").addResourceLocations("file:" + customProperties.getResourceLocation()); 25 | registry.addResourceHandler("/face_image/**").addResourceLocations("file:" + customProperties.getFaceLocation()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/config/HttpTraceActuatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.config; 2 | 3 | import org.springframework.boot.actuate.trace.http.HttpTraceRepository; 4 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Configuration 12 | public class HttpTraceActuatorConfiguration { 13 | @Bean 14 | public HttpTraceRepository httpTraceRepository() { 15 | return new InMemoryHttpTraceRepository(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/dao/StudentRoomCheckDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.dao; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 7 | import top.itning.smp.smproom.entity.StudentRoomCheck; 8 | import top.itning.smp.smproom.entity.User; 9 | 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * @author itning 15 | */ 16 | public interface StudentRoomCheckDao extends JpaRepository, JpaSpecificationExecutor { 17 | /** 18 | * 根据用户查询寝室打卡信息 19 | * 20 | * @param user 用户 21 | * @param pageable 分页 22 | * @return 用户寝室打卡信息 23 | */ 24 | Page findAllByUser(User user, Pageable pageable); 25 | 26 | /** 27 | * 获取范围打卡时间的学生打卡信息 28 | * 29 | * @param start 开始 30 | * @param end 结束 31 | * @return 学生打卡信息 32 | */ 33 | List findAllByCheckTimeBetweenOrderByCheckTimeDesc(Date start, Date end); 34 | 35 | /** 36 | * 检查学生某天是否打卡 37 | * 38 | * @param user 学生 39 | * @param start 开始日期 40 | * @param end 结束日期 41 | * @return 是否打卡 42 | */ 43 | boolean existsByUserAndCheckTimeBetween(User user, Date start, Date end); 44 | 45 | /** 46 | * 删除请假信息 47 | * 48 | * @param user 哪个学生 49 | */ 50 | void deleteAllByUser(User user); 51 | 52 | /** 53 | * 根据用户查询寝室打卡信息 54 | * 55 | * @param user 用户 56 | * @return 用户寝室打卡信息 57 | */ 58 | List findAllByUser(User user); 59 | } 60 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/dao/StudentRoomCheckMetaDataDao.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.dao; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import top.itning.smp.smproom.entity.StudentRoomCheckMetaData; 5 | import top.itning.smp.smproom.entity.StudentRoomCheckMetaDataPrimaryKey; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | public interface StudentRoomCheckMetaDataDao extends JpaRepository { 11 | /** 12 | * 根据导员ID和KEY查询元数据 13 | * 14 | * @param key KEY 15 | * @param belongCounselorId 导员ID 16 | * @return StudentRoomCheckMetaData 17 | */ 18 | StudentRoomCheckMetaData findByKeyAndBelongCounselorId(String key, String belongCounselorId); 19 | } 20 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/Apartment.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 公寓信息 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "apartment") 22 | public class Apartment implements Serializable { 23 | /** 24 | * ID 25 | */ 26 | @Id 27 | @GeneratedValue(generator = "idGenerator") 28 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 29 | @Column(length = 36, columnDefinition = "char(36)") 30 | private String id; 31 | /** 32 | * 公寓名 33 | */ 34 | @Column(nullable = false, unique = true) 35 | private String name; 36 | /** 37 | * 创建时间 38 | */ 39 | @Column(nullable = false) 40 | @CreationTimestamp 41 | private Date gmtCreate; 42 | /** 43 | * 更新时间 44 | */ 45 | @Column(nullable = false) 46 | @UpdateTimestamp 47 | private Date gmtModified; 48 | } 49 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/Face.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.awt.image.BufferedImage; 6 | import java.io.InputStream; 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | public class Face implements Serializable { 14 | private String id; 15 | private BufferedImage bufferedImage; 16 | private InputStream inputStream; 17 | } 18 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Rest 返回消息 10 | * 11 | * @author itning 12 | */ 13 | public class RestModel implements Serializable { 14 | private int code; 15 | private String msg; 16 | private T data; 17 | 18 | public RestModel() { 19 | 20 | } 21 | 22 | private RestModel(HttpStatus status, String msg, T data) { 23 | this(status.value(), msg, data); 24 | } 25 | 26 | private RestModel(int code, String msg, T data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public static ResponseEntity> ok(T data) { 33 | return ResponseEntity.ok(new RestModel<>(HttpStatus.OK, "查询成功", data)); 34 | } 35 | 36 | public static ResponseEntity> created() { 37 | return ResponseEntity.status(HttpStatus.CREATED).build(); 38 | } 39 | 40 | public static ResponseEntity> created(T data) { 41 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, "创建成功", data)); 42 | } 43 | 44 | public static ResponseEntity noContent() { 45 | return ResponseEntity.noContent().build(); 46 | } 47 | 48 | public int getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(int code) { 53 | this.code = code; 54 | } 55 | 56 | public String getMsg() { 57 | return msg; 58 | } 59 | 60 | public void setMsg(String msg) { 61 | this.msg = msg; 62 | } 63 | 64 | public T getData() { 65 | return data; 66 | } 67 | 68 | public void setData(T data) { 69 | this.data = data; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Entity; 10 | import javax.persistence.GeneratedValue; 11 | import javax.persistence.Id; 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * 角色 17 | * 18 | * @author itning 19 | */ 20 | @Data 21 | @Entity(name = "role") 22 | public class Role implements Serializable { 23 | public static final String STUDENT_ROLE_ID = "1"; 24 | public static final String STUDENT_ROLE_ID_STR = "学生"; 25 | public static final String TEACHER_ROLE_ID = "2"; 26 | public static final String TEACHER_ROLE_ID_STR = "教师"; 27 | public static final String COUNSELOR_ROLE_ID = "3"; 28 | public static final String COUNSELOR_ROLE_ID_STR = "辅导员"; 29 | 30 | /** 31 | * 角色ID 32 | */ 33 | @Id 34 | @GeneratedValue(generator = "idGenerator") 35 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 36 | @Column(length = 36, columnDefinition = "char(36)") 37 | private String id; 38 | /** 39 | * 角色名 40 | */ 41 | @Column(length = 50, unique = true, nullable = false) 42 | private String name; 43 | /** 44 | * 创建时间 45 | */ 46 | @Column(nullable = false) 47 | @CreationTimestamp 48 | private Date gmtCreate; 49 | /** 50 | * 更新时间 51 | */ 52 | @Column(nullable = false) 53 | @UpdateTimestamp 54 | private Date gmtModified; 55 | } 56 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/StudentRoomCheck.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 学生寝室签到表 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "student_room_check") 19 | public class StudentRoomCheck implements Serializable { 20 | /** 21 | * ID 22 | */ 23 | @Id 24 | @GeneratedValue(generator = "idGenerator") 25 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 26 | @Column(length = 36, columnDefinition = "char(36)") 27 | private String id; 28 | /** 29 | * 学生 30 | */ 31 | @ManyToOne(optional = false) 32 | @JoinColumn(name = "userId") 33 | private User user; 34 | /** 35 | * 签到时间 36 | */ 37 | @Column(nullable = false) 38 | private Date checkTime; 39 | /** 40 | * 经度 41 | */ 42 | @Column(nullable = false) 43 | private double longitude; 44 | /** 45 | * 纬度 46 | */ 47 | @Column(nullable = false) 48 | private double latitude; 49 | /** 50 | * 文件扩展名 51 | */ 52 | @Column(nullable = false) 53 | private String filenameExtension; 54 | /** 55 | * 打卡时的人脸相似度 56 | */ 57 | @Column(nullable = false) 58 | private float checkFaceSimilarity; 59 | /** 60 | * 创建时间 61 | */ 62 | @Column(nullable = false) 63 | @CreationTimestamp 64 | private Date gmtCreate; 65 | /** 66 | * 更新时间 67 | */ 68 | @Column(nullable = false) 69 | @UpdateTimestamp 70 | private Date gmtModified; 71 | } 72 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/StudentRoomCheckMetaData.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.UpdateTimestamp; 6 | 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.Id; 10 | import javax.persistence.IdClass; 11 | import java.io.Serializable; 12 | import java.util.Date; 13 | 14 | /** 15 | * @author itning 16 | */ 17 | @Data 18 | @IdClass(StudentRoomCheckMetaDataPrimaryKey.class) 19 | @Entity(name = "student_room_check_meta_data") 20 | public class StudentRoomCheckMetaData implements Serializable { 21 | /** 22 | * 学生寝室打卡时间 23 | */ 24 | public static final String KEY_ROOM_CHECK_TIME = "room_check_time"; 25 | /** 26 | * 学生寝室打卡坐标范围 27 | */ 28 | public static final String KEY_ROOM_CHECK_GPS_RANGE = "room_check_gps_range"; 29 | /** 30 | * KEY 31 | */ 32 | @Id 33 | @Column(name = "id", length = 50, columnDefinition = "char(50)") 34 | private String key; 35 | /** 36 | * VALUE 37 | */ 38 | @Column(nullable = false, columnDefinition = "text") 39 | private String value; 40 | /** 41 | * 所属辅导员的ID 42 | */ 43 | @Id 44 | @Column(nullable = false, columnDefinition = "char(36)", length = 36) 45 | private String belongCounselorId; 46 | /** 47 | * 创建时间 48 | */ 49 | @Column(nullable = false) 50 | @CreationTimestamp 51 | private Date gmtCreate; 52 | /** 53 | * 更新时间 54 | */ 55 | @Column(nullable = false) 56 | @UpdateTimestamp 57 | private Date gmtModified; 58 | } 59 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/StudentRoomCheckMetaDataPrimaryKey.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class StudentRoomCheckMetaDataPrimaryKey implements Serializable { 16 | private String key; 17 | private String belongCounselorId; 18 | } 19 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/entity/User.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.GenericGenerator; 6 | import org.hibernate.annotations.UpdateTimestamp; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * 用户 14 | * 15 | * @author itning 16 | */ 17 | @Data 18 | @Entity(name = "user") 19 | public class User implements Serializable { 20 | /** 21 | * 用户ID 22 | */ 23 | @Id 24 | @GeneratedValue(generator = "idGenerator") 25 | @GenericGenerator(name = "idGenerator", strategy = "org.hibernate.id.UUIDGenerator") 26 | @Column(length = 36, columnDefinition = "char(36)") 27 | private String id; 28 | /** 29 | * 用户姓名 30 | */ 31 | @Column(nullable = false) 32 | private String name; 33 | /** 34 | * 电话 35 | */ 36 | @Column(length = 11, columnDefinition = "char(11)") 37 | private String tel; 38 | /** 39 | * 邮箱 40 | */ 41 | private String email; 42 | /** 43 | * 用户名 44 | */ 45 | @Column(nullable = false, unique = true) 46 | private String username; 47 | /** 48 | * 角色 49 | */ 50 | @ManyToOne(optional = false) 51 | @JoinColumn(name = "roleId") 52 | private Role role; 53 | /** 54 | * 所对应的学生 55 | */ 56 | @OneToOne 57 | @PrimaryKeyJoinColumn 58 | private StudentUser studentUser; 59 | /** 60 | * 创建时间 61 | */ 62 | @Column(nullable = false) 63 | @CreationTimestamp 64 | private Date gmtCreate; 65 | /** 66 | * 更新时间 67 | */ 68 | @Column(nullable = false) 69 | @UpdateTimestamp 70 | private Date gmtModified; 71 | } 72 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/AppMetaException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class AppMetaException extends BaseException { 9 | public AppMetaException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/FileNotFoundException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class FileNotFoundException extends BaseException { 9 | public FileNotFoundException(String msg) { 10 | super(msg, HttpStatus.NOT_FOUND); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/GpsException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class GpsException extends BaseException { 9 | public GpsException(double longitude, double latitude) { 10 | super("GPS错误:" + longitude + ";" + latitude, HttpStatus.BAD_REQUEST); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/IllegalCheckException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 非法签到 7 | * 8 | * @author itning 9 | */ 10 | public class IllegalCheckException extends BaseException { 11 | public IllegalCheckException(String msg) { 12 | super(msg, HttpStatus.BAD_REQUEST); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/SavedException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class SavedException extends BaseException { 9 | public SavedException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/SecurityException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class SecurityException extends BaseException { 9 | public SecurityException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/exception/UserNameDoesNotExistException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class UserNameDoesNotExistException extends BaseException { 9 | public UserNameDoesNotExistException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/security/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.security; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private String roleId; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/security/MustCounselorLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.COUNSELOR) 12 | public @interface MustCounselorLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/security/MustLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target({ElementType.PARAMETER, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @Inherited 12 | public @interface MustLogin { 13 | /** 14 | * 登录角色 15 | * 16 | * @return 角色数组 17 | */ 18 | ROLE[] role(); 19 | 20 | enum ROLE { 21 | /** 22 | * 学生 23 | */ 24 | STUDENT("1", "学生"), 25 | /** 26 | * 教师 27 | */ 28 | TEACHER("2", "教师"), 29 | /** 30 | * 辅导员 31 | */ 32 | COUNSELOR("3", "辅导员"); 33 | 34 | private String id; 35 | private String name; 36 | 37 | ROLE(String id, String name) { 38 | this.id = id; 39 | this.name = name; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ROLE{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/security/MustStudentLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.STUDENT) 12 | public @interface MustStudentLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/security/MustTeacherLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.TEACHER) 12 | public @interface MustTeacherLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/security/SecurityArgumentResolversWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * MVC参数配置 12 | * 13 | * @author itning 14 | */ 15 | @Configuration 16 | public class SecurityArgumentResolversWebMvcConfig implements WebMvcConfigurer { 17 | private final SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver; 18 | 19 | @Autowired 20 | public SecurityArgumentResolversWebMvcConfig(SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver) { 21 | this.securityHandlerMethodArgumentResolver = securityHandlerMethodArgumentResolver; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(securityHandlerMethodArgumentResolver); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/service/RoomCheckMetaDataService.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.service; 2 | 3 | import top.itning.smp.smproom.security.LoginUser; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | public interface RoomCheckMetaDataService { 12 | /** 13 | * 现在可以进行学生寝室打卡 14 | * 15 | * @param loginUser 登录用户 16 | * @return 可以返回true 17 | */ 18 | boolean isNowCanRoomCheck(LoginUser loginUser); 19 | 20 | /** 21 | * 获取学生寝室允许打卡时间 22 | * 23 | * @param loginUser 登录用户 24 | * @return 寝室允许打卡时间 25 | */ 26 | Date getStudentCheckDate(LoginUser loginUser); 27 | 28 | /** 29 | * 获取GPS打卡范围 30 | * 31 | * @param loginUser 登录用户 32 | * @param isStudentLogin 学生登录? 33 | * @return 打卡范围 34 | */ 35 | List> getGpsRange(LoginUser loginUser, boolean isStudentLogin); 36 | 37 | /** 38 | * 更新学生寝室允许打卡时间 39 | * 40 | * @param dateString 打卡时间 41 | * @param loginUser 登录用户 42 | * @return 打卡时间 43 | */ 44 | String upStudentCheckDate(String dateString, LoginUser loginUser); 45 | 46 | /** 47 | * 修改允许打卡GPS坐标范围信息 48 | * 49 | * @param gps GPS坐标范围信息 50 | * @param loginUser 登录用户 51 | * @return GPS坐标范围信息 52 | */ 53 | List> upGpsRange(String gps, LoginUser loginUser); 54 | } 55 | -------------------------------------------------------------------------------- /smp-room/src/main/java/top/itning/smp/smproom/util/GpsUtils.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom.util; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class GpsUtils { 9 | private static final int MIN_SIZE = 3; 10 | public static final double MAX_LONGITUDE = 180.0D; 11 | public static final double MIN_LONGITUDE = -180.0D; 12 | public static final double MAX_LATITUDE = 90.0D; 13 | public static final double MIN_LATITUDE = -90.0D; 14 | 15 | public static boolean isPtInPoly(double lon, double lat, List> ps) { 16 | int iSum, iCount, iIndex; 17 | double dLon1, dLon2, dLat1, dLat2, dLon; 18 | if (ps.size() < MIN_SIZE) { 19 | return false; 20 | } 21 | iSum = 0; 22 | iCount = ps.size(); 23 | for (iIndex = 0; iIndex < iCount; iIndex++) { 24 | if (iIndex == iCount - 1) { 25 | dLon1 = ps.get(iIndex).get(0); 26 | dLat1 = ps.get(iIndex).get(1); 27 | dLon2 = ps.get(0).get(0); 28 | dLat2 = ps.get(0).get(1); 29 | } else { 30 | dLon1 = ps.get(iIndex).get(0); 31 | dLat1 = ps.get(iIndex).get(1); 32 | dLon2 = ps.get(iIndex + 1).get(0); 33 | dLat2 = ps.get(iIndex + 1).get(1); 34 | } 35 | // 以下语句判断A点是否在边的两端点的水平平行线之间,在则可能有交点,开始判断交点是否在左射线上 36 | if (((lat >= dLat1) && (lat < dLat2)) || ((lat >= dLat2) && (lat < dLat1))) { 37 | if (Math.abs(dLat1 - dLat2) > 0) { 38 | //得到 A点向左射线与边的交点的x坐标: 39 | dLon = dLon1 - ((dLon1 - dLon2) * (dLat1 - lat)) / (dLat1 - dLat2); 40 | // 如果交点在A点左侧(说明是做射线与 边的交点),则射线与边的全部交点数加一: 41 | if (dLon < lon) { 42 | iSum++; 43 | } 44 | } 45 | } 46 | } 47 | return (iSum % 2) != 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /smp-room/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-room/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-room/src/main/resources/seetaface.properties: -------------------------------------------------------------------------------- 1 | #依赖的lib名称,注意依赖关系顺序,用逗号隔开 2 | #linux os 3 | #libs=holiday,SeetaFaceDetector200,SeetaPointDetector200,SeetaFaceRecognizer200,SeetaFaceCropper200,SeetaFace2JNI 4 | #windows os 5 | libs=libgcc_s_sjlj-1,libeay32,libquadmath-0,ssleay32,libgfortran-3,libopenblas,holiday,SeetaFaceDetector200,SeetaPointDetector200,SeetaFaceRecognizer200,SeetaFaceCropper200,SeetaFace2JNI 6 | 7 | #依赖的lib存放目录, 等同于-Djava.library.path= 8 | #linux os 9 | #libs.path=/Users/apple/Documents/seetaface/lib 10 | #windows os 11 | libs.path=G:\\seetafaceJNI\\doc\\lib-win-x64\\lib 12 | 13 | #seetaface model目录 14 | #linux os 15 | #bindata.dir=/Users/apple/Documents/seetaface/bindata 16 | #windows os 17 | bindata.dir=G:\\seetafaceJNI\\bindata -------------------------------------------------------------------------------- /smp-room/src/test/java/top/itning/smp/smproom/SmpRoomApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smproom; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import top.itning.smp.smproom.dao.StudentRoomCheckMetaDataDao; 7 | import top.itning.smp.smproom.entity.StudentRoomCheckMetaData; 8 | 9 | @SpringBootTest 10 | class SmpRoomApplicationTests { 11 | @Autowired 12 | private StudentRoomCheckMetaDataDao studentRoomCheckMetaDataDao; 13 | 14 | @Test 15 | void contextLoads() { 16 | String counselorId = "1"; 17 | /*if (!studentRoomCheckMetaDataDao.existsById(new StudentRoomCheckMetaDataPrimaryKey(StudentRoomCheckMetaData.KEY_ROOM_CHECK_TIME, counselorId))) { 18 | StudentRoomCheckMetaData studentRoomCheckMetaData1 = new StudentRoomCheckMetaData(); 19 | studentRoomCheckMetaData1.setKey(StudentRoomCheckMetaData.KEY_ROOM_CHECK_TIME); 20 | studentRoomCheckMetaData1.setValue("20:30"); 21 | studentRoomCheckMetaData1.setBelongCounselorId(counselorId); 22 | studentRoomCheckMetaDataDao.save(studentRoomCheckMetaData1); 23 | }*/ 24 | StudentRoomCheckMetaData metaData = studentRoomCheckMetaDataDao.findByKeyAndBelongCounselorId(StudentRoomCheckMetaData.KEY_ROOM_CHECK_GPS_RANGE, counselorId); 25 | System.out.println(metaData); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /smp-security/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/SmpSecurityApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @SpringCloudApplication 11 | @EnableFeignClients 12 | public class SmpSecurityApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SmpSecurityApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/client/InfoClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import top.itning.smp.smpsecurity.client.entity.StudentUserDTO; 10 | import top.itning.smp.smpsecurity.client.entity.User; 11 | 12 | import java.util.Optional; 13 | 14 | /** 15 | * @author itning 16 | */ 17 | @FeignClient(name = "info") 18 | @Component 19 | public interface InfoClient { 20 | /** 21 | * 根据用户名获取用户信息 22 | * 23 | * @param username 用户名 24 | * @return 用户 25 | */ 26 | @GetMapping("/internal/user/{username}") 27 | Optional getUserInfoByUserName(@PathVariable String username); 28 | 29 | /** 30 | * 更改密码 31 | * 32 | * @param username 用户名 33 | * @param newPwd 新密码 34 | * @return 更改成功返回true 35 | */ 36 | @PostMapping("/internal/pwd/user/change") 37 | boolean changeUserPwd(@RequestParam String username, @RequestParam String newPwd); 38 | 39 | /** 40 | * 获取学生信息根据学号 41 | * 42 | * @param studentId 学号 43 | * @return 用户 44 | */ 45 | @GetMapping("/internal/student_user_id/{studentId}") 46 | StudentUserDTO getStudentUserDtoByStudentId(@PathVariable String studentId); 47 | } 48 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/client/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.client.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 角色 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class Role implements Serializable { 15 | /** 16 | * 角色ID 17 | */ 18 | private String id; 19 | /** 20 | * 角色名 21 | */ 22 | private String name; 23 | /** 24 | * 创建时间 25 | */ 26 | private Date gmtCreate; 27 | /** 28 | * 更新时间 29 | */ 30 | private Date gmtModified; 31 | } 32 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/client/entity/StudentUserDTO.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.client.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 学生信息DTO 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class StudentUserDTO implements Serializable { 15 | /** 16 | * 用户ID 17 | */ 18 | private String id; 19 | /** 20 | * 用户姓名 21 | */ 22 | private String name; 23 | /** 24 | * 电话 25 | */ 26 | private String tel; 27 | /** 28 | * 邮箱 29 | */ 30 | private String email; 31 | /** 32 | * 用户名 33 | */ 34 | private String username; 35 | /** 36 | * 角色 37 | */ 38 | private Role role; 39 | /** 40 | * 出生日期 41 | */ 42 | private Date birthday; 43 | /** 44 | * 性别(true 男; false 女) 45 | */ 46 | private Boolean sex; 47 | /** 48 | * 年龄 49 | */ 50 | private Integer age; 51 | /** 52 | * 学号 53 | */ 54 | private String studentId; 55 | /** 56 | * 该学生所属辅导员的ID 57 | */ 58 | private String belongCounselorId; 59 | /** 60 | * 身份证号 61 | */ 62 | private String idCard; 63 | /** 64 | * 政治面貌 65 | */ 66 | private String politicalStatus; 67 | /** 68 | * 民族 69 | */ 70 | private String ethnic; 71 | /** 72 | * 寝室号 73 | */ 74 | private String roomNum; 75 | /** 76 | * 床号 77 | */ 78 | private String bedNum; 79 | /** 80 | * 家庭地址 81 | */ 82 | private String address; 83 | /** 84 | * 创建时间 85 | */ 86 | private Date gmtCreate; 87 | /** 88 | * 更新时间 89 | */ 90 | private Date gmtModified; 91 | } 92 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/client/entity/User.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.client.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 用户 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class User implements Serializable { 15 | /** 16 | * 用户ID 17 | */ 18 | private String id; 19 | /** 20 | * 用户姓名 21 | */ 22 | private String name; 23 | /** 24 | * 电话 25 | */ 26 | private String tel; 27 | /** 28 | * 邮箱 29 | */ 30 | private String email; 31 | /** 32 | * 用户名 33 | */ 34 | private String username; 35 | /** 36 | * 密码 37 | */ 38 | private String password; 39 | /** 40 | * 角色 41 | */ 42 | private Role role; 43 | /** 44 | * 创建时间 45 | */ 46 | private Date gmtCreate; 47 | /** 48 | * 更新时间 49 | */ 50 | private Date gmtModified; 51 | } 52 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/config/HttpTraceActuatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.config; 2 | 3 | import org.springframework.boot.actuate.trace.http.HttpTraceRepository; 4 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Configuration 12 | public class HttpTraceActuatorConfiguration { 13 | @Bean 14 | public HttpTraceRepository httpTraceRepository() { 15 | return new InMemoryHttpTraceRepository(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/entity/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private Role role; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/entity/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.entity; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Rest 返回消息 10 | * 11 | * @author itning 12 | */ 13 | public class RestModel implements Serializable { 14 | private int code; 15 | private String msg; 16 | private T data; 17 | 18 | public RestModel() { 19 | 20 | } 21 | 22 | private RestModel(HttpStatus status, String msg, T data) { 23 | this(status.value(), msg, data); 24 | } 25 | 26 | private RestModel(int code, String msg, T data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public static ResponseEntity> ok(T data) { 33 | return ResponseEntity.ok(new RestModel<>(HttpStatus.OK, "查询成功", data)); 34 | } 35 | 36 | public static ResponseEntity> created() { 37 | return ResponseEntity.status(HttpStatus.CREATED).build(); 38 | } 39 | 40 | public static ResponseEntity> created(T data) { 41 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, "创建成功", data)); 42 | } 43 | 44 | public static ResponseEntity noContent() { 45 | return ResponseEntity.noContent().build(); 46 | } 47 | 48 | public int getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(int code) { 53 | this.code = code; 54 | } 55 | 56 | public String getMsg() { 57 | return msg; 58 | } 59 | 60 | public void setMsg(String msg) { 61 | this.msg = msg; 62 | } 63 | 64 | public T getData() { 65 | return data; 66 | } 67 | 68 | public void setData(T data) { 69 | this.data = data; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 角色 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class Role implements Serializable { 15 | public static final String STUDENT_ROLE_ID = "1"; 16 | public static final String STUDENT_ROLE_ID_STR = "学生"; 17 | public static final String TEACHER_ROLE_ID = "2"; 18 | public static final String TEACHER_ROLE_ID_STR = "教师"; 19 | public static final String COUNSELOR_ROLE_ID = "3"; 20 | public static final String COUNSELOR_ROLE_ID_STR = "辅导员"; 21 | 22 | /** 23 | * 角色ID 24 | */ 25 | private String id; 26 | /** 27 | * 角色名 28 | */ 29 | private String name; 30 | /** 31 | * 创建时间 32 | */ 33 | private Date gmtCreate; 34 | /** 35 | * 更新时间 36 | */ 37 | private Date gmtModified; 38 | } 39 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/exception/TokenException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class TokenException extends BaseException { 9 | public TokenException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/exception/UserNameDoesNotExistException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class UserNameDoesNotExistException extends BaseException { 9 | public UserNameDoesNotExistException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/exception/UserPasswordException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class UserPasswordException extends BaseException { 9 | public UserPasswordException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/security/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.security; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private String roleId; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/security/MustCounselorLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.COUNSELOR) 12 | public @interface MustCounselorLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/security/MustLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target({ElementType.PARAMETER, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @Inherited 12 | public @interface MustLogin { 13 | /** 14 | * 登录角色 15 | * 16 | * @return 角色数组 17 | */ 18 | ROLE[] role(); 19 | 20 | enum ROLE { 21 | /** 22 | * 学生 23 | */ 24 | STUDENT("1", "学生"), 25 | /** 26 | * 教师 27 | */ 28 | TEACHER("2", "教师"), 29 | /** 30 | * 辅导员 31 | */ 32 | COUNSELOR("3", "辅导员"); 33 | 34 | private String id; 35 | private String name; 36 | 37 | ROLE(String id, String name) { 38 | this.id = id; 39 | this.name = name; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ROLE{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/security/MustStudentLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.STUDENT) 12 | public @interface MustStudentLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/security/MustTeacherLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.TEACHER) 12 | public @interface MustTeacherLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/security/SecurityArgumentResolversWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * MVC参数配置 12 | * 13 | * @author itning 14 | */ 15 | @Configuration 16 | public class SecurityArgumentResolversWebMvcConfig implements WebMvcConfigurer { 17 | private final SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver; 18 | 19 | @Autowired 20 | public SecurityArgumentResolversWebMvcConfig(SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver) { 21 | this.securityHandlerMethodArgumentResolver = securityHandlerMethodArgumentResolver; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(securityHandlerMethodArgumentResolver); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/service/SecurityService.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.service; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import top.itning.smp.smpsecurity.security.LoginUser; 5 | 6 | /** 7 | * @author itning 8 | */ 9 | public interface SecurityService { 10 | /** 11 | * 登录 12 | * 13 | * @param username 用户名 14 | * @param password 密码 15 | * @return TOKEN 16 | * @throws JsonProcessingException see {@link JsonProcessingException} 17 | */ 18 | String login(String username, String password) throws JsonProcessingException; 19 | 20 | /** 21 | * 修改密码 22 | * 23 | * @param loginUser 登录用户 24 | * @param newPassword 新密码 25 | */ 26 | void changePwd(LoginUser loginUser, String newPassword); 27 | 28 | /** 29 | * 重置密码 30 | * 31 | * @param loginUser 登录用户 32 | * @param studentId 学生ID 33 | */ 34 | void resetPwd(LoginUser loginUser, String studentId); 35 | } 36 | -------------------------------------------------------------------------------- /smp-security/src/main/java/top/itning/smp/smpsecurity/util/OrikaUtils.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity.util; 2 | 3 | import ma.glasnost.orika.MapperFactory; 4 | import ma.glasnost.orika.impl.DefaultMapperFactory; 5 | import org.springframework.lang.NonNull; 6 | import org.springframework.lang.Nullable; 7 | 8 | /** 9 | * 实体映射工具类 10 | * 11 | * @author itning 12 | */ 13 | public class OrikaUtils { 14 | private static final MapperFactory MAPPER_FACTORY = new DefaultMapperFactory.Builder().build(); 15 | 16 | /** 17 | * 将两个实体合并为一个DTO 18 | * input1,input2 不能全为 {@code null} 19 | * 20 | * @param input1 第一个输入实体 21 | * @param input2 第二个输入实体 22 | * @param result DTO类型 23 | * @param DTO 24 | * @param ENTITY 25 | * @param ENTITY 26 | * @return DTO类型 27 | */ 28 | @NonNull 29 | public static R doubleEntity2Dto(@Nullable A input1, @Nullable B input2, @NonNull Class result) { 30 | if (input1 != null && input2 != null) { 31 | R r = MAPPER_FACTORY.getMapperFacade().map(input1, result); 32 | MAPPER_FACTORY.getMapperFacade().map(input2, r); 33 | return r; 34 | } else if (input1 != null) { 35 | return MAPPER_FACTORY.getMapperFacade().map(input1, result); 36 | } else { 37 | return MAPPER_FACTORY.getMapperFacade().map(input2, result); 38 | } 39 | } 40 | 41 | /** 42 | * A 实体 转换 B 实体 43 | * 44 | * @param a A实例 45 | * @param bClass B类型 46 | * @param A 47 | * @param B 48 | * @return B 实例 49 | */ 50 | public static B a2b(A a, Class bClass) { 51 | return MAPPER_FACTORY.getMapperFacade().map(a, bClass); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /smp-security/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-security/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-security/src/test/java/top/itning/smp/smpsecurity/SmpSecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpsecurity; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpSecurityApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /smp-statistics/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/** 4 | !**/src/test/** 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | build/ 28 | 29 | ### VS Code ### 30 | .vscode/ 31 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/SmpStatisticsApplication.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @SpringCloudApplication 11 | @EnableFeignClients 12 | public class SmpStatisticsApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SmpStatisticsApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/client/ClassClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import top.itning.smp.smpstatistics.entity.ClassComing; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @FeignClient(name = "class") 13 | @Component 14 | public interface ClassClient { 15 | /** 16 | * 获取某天所有课堂出勤信息 17 | * 18 | * @param startDate 开始日期 19 | * @param endDate 结束日期 20 | * @return 出勤信息 21 | */ 22 | @GetMapping("/internal/class_coming/count") 23 | ClassComing classComingCount(@RequestParam String startDate, @RequestParam String endDate); 24 | } 25 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/client/InfoClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import top.itning.smp.smpstatistics.client.entity.User; 8 | import top.itning.smp.smpstatistics.entity.ApartmentStatistics; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | /** 14 | * @author itning 15 | */ 16 | @FeignClient(name = "info") 17 | @Component 18 | public interface InfoClient { 19 | /** 20 | * 获取所有公寓信息 21 | * 22 | * @return 公寓信息集合 23 | */ 24 | @GetMapping("/internal/apartments") 25 | List getAllApartment(); 26 | 27 | /** 28 | * 计算学生人数 29 | * 30 | * @param username 导员用户名 31 | * @return 学生数量 32 | */ 33 | @GetMapping("/internal/student_user/count/{username}") 34 | long countStudent(@PathVariable String username); 35 | 36 | /** 37 | * 获取所有辅导员用户 38 | * 39 | * @return 辅导员用户 40 | */ 41 | @GetMapping("/internal/counselor/users") 42 | List getAllCounselorUser(); 43 | 44 | /** 45 | * 根据用户名获取用户信息 46 | * 47 | * @param username 用户名 48 | * @return 用户 49 | */ 50 | @GetMapping("/internal/user/{username}") 51 | Optional getUserInfoByUserName(@PathVariable String username); 52 | } 53 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/client/LeaveClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @FeignClient(name = "leave") 12 | @Component 13 | public interface LeaveClient { 14 | /** 15 | * 计算请假人数 16 | * 17 | * @param startDate 开始日期 18 | * @param endDate 结束日期 19 | * @param username 导员用户名,如果为空则不要这个查询条件 20 | * @return 请假人数 21 | */ 22 | @GetMapping("/internal/leave/count") 23 | long countAllLeave(@RequestParam String startDate, @RequestParam String endDate, @RequestParam(required = false) String username); 24 | } 25 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/client/RoomClient.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | @FeignClient(name = "room") 13 | @Component 14 | public interface RoomClient { 15 | /** 16 | * 计算某天归寝人数 17 | * 18 | * @param startDate 开始日期 19 | * @param endDate 结束日期 20 | * @param username 导员用户名 21 | * @return 人数 22 | */ 23 | @GetMapping("/internal/coming/count/{username}") 24 | long comingRoomCount(@RequestParam String startDate, @RequestParam String endDate, @PathVariable String username); 25 | } 26 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/client/entity/User.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.client.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 用户 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class User implements Serializable { 15 | /** 16 | * 用户ID 17 | */ 18 | private String id; 19 | /** 20 | * 用户姓名 21 | */ 22 | private String name; 23 | /** 24 | * 电话 25 | */ 26 | private String tel; 27 | /** 28 | * 邮箱 29 | */ 30 | private String email; 31 | /** 32 | * 用户名 33 | */ 34 | private String username; 35 | /** 36 | * 密码 37 | */ 38 | private String password; 39 | /** 40 | * 创建时间 41 | */ 42 | private Date gmtCreate; 43 | /** 44 | * 更新时间 45 | */ 46 | private Date gmtModified; 47 | } 48 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/config/HttpTraceActuatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.config; 2 | 3 | import org.springframework.boot.actuate.trace.http.HttpTraceRepository; 4 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Configuration 12 | public class HttpTraceActuatorConfiguration { 13 | @Bean 14 | public HttpTraceRepository httpTraceRepository() { 15 | return new InMemoryHttpTraceRepository(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/AllCounselor.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import lombok.Data; 4 | import top.itning.smp.smpstatistics.client.entity.User; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author itning 10 | */ 11 | @Data 12 | public class AllCounselor implements Serializable { 13 | private User user; 14 | private ClassComing classComing; 15 | private HomeComing homeComing; 16 | private Leave leave; 17 | } 18 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/ApartmentStatistics.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class ApartmentStatistics implements Serializable { 12 | /** 13 | * 公寓名 14 | */ 15 | private String name; 16 | /** 17 | * 人数 18 | */ 19 | private long people; 20 | } 21 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/ClassComing.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class ClassComing implements Serializable { 12 | private long sum; 13 | private long coming; 14 | } 15 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/HomeComing.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class HomeComing implements Serializable { 12 | /** 13 | * 总人数 14 | */ 15 | private long sum; 16 | /** 17 | * 归寝数 18 | */ 19 | private long coming; 20 | } 21 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/Leave.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class Leave implements Serializable { 12 | /** 13 | * 总人数 14 | */ 15 | private long sum; 16 | /** 17 | * 请假数 18 | */ 19 | private long leave; 20 | } 21 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Rest 返回消息 10 | * 11 | * @author itning 12 | */ 13 | public class RestModel implements Serializable { 14 | private int code; 15 | private String msg; 16 | private T data; 17 | 18 | public RestModel() { 19 | 20 | } 21 | 22 | private RestModel(HttpStatus status, String msg, T data) { 23 | this(status.value(), msg, data); 24 | } 25 | 26 | private RestModel(int code, String msg, T data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public static ResponseEntity> ok(T data) { 33 | return ResponseEntity.ok(new RestModel<>(HttpStatus.OK, "查询成功", data)); 34 | } 35 | 36 | public static ResponseEntity> created() { 37 | return ResponseEntity.status(HttpStatus.CREATED).build(); 38 | } 39 | 40 | public static ResponseEntity> created(T data) { 41 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, "创建成功", data)); 42 | } 43 | 44 | public static ResponseEntity noContent() { 45 | return ResponseEntity.noContent().build(); 46 | } 47 | 48 | public int getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(int code) { 53 | this.code = code; 54 | } 55 | 56 | public String getMsg() { 57 | return msg; 58 | } 59 | 60 | public void setMsg(String msg) { 61 | this.msg = msg; 62 | } 63 | 64 | public T getData() { 65 | return data; 66 | } 67 | 68 | public void setData(T data) { 69 | this.data = data; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/entity/Role.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * 角色 10 | * 11 | * @author itning 12 | */ 13 | @Data 14 | public class Role implements Serializable { 15 | public static final String STUDENT_ROLE_ID = "1"; 16 | public static final String STUDENT_ROLE_ID_STR = "学生"; 17 | public static final String TEACHER_ROLE_ID = "2"; 18 | public static final String TEACHER_ROLE_ID_STR = "教师"; 19 | public static final String COUNSELOR_ROLE_ID = "3"; 20 | public static final String COUNSELOR_ROLE_ID_STR = "辅导员"; 21 | 22 | /** 23 | * 角色ID 24 | */ 25 | private String id; 26 | /** 27 | * 角色名 28 | */ 29 | private String name; 30 | /** 31 | * 创建时间 32 | */ 33 | private Date gmtCreate; 34 | /** 35 | * 更新时间 36 | */ 37 | private Date gmtModified; 38 | } 39 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author itning 9 | */ 10 | public abstract class BaseException extends RuntimeException { 11 | private String msg; 12 | private HttpStatus code; 13 | 14 | public BaseException(String msg, HttpStatus code) { 15 | super(msg); 16 | this.msg = msg; 17 | this.code = code; 18 | } 19 | 20 | public String getMsg() { 21 | return msg; 22 | } 23 | 24 | public void setMsg(String msg) { 25 | this.msg = msg; 26 | } 27 | 28 | public HttpStatus getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(HttpStatus code) { 33 | this.code = code; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/exception/SecurityException.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | public class SecurityException extends BaseException { 9 | public SecurityException(String msg, HttpStatus code) { 10 | super(msg, code); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/security/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.security; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author itning 9 | */ 10 | @Data 11 | public class LoginUser implements Serializable { 12 | private String name; 13 | private String username; 14 | private String roleId; 15 | private String email; 16 | private String tel; 17 | } 18 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/security/MustCounselorLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.COUNSELOR) 12 | public @interface MustCounselorLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/security/MustLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target({ElementType.PARAMETER, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @Inherited 12 | public @interface MustLogin { 13 | /** 14 | * 登录角色 15 | * 16 | * @return 角色数组 17 | */ 18 | ROLE[] role(); 19 | 20 | enum ROLE { 21 | /** 22 | * 学生 23 | */ 24 | STUDENT("1", "学生"), 25 | /** 26 | * 教师 27 | */ 28 | TEACHER("2", "教师"), 29 | /** 30 | * 辅导员 31 | */ 32 | COUNSELOR("3", "辅导员"); 33 | 34 | private String id; 35 | private String name; 36 | 37 | ROLE(String id, String name) { 38 | this.id = id; 39 | this.name = name; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ROLE{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | '}'; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/security/MustStudentLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.STUDENT) 12 | public @interface MustStudentLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/security/MustTeacherLogin.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.security; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author itning 7 | */ 8 | @Target(ElementType.PARAMETER) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Documented 11 | @MustLogin(role = MustLogin.ROLE.TEACHER) 12 | public @interface MustTeacherLogin { 13 | } 14 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/security/SecurityArgumentResolversWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.security; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * MVC参数配置 12 | * 13 | * @author itning 14 | */ 15 | @Configuration 16 | public class SecurityArgumentResolversWebMvcConfig implements WebMvcConfigurer { 17 | private final SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver; 18 | 19 | @Autowired 20 | public SecurityArgumentResolversWebMvcConfig(SecurityHandlerMethodArgumentResolver securityHandlerMethodArgumentResolver) { 21 | this.securityHandlerMethodArgumentResolver = securityHandlerMethodArgumentResolver; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(securityHandlerMethodArgumentResolver); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /smp-statistics/src/main/java/top/itning/smp/smpstatistics/service/StatisticsService.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics.service; 2 | 3 | import top.itning.smp.smpstatistics.entity.*; 4 | import top.itning.smp.smpstatistics.security.LoginUser; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * @author itning 11 | */ 12 | public interface StatisticsService { 13 | /** 14 | * 获取各公寓人数 15 | * 16 | * @return 各公寓人数集合 17 | */ 18 | List getApartmentChart(); 19 | 20 | /** 21 | * 某天归寝信息 22 | * 23 | * @param date 哪天 24 | * @param loginUser 登录用户 25 | * @return 归寝信息 26 | */ 27 | HomeComing getHomeComingChart(Date date, LoginUser loginUser); 28 | 29 | /** 30 | * 请假信息 31 | * 32 | * @param date 哪天 33 | * @param loginUser 登录用户 34 | * @return 请假信息 35 | */ 36 | Leave getLeaveChart(Date date, LoginUser loginUser); 37 | 38 | /** 39 | * 出勤信息 40 | * 41 | * @param date 哪天 42 | * @param loginUser 登录用户 43 | * @return 出勤信息 44 | */ 45 | ClassComing getClassComingChart(Date date, LoginUser loginUser); 46 | 47 | /** 48 | * 辅导员各项数据 49 | * 50 | * @param loginUser 登录用汉语 51 | * @param startDate 开始日期 52 | * @param endDate 结束日期 53 | * @return 所有数据 54 | */ 55 | List getAllCounselorChart(LoginUser loginUser, Date startDate, Date endDate); 56 | } 57 | -------------------------------------------------------------------------------- /smp-statistics/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/smp-server/515da18d462ab5d403cdd547126af2d6eb819091/smp-statistics/src/main/resources/bootstrap.properties -------------------------------------------------------------------------------- /smp-statistics/src/test/java/top/itning/smp/smpstatistics/SmpStatisticsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package top.itning.smp.smpstatistics; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SmpStatisticsApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------