├── tmpp-core └── src │ ├── main │ ├── resources │ │ ├── execute_plan_template.xlsx │ │ ├── application-dev.yml │ │ ├── application-docker.yml │ │ ├── application.yml │ │ └── logback.xml │ └── java │ │ └── top │ │ └── sl │ │ └── tmpp │ │ └── core │ │ ├── TMPPApplication.java │ │ ├── config │ │ └── CustomWebMvcConfig.java │ │ └── exception │ │ ├── ErrorHandler.java │ │ └── ExceptionResolver.java │ └── test │ └── java │ └── top │ └── sl │ └── tmpp │ ├── export │ ├── mapper │ │ └── ExportMapperTest.java │ └── service │ │ └── ExportServiceTest.java │ ├── security │ └── mapper │ │ └── CasMapperTest.java │ ├── plan │ └── service │ │ └── ReferPlanServiceTest.java │ └── purchase │ └── service │ └── PurchaseServiceTest.java ├── tmpp-common ├── src │ └── main │ │ ├── resources │ │ ├── context.properties │ │ ├── mappers │ │ │ ├── PlanBookMapper.xml │ │ │ ├── CasMapper.xml │ │ │ ├── DepartmentMapper.xml │ │ │ ├── DiscountsMapper.xml │ │ │ ├── LevelMapper.xml │ │ │ ├── CollegesMapper.xml │ │ │ └── LoginUserMapper.xml │ │ └── generatorConfig.xml │ │ └── java │ │ └── top │ │ └── sl │ │ └── tmpp │ │ └── common │ │ ├── mapper │ │ ├── PlanBookMapper.java │ │ ├── LoginUserMapper.java │ │ ├── LevelMapper.java │ │ ├── DiscountsMapper.java │ │ ├── DepartmentMapper.java │ │ ├── CasMapper.java │ │ ├── CollegesMapper.java │ │ ├── ExecutePlanMapper.java │ │ ├── PlanMapper.java │ │ ├── BookMapper.java │ │ └── ExportMapper.java │ │ ├── exception │ │ ├── EmptyParameterException.java │ │ ├── IdNotFoundException.java │ │ ├── IllegalParameterException.java │ │ ├── PermissionException.java │ │ └── BaseException.java │ │ ├── entity │ │ ├── PlanBook.java │ │ ├── Colleges.java │ │ ├── Department.java │ │ ├── Discounts.java │ │ ├── Level.java │ │ ├── AdminResource.java │ │ ├── LoginUser.java │ │ ├── AdminUser.java │ │ ├── ExecutePlan.java │ │ └── Plan.java │ │ ├── pojo │ │ ├── CourseDTO.java │ │ ├── PublisherStatistics.java │ │ ├── StudentReceiveBook.java │ │ ├── ExecutePlanDTO.java │ │ ├── PurchasingMaterials.java │ │ ├── TeacherReceiveBook.java │ │ ├── SubscriptionBook.java │ │ └── SubscriptionBookPlan.java │ │ └── util │ │ ├── RestModel.java │ │ └── ObjectUtils.java └── pom.xml ├── tmpp-security ├── src │ ├── main │ │ └── java │ │ │ └── top │ │ │ └── sl │ │ │ └── tmpp │ │ │ └── security │ │ │ ├── exception │ │ │ ├── RoleException.java │ │ │ ├── CasException.java │ │ │ └── BaseLoginException.java │ │ │ ├── cas │ │ │ ├── config │ │ │ │ └── CasConfigImpl.java │ │ │ ├── LoginUserArgumentResolver.java │ │ │ └── callback │ │ │ │ └── JwtCasCallBackImpl.java │ │ │ └── util │ │ │ └── JwtUtils.java │ └── test │ │ └── java │ │ └── top │ │ └── sl │ │ └── tmpp │ │ └── security │ │ └── util │ │ └── JwtUtilsTest.java └── pom.xml ├── .gitignore ├── tmpp-plan ├── src │ └── main │ │ └── java │ │ └── top │ │ └── sl │ │ └── tmpp │ │ └── plan │ │ ├── service │ │ ├── FileService.java │ │ ├── ReferPlanService.java │ │ └── impl │ │ │ └── FileServiceImpl.java │ │ ├── exception │ │ ├── AddPlanException.java │ │ ├── ApiException.java │ │ ├── FileException.java │ │ ├── FileIsNullException.java │ │ ├── FileTypeException.java │ │ └── ExcelReadException.java │ │ ├── entity │ │ └── CourseEducationalCache.java │ │ ├── util │ │ └── FileUtil.java │ │ └── controller │ │ └── PlanController.java └── pom.xml ├── tmpp-export ├── src │ └── main │ │ └── java │ │ └── top │ │ └── sl │ │ └── tmpp │ │ └── export │ │ ├── util │ │ └── Tuple.java │ │ ├── service │ │ └── ExportService.java │ │ └── controller │ │ └── ExportController.java └── pom.xml ├── tmpp-discounts ├── src │ ├── test │ │ └── java │ │ │ └── top │ │ │ └── sl │ │ │ └── tmpp │ │ │ └── acquire │ │ │ ├── service │ │ │ └── DiscountsServiceTest.java │ │ │ └── controller │ │ │ └── DiscountsControllerTest.java │ └── main │ │ └── java │ │ └── top │ │ └── sl │ │ └── tmpp │ │ └── discounts │ │ ├── service │ │ ├── DiscountsService.java │ │ └── impl │ │ │ └── DiscountsServiceImpl.java │ │ └── controller │ │ └── DiscountsController.java └── pom.xml ├── tmpp-acquire ├── pom.xml └── src │ └── main │ └── java │ └── top │ └── sl │ └── tmpp │ └── acquire │ ├── service │ ├── AcquireService.java │ └── impl │ │ └── AcquireServiceImpl.java │ └── controller │ └── AcquireController.java ├── tmpp-review ├── pom.xml └── src │ └── main │ └── java │ └── top │ └── sl │ └── tmpp │ └── review │ ├── service │ ├── ReviewService.java │ └── impl │ │ └── ReviewServiceImpl.java │ └── controller │ └── ReviewController.java ├── tmpp-purchase ├── pom.xml └── src │ └── main │ └── java │ └── top │ └── sl │ └── tmpp │ └── purchase │ └── service │ ├── PurchaseService.java │ └── impl │ └── PurchaseServiceImpl.java ├── README.md └── mvnw.cmd /tmpp-core/src/main/resources/execute_plan_template.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itning/TMPP/master/tmpp-core/src/main/resources/execute_plan_template.xlsx -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/context.properties: -------------------------------------------------------------------------------- 1 | driverClass=com.mysql.jdbc.Driver 2 | jdbcUrl=jdbc:mysql:///tmpp?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=0&serverTimezone=UTC 3 | user=root 4 | password=shulu -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/PlanBookMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.entity.PlanBook; 5 | 6 | public interface PlanBookMapper { 7 | int insert(PlanBook record); 8 | 9 | int insertSelective(PlanBook record); 10 | 11 | int deleteByPlanId(@Param("planId") String planId); 12 | } -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/exception/RoleException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * @author itning 7 | * @date 2019/6/17 19:29 8 | */ 9 | public class RoleException extends BaseLoginException { 10 | public RoleException(String msg, HttpStatus code) { 11 | super(msg, code); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/exception/CasException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.exception; 2 | 3 | 4 | import org.springframework.http.HttpStatus; 5 | 6 | /** 7 | * CAS 异常 8 | * 9 | * @author itning 10 | * @date 2019/6/17 8:54 11 | */ 12 | public class CasException extends BaseLoginException { 13 | public CasException(String msg, HttpStatus code) { 14 | super(msg, code); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ 25 | /build/ 26 | 27 | ### VS Code ### 28 | .vscode/ 29 | 30 | .mvn/ 31 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/service/FileService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | /** 6 | * @author ShuLu 7 | * @date 2019/6/17 15:10 8 | */ 9 | public interface FileService { 10 | /** 11 | * 上传执行计划文件 12 | * 13 | * @param file {@link MultipartFile} 14 | * @return 文件名 15 | */ 16 | String fileUpload(MultipartFile file); 17 | } 18 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/exception/EmptyParameterException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 所需不为空的参数为空 7 | * 8 | * @author ShuLu 9 | * @date 2019/6/24 15:26 10 | */ 11 | public class EmptyParameterException extends BaseException { 12 | public EmptyParameterException(String msg) { 13 | super(msg, HttpStatus.BAD_REQUEST); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/exception/IdNotFoundException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * ID不存在 7 | * 8 | * @author ShuLu 9 | * @date 2019/6/30 13:07 10 | */ 11 | public class IdNotFoundException extends BaseException { 12 | public IdNotFoundException(String id) { 13 | super("ID:" + id + "不存在", HttpStatus.BAD_REQUEST); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/exception/IllegalParameterException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 非法参数异常 7 | * 8 | * @author itning 9 | * @date 2019/7/2 9:43 10 | */ 11 | public class IllegalParameterException extends BaseException { 12 | public IllegalParameterException(String msg) { 13 | super(msg, HttpStatus.BAD_REQUEST); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/exception/AddPlanException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * @author ShuLu 8 | * @date 2019/6/23 13:52 9 | */ 10 | public class AddPlanException extends BaseException { 11 | public AddPlanException(String msg, HttpStatus code) { 12 | super(msg, code); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/exception/ApiException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * @author itning 8 | * @date 2019/7/3 10:35 9 | */ 10 | public class ApiException extends BaseException { 11 | public ApiException(String msg) { 12 | super(msg, HttpStatus.SERVICE_UNAVAILABLE); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/exception/FileException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * @author ShuLu 8 | * @date 2019/6/23 15:05 9 | */ 10 | public class FileException extends BaseException { 11 | 12 | public FileException(String msg, HttpStatus code) { 13 | super(msg, code); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/exception/FileIsNullException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * @author ShuLu 8 | * @date 2019/6/17 15:38 9 | */ 10 | public class FileIsNullException extends BaseException { 11 | public FileIsNullException(String msg, HttpStatus code) { 12 | super(msg, code); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/exception/FileTypeException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * @author ShuLu 8 | * @date 2019/6/22 13:32 9 | */ 10 | public class FileTypeException extends BaseException { 11 | 12 | public FileTypeException(String msg, HttpStatus code) { 13 | super(msg, code); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tmpp-export/src/main/java/top/sl/tmpp/export/util/Tuple.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.export.util; 2 | 3 | /** 4 | * @author ShuLu 5 | * @date 2019/6/27 14:00 6 | */ 7 | public class Tuple { 8 | private final T1 t1; 9 | private final T2 t2; 10 | 11 | public Tuple(T1 t1, T2 t2) { 12 | this.t1 = t1; 13 | this.t2 = t2; 14 | } 15 | 16 | public T1 getT1() { 17 | return t1; 18 | } 19 | 20 | public T2 getT2() { 21 | return t2; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/exception/BaseLoginException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * 登录时发生的异常 8 | * 9 | * @author itning 10 | * @date 2019/6/17 8:49 11 | */ 12 | public abstract class BaseLoginException extends BaseException { 13 | 14 | public BaseLoginException(String msg, HttpStatus code) { 15 | super(msg, code); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/LoginUserMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import top.sl.tmpp.common.entity.LoginUser; 4 | 5 | public interface LoginUserMapper { 6 | int deleteByPrimaryKey(String id); 7 | 8 | int insert(LoginUser record); 9 | 10 | int insertSelective(LoginUser record); 11 | 12 | LoginUser selectByPrimaryKey(String id); 13 | 14 | int updateByPrimaryKeySelective(LoginUser record); 15 | 16 | int updateByPrimaryKey(LoginUser record); 17 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/exception/PermissionException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 权限不足/横向越权 7 | * 8 | * @author ShuLu 9 | * @date 2019/6/30 13:05 10 | */ 11 | public class PermissionException extends BaseException { 12 | public PermissionException() { 13 | this("FORBIDDEN"); 14 | } 15 | 16 | public PermissionException(String msg) { 17 | super(msg, HttpStatus.FORBIDDEN); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tmpp-core/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | username: ${MYSQL_USERNAME} 4 | password: ${MYSQL_PASSWORD} 5 | url: jdbc:mysql://${MYSQL_URL}/tmpp?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=0&serverTimezone=UTC&allowPublicKeyRetrieval=true 6 | logging: 7 | level: debug 8 | level.top: debug 9 | cas: 10 | login-success-url: http://localhost:8081 11 | local-server-url: http://localhost:8080 -------------------------------------------------------------------------------- /tmpp-core/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | spring: 4 | datasource: 5 | username: ${MYSQL_USERNAME} 6 | password: ${MYSQL_PASSWORD} 7 | url: jdbc:mysql://${MYSQL_URL}/tmpp?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=0&serverTimezone=UTC&allowPublicKeyRetrieval=true 8 | logging: 9 | level: warn 10 | level.top: warn 11 | cas: 12 | login-success-url: ${LOGIN_SUCCESS_URL} 13 | local-server-url: ${LOCAL_SERVER_URL} -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/LevelMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import top.sl.tmpp.common.entity.Level; 4 | 5 | import java.util.List; 6 | 7 | public interface LevelMapper { 8 | int deleteByPrimaryKey(String id); 9 | 10 | int insert(Level record); 11 | 12 | int insertSelective(Level record); 13 | 14 | Level selectByPrimaryKey(String id); 15 | 16 | int updateByPrimaryKeySelective(Level record); 17 | 18 | int updateByPrimaryKey(Level record); 19 | 20 | List selectAll(); 21 | } -------------------------------------------------------------------------------- /tmpp-discounts/src/test/java/top/sl/tmpp/acquire/service/DiscountsServiceTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.acquire.service; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | import top.sl.tmpp.discounts.service.DiscountsService; 8 | 9 | @SpringBootTest(classes = DiscountsService.class) 10 | @RunWith(SpringRunner.class) 11 | public class DiscountsServiceTest { 12 | 13 | @Test 14 | public void save() { 15 | } 16 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/DiscountsMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import top.sl.tmpp.common.entity.Discounts; 4 | 5 | import java.util.List; 6 | 7 | public interface DiscountsMapper { 8 | int deleteByPrimaryKey(String id); 9 | 10 | int insert(Discounts record); 11 | 12 | int insertSelective(Discounts record); 13 | 14 | Discounts selectByPrimaryKey(String id); 15 | 16 | int updateByPrimaryKeySelective(Discounts record); 17 | 18 | int updateByPrimaryKey(Discounts record); 19 | 20 | List selectAll(); 21 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/DepartmentMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import top.sl.tmpp.common.entity.Department; 4 | 5 | import java.util.List; 6 | 7 | public interface DepartmentMapper { 8 | int deleteByPrimaryKey(String id); 9 | 10 | int insert(Department record); 11 | 12 | int insertSelective(Department record); 13 | 14 | Department selectByPrimaryKey(String id); 15 | 16 | int updateByPrimaryKeySelective(Department record); 17 | 18 | int updateByPrimaryKey(Department record); 19 | 20 | List selectAll(); 21 | 22 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/CasMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.entity.AdminResource; 5 | import top.sl.tmpp.common.entity.AdminUser; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author ShuLu 11 | * @date 2019/6/24 15:14 12 | */ 13 | public interface CasMapper { 14 | List getResourcesByUserName(@Param("username") String username); 15 | 16 | AdminUser selectByUserName(@Param("username") String username); 17 | 18 | List getResourcesByUserTypeIsTeacher(); 19 | } 20 | -------------------------------------------------------------------------------- /tmpp-core/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | datasource: 5 | driver-class-name: com.mysql.jdbc.Driver 6 | jackson: 7 | time-zone: Asia/Shanghai 8 | servlet: 9 | multipart: 10 | max-file-size: 1024MB 11 | max-request-size: 1024MB 12 | enabled: true 13 | server: 14 | port: 8080 15 | mybatis: 16 | type-aliases-package: top.sl.tmpp.common.entity,top.sl.tmpp.common.pojo 17 | mapper-locations: classpath:mappers/*.xml 18 | cas: 19 | enabled: true 20 | debug: true 21 | server-url: http://login.greathiit.com 22 | login-url: http://login.greathiit.com/login 23 | logout-url: http://login.greathiit.com/logout -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/CollegesMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.entity.Colleges; 5 | 6 | import java.util.List; 7 | 8 | public interface CollegesMapper { 9 | int deleteByPrimaryKey(String id); 10 | 11 | int insert(Colleges record); 12 | 13 | int insertSelective(Colleges record); 14 | 15 | Colleges selectByPrimaryKey(String id); 16 | 17 | int updateByPrimaryKeySelective(Colleges record); 18 | 19 | int updateByPrimaryKey(Colleges record); 20 | 21 | List selectAll(); 22 | 23 | String selectIdByName(@Param("name") String name); 24 | } -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/exception/ExcelReadException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import top.sl.tmpp.common.exception.BaseException; 5 | 6 | /** 7 | * @author ShuLu 8 | * @date 2019/6/24 20:10 9 | */ 10 | public class ExcelReadException extends BaseException { 11 | /** 12 | * @param row 行 13 | * @param cell 列 14 | */ 15 | public ExcelReadException(int row, int cell, String msg) { 16 | super("第" + row + "行第" + cell + "列 " + msg, HttpStatus.BAD_REQUEST); 17 | } 18 | 19 | public ExcelReadException(int row, int cell) { 20 | this(row, cell, "为空"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tmpp-security/src/test/java/top/sl/tmpp/security/util/JwtUtilsTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.util; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import top.sl.tmpp.common.entity.LoginUser; 5 | 6 | public class JwtUtilsTest { 7 | 8 | @org.junit.Test 9 | public void buildJwt() throws JsonProcessingException { 10 | LoginUser loginUser = new LoginUser(); 11 | loginUser.setId("14008"); 12 | loginUser.setName("舒露"); 13 | loginUser.setUserType("13"); 14 | 15 | 16 | String s = JwtUtils.buildJwt(loginUser); 17 | System.out.println(s); 18 | } 19 | 20 | @org.junit.Test 21 | public void getLoginUser() { 22 | } 23 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/PlanBook.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | public class PlanBook { 4 | private String planId; 5 | 6 | private String bookId; 7 | 8 | public PlanBook(String planId, String bookId) { 9 | this.planId = planId; 10 | this.bookId = bookId; 11 | } 12 | 13 | public PlanBook() { 14 | super(); 15 | } 16 | 17 | public String getPlanId() { 18 | return planId; 19 | } 20 | 21 | public void setPlanId(String planId) { 22 | this.planId = planId == null ? null : planId.trim(); 23 | } 24 | 25 | public String getBookId() { 26 | return bookId; 27 | } 28 | 29 | public void setBookId(String bookId) { 30 | this.bookId = bookId == null ? null : bookId.trim(); 31 | } 32 | } -------------------------------------------------------------------------------- /tmpp-discounts/src/main/java/top/sl/tmpp/discounts/service/DiscountsService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.discounts.service; 2 | 3 | import top.sl.tmpp.common.entity.Discounts; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.List; 7 | 8 | /** 9 | * @author ShuLu 10 | */ 11 | public interface DiscountsService { 12 | /** 13 | * 添加折扣 14 | * @param discount 折扣信息 15 | */ 16 | void save(BigDecimal discount); 17 | 18 | /** 19 | * 获取所有折扣哦 20 | * @return 折扣集合 21 | */ 22 | List getAllDiscount(); 23 | 24 | /** 25 | * 删除折扣信息 26 | * @param id 折扣id 27 | */ 28 | void remove(String id); 29 | 30 | /** 31 | *修改折扣 32 | * @param id 折扣id 33 | * @param decimal 折扣信息 34 | */ 35 | void modify(String id,BigDecimal decimal); 36 | } 37 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | /** 6 | * 异常基类 7 | * 8 | * @author ShuLu 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 | -------------------------------------------------------------------------------- /tmpp-core/src/test/java/top/sl/tmpp/export/mapper/ExportMapperTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.export.mapper; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | import top.sl.tmpp.common.mapper.ExportMapper; 9 | import top.sl.tmpp.core.TMPPApplication; 10 | 11 | /** 12 | * @author ShuLu 13 | * @date 2019/6/29 16:19 14 | */ 15 | @SpringBootTest(classes = TMPPApplication.class) 16 | @RunWith(SpringRunner.class) 17 | public class ExportMapperTest { 18 | @Autowired 19 | private ExportMapper exportMapper; 20 | 21 | @Test 22 | public void selectBookMaterials() { 23 | exportMapper.selectBookMaterials("2017-2018", null, null, false); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tmpp-acquire/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-acquire 13 | 14 | 15 | top.sl.tmpp 16 | tmpp-common 17 | 18 | 19 | com.github.pagehelper 20 | pagehelper-spring-boot-starter 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tmpp-review/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-review 13 | 14 | 15 | 16 | top.sl.tmpp 17 | tmpp-common 18 | 19 | 20 | com.github.pagehelper 21 | pagehelper-spring-boot-starter 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/service/ReferPlanService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.service; 2 | 3 | import top.sl.tmpp.common.entity.ExecutePlan; 4 | 5 | /** 6 | * @author ShuLu 7 | * @date 2019/6/17 12:18 8 | */ 9 | public interface ReferPlanService { 10 | /** 11 | * 提交执行计划 12 | * 13 | * @param year 学年 14 | * @param term 学期 15 | * @param teachingDepartment 授课部门 16 | * @param educationalLevel 教育层次 17 | * @param fileId 执行计划文件 ID 18 | */ 19 | void referPlan(String year, boolean term, String teachingDepartment, String educationalLevel, String fileId); 20 | 21 | /** 22 | * 查询需下载的执行计划 23 | * 24 | * @param id 执行计划id 25 | * @return 执行计划 26 | */ 27 | ExecutePlan downloadExecutePlan(String id); 28 | 29 | /** 30 | * 删除执行计划 31 | * 32 | * @param id 删除的执行计划id 33 | */ 34 | void removeExecutePlan(String id); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /tmpp-core/src/main/java/top/sl/tmpp/core/TMPPApplication.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.core; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | 9 | /** 10 | * @author ShuLu 11 | */ 12 | @SpringBootApplication(scanBasePackages = "top.sl.tmpp") 13 | @MapperScan("top.sl.tmpp.common.mapper") 14 | public class TMPPApplication { 15 | private static final Logger logger = LoggerFactory.getLogger(TMPPApplication.class); 16 | 17 | public static void main(String[] args) { 18 | logger.info("MYSQL::url: {}", System.getenv("MYSQL_URL")); 19 | logger.info("MYSQL::username: {}", System.getenv("MYSQL_USERNAME")); 20 | logger.info("MYSQL::password: {}", System.getenv("MYSQL_PASSWORD")); 21 | SpringApplication.run(TMPPApplication.class, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/cas/config/CasConfigImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.cas.config; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.springframework.http.HttpHeaders; 5 | import org.springframework.stereotype.Component; 6 | import top.itning.cas.config.ICheckIsLoginConfig; 7 | import top.itning.cas.config.INeedSetMap2SessionConfig; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | /** 13 | * Cas配置实现 14 | * 15 | * @author itning 16 | */ 17 | @Component 18 | public class CasConfigImpl implements ICheckIsLoginConfig, INeedSetMap2SessionConfig { 19 | 20 | @Override 21 | public boolean isLogin(HttpServletResponse resp, HttpServletRequest req) { 22 | return StringUtils.isNotBlank(req.getHeader(HttpHeaders.AUTHORIZATION)); 23 | } 24 | 25 | @Override 26 | public boolean needSetMapSession() { 27 | return false; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/ExecutePlanMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.entity.ExecutePlan; 5 | import top.sl.tmpp.common.pojo.ExecutePlanDTO; 6 | 7 | import java.util.List; 8 | 9 | public interface ExecutePlanMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(ExecutePlan record); 13 | 14 | int insertSelective(ExecutePlan record); 15 | 16 | ExecutePlan selectByPrimaryKey(String id); 17 | 18 | int updateByPrimaryKeySelective(ExecutePlan record); 19 | 20 | int updateByPrimaryKeyWithBLOBs(ExecutePlan record); 21 | 22 | int updateByPrimaryKey(ExecutePlan record); 23 | 24 | List selectAll(); 25 | 26 | List selectDistinctYear(); 27 | 28 | List selectTermByYear(@Param("year") String year); 29 | 30 | ExecutePlan selectFileById(@Param("id") String id); 31 | 32 | List selectByStatus(@Param("status") Boolean status); 33 | } -------------------------------------------------------------------------------- /tmpp-core/src/test/java/top/sl/tmpp/security/mapper/CasMapperTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.mapper; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | import top.sl.tmpp.common.entity.AdminResource; 9 | import top.sl.tmpp.common.mapper.CasMapper; 10 | import top.sl.tmpp.core.TMPPApplication; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author itning 16 | * @date 2019/6/29 19:29 17 | */ 18 | @SpringBootTest(classes = TMPPApplication.class) 19 | @RunWith(SpringRunner.class) 20 | public class CasMapperTest { 21 | @Autowired 22 | private CasMapper casMapper; 23 | 24 | @Test 25 | public void getResourcesByUserName() { 26 | List list = casMapper.getResourcesByUserName("0002"); 27 | System.out.println(list.size()); 28 | list.forEach(System.out::println); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tmpp-core/src/test/java/top/sl/tmpp/plan/service/ReferPlanServiceTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.service; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | import top.sl.tmpp.core.TMPPApplication; 9 | 10 | /** 11 | * @author ShuLu 12 | * @date 2019/6/17 12:18 13 | */ 14 | @SpringBootTest(classes = TMPPApplication.class) 15 | @RunWith(SpringRunner.class) 16 | public class ReferPlanServiceTest { 17 | @Autowired 18 | private ReferPlanService referPlanService; 19 | 20 | @Test 21 | public void referPlan() { 22 | referPlanService.referPlan("2017-2018", false, "1", "1", "执行计划模板.xlsx"); 23 | } 24 | 25 | @Test 26 | public void downloadExecutePlan() { 27 | } 28 | 29 | @Test 30 | public void removeExecutePlan() { 31 | referPlanService.removeExecutePlan("f6f495bdfa644609ab9a33a6c6ce66e8"); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/PlanMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.entity.Plan; 5 | import top.sl.tmpp.common.pojo.CourseDTO; 6 | 7 | import java.util.List; 8 | 9 | public interface PlanMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(Plan record); 13 | 14 | int insertSelective(Plan record); 15 | 16 | Plan selectByPrimaryKey(String id); 17 | 18 | int updateByPrimaryKeySelective(Plan record); 19 | 20 | int updateByPrimaryKey(Plan record); 21 | 22 | long countByCourseId(@Param("courseId") String courseId); 23 | 24 | List selectByExecutePlanId(String id); 25 | 26 | List selectByExecutePlanIdAndCourseCode(@Param("executePlanId") String executePlanId, @Param("courseCode") String courseCode); 27 | 28 | List selectCourseByExecutePlanId(@Param("executePlanId") String executePlanId); 29 | 30 | List selectAllByExecutePlanGroupByBookId(@Param("executePlanId") String executePlanId); 31 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/CourseDTO.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | /** 4 | * 课程信息DTO 5 | * 6 | * @author itning 7 | * @date 2019/7/1 15:24 8 | */ 9 | public class CourseDTO { 10 | private String courseCode; 11 | private String courseName; 12 | 13 | public CourseDTO() { 14 | } 15 | 16 | public CourseDTO(String courseCode, String courseName) { 17 | this.courseCode = courseCode; 18 | this.courseName = courseName; 19 | } 20 | 21 | public String getCourseCode() { 22 | return courseCode; 23 | } 24 | 25 | public void setCourseCode(String courseCode) { 26 | this.courseCode = courseCode; 27 | } 28 | 29 | public String getCourseName() { 30 | return courseName; 31 | } 32 | 33 | public void setCourseName(String courseName) { 34 | this.courseName = courseName; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "CourseDTO{" + 40 | "courseCode='" + courseCode + '\'' + 41 | ", courseName='" + courseName + '\'' + 42 | '}'; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tmpp-purchase/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-purchase 13 | 14 | 15 | 16 | com.github.pagehelper 17 | pagehelper-spring-boot-starter 18 | 19 | 20 | top.sl.tmpp 21 | tmpp-common 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-test 27 | test 28 | 29 | 30 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/BookMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.entity.Book; 5 | import top.sl.tmpp.common.pojo.BookDTO; 6 | import top.sl.tmpp.common.pojo.BookReviewDTO; 7 | 8 | import java.util.List; 9 | 10 | public interface BookMapper { 11 | int deleteByPrimaryKey(String id); 12 | 13 | int insert(Book record); 14 | 15 | int insertSelective(Book record); 16 | 17 | Book selectByPrimaryKey(String id); 18 | 19 | int updateByPrimaryKeySelective(Book record); 20 | 21 | int updateByPrimaryKey(Book record); 22 | 23 | List selectMyBook(@Param("loginUserId") String loginUserId, @Param("executePlanId") String executePlanId); 24 | 25 | List selectReviews(@Param("executePlanId") String executePlanId); 26 | 27 | List selectAllByExecutePlanId(@Param("executePlanId") String executePlanId); 28 | 29 | List selectIdAndStatus(@Param("executePlanId") String executePlanId); 30 | 31 | List selectByPlanId(@Param("planId") String planId); 32 | 33 | long countByExecutePlanAndStatusNot2(@Param("executePlanId") String executePlanId); 34 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/PublisherStatistics.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | /** 4 | * 出版社统计数量表 5 | * 6 | * @author ShuLu 7 | * @date 2019/6/26 11:18 8 | */ 9 | public class PublisherStatistics { 10 | /** 11 | * 学院名称 12 | */ 13 | private String collegesName; 14 | /** 15 | * 出版社 16 | */ 17 | private String press; 18 | /** 19 | * 总数 20 | */ 21 | private Integer total; 22 | 23 | public PublisherStatistics() { 24 | } 25 | 26 | public PublisherStatistics(String collegesName, String press, Integer total) { 27 | this.collegesName = collegesName; 28 | this.press = press; 29 | this.total = total; 30 | } 31 | 32 | public String getCollegesName() { 33 | return collegesName; 34 | } 35 | 36 | public void setCollegesName(String collegesName) { 37 | this.collegesName = collegesName; 38 | } 39 | 40 | public String getPress() { 41 | return press; 42 | } 43 | 44 | public void setPress(String press) { 45 | this.press = press; 46 | } 47 | 48 | public Integer getTotal() { 49 | return total; 50 | } 51 | 52 | public void setTotal(Integer total) { 53 | this.total = total; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tmpp-discounts/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-discounts 13 | 14 | 15 | 16 | top.sl.tmpp 17 | tmpp-common 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-test 26 | test 27 | 28 | 29 | org.apache.commons 30 | commons-lang3 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/Colleges.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Colleges { 6 | private String id; 7 | 8 | private String name; 9 | 10 | private Date gmtModified; 11 | 12 | private Date gmtCreate; 13 | 14 | public Colleges(String id, String name, Date gmtModified, Date gmtCreate) { 15 | this.id = id; 16 | this.name = name; 17 | this.gmtModified = gmtModified; 18 | this.gmtCreate = gmtCreate; 19 | } 20 | 21 | public Colleges() { 22 | super(); 23 | } 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id == null ? null : id.trim(); 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name == null ? null : name.trim(); 39 | } 40 | 41 | public Date getGmtModified() { 42 | return gmtModified; 43 | } 44 | 45 | public void setGmtModified(Date gmtModified) { 46 | this.gmtModified = gmtModified; 47 | } 48 | 49 | public Date getGmtCreate() { 50 | return gmtCreate; 51 | } 52 | 53 | public void setGmtCreate(Date gmtCreate) { 54 | this.gmtCreate = gmtCreate; 55 | } 56 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/Department.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Department { 6 | private String id; 7 | 8 | private String name; 9 | 10 | private Date gmtModified; 11 | 12 | private Date gmtCreate; 13 | 14 | public Department(String id, String name, Date gmtModified, Date gmtCreate) { 15 | this.id = id; 16 | this.name = name; 17 | this.gmtModified = gmtModified; 18 | this.gmtCreate = gmtCreate; 19 | } 20 | 21 | public Department() { 22 | super(); 23 | } 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id == null ? null : id.trim(); 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name == null ? null : name.trim(); 39 | } 40 | 41 | public Date getGmtModified() { 42 | return gmtModified; 43 | } 44 | 45 | public void setGmtModified(Date gmtModified) { 46 | this.gmtModified = gmtModified; 47 | } 48 | 49 | public Date getGmtCreate() { 50 | return gmtCreate; 51 | } 52 | 53 | public void setGmtCreate(Date gmtCreate) { 54 | this.gmtCreate = gmtCreate; 55 | } 56 | } -------------------------------------------------------------------------------- /tmpp-core/src/main/java/top/sl/tmpp/core/config/CustomWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.core.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 5 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | import top.sl.tmpp.common.mapper.CasMapper; 8 | import top.sl.tmpp.security.cas.LoginUserArgumentResolver; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author itning 14 | * @date 2019/6/17 8:43 15 | */ 16 | @Configuration 17 | public class CustomWebMvcConfig implements WebMvcConfigurer { 18 | private final CasMapper casMapper; 19 | 20 | public CustomWebMvcConfig(CasMapper casMapper) { 21 | this.casMapper = casMapper; 22 | } 23 | 24 | @Override 25 | public void addArgumentResolvers(List resolvers) { 26 | resolvers.add(new LoginUserArgumentResolver(casMapper)); 27 | } 28 | 29 | @Override 30 | public void addCorsMappings(CorsRegistry registry) { 31 | registry.addMapping("/**") 32 | .allowedOrigins("*") 33 | .allowCredentials(true) 34 | .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH") 35 | .maxAge(3600); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/Discounts.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class Discounts { 7 | private String id; 8 | 9 | private BigDecimal discount; 10 | 11 | private Date gmtModified; 12 | 13 | private Date gmtCreate; 14 | 15 | public Discounts(String id, BigDecimal discount, Date gmtModified, Date gmtCreate) { 16 | this.id = id; 17 | this.discount = discount; 18 | this.gmtModified = gmtModified; 19 | this.gmtCreate = gmtCreate; 20 | } 21 | 22 | public Discounts() { 23 | super(); 24 | } 25 | 26 | public String getId() { 27 | return id; 28 | } 29 | 30 | public void setId(String id) { 31 | this.id = id == null ? null : id.trim(); 32 | } 33 | 34 | public BigDecimal getDiscount() { 35 | return discount; 36 | } 37 | 38 | public void setDiscount(BigDecimal discount) { 39 | this.discount = discount; 40 | } 41 | 42 | public Date getGmtModified() { 43 | return gmtModified; 44 | } 45 | 46 | public void setGmtModified(Date gmtModified) { 47 | this.gmtModified = gmtModified; 48 | } 49 | 50 | public Date getGmtCreate() { 51 | return gmtCreate; 52 | } 53 | 54 | public void setGmtCreate(Date gmtCreate) { 55 | this.gmtCreate = gmtCreate; 56 | } 57 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 教材管理系统 2 | 3 | [![GitHub stars](https://img.shields.io/github/stars/itning/TMPP.svg?style=social&label=Stars)](https://github.com/itning/TMPP/stargazers) 4 | [![GitHub forks](https://img.shields.io/github/forks/itning/TMPP.svg?style=social&label=Fork)](https://github.com/itning/TMPP/network/members) 5 | [![GitHub watchers](https://img.shields.io/github/watchers/itning/TMPP.svg?style=social&label=Watch)](https://github.com/itning/TMPP/watchers) 6 | [![GitHub followers](https://img.shields.io/github/followers/itning.svg?style=social&label=Follow)](https://github.com/itning?tab=followers) 7 | 8 | [![GitHub issues](https://img.shields.io/github/issues/itning/TMPP.svg)](https://github.com/itning/TMPP/issues) 9 | [![GitHub license](https://img.shields.io/github/license/itning/TMPP.svg)](https://github.com/itning/TMPP/blob/master/LICENSE) 10 | [![GitHub last commit](https://img.shields.io/github/last-commit/itning/TMPP.svg)](https://github.com/itning/TMPP/commits) 11 | [![GitHub release](https://img.shields.io/github/release/itning/TMPP.svg)](https://github.com/itning/TMPP/releases) 12 | [![GitHub repo size in bytes](https://img.shields.io/github/repo-size/itning/TMPP.svg)](https://github.com/itning/TMPP) 13 | [![HitCount](http://hits.dwyl.io/itning/TMPP.svg)](http://hits.dwyl.io/itning/TMPP) 14 | [![language](https://img.shields.io/badge/language-JAVA-green.svg)](https://github.com/itning/TMPP) 15 | 16 | [README](https://github.com/HXCI-Studio/TMPP-Info) 17 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/Level.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Level { 6 | private String id; 7 | 8 | private String educationalLevel; 9 | 10 | private Date gmtModified; 11 | 12 | private Date gmtCreate; 13 | 14 | public Level(String id, String educationalLevel, Date gmtModified, Date gmtCreate) { 15 | this.id = id; 16 | this.educationalLevel = educationalLevel; 17 | this.gmtModified = gmtModified; 18 | this.gmtCreate = gmtCreate; 19 | } 20 | 21 | public Level() { 22 | super(); 23 | } 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id == null ? null : id.trim(); 31 | } 32 | 33 | public String getEducationalLevel() { 34 | return educationalLevel; 35 | } 36 | 37 | public void setEducationalLevel(String educationalLevel) { 38 | this.educationalLevel = educationalLevel == null ? null : educationalLevel.trim(); 39 | } 40 | 41 | public Date getGmtModified() { 42 | return gmtModified; 43 | } 44 | 45 | public void setGmtModified(Date gmtModified) { 46 | this.gmtModified = gmtModified; 47 | } 48 | 49 | public Date getGmtCreate() { 50 | return gmtCreate; 51 | } 52 | 53 | public void setGmtCreate(Date gmtCreate) { 54 | this.gmtCreate = gmtCreate; 55 | } 56 | } -------------------------------------------------------------------------------- /tmpp-export/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-export 13 | 14 | 15 | 16 | top.sl.tmpp 17 | tmpp-common 18 | 19 | 20 | 21 | commons-codec 22 | commons-codec 23 | 24 | 25 | commons-fileupload 26 | commons-fileupload 27 | 28 | 29 | 30 | org.apache.poi 31 | poi 32 | 33 | 34 | org.apache.poi 35 | poi-ooxml 36 | 37 | 38 | -------------------------------------------------------------------------------- /tmpp-plan/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-plan 13 | 14 | 15 | 16 | top.sl.tmpp 17 | tmpp-common 18 | 19 | 20 | 21 | commons-codec 22 | commons-codec 23 | 24 | 25 | commons-fileupload 26 | commons-fileupload 27 | 28 | 29 | 30 | org.apache.poi 31 | poi 32 | 33 | 34 | org.apache.poi 35 | poi-ooxml 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /tmpp-core/src/test/java/top/sl/tmpp/export/service/ExportServiceTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.export.service; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | import top.sl.tmpp.core.TMPPApplication; 9 | 10 | /** 11 | * @author ShuLu 12 | * @date 2019/6/26 14:32 13 | */ 14 | @SpringBootTest(classes = TMPPApplication.class) 15 | @RunWith(SpringRunner.class) 16 | public class ExportServiceTest { 17 | @Autowired 18 | private ExportService exportService; 19 | @Test 20 | public void procurementTable(){ 21 | //exportService.procurementTable("ccf4c148bcef4d7592b34ca0a3bcd586"); 22 | } 23 | @Test 24 | public void studentClassBookTable() { 25 | //exportService.studentClassBookTable("ccf4c148bcef4d7592b34ca0a3bcd586"); 26 | } 27 | @Test 28 | public void publishingHouseStatistics(){ 29 | //exportService.publishingHouseStatistics("ccf4c148bcef4d7592b34ca0a3bcd586"); 30 | } 31 | @Test 32 | public void subscriptionBook(){ 33 | //exportService.subscriptionBook("ccf4c148bcef4d7592b34ca0a3bcd586"); 34 | } 35 | @Test 36 | public void TeacherReceiveBook(){ 37 | //exportService.TeacherReceiveBook("ccf4c148bcef4d7592b34ca0a3bcd586"); 38 | } 39 | 40 | @Test 41 | public void SummaryTable(){ 42 | //exportService.summaryTable("ccf4c148bcef4d7592b34ca0a3bcd586"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tmpp-core/src/test/java/top/sl/tmpp/purchase/service/PurchaseServiceTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.purchase.service; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | import top.sl.tmpp.common.entity.Book; 8 | import top.sl.tmpp.core.TMPPApplication; 9 | 10 | @SpringBootTest(classes = TMPPApplication.class) 11 | @RunWith(SpringRunner.class) 12 | public class PurchaseServiceTest { 13 | @Autowired 14 | private PurchaseService purchaseService; 15 | 16 | @org.junit.Test 17 | public void saveBook() { 18 | Book book = new Book(); 19 | // book.setIsbn("9787547240502"); 20 | // book.setTextBookName("逻辑思维训练大脑提高记忆力学习力书籍"); 21 | // book.setTextBookCategory(false); 22 | // book.setPress("吉林文史出版社"); 23 | // book.setAuthor("好多人"); 24 | // book.setUnitPrice(new BigDecimal("39.80")); 25 | // book.setTeacherBookNumber(2); 26 | // book.setDiscountId("1"); 27 | // book.setAwardInformation("什么什么"); 28 | // book.setPublicationDate(new Date()); 29 | // book.setSubscriber("订阅"); 30 | // book.setSubscriberTel("17645458836"); 31 | book.setIsBookPurchase(false); 32 | book.setReason("不想买"); 33 | book.setLoginUserId("0002"); 34 | } 35 | 36 | @org.junit.Test 37 | public void getAllTeacherBooks() { 38 | 39 | } 40 | 41 | @org.junit.Test 42 | public void upTeacherBook() { 43 | } 44 | } -------------------------------------------------------------------------------- /tmpp-security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-security 13 | 14 | 15 | 16 | top.sl.tmpp 17 | tmpp-common 18 | 19 | 20 | com.github.itning 21 | cas-spring-boot-starter 22 | 23 | 24 | org.apache.commons 25 | commons-lang3 26 | 27 | 28 | io.jsonwebtoken 29 | jjwt 30 | 31 | 32 | com.google.guava 33 | guava 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | -------------------------------------------------------------------------------- /tmpp-review/src/main/java/top/sl/tmpp/review/service/ReviewService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.review.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import top.sl.tmpp.common.pojo.BookDTO; 5 | 6 | 7 | /** 8 | * @author itning 9 | * @date 2019/6/23 11:35 10 | */ 11 | public interface ReviewService { 12 | /** 13 | * 办公室主任我的审核 14 | * 15 | * @param executePlanId 执行计划id 16 | * @param page 页数 17 | * @param size 每页大小 18 | * @return {@link PageInfo} 19 | */ 20 | PageInfo getDirectorReview(String executePlanId, int page, int size); 21 | 22 | /** 23 | * 教务处我的审核 24 | * 25 | * @param executePlanId 执行计划id 26 | * @param page 页数 27 | * @param size 每页大小 28 | * @return {@link PageInfo} 29 | */ 30 | PageInfo getMyReview(String executePlanId, int page, int size); 31 | 32 | /** 33 | * 教务处是否购买样书 34 | * 35 | * @param id 购书计划id 36 | * @param is 是1 否0 37 | */ 38 | void isByBook(String id, boolean is); 39 | 40 | /** 41 | * 办公室主任全部审核通过 42 | * 43 | * @param executePlanId 执行计划ID 44 | */ 45 | void oAllPassed(String executePlanId); 46 | 47 | /** 48 | * 教务处全部审核通过 49 | * 50 | * @param executePlanId 执行计划ID 51 | */ 52 | void aAllPassed(String executePlanId); 53 | 54 | /** 55 | * 办公室主任驳回 56 | * 57 | * @param id 购书计划id 58 | */ 59 | void oTurnDown(String id); 60 | 61 | /** 62 | * 教务处驳回 63 | * 64 | * @param id 购书计划id 65 | */ 66 | void aTurnDown(String id); 67 | } 68 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/PlanBookMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | insert into plan_book (plan_id, book_id) 12 | values (#{planId,jdbcType=VARCHAR}, #{bookId,jdbcType=VARCHAR}) 13 | 14 | 15 | insert into plan_book 16 | 17 | 18 | plan_id, 19 | 20 | 21 | book_id, 22 | 23 | 24 | 25 | 26 | #{planId,jdbcType=VARCHAR}, 27 | 28 | 29 | #{bookId,jdbcType=VARCHAR}, 30 | 31 | 32 | 33 | 34 | delete 35 | from plan_book 36 | where plan_id = #{planId,jdbcType=VARCHAR} 37 | 38 | -------------------------------------------------------------------------------- /tmpp-core/src/main/java/top/sl/tmpp/core/exception/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.core.exception; 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 | * @author itning 17 | * @date 2019/6/17 9:25 18 | */ 19 | @RestController 20 | public class ErrorHandler implements ErrorController { 21 | private final ErrorAttributes errorAttributes; 22 | 23 | @Autowired 24 | public ErrorHandler(ErrorAttributes errorAttributes) { 25 | this.errorAttributes = errorAttributes; 26 | } 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 | -------------------------------------------------------------------------------- /tmpp-acquire/src/main/java/top/sl/tmpp/acquire/service/AcquireService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.acquire.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import top.sl.tmpp.common.entity.*; 5 | import top.sl.tmpp.common.pojo.CourseDTO; 6 | import top.sl.tmpp.common.pojo.ExecutePlanDTO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author ShuLu 12 | * @date 2019/6/24 14:41 13 | */ 14 | public interface AcquireService { 15 | /** 16 | * 获取所有学院 17 | * 18 | * @return colleges 19 | */ 20 | List getAllCollege(); 21 | 22 | /** 23 | * 获取所有课程 24 | * 25 | * @param executePlanId 执行计划ID 26 | * @return 所有课程集合 27 | */ 28 | List getAllCourse(String executePlanId); 29 | 30 | /** 31 | * 获取所有授课部门 32 | * 33 | * @return departments 34 | */ 35 | List getAllDepartment(); 36 | 37 | /** 38 | * 执行计划 39 | * 40 | * @param page 页码 41 | * @param size 数量 42 | * @return 执行计划集合 43 | */ 44 | PageInfo getAllExecutePlan(int page, int size); 45 | 46 | /** 47 | * 获取所有层次 48 | * 49 | * @return 所有层次集合 50 | */ 51 | List getAllLevel(); 52 | 53 | /** 54 | * 获取未完成执行计划 55 | * 56 | * @return 未完成执行计划集合 57 | */ 58 | List getAllUnDoneExecutePlan(); 59 | 60 | /** 61 | * 获取执行计划年 62 | * 63 | * @return 执行计划年集合 64 | */ 65 | List getYears(); 66 | 67 | /** 68 | * 获取计划学期 69 | * 70 | * @param year 学年 71 | * @return 计划学期 72 | */ 73 | List getTerms(String year); 74 | 75 | /** 76 | * 获取已完成执行计划 77 | * 78 | * @return 已完成执行计划集合 79 | */ 80 | List getAllDoneExecutePlan(); 81 | } 82 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/entity/CourseEducationalCache.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.entity; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.http.client.SimpleClientHttpRequestFactory; 7 | import org.springframework.web.client.RestTemplate; 8 | import top.sl.tmpp.plan.exception.ApiException; 9 | 10 | import java.util.Map; 11 | import java.util.Optional; 12 | import java.util.stream.Collectors; 13 | 14 | /** 15 | * @author itning 16 | * @date 2019/7/3 8:55 17 | */ 18 | public class CourseEducationalCache { 19 | private static final Logger logger = LoggerFactory.getLogger(CourseEducationalCache.class); 20 | private static Map courseMap; 21 | private static RestTemplate restTemplate; 22 | 23 | static { 24 | SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); 25 | //ms 26 | factory.setReadTimeout(5000); 27 | //ms 28 | factory.setConnectTimeout(5000); 29 | restTemplate = new RestTemplate(factory); 30 | refreshCourseMap(); 31 | } 32 | 33 | public static void refreshCourseMap() { 34 | ResponseEntity responseEntity = restTemplate.getForEntity("http://www.greathiit.com/api/getCourseEducational", CourseEducational.class); 35 | CourseEducational body = responseEntity.getBody(); 36 | if (body == null || body.getResult() == null) { 37 | throw new ApiException("API获取课程信息失败"); 38 | } 39 | courseMap = body.getResult().parallelStream().collect(Collectors.toMap(CourseEducational.ResultBean::getCursNum, CourseEducational.ResultBean::getCursName)); 40 | logger.debug("course map size: {}", courseMap.size()); 41 | } 42 | 43 | public static Optional getCourseName(String courseCode) { 44 | return Optional.ofNullable(courseMap.get(courseCode)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tmpp-discounts/src/test/java/top/sl/tmpp/acquire/controller/DiscountsControllerTest.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.acquire.controller; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.web.servlet.MockMvc; 13 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 14 | import org.springframework.web.context.WebApplicationContext; 15 | import top.sl.tmpp.discounts.controller.DiscountsController; 16 | 17 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; 18 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 20 | 21 | @SpringBootTest(classes = DiscountsController.class) 22 | @RunWith(SpringRunner.class) 23 | public class DiscountsControllerTest { 24 | private Logger log = LoggerFactory.getLogger(DiscountsControllerTest.class); 25 | private MockMvc mockMvc; 26 | @Autowired 27 | protected WebApplicationContext wac; 28 | 29 | @Before() //这个方法在每个方法执行之前都会执行一遍 30 | public void setup() { 31 | mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); //初始化MockMvc对象 32 | } 33 | 34 | @Test 35 | public void saveDiscount() throws Exception { 36 | mockMvc.perform( 37 | post("/discount") 38 | .contentType(MediaType.APPLICATION_FORM_URLENCODED) 39 | .content("discount=" + 0.76) 40 | ).andExpect(status().isOk()) 41 | .andDo(print()) //打印出请求和相应的内容 42 | .andReturn().getResponse().getContentAsString(); 43 | } 44 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/util/RestModel.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.util; 2 | 3 | 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * Rest 返回消息 12 | * 13 | * @author shulu 14 | */ 15 | @Component 16 | public class RestModel implements Serializable { 17 | private int code; 18 | private String msg; 19 | private T data; 20 | 21 | public RestModel() { 22 | } 23 | 24 | public RestModel(int code, String msg, T data) { 25 | this.code = code; 26 | this.msg = msg; 27 | this.data = data; 28 | } 29 | 30 | public RestModel(int code, String msg) { 31 | this.code = code; 32 | this.msg = msg; 33 | } 34 | 35 | public RestModel(HttpStatus status, String msg, T data) { 36 | this(status.value(), msg, data); 37 | } 38 | 39 | public RestModel(T data) { 40 | this(HttpStatus.OK.value(), "查询成功", data); 41 | } 42 | 43 | 44 | public static ResponseEntity ok(T data) { 45 | return ResponseEntity.ok(new RestModel<>(data)); 46 | } 47 | 48 | public static ResponseEntity created(String msg, T data) { 49 | return ResponseEntity.status(HttpStatus.CREATED).body(new RestModel<>(HttpStatus.CREATED, msg, data)); 50 | } 51 | 52 | public static ResponseEntity noContent() { 53 | return ResponseEntity.noContent().build(); 54 | } 55 | 56 | public int getCode() { 57 | return code; 58 | } 59 | 60 | public void setCode(int code) { 61 | this.code = code; 62 | } 63 | 64 | public String getMsg() { 65 | return msg; 66 | } 67 | 68 | public void setMsg(String msg) { 69 | this.msg = msg; 70 | } 71 | 72 | public T getData() { 73 | return data; 74 | } 75 | 76 | public void setData(T data) { 77 | this.data = data; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/AdminResource.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class AdminResource { 6 | private String id; 7 | 8 | private String url; 9 | 10 | private String method; 11 | 12 | private Date gmtCreate; 13 | 14 | private Date gmtModified; 15 | 16 | public AdminResource(String id, String url, String method, Date gmtCreate, Date gmtModified) { 17 | this.id = id; 18 | this.url = url; 19 | this.method = method; 20 | this.gmtCreate = gmtCreate; 21 | this.gmtModified = gmtModified; 22 | } 23 | 24 | public AdminResource() { 25 | super(); 26 | } 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id == null ? null : id.trim(); 34 | } 35 | 36 | public String getUrl() { 37 | return url; 38 | } 39 | 40 | public void setUrl(String url) { 41 | this.url = url == null ? null : url.trim(); 42 | } 43 | 44 | public String getMethod() { 45 | return method; 46 | } 47 | 48 | public void setMethod(String method) { 49 | this.method = method == null ? null : method.trim(); 50 | } 51 | 52 | public Date getGmtCreate() { 53 | return gmtCreate; 54 | } 55 | 56 | public void setGmtCreate(Date gmtCreate) { 57 | this.gmtCreate = gmtCreate; 58 | } 59 | 60 | public Date getGmtModified() { 61 | return gmtModified; 62 | } 63 | 64 | public void setGmtModified(Date gmtModified) { 65 | this.gmtModified = gmtModified; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "AdminResource{" + 71 | "id='" + id + '\'' + 72 | ", url='" + url + '\'' + 73 | ", method='" + method + '\'' + 74 | ", gmtCreate=" + gmtCreate + 75 | ", gmtModified=" + gmtModified + 76 | '}'; 77 | } 78 | } -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/service/impl/FileServiceImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.service.impl; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.web.multipart.MultipartFile; 8 | import top.sl.tmpp.plan.entity.CourseEducationalCache; 9 | import top.sl.tmpp.plan.exception.FileIsNullException; 10 | import top.sl.tmpp.plan.exception.FileTypeException; 11 | import top.sl.tmpp.plan.service.FileService; 12 | import top.sl.tmpp.plan.util.FileUtil; 13 | 14 | import java.io.File; 15 | import java.io.IOException; 16 | 17 | /** 18 | * @author ShuLu 19 | * @date 2019/6/17 15:10 20 | */ 21 | @Service 22 | public class FileServiceImpl implements FileService { 23 | private static final Logger logger = LoggerFactory.getLogger(FileServiceImpl.class); 24 | 25 | @Override 26 | public String fileUpload(MultipartFile multipartFile) { 27 | logger.debug("upload multipartFile: {} {} ", multipartFile.getContentType(), multipartFile.getSize()); 28 | if (multipartFile.isEmpty()) { 29 | throw new FileIsNullException("上传文件为空", HttpStatus.BAD_REQUEST); 30 | } 31 | if (!FileUtil.isExcelType(multipartFile)) { 32 | throw new FileTypeException("上传文件类型有误", HttpStatus.BAD_REQUEST); 33 | } 34 | try { 35 | byte[] bytes = multipartFile.getBytes(); 36 | String fileName = FileUtil.getFileMd5(bytes) + FileUtil.getExtensionName(multipartFile); 37 | File newFile = new File(System.getProperty("java.io.tmpdir") + File.separator + fileName); 38 | multipartFile.transferTo(newFile); 39 | CourseEducationalCache.refreshCourseMap(); 40 | logger.debug("You successfully uploaded"); 41 | return fileName; 42 | } catch (IOException e) { 43 | throw new FileIsNullException("上传文件失败:" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/LoginUser.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class LoginUser { 6 | private String id; 7 | 8 | private String name; 9 | 10 | private String userType; 11 | 12 | private Date gmtCreate; 13 | 14 | private Date gmtModified; 15 | 16 | public LoginUser(String id, String name, String userType, Date gmtCreate, Date gmtModified) { 17 | this.id = id; 18 | this.name = name; 19 | this.userType = userType; 20 | this.gmtCreate = gmtCreate; 21 | this.gmtModified = gmtModified; 22 | } 23 | 24 | public LoginUser() { 25 | super(); 26 | } 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id == null ? null : id.trim(); 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name == null ? null : name.trim(); 42 | } 43 | 44 | public String getUserType() { 45 | return userType; 46 | } 47 | 48 | public void setUserType(String userType) { 49 | this.userType = userType == null ? null : userType.trim(); 50 | } 51 | 52 | public Date getGmtCreate() { 53 | return gmtCreate; 54 | } 55 | 56 | public void setGmtCreate(Date gmtCreate) { 57 | this.gmtCreate = gmtCreate; 58 | } 59 | 60 | public Date getGmtModified() { 61 | return gmtModified; 62 | } 63 | 64 | public void setGmtModified(Date gmtModified) { 65 | this.gmtModified = gmtModified; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "LoginUser{" + 71 | "id='" + id + '\'' + 72 | ", name='" + name + '\'' + 73 | ", userType='" + userType + '\'' + 74 | ", gmtCreate=" + gmtCreate + 75 | ", gmtModified=" + gmtModified + 76 | '}'; 77 | } 78 | } -------------------------------------------------------------------------------- /tmpp-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | tmpp 7 | top.sl.tmpp 8 | 1.0.0-RC 9 | 10 | 4.0.0 11 | 12 | tmpp-common 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-web 18 | 19 | 20 | org.mybatis.spring.boot 21 | mybatis-spring-boot-starter 22 | 23 | 24 | mysql 25 | mysql-connector-java 26 | 27 | 28 | org.apache.commons 29 | commons-lang3 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.mybatis.generator 37 | mybatis-generator-maven-plugin 38 | 1.3.7 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | mysql 47 | mysql-connector-java 48 | 5.1.47 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tmpp-purchase/src/main/java/top/sl/tmpp/purchase/service/PurchaseService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.purchase.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import top.sl.tmpp.common.pojo.BookDTO; 5 | 6 | import java.math.BigDecimal; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author itning 11 | * @date 2019/6/23 15:10 12 | */ 13 | public interface PurchaseService { 14 | /** 15 | * 购买、修改书 16 | * 17 | * @param loginUserId 登录用户ID 18 | * @param executePlanId 执行计划ID 19 | * @param courseCode 课程代码 20 | * @param isbn 书籍ISBN 21 | * @param textBookName 书名 22 | * @param textBookCategory 教材类别 23 | * @param press 出版社 24 | * @param author 作者 25 | * @param unitPrice 单价 26 | * @param teacherBookNumber 教师样书数量 27 | * @param discount 折扣 28 | * @param awardInformation 获奖信息和丛书名称 29 | * @param publicationDate 出版日期 30 | * @param subscriber 订阅人 31 | * @param subscriberTel 联系电话 32 | * @param bookId 图书ID(传入不为NULL则修改) 33 | */ 34 | void buyBook(String loginUserId, String executePlanId, String courseCode, String isbn, String textBookName, Boolean textBookCategory, 35 | String press, String author, BigDecimal unitPrice, Integer teacherBookNumber, BigDecimal discount, 36 | String awardInformation, Date publicationDate, String subscriber, String subscriberTel, String bookId); 37 | 38 | /** 39 | * 教师提交修改不买书 40 | * 41 | * @param loginUserId 登录用户ID 42 | * @param executePlanId 执行计划ID 43 | * @param courseCode 课程代码 44 | * @param reason 不买原因 45 | * @param bookId 图书ID(传入不为NULL则修改) 46 | */ 47 | void notBuyBook(String loginUserId, String executePlanId, String courseCode, String reason, String bookId); 48 | 49 | /** 50 | * 根据执行计划ID获取教师购书 51 | * 52 | * @param loginUserId 用户ID 53 | * @param executePlanId 执行计划ID 54 | * @param page 页数 55 | * @param size 数量 56 | * @return 教师购书 57 | */ 58 | PageInfo getAllTeacherBooks(String loginUserId, String executePlanId, int page, int size); 59 | } 60 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/AdminUser.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class AdminUser { 6 | private String id; 7 | 8 | private String name; 9 | 10 | private String username; 11 | 12 | private String password; 13 | 14 | private String type; 15 | 16 | private Date gmtCreate; 17 | 18 | private Date gmtModified; 19 | 20 | public AdminUser(String id, String name, String username, String password, String type, Date gmtCreate, Date gmtModified) { 21 | this.id = id; 22 | this.name = name; 23 | this.username = username; 24 | this.password = password; 25 | this.type = type; 26 | this.gmtCreate = gmtCreate; 27 | this.gmtModified = gmtModified; 28 | } 29 | 30 | public AdminUser() { 31 | super(); 32 | } 33 | 34 | public String getId() { 35 | return id; 36 | } 37 | 38 | public void setId(String id) { 39 | this.id = id == null ? null : id.trim(); 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public void setName(String name) { 47 | this.name = name == null ? null : name.trim(); 48 | } 49 | 50 | public String getUsername() { 51 | return username; 52 | } 53 | 54 | public void setUsername(String username) { 55 | this.username = username == null ? null : username.trim(); 56 | } 57 | 58 | public String getPassword() { 59 | return password; 60 | } 61 | 62 | public void setPassword(String password) { 63 | this.password = password == null ? null : password.trim(); 64 | } 65 | 66 | public String getType() { 67 | return type; 68 | } 69 | 70 | public void setType(String type) { 71 | this.type = type == null ? null : type.trim(); 72 | } 73 | 74 | public Date getGmtCreate() { 75 | return gmtCreate; 76 | } 77 | 78 | public void setGmtCreate(Date gmtCreate) { 79 | this.gmtCreate = gmtCreate; 80 | } 81 | 82 | public Date getGmtModified() { 83 | return gmtModified; 84 | } 85 | 86 | public void setGmtModified(Date gmtModified) { 87 | this.gmtModified = gmtModified; 88 | } 89 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/mapper/ExportMapper.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | import top.sl.tmpp.common.pojo.*; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author ShuLu 10 | * @date 2019/6/26 14:12 11 | */ 12 | public interface ExportMapper { 13 | /** 14 | * 导出采购教材汇总表 15 | * 16 | * @return PurchasingMaterials集合 17 | */ 18 | List getPurchasingMaterials(String executePlanId); 19 | 20 | String selectYear(String executePlanId); 21 | 22 | String selectTerm(String executePlanId); 23 | 24 | List selectClazz(String executePlanId); 25 | 26 | List selectStudentReceiveBooks(String clazz); 27 | 28 | List selectPublishingHouseStatistics(String executePlanId); 29 | 30 | List selectSubscriptionBook(String executePlanId); 31 | 32 | List selectTeacherReceiveBook(String executePlanId); 33 | 34 | List selectSubscriptionBookPlan(String executePlanId); 35 | 36 | List selectBookMaterials(@Param("year") String year, @Param("college") String college, 37 | @Param("teachingDepartment") String teachingDepartment, @Param("term") Boolean term); 38 | 39 | /** 40 | * 考试课 课程总门数 41 | * 42 | * @param executePlanId 执行计划ID 43 | * @return list 44 | */ 45 | List selectTheTotalCourses(String executePlanId); 46 | 47 | /** 48 | * 考查课 课程总门数 49 | * 50 | * @param executePlanId 执行计划ID 51 | * @return list 52 | */ 53 | List selectTheStudyCourses(String executePlanId); 54 | 55 | /** 56 | * 考试课 订购教材课程门数 57 | * 58 | * @param executePlanId 执行计划ID 59 | * @return list 60 | */ 61 | List selectExaminationCourse(String executePlanId); 62 | 63 | /** 64 | * 考查课 订购教材课程门数 65 | * 66 | * @param executePlanId 执行计划ID 67 | * @return list 68 | */ 69 | List selectStudyClass(String executePlanId); 70 | 71 | /** 72 | * 查找教育层次 73 | * 74 | * @param executePlanId 执行计划ID 75 | * @return 教育层次 76 | */ 77 | String selectLevel(String executePlanId); 78 | } 79 | -------------------------------------------------------------------------------- /tmpp-discounts/src/main/java/top/sl/tmpp/discounts/service/impl/DiscountsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.discounts.service.impl; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Service; 6 | import top.sl.tmpp.common.entity.Discounts; 7 | import top.sl.tmpp.common.exception.IdNotFoundException; 8 | import top.sl.tmpp.common.mapper.DiscountsMapper; 9 | import top.sl.tmpp.discounts.service.DiscountsService; 10 | 11 | import java.math.BigDecimal; 12 | import java.util.Date; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | /** 17 | * @author ShuLu 18 | */ 19 | @Service 20 | public class DiscountsServiceImpl implements DiscountsService { 21 | private final DiscountsMapper discountsMapper; 22 | private Logger log = LoggerFactory.getLogger(DiscountsServiceImpl.class); 23 | 24 | public DiscountsServiceImpl(DiscountsMapper discountsMapper) { 25 | this.discountsMapper = discountsMapper; 26 | } 27 | 28 | @Override 29 | public void save(BigDecimal discount) { 30 | log.debug("添加折扣"); 31 | Date date = new Date(); 32 | Discounts discounts = new Discounts(UUID.randomUUID().toString().replace("-", ""), discount, date, date); 33 | discountsMapper.insert(discounts); 34 | } 35 | 36 | @Override 37 | public List getAllDiscount() { 38 | List discounts = discountsMapper.selectAll(); 39 | log.debug("查找全部折扣"); 40 | return discounts; 41 | } 42 | 43 | @Override 44 | public void remove(String id) { 45 | if (discountsMapper.selectByPrimaryKey(id) == null) { 46 | log.debug("删除失败"); 47 | throw new IdNotFoundException(id); 48 | } 49 | log.debug("删除折扣"); 50 | discountsMapper.deleteByPrimaryKey(id); 51 | } 52 | 53 | @Override 54 | public void modify(String id, BigDecimal discount) { 55 | Discounts modifyDiscount = discountsMapper.selectByPrimaryKey(id); 56 | if (modifyDiscount == null) { 57 | log.debug("修改折扣失败"); 58 | throw new IdNotFoundException(id); 59 | } 60 | log.debug("修改折扣"); 61 | modifyDiscount.setDiscount(discount); 62 | modifyDiscount.setGmtModified(new Date()); 63 | discountsMapper.updateByPrimaryKey(modifyDiscount); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tmpp-core/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 9 | 10 | 12 | 13 | 14 | 15 | ${CONSOLE_LOG_PATTERN} 16 | utf8 17 | 18 | 19 | 20 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/CasMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 28 | 33 | 43 | -------------------------------------------------------------------------------- /tmpp-export/src/main/java/top/sl/tmpp/export/service/ExportService.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.export.service; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | /** 7 | * @author ShuLu 8 | * @date 2019/6/26 10:49 9 | */ 10 | public interface ExportService { 11 | /** 12 | * 导出采购教材汇总表 13 | * 14 | * @param outputStream 输出流 15 | * @param executePlanId 执行计划ID 16 | * @throws IOException IOException 17 | */ 18 | void procurementTable(String executePlanId, OutputStream outputStream) throws IOException; 19 | 20 | /** 21 | * 导出学生班级教材信息表 22 | * 23 | * @param executePlanId 执行计划ID 24 | * @param outputStream 输出流 25 | * @throws IOException IOException 26 | */ 27 | void studentClassBookTable(String executePlanId, OutputStream outputStream) throws IOException; 28 | 29 | /** 30 | * 出版社统计数量表 31 | * 32 | * @param executePlanId 执行计划ID 33 | * @param outputStream 输出流 34 | * @throws IOException IOException 35 | */ 36 | void publishingHouseStatistics(String executePlanId, OutputStream outputStream) throws IOException; 37 | 38 | /** 39 | * 教材样书统计表 40 | * 41 | * @param executePlanId 执行计划ID 42 | * @param outputStream 输出流 43 | * @throws IOException IOException 44 | */ 45 | void subscriptionBook(String executePlanId, OutputStream outputStream) throws IOException; 46 | 47 | /** 48 | * 教师领取教材汇总表 49 | * 50 | * @param executePlanId 执行计划ID 51 | * @param outputStream 输出流 52 | * @throws IOException IOException 53 | */ 54 | void teacherReceiveBook(String executePlanId, OutputStream outputStream) throws IOException; 55 | 56 | /** 57 | * 征订教材计划统计表 58 | * 59 | * @param executePlanId 执行计划ID 60 | * @param outputStream 输出流 61 | * @throws IOException IOException 62 | */ 63 | void subscriptionBookPlan(String executePlanId, OutputStream outputStream) throws IOException; 64 | 65 | /** 66 | * 考试/考查/总体订书率表 67 | * 68 | * @param executePlanId 执行计划ID 69 | * @param outputStream 输出流 70 | * @throws IOException IOException 71 | */ 72 | void summaryTable(String executePlanId, OutputStream outputStream) throws IOException; 73 | 74 | /** 75 | * 征订教材汇总表格 76 | * 77 | * @param year 年 78 | * @param college 学院 79 | * @param teachingDepartment 授课部门 80 | * @param term 学期 81 | * @param outputStream 输出流 82 | * @throws IOException IOException 83 | */ 84 | void downBookMaterials(String year, String college, String teachingDepartment, Boolean term, OutputStream outputStream) throws IOException; 85 | } 86 | -------------------------------------------------------------------------------- /tmpp-discounts/src/main/java/top/sl/tmpp/discounts/controller/DiscountsController.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.discounts.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.*; 8 | import top.sl.tmpp.common.entity.Discounts; 9 | import top.sl.tmpp.common.entity.LoginUser; 10 | import top.sl.tmpp.common.util.RestModel; 11 | import top.sl.tmpp.discounts.service.DiscountsService; 12 | 13 | import java.math.BigDecimal; 14 | import java.util.List; 15 | 16 | /** 17 | * @author ShuLu 18 | */ 19 | @RestController 20 | public class DiscountsController { 21 | private static final Logger logger = LoggerFactory.getLogger(DiscountsController.class); 22 | 23 | private final DiscountsService discountsService; 24 | 25 | @Autowired 26 | public DiscountsController(DiscountsService discountsService) { 27 | this.discountsService = discountsService; 28 | } 29 | 30 | /** 31 | * 添加折扣 32 | * 33 | * @param discount 折扣数量 34 | * @return {@link ResponseEntity} {@link RestModel} 35 | */ 36 | @PostMapping("/discount") 37 | public ResponseEntity saveDiscount(@RequestParam("discount") BigDecimal discount, LoginUser loginUser) { 38 | discountsService.save(discount); 39 | logger.debug("添加折扣成功"); 40 | return RestModel.created("添加折扣成功", null); 41 | } 42 | 43 | /** 44 | * 获取所有折扣信息 45 | * 46 | * @return {@link ResponseEntity} {@link RestModel} 47 | */ 48 | @GetMapping("/discounts") 49 | public ResponseEntity getAllDiscount(LoginUser loginUser) { 50 | List discounts = discountsService.getAllDiscount(); 51 | logger.debug("查找所有折扣成功"); 52 | return RestModel.ok(discounts); 53 | } 54 | 55 | /** 56 | * 删除折扣信息 57 | * 58 | * @param id 折扣ID 59 | * @return {@link ResponseEntity} {@link RestModel} 60 | */ 61 | @DeleteMapping("/discount") 62 | public ResponseEntity remove(@RequestParam("id") String id, LoginUser loginUser) { 63 | discountsService.remove(id); 64 | logger.debug("删除成功"); 65 | return RestModel.noContent(); 66 | } 67 | 68 | /** 69 | * 修改折扣 70 | * 71 | * @param id 折扣ID 72 | * @param discount 折扣数 73 | * @return {@link ResponseEntity} {@link RestModel} 74 | */ 75 | @PatchMapping("/discount") 76 | public ResponseEntity modify(@RequestParam("id") String id, @RequestParam("discount") BigDecimal discount, LoginUser loginUser) { 77 | discountsService.modify(id, discount); 78 | logger.debug("修改折扣成功"); 79 | return RestModel.noContent(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/util/JwtUtils.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.util; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import io.jsonwebtoken.*; 6 | import org.springframework.http.HttpStatus; 7 | import top.sl.tmpp.common.entity.LoginUser; 8 | import top.sl.tmpp.security.exception.CasException; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Jwt 工具类 14 | * 15 | * @author itning 16 | */ 17 | public final class JwtUtils { 18 | private static final String PRIVATE_KEY = "hxcshw"; 19 | private static final String LOGIN_USER = "loginUser"; 20 | private static final String DEFAULT_STR = "null"; 21 | private static final ObjectMapper MAPPER = new ObjectMapper(); 22 | 23 | private JwtUtils() { 24 | 25 | } 26 | 27 | public static String buildJwt(Object o) throws JsonProcessingException { 28 | return Jwts.builder() 29 | //SECRET_KEY是加密算法对应的密钥,这里使用额是HS256加密算法 30 | .signWith(SignatureAlgorithm.HS256, PRIVATE_KEY) 31 | //expTime是过期时间 32 | .setExpiration(new Date(System.currentTimeMillis() + 60 * 60 * 1000)) 33 | .claim(LOGIN_USER, MAPPER.writeValueAsString(o)) 34 | //令牌的发行者 35 | .setIssuer("itning") 36 | .compact(); 37 | } 38 | 39 | public static LoginUser getLoginUser(String jwt) { 40 | if (DEFAULT_STR.equals(jwt)) { 41 | throw new CasException("请先登陆", HttpStatus.UNAUTHORIZED); 42 | } 43 | try { 44 | //解析JWT字符串中的数据,并进行最基础的验证 45 | Claims claims = Jwts.parser() 46 | //SECRET_KEY是加密算法对应的密钥,jjwt可以自动判断机密算法 47 | .setSigningKey(PRIVATE_KEY) 48 | //jwt是JWT字符串 49 | .parseClaimsJws(jwt) 50 | .getBody(); 51 | //获取自定义字段key 52 | String loginUserJson = claims.get(LOGIN_USER, String.class); 53 | LoginUser loginUser = MAPPER.readValue(loginUserJson, LoginUser.class); 54 | //判断自定义字段是否正确 55 | if (loginUser == null) { 56 | throw new CasException("登陆失败", HttpStatus.UNAUTHORIZED); 57 | } else { 58 | return loginUser; 59 | } 60 | //在解析JWT字符串时,如果密钥不正确,将会解析失败,抛出SignatureException异常,说明该JWT字符串是伪造的 61 | //在解析JWT字符串时,如果‘过期时间字段’已经早于当前时间,将会抛出ExpiredJwtException异常,说明本次请求已经失效 62 | } catch (ExpiredJwtException e) { 63 | throw new CasException("登陆超时", HttpStatus.UNAUTHORIZED); 64 | } catch (SignatureException e) { 65 | throw new CasException("凭据错误", HttpStatus.BAD_REQUEST); 66 | } catch (Exception e) { 67 | throw new CasException("登陆失败", HttpStatus.UNAUTHORIZED); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.util; 2 | 3 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 4 | import org.apache.poi.ss.usermodel.Workbook; 5 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.util.DigestUtils; 8 | import org.springframework.web.multipart.MultipartFile; 9 | import top.sl.tmpp.plan.exception.FileException; 10 | 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | 14 | /** 15 | * @author ShuLu 16 | * @date 2019/6/17 13:59 17 | */ 18 | public class FileUtil { 19 | /** 20 | * 获取文件扩展名 21 | * 22 | * @param file {@link MultipartFile} 23 | * @return 文件扩展名 24 | */ 25 | public static String getExtensionName(MultipartFile file) { 26 | String originalFilename = file.getOriginalFilename(); 27 | String extensionName = ""; 28 | if (originalFilename != null) { 29 | int i = originalFilename.lastIndexOf("."); 30 | if (i != -1) { 31 | extensionName = file.getOriginalFilename().substring(i); 32 | } 33 | } 34 | return extensionName; 35 | } 36 | 37 | /** 38 | * 根据文件扩展名获取MIME类型 39 | * 40 | * @param extensionName 扩展名 41 | * @return MIME类型 42 | */ 43 | public static String getContentTypeByExtensionName(String extensionName) { 44 | switch (extensionName) { 45 | case "xls": 46 | return "application/vnd.ms-excel"; 47 | case "xlsx": 48 | return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 49 | default: 50 | return null; 51 | } 52 | } 53 | 54 | /** 55 | * 检查改文件是否是Excel文件 56 | * 57 | * @param file {@link MultipartFile} 58 | * @return 是返回真 59 | */ 60 | public static boolean isExcelType(MultipartFile file) { 61 | String fileType = FileUtil.getExtensionName(file); 62 | if (".xls".equals(fileType)) { 63 | return true; 64 | } else { 65 | return ".xlsx".equals(fileType); 66 | } 67 | } 68 | 69 | /** 70 | * 判断文件格式 71 | * 72 | * @param inStr {@link InputStream} 73 | * @param fileName 文件名 74 | * @return {@link Workbook} 75 | * @throws IOException IOException 76 | */ 77 | public static Workbook getWorkbook(InputStream inStr, String fileName) throws IOException { 78 | Workbook workbook; 79 | String fileType = fileName.substring(fileName.lastIndexOf(".")); 80 | if (".xls".equals(fileType)) { 81 | workbook = new HSSFWorkbook(inStr); 82 | } else if (".xlsx".equals(fileType)) { 83 | workbook = new XSSFWorkbook(inStr); 84 | } else { 85 | throw new FileException("文件格式不正确", HttpStatus.BAD_REQUEST); 86 | } 87 | return workbook; 88 | } 89 | 90 | public static String getFileMd5(byte[] bytes) { 91 | return DigestUtils.md5DigestAsHex(bytes); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/StudentReceiveBook.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * 班级领取教材反馈表 7 | * 8 | * @author ShuLu 9 | * @date 2019/6/26 11:38 10 | */ 11 | public class StudentReceiveBook { 12 | /** 13 | * 开课院系 14 | */ 15 | private String collegesName; 16 | /** 17 | * 使用班级 18 | */ 19 | private String clazz; 20 | /** 21 | * 书籍编号 22 | */ 23 | private String isbn; 24 | /** 25 | * 教材名称 26 | */ 27 | private String textBookName; 28 | /** 29 | * 出版社 30 | */ 31 | private String press; 32 | /** 33 | * 单价 34 | */ 35 | private BigDecimal unitPrice; 36 | /** 37 | * 数量 38 | */ 39 | private Integer clazzNumber; 40 | /** 41 | * 折扣 42 | */ 43 | private BigDecimal discounts; 44 | 45 | public StudentReceiveBook() { 46 | } 47 | 48 | public StudentReceiveBook(String collegesName, String clazz, String isbn, String textBookName, String press, BigDecimal unitPrice, Integer clazzNumber, BigDecimal discounts) { 49 | this.collegesName = collegesName; 50 | this.clazz = clazz; 51 | this.isbn = isbn; 52 | this.textBookName = textBookName; 53 | this.press = press; 54 | this.unitPrice = unitPrice; 55 | this.clazzNumber = clazzNumber; 56 | this.discounts = discounts; 57 | } 58 | 59 | public String getCollegesName() { 60 | return collegesName; 61 | } 62 | 63 | public void setCollegesName(String collegesName) { 64 | this.collegesName = collegesName; 65 | } 66 | 67 | public String getClazz() { 68 | return clazz; 69 | } 70 | 71 | public void setClazz(String clazz) { 72 | this.clazz = clazz; 73 | } 74 | 75 | public String getIsbn() { 76 | return isbn; 77 | } 78 | 79 | public void setIsbn(String isbn) { 80 | this.isbn = isbn; 81 | } 82 | 83 | public String getTextBookName() { 84 | return textBookName; 85 | } 86 | 87 | public void setTextBookName(String textBookName) { 88 | this.textBookName = textBookName; 89 | } 90 | 91 | public String getPress() { 92 | return press; 93 | } 94 | 95 | public void setPress(String press) { 96 | this.press = press; 97 | } 98 | 99 | public BigDecimal getUnitPrice() { 100 | return unitPrice; 101 | } 102 | 103 | public void setUnitPrice(BigDecimal unitPrice) { 104 | this.unitPrice = unitPrice; 105 | } 106 | 107 | public Integer getClazzNumber() { 108 | return clazzNumber; 109 | } 110 | 111 | public void setClazzNumber(Integer clazzNumber) { 112 | this.clazzNumber = clazzNumber; 113 | } 114 | 115 | public BigDecimal getDiscounts() { 116 | return discounts; 117 | } 118 | 119 | public void setDiscounts(BigDecimal discounts) { 120 | this.discounts = discounts; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /tmpp-acquire/src/main/java/top/sl/tmpp/acquire/service/impl/AcquireServiceImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.acquire.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import top.sl.tmpp.acquire.service.AcquireService; 10 | import top.sl.tmpp.common.entity.Colleges; 11 | import top.sl.tmpp.common.entity.Department; 12 | import top.sl.tmpp.common.entity.Level; 13 | import top.sl.tmpp.common.mapper.*; 14 | import top.sl.tmpp.common.pojo.CourseDTO; 15 | import top.sl.tmpp.common.pojo.ExecutePlanDTO; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @author ShuLu 21 | * @date 2019/6/24 14:42 22 | */ 23 | @Service 24 | public class AcquireServiceImpl implements AcquireService { 25 | private static final Logger logger = LoggerFactory.getLogger(AcquireServiceImpl.class); 26 | 27 | private final CollegesMapper collegesMapper; 28 | private final DepartmentMapper departmentMapper; 29 | private final ExecutePlanMapper executePlanMapper; 30 | private final LevelMapper levelMapper; 31 | private final PlanMapper planMapper; 32 | 33 | @Autowired 34 | public AcquireServiceImpl(CollegesMapper collegesMapper, DepartmentMapper departmentMapper, ExecutePlanMapper executePlanMapper, LevelMapper levelMapper, PlanMapper planMapper) { 35 | this.collegesMapper = collegesMapper; 36 | this.departmentMapper = departmentMapper; 37 | this.executePlanMapper = executePlanMapper; 38 | this.levelMapper = levelMapper; 39 | this.planMapper = planMapper; 40 | } 41 | 42 | @Override 43 | public List getAllCollege() { 44 | List colleges = collegesMapper.selectAll(); 45 | logger.debug("获取所有学院"); 46 | return colleges; 47 | } 48 | 49 | @Override 50 | public List getAllCourse(String executePlanId) { 51 | return planMapper.selectCourseByExecutePlanId(executePlanId); 52 | } 53 | 54 | @Override 55 | public List getAllDepartment() { 56 | logger.debug("查询所有授课部门"); 57 | return departmentMapper.selectAll(); 58 | } 59 | 60 | @Override 61 | public PageInfo getAllExecutePlan(int page, int size) { 62 | return PageHelper 63 | .startPage(page, size) 64 | .doSelectPageInfo(executePlanMapper::selectAll); 65 | } 66 | 67 | @Override 68 | public List getAllLevel() { 69 | List levels = levelMapper.selectAll(); 70 | logger.debug("查询所有层次"); 71 | return levels; 72 | } 73 | 74 | @Override 75 | public List getAllUnDoneExecutePlan() { 76 | return executePlanMapper.selectByStatus(false); 77 | } 78 | 79 | @Override 80 | public List getYears() { 81 | return executePlanMapper.selectDistinctYear(); 82 | } 83 | 84 | @Override 85 | public List getTerms(String year) { 86 | return executePlanMapper.selectTermByYear(year); 87 | } 88 | 89 | @Override 90 | public List getAllDoneExecutePlan() { 91 | return executePlanMapper.selectByStatus(true); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/ExecutePlanDTO.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author itning 7 | * @date 2019/6/29 19:46 8 | */ 9 | public class ExecutePlanDTO { 10 | private String id; 11 | 12 | private String year; 13 | 14 | private Boolean term; 15 | 16 | private Integer grade; 17 | 18 | private Boolean status; 19 | 20 | private String level; 21 | 22 | private String department; 23 | 24 | private Date gmtModified; 25 | 26 | private Date gmtCreate; 27 | 28 | public ExecutePlanDTO() { 29 | } 30 | 31 | public ExecutePlanDTO(String id, String year, Boolean term, Integer grade, Boolean status, String level, String department, Date gmtModified, Date gmtCreate) { 32 | this.id = id; 33 | this.year = year; 34 | this.term = term; 35 | this.grade = grade; 36 | this.status = status; 37 | this.level = level; 38 | this.department = department; 39 | this.gmtModified = gmtModified; 40 | this.gmtCreate = gmtCreate; 41 | } 42 | 43 | public String getId() { 44 | return id; 45 | } 46 | 47 | public void setId(String id) { 48 | this.id = id; 49 | } 50 | 51 | public String getYear() { 52 | return year; 53 | } 54 | 55 | public void setYear(String year) { 56 | this.year = year; 57 | } 58 | 59 | public Boolean getTerm() { 60 | return term; 61 | } 62 | 63 | public void setTerm(Boolean term) { 64 | this.term = term; 65 | } 66 | 67 | public Integer getGrade() { 68 | return grade; 69 | } 70 | 71 | public void setGrade(Integer grade) { 72 | this.grade = grade; 73 | } 74 | 75 | public Boolean getStatus() { 76 | return status; 77 | } 78 | 79 | public void setStatus(Boolean status) { 80 | this.status = status; 81 | } 82 | 83 | public String getLevel() { 84 | return level; 85 | } 86 | 87 | public void setLevel(String level) { 88 | this.level = level; 89 | } 90 | 91 | public String getDepartment() { 92 | return department; 93 | } 94 | 95 | public void setDepartment(String department) { 96 | this.department = department; 97 | } 98 | 99 | public Date getGmtModified() { 100 | return gmtModified; 101 | } 102 | 103 | public void setGmtModified(Date gmtModified) { 104 | this.gmtModified = gmtModified; 105 | } 106 | 107 | public Date getGmtCreate() { 108 | return gmtCreate; 109 | } 110 | 111 | public void setGmtCreate(Date gmtCreate) { 112 | this.gmtCreate = gmtCreate; 113 | } 114 | 115 | @Override 116 | public String toString() { 117 | return "ExecutePlanDTO{" + 118 | "id='" + id + '\'' + 119 | ", year='" + year + '\'' + 120 | ", term=" + term + 121 | ", grade=" + grade + 122 | ", status=" + status + 123 | ", level='" + level + '\'' + 124 | ", department='" + department + '\'' + 125 | ", gmtModified=" + gmtModified + 126 | ", gmtCreate=" + gmtCreate + 127 | '}'; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/util/ObjectUtils.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.springframework.http.HttpStatus; 5 | import top.sl.tmpp.common.exception.BaseException; 6 | 7 | import java.lang.reflect.Field; 8 | import java.util.Optional; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * @author ShuLu 13 | * @date 2019/6/24 15:46 14 | */ 15 | public class ObjectUtils { 16 | /** 17 | * 检查对象中的属性不为null,String不为空 18 | * 19 | * @param t 对象 20 | * @param ignoreFieldsName 忽略属性 21 | * @param 对象 22 | */ 23 | public static void checkObjectFieldsNotEmpty(T t, String... ignoreFieldsName) { 24 | try { 25 | Field[] fields = t.getClass().getDeclaredFields(); 26 | a: 27 | for (Field field : fields) { 28 | for (String ignore : ignoreFieldsName) { 29 | if (ignore.equals(field.getName())) { 30 | continue a; 31 | } 32 | } 33 | field.setAccessible(true); 34 | Object o = field.get(t); 35 | if (null == o) { 36 | throw new BaseException(field.getName() + " 为空", HttpStatus.BAD_REQUEST) { 37 | }; 38 | } else if (o instanceof CharSequence) { 39 | if (StringUtils.isBlank((CharSequence) o)) { 40 | throw new BaseException(field.getName() + " 为空", HttpStatus.BAD_REQUEST) { 41 | }; 42 | } 43 | } 44 | } 45 | } catch (IllegalAccessException e) { 46 | throw new BaseException(e.getMessage(), HttpStatus.BAD_REQUEST) { 47 | }; 48 | } 49 | } 50 | 51 | /** 52 | * 检查字符串不为空 53 | * 54 | * @param str 字符串 55 | * @return 如果不为空返回{@link Optional#empty},为空返回数组索引 56 | */ 57 | public static Optional checkStringIsNotBlank(String... str) { 58 | int i = 0; 59 | for (String s : str) { 60 | if (StringUtils.isBlank(s)) { 61 | return Optional.of(i); 62 | } 63 | i++; 64 | } 65 | return Optional.empty(); 66 | } 67 | 68 | /** 69 | * 检查对象不为空 70 | * 71 | * @param t 对象 72 | * @param supplier 为空抛的异常 73 | * @param 对象 74 | * @return 对象 75 | */ 76 | public static T checkNotNull(T t, Supplier supplier) { 77 | if (t == null) { 78 | throw supplier.get(); 79 | } 80 | return t; 81 | } 82 | 83 | /** 84 | * 将字符串转换为int,小数直接截取整数部分 85 | * 86 | * @param want 字符串 87 | * @param supplier 转换失败抛的异常 88 | * @return int 89 | */ 90 | public static int toInt(String want, Supplier supplier) { 91 | int i = want.indexOf("."); 92 | try { 93 | if (i == 1) { 94 | return Integer.parseInt(want); 95 | } else { 96 | return Integer.parseInt(want.substring(0, i)); 97 | } 98 | } catch (NumberFormatException e) { 99 | throw supplier.get(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/PurchasingMaterials.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * 采购教材汇总表 7 | * 8 | * @author ShuLu 9 | * @date 2019/6/26 11:44 10 | */ 11 | public class PurchasingMaterials { 12 | /** 13 | * 教材名称 14 | */ 15 | private String textBookName; 16 | /** 17 | * 出版社 18 | */ 19 | private String press; 20 | /** 21 | * 作者 22 | */ 23 | private String author; 24 | /** 25 | * 书籍编号 26 | */ 27 | private String isbn; 28 | /** 29 | * 单价 30 | */ 31 | private BigDecimal unitPrice; 32 | /** 33 | * 使用班级人数 34 | */ 35 | private Integer clazzNumber; 36 | /** 37 | * 教师样书数量 38 | */ 39 | private Integer teacherBookNumber; 40 | /** 41 | * 教务处是否购书 42 | */ 43 | private Byte isBuyBook; 44 | /** 45 | * 购书总数 46 | */ 47 | private Integer total; 48 | 49 | public PurchasingMaterials() { 50 | } 51 | 52 | public PurchasingMaterials(String textBookName, String press, String author, String isbn, BigDecimal unitPrice, Integer clazzNumber, Integer teacherBookNumber, Byte isBuyBook, Integer total) { 53 | this.textBookName = textBookName; 54 | this.press = press; 55 | this.author = author; 56 | this.isbn = isbn; 57 | this.unitPrice = unitPrice; 58 | this.clazzNumber = clazzNumber; 59 | this.teacherBookNumber = teacherBookNumber; 60 | this.isBuyBook = isBuyBook; 61 | this.total = total; 62 | } 63 | 64 | public String getTextBookName() { 65 | return textBookName; 66 | } 67 | 68 | public void setTextBookName(String textBookName) { 69 | this.textBookName = textBookName; 70 | } 71 | 72 | public String getPress() { 73 | return press; 74 | } 75 | 76 | public void setPress(String press) { 77 | this.press = press; 78 | } 79 | 80 | public String getAuthor() { 81 | return author; 82 | } 83 | 84 | public void setAuthor(String author) { 85 | this.author = author; 86 | } 87 | 88 | public String getIsbn() { 89 | return isbn; 90 | } 91 | 92 | public void setIsbn(String isbn) { 93 | this.isbn = isbn; 94 | } 95 | 96 | public BigDecimal getUnitPrice() { 97 | return unitPrice; 98 | } 99 | 100 | public void setUnitPrice(BigDecimal unitPrice) { 101 | this.unitPrice = unitPrice; 102 | } 103 | 104 | public Integer getClazzNumber() { 105 | return clazzNumber; 106 | } 107 | 108 | public void setClazzNumber(Integer clazzNumber) { 109 | this.clazzNumber = clazzNumber; 110 | } 111 | 112 | public Integer getTeacherBookNumber() { 113 | return teacherBookNumber; 114 | } 115 | 116 | public void setTeacherBookNumber(Integer teacherBookNumber) { 117 | this.teacherBookNumber = teacherBookNumber; 118 | } 119 | 120 | public Byte getBuyBook() { 121 | return isBuyBook; 122 | } 123 | 124 | public void setBuyBook(Byte buyBook) { 125 | isBuyBook = buyBook; 126 | } 127 | 128 | public Integer getTotal() { 129 | return total; 130 | } 131 | 132 | public void setTotal(Integer total) { 133 | this.total = total; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 73 | 74 | -------------------------------------------------------------------------------- /tmpp-core/src/main/java/top/sl/tmpp/core/exception/ExceptionResolver.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.core.exception; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.web.bind.MissingServletRequestParameterException; 7 | import org.springframework.web.bind.annotation.ControllerAdvice; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; 11 | import top.sl.tmpp.common.exception.BaseException; 12 | import top.sl.tmpp.common.util.RestModel; 13 | 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | /** 17 | * 异常处理 18 | * 19 | * @author Ning 20 | */ 21 | @ControllerAdvice 22 | public class ExceptionResolver { 23 | private static final Logger logger = LoggerFactory.getLogger(ExceptionResolver.class); 24 | 25 | /** 26 | * 请求参数不匹配 27 | * 28 | * @param response HttpServletResponse 29 | * @param m MissingServletRequestParameterException 30 | * @return RestModel 31 | */ 32 | @ExceptionHandler(value = MissingServletRequestParameterException.class) 33 | @ResponseBody 34 | public RestModel missingServletRequestParameterException(HttpServletResponse response, MissingServletRequestParameterException m) { 35 | RestModel restModel = new RestModel(); 36 | restModel.setCode(HttpStatus.BAD_REQUEST.value()); 37 | restModel.setMsg(m.getMessage()); 38 | response.setStatus(HttpStatus.BAD_REQUEST.value()); 39 | return restModel; 40 | } 41 | 42 | /** 43 | * 用户传参错误 44 | * 45 | * @param response HttpServletResponse 46 | * @param m MethodArgumentTypeMismatchException 47 | * @return RestModel 48 | */ 49 | @ExceptionHandler(value = MethodArgumentTypeMismatchException.class) 50 | @ResponseBody 51 | public RestModel methodArgumentTypeMismatchException(HttpServletResponse response, MethodArgumentTypeMismatchException m) { 52 | RestModel restModel = new RestModel(); 53 | restModel.setCode(HttpStatus.BAD_REQUEST.value()); 54 | restModel.setMsg("参数:" + m.getName() + "的值无法转换成" + m.getRequiredType()); 55 | response.setStatus(HttpStatus.BAD_REQUEST.value()); 56 | return restModel; 57 | } 58 | 59 | /** 60 | * json 格式错误消息 61 | * 62 | * @param response HttpServletResponse 63 | * @param e Exception 64 | * @return 异常消息 65 | */ 66 | @ExceptionHandler(value = Exception.class) 67 | @ResponseBody 68 | public RestModel jsonErrorHandler(HttpServletResponse response, Exception e) { 69 | logger.error("jsonErrorHandler->{}:{} {}", e.getClass().getSimpleName(), e.getMessage(), e); 70 | RestModel restModel = new RestModel(); 71 | restModel.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value()); 72 | restModel.setMsg(e.getMessage()); 73 | response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); 74 | return restModel; 75 | } 76 | 77 | /** 78 | * BaseException 错误 79 | * 80 | * @param response HttpServletResponse 81 | * @param e BaseException 82 | * @return 异常消息 83 | */ 84 | @ExceptionHandler(value = BaseException.class) 85 | @ResponseBody 86 | public RestModel baseErrorHandler(HttpServletResponse response, BaseException e) { 87 | logger.info("baseErrorHandler->{}:{}", e.getClass().getSimpleName(), e.getMessage()); 88 | RestModel restModel = new RestModel(); 89 | restModel.setCode(e.getCode().value()); 90 | restModel.setMsg(e.getMessage()); 91 | response.setStatus(e.getCode().value()); 92 | return restModel; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/DepartmentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, 14 | name, 15 | gmt_modified, 16 | gmt_create 17 | 18 | 24 | 25 | delete 26 | from department 27 | where id = #{id,jdbcType=VARCHAR} 28 | 29 | 30 | insert into department (id, name, gmt_modified, 31 | gmt_create) 32 | values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gmtModified,jdbcType=TIMESTAMP}, 33 | #{gmtCreate,jdbcType=TIMESTAMP}) 34 | 35 | 36 | insert into department 37 | 38 | 39 | id, 40 | 41 | 42 | name, 43 | 44 | 45 | gmt_modified, 46 | 47 | 48 | gmt_create, 49 | 50 | 51 | 52 | 53 | #{id,jdbcType=VARCHAR}, 54 | 55 | 56 | #{name,jdbcType=VARCHAR}, 57 | 58 | 59 | #{gmtModified,jdbcType=TIMESTAMP}, 60 | 61 | 62 | #{gmtCreate,jdbcType=TIMESTAMP}, 63 | 64 | 65 | 66 | 67 | update department 68 | 69 | 70 | name = #{name,jdbcType=VARCHAR}, 71 | 72 | 73 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 74 | 75 | 76 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, 77 | 78 | 79 | where id = #{id,jdbcType=VARCHAR} 80 | 81 | 82 | update department 83 | set name = #{name,jdbcType=VARCHAR}, 84 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 85 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP} 86 | where id = #{id,jdbcType=VARCHAR} 87 | 88 | 93 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/DiscountsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, 14 | discount, 15 | gmt_modified, 16 | gmt_create 17 | 18 | 24 | 25 | delete 26 | from discounts 27 | where id = #{id,jdbcType=VARCHAR} 28 | 29 | 30 | insert into discounts (id, discount, gmt_modified, 31 | gmt_create) 32 | values (#{id,jdbcType=VARCHAR}, #{discount,jdbcType=DECIMAL}, #{gmtModified,jdbcType=TIMESTAMP}, 33 | #{gmtCreate,jdbcType=TIMESTAMP}) 34 | 35 | 36 | insert into discounts 37 | 38 | 39 | id, 40 | 41 | 42 | discount, 43 | 44 | 45 | gmt_modified, 46 | 47 | 48 | gmt_create, 49 | 50 | 51 | 52 | 53 | #{id,jdbcType=VARCHAR}, 54 | 55 | 56 | #{discount,jdbcType=DECIMAL}, 57 | 58 | 59 | #{gmtModified,jdbcType=TIMESTAMP}, 60 | 61 | 62 | #{gmtCreate,jdbcType=TIMESTAMP}, 63 | 64 | 65 | 66 | 67 | update discounts 68 | 69 | 70 | discount = #{discount,jdbcType=DECIMAL}, 71 | 72 | 73 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 74 | 75 | 76 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, 77 | 78 | 79 | where id = #{id,jdbcType=VARCHAR} 80 | 81 | 82 | update discounts 83 | set discount = #{discount,jdbcType=DECIMAL}, 84 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 85 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP} 86 | where id = #{id,jdbcType=VARCHAR} 87 | 88 | 93 | -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/cas/LoginUserArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.cas; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.core.MethodParameter; 6 | import org.springframework.http.HttpHeaders; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.web.bind.support.WebDataBinderFactory; 9 | import org.springframework.web.context.request.NativeWebRequest; 10 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 11 | import org.springframework.web.method.support.ModelAndViewContainer; 12 | import top.sl.tmpp.common.entity.AdminResource; 13 | import top.sl.tmpp.common.entity.AdminUser; 14 | import top.sl.tmpp.common.entity.LoginUser; 15 | import top.sl.tmpp.common.mapper.CasMapper; 16 | import top.sl.tmpp.security.exception.RoleException; 17 | import top.sl.tmpp.security.util.JwtUtils; 18 | 19 | import javax.annotation.Nonnull; 20 | import javax.servlet.http.HttpServletRequest; 21 | import java.util.List; 22 | 23 | /** 24 | * @author itning 25 | * @date 2019/6/17 8:43 26 | */ 27 | public class LoginUserArgumentResolver implements HandlerMethodArgumentResolver { 28 | private static final Logger logger = LoggerFactory.getLogger(LoginUserArgumentResolver.class); 29 | 30 | private final CasMapper casMapper; 31 | 32 | public LoginUserArgumentResolver(CasMapper casMapper) { 33 | this.casMapper = casMapper; 34 | } 35 | 36 | @Override 37 | public boolean supportsParameter(MethodParameter parameter) { 38 | return parameter.getParameterType().isAssignableFrom(LoginUser.class); 39 | } 40 | 41 | @Override 42 | public Object resolveArgument(@Nonnull MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { 43 | String authorization = webRequest.getHeader(HttpHeaders.AUTHORIZATION); 44 | LoginUser loginUser = JwtUtils.getLoginUser(authorization); 45 | logger.debug("get login user: {}", loginUser); 46 | HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); 47 | String requestUri = request.getRequestURI(); 48 | String method = request.getMethod(); 49 | checkPermission(loginUser, requestUri, method.toUpperCase()); 50 | return loginUser; 51 | } 52 | 53 | /** 54 | * 检查权限 55 | * 56 | * @param loginUser 登录用户 57 | * @param requestUri 请求URI 58 | * @param method 请求方法 59 | */ 60 | private void checkPermission(LoginUser loginUser, String requestUri, String method) { 61 | String loginId = loginUser.getId(); 62 | AdminUser adminUser = casMapper.selectByUserName(loginId); 63 | if (adminUser == null) { 64 | //普通教师角色 65 | long teacherCount = casMapper.getResourcesByUserTypeIsTeacher() 66 | .stream() 67 | .filter(adminResource -> requestUri.startsWith(adminResource.getUrl())) 68 | .filter(adminResource -> adminResource.getMethod().equals(method)) 69 | .count(); 70 | if (teacherCount == 0L) { 71 | logger.debug("CheckPermission FORBIDDEN {}", loginUser); 72 | logger.debug("request uri {}", requestUri); 73 | throw new RoleException("FORBIDDEN", HttpStatus.FORBIDDEN); 74 | } 75 | return; 76 | } 77 | List adminResourceList = casMapper.getResourcesByUserName(loginId); 78 | long admin = adminResourceList 79 | .stream() 80 | .filter(adminResource -> requestUri.startsWith(adminResource.getUrl())) 81 | .filter(adminResource -> adminResource.getMethod().equals(method)) 82 | .count(); 83 | if (admin == 0L) { 84 | logger.debug("CheckPermission FORBIDDEN {}", loginUser); 85 | logger.debug("request uri {}", requestUri); 86 | throw new RoleException("FORBIDDEN", HttpStatus.FORBIDDEN); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/LevelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, 14 | educational_level, 15 | gmt_modified, 16 | gmt_create 17 | 18 | 24 | 25 | delete 26 | from level 27 | where id = #{id,jdbcType=VARCHAR} 28 | 29 | 30 | insert into level (id, educational_level, gmt_modified, 31 | gmt_create) 32 | values (#{id,jdbcType=VARCHAR}, #{educationalLevel,jdbcType=VARCHAR}, #{gmtModified,jdbcType=TIMESTAMP}, 33 | #{gmtCreate,jdbcType=TIMESTAMP}) 34 | 35 | 36 | insert into level 37 | 38 | 39 | id, 40 | 41 | 42 | educational_level, 43 | 44 | 45 | gmt_modified, 46 | 47 | 48 | gmt_create, 49 | 50 | 51 | 52 | 53 | #{id,jdbcType=VARCHAR}, 54 | 55 | 56 | #{educationalLevel,jdbcType=VARCHAR}, 57 | 58 | 59 | #{gmtModified,jdbcType=TIMESTAMP}, 60 | 61 | 62 | #{gmtCreate,jdbcType=TIMESTAMP}, 63 | 64 | 65 | 66 | 67 | update level 68 | 69 | 70 | educational_level = #{educationalLevel,jdbcType=VARCHAR}, 71 | 72 | 73 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 74 | 75 | 76 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, 77 | 78 | 79 | where id = #{id,jdbcType=VARCHAR} 80 | 81 | 82 | update level 83 | set educational_level = #{educationalLevel,jdbcType=VARCHAR}, 84 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 85 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP} 86 | where id = #{id,jdbcType=VARCHAR} 87 | 88 | 93 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/CollegesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, 14 | name, 15 | gmt_modified, 16 | gmt_create 17 | 18 | 24 | 25 | delete 26 | from colleges 27 | where id = #{id,jdbcType=VARCHAR} 28 | 29 | 30 | insert into colleges (id, name, gmt_modified, 31 | gmt_create) 32 | values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gmtModified,jdbcType=TIMESTAMP}, 33 | #{gmtCreate,jdbcType=TIMESTAMP}) 34 | 35 | 36 | insert into colleges 37 | 38 | 39 | id, 40 | 41 | 42 | name, 43 | 44 | 45 | gmt_modified, 46 | 47 | 48 | gmt_create, 49 | 50 | 51 | 52 | 53 | #{id,jdbcType=VARCHAR}, 54 | 55 | 56 | #{name,jdbcType=VARCHAR}, 57 | 58 | 59 | #{gmtModified,jdbcType=TIMESTAMP}, 60 | 61 | 62 | #{gmtCreate,jdbcType=TIMESTAMP}, 63 | 64 | 65 | 66 | 67 | update colleges 68 | 69 | 70 | name = #{name,jdbcType=VARCHAR}, 71 | 72 | 73 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 74 | 75 | 76 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, 77 | 78 | 79 | where id = #{id,jdbcType=VARCHAR} 80 | 81 | 82 | update colleges 83 | set name = #{name,jdbcType=VARCHAR}, 84 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 85 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP} 86 | where id = #{id,jdbcType=VARCHAR} 87 | 88 | 93 | 98 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/ExecutePlan.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class ExecutePlan { 6 | private String id; 7 | 8 | private String year; 9 | 10 | private Boolean term; 11 | 12 | private Integer grade; 13 | 14 | private Boolean status; 15 | 16 | private String fileType; 17 | 18 | private String levelId; 19 | 20 | private String departmentId; 21 | 22 | private Date gmtModified; 23 | 24 | private Date gmtCreate; 25 | 26 | private byte[] file; 27 | 28 | public ExecutePlan(String fileType, byte[] file) { 29 | this.fileType = fileType; 30 | this.file = file; 31 | } 32 | 33 | public ExecutePlan(String id, String year, Boolean term, Integer grade, Boolean status, String fileType, String levelId, String departmentId, Date gmtModified, Date gmtCreate) { 34 | this.id = id; 35 | this.year = year; 36 | this.term = term; 37 | this.grade = grade; 38 | this.status = status; 39 | this.fileType = fileType; 40 | this.levelId = levelId; 41 | this.departmentId = departmentId; 42 | this.gmtModified = gmtModified; 43 | this.gmtCreate = gmtCreate; 44 | } 45 | 46 | public ExecutePlan(String id, String year, Boolean term, Integer grade, Boolean status, String fileType, String levelId, String departmentId, Date gmtModified, Date gmtCreate, byte[] file) { 47 | this.id = id; 48 | this.year = year; 49 | this.term = term; 50 | this.grade = grade; 51 | this.status = status; 52 | this.fileType = fileType; 53 | this.levelId = levelId; 54 | this.departmentId = departmentId; 55 | this.gmtModified = gmtModified; 56 | this.gmtCreate = gmtCreate; 57 | this.file = file; 58 | } 59 | 60 | public ExecutePlan() { 61 | super(); 62 | } 63 | 64 | public String getId() { 65 | return id; 66 | } 67 | 68 | public void setId(String id) { 69 | this.id = id == null ? null : id.trim(); 70 | } 71 | 72 | public String getYear() { 73 | return year; 74 | } 75 | 76 | public void setYear(String year) { 77 | this.year = year == null ? null : year.trim(); 78 | } 79 | 80 | public Boolean getTerm() { 81 | return term; 82 | } 83 | 84 | public void setTerm(Boolean term) { 85 | this.term = term; 86 | } 87 | 88 | public Integer getGrade() { 89 | return grade; 90 | } 91 | 92 | public void setGrade(Integer grade) { 93 | this.grade = grade; 94 | } 95 | 96 | public Boolean getStatus() { 97 | return status; 98 | } 99 | 100 | public void setStatus(Boolean status) { 101 | this.status = status; 102 | } 103 | 104 | public String getFileType() { 105 | return fileType; 106 | } 107 | 108 | public void setFileType(String fileType) { 109 | this.fileType = fileType == null ? null : fileType.trim(); 110 | } 111 | 112 | public String getLevelId() { 113 | return levelId; 114 | } 115 | 116 | public void setLevelId(String levelId) { 117 | this.levelId = levelId == null ? null : levelId.trim(); 118 | } 119 | 120 | public String getDepartmentId() { 121 | return departmentId; 122 | } 123 | 124 | public void setDepartmentId(String departmentId) { 125 | this.departmentId = departmentId == null ? null : departmentId.trim(); 126 | } 127 | 128 | public Date getGmtModified() { 129 | return gmtModified; 130 | } 131 | 132 | public void setGmtModified(Date gmtModified) { 133 | this.gmtModified = gmtModified; 134 | } 135 | 136 | public Date getGmtCreate() { 137 | return gmtCreate; 138 | } 139 | 140 | public void setGmtCreate(Date gmtCreate) { 141 | this.gmtCreate = gmtCreate; 142 | } 143 | 144 | public byte[] getFile() { 145 | return file; 146 | } 147 | 148 | public void setFile(byte[] file) { 149 | this.file = file; 150 | } 151 | } -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/entity/Plan.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.entity; 2 | 3 | import java.util.Date; 4 | 5 | public class Plan { 6 | private String id; 7 | 8 | private String collegesId; 9 | 10 | private String courseCode; 11 | 12 | private String courseName; 13 | 14 | private String startPro; 15 | 16 | private Boolean type; 17 | 18 | private String clazz; 19 | 20 | private Integer clazzNumber; 21 | 22 | private String teacher; 23 | 24 | private String remark; 25 | 26 | private String executePlanId; 27 | 28 | private Date gmtCreate; 29 | 30 | private Date gmtModified; 31 | 32 | public Plan(String id, String collegesId, String courseCode, String courseName, String startPro, Boolean type, String clazz, Integer clazzNumber, String teacher, String remark, String executePlanId, Date gmtCreate, Date gmtModified) { 33 | this.id = id; 34 | this.collegesId = collegesId; 35 | this.courseCode = courseCode; 36 | this.courseName = courseName; 37 | this.startPro = startPro; 38 | this.type = type; 39 | this.clazz = clazz; 40 | this.clazzNumber = clazzNumber; 41 | this.teacher = teacher; 42 | this.remark = remark; 43 | this.executePlanId = executePlanId; 44 | this.gmtCreate = gmtCreate; 45 | this.gmtModified = gmtModified; 46 | } 47 | 48 | public Plan() { 49 | super(); 50 | } 51 | 52 | public String getId() { 53 | return id; 54 | } 55 | 56 | public void setId(String id) { 57 | this.id = id == null ? null : id.trim(); 58 | } 59 | 60 | public String getCollegesId() { 61 | return collegesId; 62 | } 63 | 64 | public void setCollegesId(String collegesId) { 65 | this.collegesId = collegesId == null ? null : collegesId.trim(); 66 | } 67 | 68 | public String getCourseCode() { 69 | return courseCode; 70 | } 71 | 72 | public void setCourseCode(String courseCode) { 73 | this.courseCode = courseCode == null ? null : courseCode.trim(); 74 | } 75 | 76 | public String getCourseName() { 77 | return courseName; 78 | } 79 | 80 | public void setCourseName(String courseName) { 81 | this.courseName = courseName == null ? null : courseName.trim(); 82 | } 83 | 84 | public String getStartPro() { 85 | return startPro; 86 | } 87 | 88 | public void setStartPro(String startPro) { 89 | this.startPro = startPro == null ? null : startPro.trim(); 90 | } 91 | 92 | public Boolean getType() { 93 | return type; 94 | } 95 | 96 | public void setType(Boolean type) { 97 | this.type = type; 98 | } 99 | 100 | public String getClazz() { 101 | return clazz; 102 | } 103 | 104 | public void setClazz(String clazz) { 105 | this.clazz = clazz == null ? null : clazz.trim(); 106 | } 107 | 108 | public Integer getClazzNumber() { 109 | return clazzNumber; 110 | } 111 | 112 | public void setClazzNumber(Integer clazzNumber) { 113 | this.clazzNumber = clazzNumber; 114 | } 115 | 116 | public String getTeacher() { 117 | return teacher; 118 | } 119 | 120 | public void setTeacher(String teacher) { 121 | this.teacher = teacher == null ? null : teacher.trim(); 122 | } 123 | 124 | public String getRemark() { 125 | return remark; 126 | } 127 | 128 | public void setRemark(String remark) { 129 | this.remark = remark == null ? null : remark.trim(); 130 | } 131 | 132 | public String getExecutePlanId() { 133 | return executePlanId; 134 | } 135 | 136 | public void setExecutePlanId(String executePlanId) { 137 | this.executePlanId = executePlanId == null ? null : executePlanId.trim(); 138 | } 139 | 140 | public Date getGmtCreate() { 141 | return gmtCreate; 142 | } 143 | 144 | public void setGmtCreate(Date gmtCreate) { 145 | this.gmtCreate = gmtCreate; 146 | } 147 | 148 | public Date getGmtModified() { 149 | return gmtModified; 150 | } 151 | 152 | public void setGmtModified(Date gmtModified) { 153 | this.gmtModified = gmtModified; 154 | } 155 | } -------------------------------------------------------------------------------- /tmpp-plan/src/main/java/top/sl/tmpp/plan/controller/PlanController.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.plan.controller; 2 | 3 | import org.apache.commons.io.IOUtils; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.*; 9 | import org.springframework.web.multipart.MultipartFile; 10 | import top.sl.tmpp.common.entity.ExecutePlan; 11 | import top.sl.tmpp.common.entity.LoginUser; 12 | import top.sl.tmpp.common.util.RestModel; 13 | import top.sl.tmpp.plan.exception.FileException; 14 | import top.sl.tmpp.plan.service.FileService; 15 | import top.sl.tmpp.plan.service.ReferPlanService; 16 | import top.sl.tmpp.plan.util.FileUtil; 17 | 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.io.ByteArrayInputStream; 20 | import java.nio.charset.StandardCharsets; 21 | 22 | 23 | /** 24 | * @author ShuLu 25 | * @date 2019/6/17 13:46 26 | */ 27 | @RestController 28 | public class PlanController { 29 | private static final Logger logger = LoggerFactory.getLogger(PlanController.class); 30 | 31 | private final ReferPlanService referPlanService; 32 | private final FileService fileService; 33 | 34 | public PlanController(ReferPlanService referPlanService, FileService fileService) { 35 | this.referPlanService = referPlanService; 36 | this.fileService = fileService; 37 | } 38 | 39 | /** 40 | * 上传执行计划文件 41 | * 42 | * @param file 文件 43 | * @return ResponseEntity 44 | */ 45 | @PostMapping("/execute_plan_file") 46 | public ResponseEntity uploadFile(LoginUser loginUser, @RequestParam("planFile") MultipartFile file) { 47 | return RestModel.created("上传成功", fileService.fileUpload(file)); 48 | } 49 | 50 | /** 51 | * 提交执行计划 52 | * 53 | * @param year 学年 54 | * @param term 学期 55 | * @param teachingDepartment 授课部门 56 | * @param educationalLevel 教育层次 57 | * @param fileId 执行计划文件 ID 58 | * @return ResponseEntity 59 | */ 60 | @PostMapping("/execute_plan") 61 | public ResponseEntity plan(LoginUser loginUser, 62 | @RequestParam String year, 63 | @RequestParam boolean term, 64 | @RequestParam String teachingDepartment, 65 | @RequestParam String educationalLevel, 66 | @RequestParam String fileId) { 67 | referPlanService.referPlan(year, term, teachingDepartment, educationalLevel, fileId); 68 | return RestModel.created("提交成功", null); 69 | } 70 | 71 | /** 72 | * 下载执行计划 73 | * 74 | * @param executePlanId 执行计划ID 75 | * @param response {@link HttpServletResponse} 76 | */ 77 | @GetMapping("/down_execute_plan") 78 | public void downPlan(LoginUser loginUser, @RequestParam String executePlanId, HttpServletResponse response) { 79 | ExecutePlan executePlan = referPlanService.downloadExecutePlan(executePlanId); 80 | byte[] file = executePlan.getFile(); 81 | String fileName = "执行计划." + executePlan.getFileType(); 82 | response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(), StandardCharsets.ISO_8859_1)); 83 | response.setIntHeader("Content-Length", file.length); 84 | response.setContentType(FileUtil.getContentTypeByExtensionName(executePlan.getFileType())); 85 | try (ByteArrayInputStream bis = new ByteArrayInputStream(file)) { 86 | IOUtils.copy(bis, response.getOutputStream()); 87 | } catch (Exception e) { 88 | if (!e.getMessage().contains("连接")) { 89 | throw new FileException("下载失败:" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); 90 | } 91 | } 92 | } 93 | 94 | /** 95 | * 删除执行计划 96 | * 97 | * @param id 执行计划ID 98 | * @return ResponseEntity 99 | */ 100 | @DeleteMapping("/execute_plan") 101 | public ResponseEntity removeExecutePlan(LoginUser loginUser, @RequestParam String id) { 102 | referPlanService.removeExecutePlan(id); 103 | return RestModel.noContent(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /tmpp-common/src/main/resources/mappers/LoginUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, 15 | name, 16 | user_type, 17 | gmt_create, 18 | gmt_modified 19 | 20 | 26 | 27 | delete 28 | from login_user 29 | where id = #{id,jdbcType=VARCHAR} 30 | 31 | 32 | insert into login_user (id, name, user_type, 33 | gmt_create, gmt_modified) 34 | values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{userType,jdbcType=VARCHAR}, 35 | #{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}) 36 | 37 | 38 | insert into login_user 39 | 40 | 41 | id, 42 | 43 | 44 | name, 45 | 46 | 47 | user_type, 48 | 49 | 50 | gmt_create, 51 | 52 | 53 | gmt_modified, 54 | 55 | 56 | 57 | 58 | #{id,jdbcType=VARCHAR}, 59 | 60 | 61 | #{name,jdbcType=VARCHAR}, 62 | 63 | 64 | #{userType,jdbcType=VARCHAR}, 65 | 66 | 67 | #{gmtCreate,jdbcType=TIMESTAMP}, 68 | 69 | 70 | #{gmtModified,jdbcType=TIMESTAMP}, 71 | 72 | 73 | 74 | 75 | update login_user 76 | 77 | 78 | name = #{name,jdbcType=VARCHAR}, 79 | 80 | 81 | user_type = #{userType,jdbcType=VARCHAR}, 82 | 83 | 84 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, 85 | 86 | 87 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, 88 | 89 | 90 | where id = #{id,jdbcType=VARCHAR} 91 | 92 | 93 | update login_user 94 | set name = #{name,jdbcType=VARCHAR}, 95 | user_type = #{userType,jdbcType=VARCHAR}, 96 | gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, 97 | gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} 98 | where id = #{id,jdbcType=VARCHAR} 99 | 100 | -------------------------------------------------------------------------------- /tmpp-acquire/src/main/java/top/sl/tmpp/acquire/controller/AcquireController.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.acquire.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | import top.sl.tmpp.acquire.service.AcquireService; 11 | import top.sl.tmpp.common.entity.Colleges; 12 | import top.sl.tmpp.common.entity.Department; 13 | import top.sl.tmpp.common.entity.Level; 14 | import top.sl.tmpp.common.entity.LoginUser; 15 | import top.sl.tmpp.common.pojo.CourseDTO; 16 | import top.sl.tmpp.common.util.RestModel; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * 获取 22 | * 23 | * @author ShuLu 24 | * @date 2019/6/24 14:39 25 | */ 26 | @RestController 27 | public class AcquireController { 28 | private static final Logger logger = LoggerFactory.getLogger(AcquireController.class); 29 | 30 | private final AcquireService acquireService; 31 | 32 | @Autowired 33 | public AcquireController(AcquireService acquireService) { 34 | this.acquireService = acquireService; 35 | } 36 | 37 | /** 38 | * 查询所有学院 39 | * 40 | * @return ResponseEntity 41 | */ 42 | @GetMapping("/colleges") 43 | public ResponseEntity getAllCollege(LoginUser loginUser) { 44 | List colleges = acquireService.getAllCollege(); 45 | logger.debug("查询所有学院成功"); 46 | return RestModel.ok(colleges); 47 | } 48 | 49 | /** 50 | * 获取所有课程 51 | * 52 | * @param executePlanId 执行计划ID 53 | * @return ResponseEntity 54 | */ 55 | @GetMapping("/courseTitles") 56 | public ResponseEntity getAllCourse(@RequestParam("execute_plan_id") String executePlanId, LoginUser loginUser) { 57 | List courses = acquireService.getAllCourse(executePlanId); 58 | logger.debug("查询成功"); 59 | return RestModel.ok(courses); 60 | } 61 | 62 | /** 63 | * 获取所有授课部门 64 | * 65 | * @return ResponseEntity 66 | */ 67 | @GetMapping("/teaching_departments") 68 | public ResponseEntity getAllDepartment(LoginUser loginUser) { 69 | List departments = acquireService.getAllDepartment(); 70 | logger.debug("获取所有授课部门成功"); 71 | return RestModel.ok(departments); 72 | } 73 | 74 | /** 75 | * 获取所有计划列表 76 | * 77 | * @param page 页码 78 | * @param size 数量 79 | * @return ResponseEntity 80 | */ 81 | @GetMapping("/execute_plans") 82 | public ResponseEntity plan(@RequestParam(required = false, defaultValue = "1") int page, 83 | @RequestParam(required = false, defaultValue = "50") int size, 84 | LoginUser loginUser) { 85 | return RestModel.ok(acquireService.getAllExecutePlan(page, size)); 86 | } 87 | 88 | /** 89 | * 获取所有教育层次 90 | * 91 | * @return ResponseEntity 92 | */ 93 | @GetMapping("/educational_levels") 94 | public ResponseEntity getAllLevel(LoginUser loginUser) { 95 | List levels = acquireService.getAllLevel(); 96 | logger.debug("获取所有层次成功"); 97 | return RestModel.ok(levels); 98 | } 99 | 100 | /** 101 | * 获取未完成执行计划 102 | * 103 | * @return ResponseEntity 104 | */ 105 | @GetMapping("/undone_execute_plan") 106 | public ResponseEntity undoneExecutePlan(LoginUser loginUser) { 107 | return RestModel.ok(acquireService.getAllUnDoneExecutePlan()); 108 | } 109 | 110 | /** 111 | * 获取执行计划年 112 | * 113 | * @return ResponseEntity 114 | */ 115 | @GetMapping("/year") 116 | public ResponseEntity year(LoginUser loginUser) { 117 | return RestModel.ok(acquireService.getYears()); 118 | } 119 | 120 | /** 121 | * 获取计划学期 122 | * 123 | * @param year 学年 124 | * @return ResponseEntity 125 | */ 126 | @GetMapping("/term") 127 | public ResponseEntity term(@RequestParam String year, LoginUser loginUser) { 128 | return RestModel.ok(acquireService.getTerms(year)); 129 | } 130 | 131 | /** 132 | * 获取已完成执行计划 133 | * 134 | * @return ResponseEntity 135 | */ 136 | @GetMapping("/done_execute_plan") 137 | public ResponseEntity doneExecutePlan(LoginUser loginUser) { 138 | return RestModel.ok(acquireService.getAllDoneExecutePlan()); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /tmpp-review/src/main/java/top/sl/tmpp/review/controller/ReviewController.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.review.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | import top.sl.tmpp.common.entity.LoginUser; 13 | import top.sl.tmpp.common.pojo.BookDTO; 14 | import top.sl.tmpp.common.util.RestModel; 15 | import top.sl.tmpp.review.service.ReviewService; 16 | 17 | /** 18 | * 审核 19 | * 20 | * @author itning 21 | * @date 2019/6/23 11:14 22 | */ 23 | @RestController 24 | public class ReviewController { 25 | private static final Logger logger = LoggerFactory.getLogger(ReviewController.class); 26 | 27 | private final ReviewService reviewService; 28 | 29 | @Autowired 30 | public ReviewController(ReviewService reviewService) { 31 | this.reviewService = reviewService; 32 | } 33 | 34 | /** 35 | * 办公室主任全部审核通过 36 | * 37 | * @param executePlanId 执行计划id 38 | * @return ResponseEntity 39 | */ 40 | @PostMapping("/all_passed") 41 | public ResponseEntity allPassed(LoginUser loginUser, @RequestParam String executePlanId) { 42 | reviewService.oAllPassed(executePlanId); 43 | return RestModel.created("办公室主任全部审核通过", null); 44 | } 45 | 46 | /** 47 | * 教务处全部审核通过 48 | * 49 | * @param executePlanId 执行计划id 50 | * @return ResponseEntity 51 | */ 52 | @PostMapping("/examination_passed") 53 | public ResponseEntity examinationPassed(LoginUser loginUser, @RequestParam String executePlanId) { 54 | reviewService.aAllPassed(executePlanId); 55 | return RestModel.created("全部审核通过", null); 56 | } 57 | 58 | /** 59 | * 教务处驳回 60 | * 61 | * @param id 购书计划id 62 | * @return ResponseEntity 63 | */ 64 | @PostMapping("/turn_down") 65 | public ResponseEntity turnDown(LoginUser loginUser, @RequestParam String id) { 66 | reviewService.aTurnDown(id); 67 | return RestModel.created("驳回操作成功", null); 68 | } 69 | 70 | /** 71 | * 办公室主任驳回 72 | * 73 | * @param id 购书计划id 74 | * @return ResponseEntity 75 | */ 76 | @PostMapping("/office_turn_down") 77 | public ResponseEntity officeTurnDown(LoginUser loginUser, @RequestParam String id) { 78 | reviewService.oTurnDown(id); 79 | return RestModel.created("驳回操作成功", null); 80 | } 81 | 82 | /** 83 | * 教务处是否购买样书 84 | * 85 | * @param bookId 购书计划id 86 | * @param isBuyBook 是否购买样书(是:1,否:0) 87 | * @return ResponseEntity 88 | */ 89 | @PostMapping("/buy_sample_book") 90 | public ResponseEntity buySampleBook(LoginUser loginUser, @RequestParam String bookId, @RequestParam boolean isBuyBook) { 91 | reviewService.isByBook(bookId, isBuyBook); 92 | return RestModel.created("操作成功", null); 93 | } 94 | 95 | /** 96 | * 教务处我的审核 97 | * 98 | * @param executePlanId 执行计划id 99 | * @param page 页码 100 | * @param size 数量 101 | * @return ResponseEntity 102 | */ 103 | @GetMapping("/my_review") 104 | public ResponseEntity myReview(LoginUser loginUser, 105 | @RequestParam String executePlanId, 106 | @RequestParam(required = false, defaultValue = "1") int page, 107 | @RequestParam(required = false, defaultValue = "50") int size) { 108 | logger.debug("my_review params: {} {} {}", executePlanId, page, size); 109 | PageInfo bookPageInfo = reviewService.getMyReview(executePlanId, page, size); 110 | return RestModel.ok(bookPageInfo); 111 | } 112 | 113 | /** 114 | * 办公室主任我的审核 115 | * 116 | * @param executePlanId 执行计划id 117 | * @param page 页码 118 | * @param size 数量 119 | * @return ResponseEntity 120 | */ 121 | @GetMapping("/director_review") 122 | public ResponseEntity directorReview(LoginUser loginUser, 123 | @RequestParam String executePlanId, 124 | @RequestParam(required = false, defaultValue = "1") int page, 125 | @RequestParam(required = false, defaultValue = "50") int size) { 126 | logger.debug("director_review params: {} {} {}", executePlanId, page, size); 127 | PageInfo oReviews = reviewService.getDirectorReview(executePlanId, page, size); 128 | return RestModel.ok(oReviews); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /tmpp-review/src/main/java/top/sl/tmpp/review/service/impl/ReviewServiceImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.review.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | import top.sl.tmpp.common.entity.Book; 9 | import top.sl.tmpp.common.entity.ExecutePlan; 10 | import top.sl.tmpp.common.exception.IdNotFoundException; 11 | import top.sl.tmpp.common.exception.IllegalParameterException; 12 | import top.sl.tmpp.common.mapper.BookMapper; 13 | import top.sl.tmpp.common.mapper.ExecutePlanMapper; 14 | import top.sl.tmpp.common.mapper.PlanMapper; 15 | import top.sl.tmpp.common.pojo.BookDTO; 16 | import top.sl.tmpp.review.service.ReviewService; 17 | 18 | import java.util.Date; 19 | import java.util.Objects; 20 | 21 | /** 22 | * @author itning 23 | * @date 2019/6/23 11:46 24 | */ 25 | @Service 26 | @Transactional(rollbackFor = Exception.class) 27 | public class ReviewServiceImpl implements ReviewService { 28 | private final BookMapper bookMapper; 29 | private final PlanMapper planMapper; 30 | private final ExecutePlanMapper executePlanMapper; 31 | 32 | @Autowired 33 | public ReviewServiceImpl(BookMapper bookMapper, PlanMapper planMapper, ExecutePlanMapper executePlanMapper) { 34 | this.bookMapper = bookMapper; 35 | this.planMapper = planMapper; 36 | this.executePlanMapper = executePlanMapper; 37 | } 38 | 39 | @Override 40 | public PageInfo getDirectorReview(String executePlanId, int page, int size) { 41 | return PageHelper 42 | .startPage(page, size) 43 | .doSelectPageInfo(() -> bookMapper.selectReviews(executePlanId)); 44 | } 45 | 46 | @Override 47 | public PageInfo getMyReview(String executePlanId, int page, int size) { 48 | return PageHelper 49 | .startPage(page, size) 50 | .doSelectPageInfo(() -> bookMapper.selectAllByExecutePlanId(executePlanId)); 51 | } 52 | 53 | @Override 54 | public void isByBook(String id, boolean is) { 55 | Book b = bookMapper.selectByPrimaryKey(id); 56 | if (b == null) { 57 | throw new IdNotFoundException(id); 58 | } 59 | if (!b.getIsBookPurchase()) { 60 | throw new IllegalParameterException("教师未购书,教务处无法购买样书"); 61 | } 62 | Book book = new Book(); 63 | book.setId(id); 64 | book.setIsBuyBook(is); 65 | book.setGmtModified(new Date()); 66 | bookMapper.updateByPrimaryKeySelective(book); 67 | } 68 | 69 | @Override 70 | public void oAllPassed(String executePlanId) { 71 | bookMapper.selectIdAndStatus(executePlanId) 72 | .stream() 73 | //办公室主任全部审核通过 只要没审核的 74 | .filter(book -> book.getStatus() == 0) 75 | .map(book -> { 76 | Book b = new Book(); 77 | b.setId(book.getId()); 78 | b.setStatus(1); 79 | b.setGmtModified(new Date()); 80 | return b; 81 | }) 82 | .forEach(bookMapper::updateByPrimaryKeySelective); 83 | } 84 | 85 | @Override 86 | public void aAllPassed(String executePlanId) { 87 | bookMapper.selectIdAndStatus(executePlanId) 88 | .stream() 89 | //教务处全部审核通过 办公室主任审核通过的 90 | .filter(book -> book.getStatus() == 1) 91 | .map(book -> { 92 | Book b = new Book(); 93 | b.setId(book.getId()); 94 | b.setStatus(2); 95 | b.setGmtModified(new Date()); 96 | return b; 97 | }) 98 | .forEach(bookMapper::updateByPrimaryKeySelective); 99 | //获取null的数量 100 | long count = planMapper.selectAllByExecutePlanGroupByBookId(executePlanId).stream().filter(Objects::isNull).count(); 101 | if (count == 0L) { 102 | long l = bookMapper.countByExecutePlanAndStatusNot2(executePlanId); 103 | if (l == 0L) { 104 | //全是教务处审核通过 105 | ExecutePlan executePlan = new ExecutePlan(); 106 | executePlan.setId(executePlanId); 107 | executePlan.setStatus(true); 108 | executePlan.setGmtModified(new Date()); 109 | executePlanMapper.updateByPrimaryKeySelective(executePlan); 110 | } 111 | } 112 | } 113 | 114 | @Override 115 | public void oTurnDown(String id) { 116 | Book book = new Book(); 117 | book.setId(id); 118 | book.setStatus(3); 119 | book.setGmtModified(new Date()); 120 | bookMapper.updateByPrimaryKeySelective(book); 121 | } 122 | 123 | @Override 124 | public void aTurnDown(String id) { 125 | Book book = new Book(); 126 | book.setId(id); 127 | book.setStatus(4); 128 | book.setGmtModified(new Date()); 129 | bookMapper.updateByPrimaryKeySelective(book); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/TeacherReceiveBook.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | /** 7 | * 教师领取教材汇总表 8 | * 9 | * @author ShuLu 10 | * @date 2019/6/26 11:31 11 | */ 12 | public class TeacherReceiveBook { 13 | /** 14 | * 授课部门名称 15 | */ 16 | private String departmentName; 17 | /** 18 | * 课程名称 19 | */ 20 | private String courseName; 21 | /** 22 | * 课程类型 23 | */ 24 | private String type; 25 | /** 26 | * 专业 27 | */ 28 | private String startPro; 29 | /** 30 | * 教材名称 31 | */ 32 | private String textBookName; 33 | /** 34 | * 作者 35 | */ 36 | private String author; 37 | /** 38 | * 出版社 39 | */ 40 | private String press; 41 | /** 42 | * 书号isbn 43 | */ 44 | private String isbn; 45 | /** 46 | * 出版日期 47 | */ 48 | private Date publicationDate; 49 | /** 50 | * 获奖信息 51 | */ 52 | private String awardInformation; 53 | /** 54 | * 单价 55 | */ 56 | private BigDecimal unitPrice; 57 | /** 58 | * 使用年级 59 | */ 60 | private String grade; 61 | /** 62 | * 使用班级 63 | */ 64 | private String clazz; 65 | /** 66 | * 教师样书数量 67 | */ 68 | private Integer teacherBookNumber; 69 | /** 70 | * 征订人 71 | */ 72 | private String subscriber; 73 | 74 | public TeacherReceiveBook() { 75 | } 76 | 77 | public TeacherReceiveBook(String departmentName, String courseName, String type, String startPro, String textBookName, String author, String press, String isbn, Date publicationDate, String awardInformation, BigDecimal unitPrice, String grade, String clazz, Integer teacherBookNumber, String subscriber) { 78 | this.departmentName = departmentName; 79 | this.courseName = courseName; 80 | this.type = type; 81 | this.startPro = startPro; 82 | this.textBookName = textBookName; 83 | this.author = author; 84 | this.press = press; 85 | this.isbn = isbn; 86 | this.publicationDate = publicationDate; 87 | this.awardInformation = awardInformation; 88 | this.unitPrice = unitPrice; 89 | this.grade = grade; 90 | this.clazz = clazz; 91 | this.teacherBookNumber = teacherBookNumber; 92 | this.subscriber = subscriber; 93 | } 94 | 95 | public String getDepartmentName() { 96 | return departmentName; 97 | } 98 | 99 | public void setDepartmentName(String departmentName) { 100 | this.departmentName = departmentName; 101 | } 102 | 103 | public String getCourseName() { 104 | return courseName; 105 | } 106 | 107 | public void setCourseName(String courseName) { 108 | this.courseName = courseName; 109 | } 110 | 111 | public String getType() { 112 | return type; 113 | } 114 | 115 | public void setType(String type) { 116 | this.type = type; 117 | } 118 | 119 | public String getStartPro() { 120 | return startPro; 121 | } 122 | 123 | public void setStartPro(String startPro) { 124 | this.startPro = startPro; 125 | } 126 | 127 | public String getTextBookName() { 128 | return textBookName; 129 | } 130 | 131 | public void setTextBookName(String textBookName) { 132 | this.textBookName = textBookName; 133 | } 134 | 135 | public String getAuthor() { 136 | return author; 137 | } 138 | 139 | public void setAuthor(String author) { 140 | this.author = author; 141 | } 142 | 143 | public String getPress() { 144 | return press; 145 | } 146 | 147 | public void setPress(String press) { 148 | this.press = press; 149 | } 150 | 151 | public String getIsbn() { 152 | return isbn; 153 | } 154 | 155 | public void setIsbn(String isbn) { 156 | this.isbn = isbn; 157 | } 158 | 159 | public Date getPublicationDate() { 160 | return publicationDate; 161 | } 162 | 163 | public void setPublicationDate(Date publicationDate) { 164 | this.publicationDate = publicationDate; 165 | } 166 | 167 | public String getAwardInformation() { 168 | return awardInformation; 169 | } 170 | 171 | public void setAwardInformation(String awardInformation) { 172 | this.awardInformation = awardInformation; 173 | } 174 | 175 | public BigDecimal getUnitPrice() { 176 | return unitPrice; 177 | } 178 | 179 | public void setUnitPrice(BigDecimal unitPrice) { 180 | this.unitPrice = unitPrice; 181 | } 182 | 183 | public String getGrade() { 184 | return grade; 185 | } 186 | 187 | public void setGrade(String grade) { 188 | this.grade = grade; 189 | } 190 | 191 | public String getClazz() { 192 | return clazz; 193 | } 194 | 195 | public void setClazz(String clazz) { 196 | this.clazz = clazz; 197 | } 198 | 199 | public Integer getTeacherBookNumber() { 200 | return teacherBookNumber; 201 | } 202 | 203 | public void setTeacherBookNumber(Integer teacherBookNumber) { 204 | this.teacherBookNumber = teacherBookNumber; 205 | } 206 | 207 | public String getSubscriber() { 208 | return subscriber; 209 | } 210 | 211 | public void setSubscriber(String subscriber) { 212 | this.subscriber = subscriber; 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/SubscriptionBook.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | /** 7 | * 征订教材样书统计表 8 | * 9 | * @author ShuLu 10 | * @date 2019/6/26 11:22 11 | */ 12 | public class SubscriptionBook { 13 | /** 14 | * 授课部门名称 15 | */ 16 | private String departmentName; 17 | /** 18 | * 课程名称 19 | */ 20 | private String courseName; 21 | /** 22 | * 课程类型 23 | */ 24 | private String type; 25 | /** 26 | * 专业 27 | */ 28 | private String startPro; 29 | /** 30 | * 教材名称 31 | */ 32 | private String textBookName; 33 | /** 34 | * 作者 35 | */ 36 | private String author; 37 | /** 38 | * 出版社 39 | */ 40 | private String press; 41 | /** 42 | * 书籍编号 43 | */ 44 | private String isbn; 45 | /** 46 | * 出版日期 47 | */ 48 | private Date publicationDate; 49 | /** 50 | * 获奖信息 51 | */ 52 | private String awardInformation; 53 | /** 54 | * 单价 55 | */ 56 | private BigDecimal unitPrice; 57 | /** 58 | * 使用年级 59 | */ 60 | private String grade; 61 | /** 62 | * 教务处样书 63 | */ 64 | private Integer isBuyBook; 65 | /** 66 | * 征订人 67 | */ 68 | private String subscriber; 69 | /** 70 | * 征订人电话 71 | */ 72 | private String subscriberTel; 73 | /** 74 | * 备注 75 | */ 76 | private String remark; 77 | 78 | public SubscriptionBook() { 79 | } 80 | 81 | public SubscriptionBook(String departmentName, String courseName, String type, String startPro, String textBookName, String author, String press, String isbn, Date publicationDate, String awardInformation, BigDecimal unitPrice, String grade, Integer isBuyBook, String subscriber, String subscriberTel, String remark) { 82 | this.departmentName = departmentName; 83 | this.courseName = courseName; 84 | this.type = type; 85 | this.startPro = startPro; 86 | this.textBookName = textBookName; 87 | this.author = author; 88 | this.press = press; 89 | this.isbn = isbn; 90 | this.publicationDate = publicationDate; 91 | this.awardInformation = awardInformation; 92 | this.unitPrice = unitPrice; 93 | this.grade = grade; 94 | this.isBuyBook = isBuyBook; 95 | this.subscriber = subscriber; 96 | this.subscriberTel = subscriberTel; 97 | this.remark = remark; 98 | } 99 | 100 | public String getDepartmentName() { 101 | return departmentName; 102 | } 103 | 104 | public void setDepartmentName(String departmentName) { 105 | this.departmentName = departmentName; 106 | } 107 | 108 | public String getCourseName() { 109 | return courseName; 110 | } 111 | 112 | public void setCourseName(String courseName) { 113 | this.courseName = courseName; 114 | } 115 | 116 | public String getType() { 117 | return type; 118 | } 119 | 120 | public void setType(String type) { 121 | this.type = type; 122 | } 123 | 124 | public String getStartPro() { 125 | return startPro; 126 | } 127 | 128 | public void setStartPro(String startPro) { 129 | this.startPro = startPro; 130 | } 131 | 132 | public String getTextBookName() { 133 | return textBookName; 134 | } 135 | 136 | public void setTextBookName(String textBookName) { 137 | this.textBookName = textBookName; 138 | } 139 | 140 | public String getAuthor() { 141 | return author; 142 | } 143 | 144 | public void setAuthor(String author) { 145 | this.author = author; 146 | } 147 | 148 | public String getPress() { 149 | return press; 150 | } 151 | 152 | public void setPress(String press) { 153 | this.press = press; 154 | } 155 | 156 | public String getIsbn() { 157 | return isbn; 158 | } 159 | 160 | public void setIsbn(String isbn) { 161 | this.isbn = isbn; 162 | } 163 | 164 | public Date getPublicationDate() { 165 | return publicationDate; 166 | } 167 | 168 | public void setPublicationDate(Date publicationDate) { 169 | this.publicationDate = publicationDate; 170 | } 171 | 172 | public String getAwardInformation() { 173 | return awardInformation; 174 | } 175 | 176 | public void setAwardInformation(String awardInformation) { 177 | this.awardInformation = awardInformation; 178 | } 179 | 180 | public BigDecimal getUnitPrice() { 181 | return unitPrice; 182 | } 183 | 184 | public void setUnitPrice(BigDecimal unitPrice) { 185 | this.unitPrice = unitPrice; 186 | } 187 | 188 | public String getGrade() { 189 | return grade; 190 | } 191 | 192 | public void setGrade(String grade) { 193 | this.grade = grade; 194 | } 195 | 196 | public Integer getIsBuyBook() { 197 | return isBuyBook; 198 | } 199 | 200 | public void setIsBuyBook(Integer isBuyBook) { 201 | this.isBuyBook = isBuyBook; 202 | } 203 | 204 | public String getSubscriber() { 205 | return subscriber; 206 | } 207 | 208 | public void setSubscriber(String subscriber) { 209 | this.subscriber = subscriber; 210 | } 211 | 212 | public String getSubscriberTel() { 213 | return subscriberTel; 214 | } 215 | 216 | public void setSubscriberTel(String subscriberTel) { 217 | this.subscriberTel = subscriberTel; 218 | } 219 | 220 | public String getRemark() { 221 | return remark; 222 | } 223 | 224 | public void setRemark(String remark) { 225 | this.remark = remark; 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /tmpp-common/src/main/java/top/sl/tmpp/common/pojo/SubscriptionBookPlan.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.common.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | /** 7 | * 征订教材计划统计表 8 | * 9 | * @author ShuLu 10 | * @date 2019/6/29 12:22 11 | */ 12 | public class SubscriptionBookPlan { 13 | /** 14 | * 课程代码 15 | */ 16 | private String code; 17 | /** 18 | * 课程名称 19 | */ 20 | private String name; 21 | /** 22 | * 书籍编号 23 | */ 24 | private String isbn; 25 | /** 26 | * 教材名称 27 | */ 28 | private String textBookName; 29 | /** 30 | * 教材类别 31 | */ 32 | private String textBookCategory; 33 | /** 34 | * 出版社 35 | */ 36 | private String press; 37 | /** 38 | * 作者 39 | */ 40 | private String author; 41 | /** 42 | * 单价 43 | */ 44 | private BigDecimal unitPrice; 45 | /** 46 | * 教师样书数量 47 | */ 48 | private Integer teacherBookNumber; 49 | /** 50 | * 折扣 51 | */ 52 | private BigDecimal discount; 53 | /** 54 | * 获奖信息 55 | */ 56 | private String awardInformation; 57 | /** 58 | * 出版日期 59 | */ 60 | private Date publicationDate; 61 | /** 62 | * 征订人 63 | */ 64 | private String subscriber; 65 | /** 66 | * 联系电话 67 | */ 68 | private String subscriberTel; 69 | /** 70 | * 是否购书 71 | */ 72 | private String isBookPurchase; 73 | /** 74 | * 备注 75 | */ 76 | private String reason; 77 | 78 | public SubscriptionBookPlan() { 79 | } 80 | 81 | public SubscriptionBookPlan(String code, String name, String isbn, String textBookName, String textBookCategory, String press, String author, BigDecimal unitPrice, Integer teacherBookNumber, BigDecimal discount, String awardInformation, Date publicationDate, String subscriber, String subscriberTel, String isBookPurchase, String reason) { 82 | this.code = code; 83 | this.name = name; 84 | this.isbn = isbn; 85 | this.textBookName = textBookName; 86 | this.textBookCategory = textBookCategory; 87 | this.press = press; 88 | this.author = author; 89 | this.unitPrice = unitPrice; 90 | this.teacherBookNumber = teacherBookNumber; 91 | this.discount = discount; 92 | this.awardInformation = awardInformation; 93 | this.publicationDate = publicationDate; 94 | this.subscriber = subscriber; 95 | this.subscriberTel = subscriberTel; 96 | this.isBookPurchase = isBookPurchase; 97 | this.reason = reason; 98 | } 99 | 100 | public String getCode() { 101 | return code; 102 | } 103 | 104 | public void setCode(String code) { 105 | this.code = code; 106 | } 107 | 108 | public String getName() { 109 | return name; 110 | } 111 | 112 | public void setName(String name) { 113 | this.name = name; 114 | } 115 | 116 | public String getIsbn() { 117 | return isbn; 118 | } 119 | 120 | public void setIsbn(String isbn) { 121 | this.isbn = isbn; 122 | } 123 | 124 | public String getTextBookName() { 125 | return textBookName; 126 | } 127 | 128 | public void setTextBookName(String textBookName) { 129 | this.textBookName = textBookName; 130 | } 131 | 132 | public String getTextBookCategory() { 133 | return textBookCategory; 134 | } 135 | 136 | public void setTextBookCategory(String textBookCategory) { 137 | this.textBookCategory = textBookCategory; 138 | } 139 | 140 | public String getPress() { 141 | return press; 142 | } 143 | 144 | public void setPress(String press) { 145 | this.press = press; 146 | } 147 | 148 | public String getAuthor() { 149 | return author; 150 | } 151 | 152 | public void setAuthor(String author) { 153 | this.author = author; 154 | } 155 | 156 | public BigDecimal getUnitPrice() { 157 | return unitPrice; 158 | } 159 | 160 | public void setUnitPrice(BigDecimal unitPrice) { 161 | this.unitPrice = unitPrice; 162 | } 163 | 164 | public Integer getTeacherBookNumber() { 165 | return teacherBookNumber; 166 | } 167 | 168 | public void setTeacherBookNumber(Integer teacherBookNumber) { 169 | this.teacherBookNumber = teacherBookNumber; 170 | } 171 | 172 | public BigDecimal getDiscount() { 173 | return discount; 174 | } 175 | 176 | public void setDiscount(BigDecimal discount) { 177 | this.discount = discount; 178 | } 179 | 180 | public String getAwardInformation() { 181 | return awardInformation; 182 | } 183 | 184 | public void setAwardInformation(String awardInformation) { 185 | this.awardInformation = awardInformation; 186 | } 187 | 188 | public Date getPublicationDate() { 189 | return publicationDate; 190 | } 191 | 192 | public void setPublicationDate(Date publicationDate) { 193 | this.publicationDate = publicationDate; 194 | } 195 | 196 | public String getSubscriber() { 197 | return subscriber; 198 | } 199 | 200 | public void setSubscriber(String subscriber) { 201 | this.subscriber = subscriber; 202 | } 203 | 204 | public String getSubscriberTel() { 205 | return subscriberTel; 206 | } 207 | 208 | public void setSubscriberTel(String subscriberTel) { 209 | this.subscriberTel = subscriberTel; 210 | } 211 | 212 | public String getIsBookPurchase() { 213 | return isBookPurchase; 214 | } 215 | 216 | public void setIsBookPurchase(String isBookPurchase) { 217 | this.isBookPurchase = isBookPurchase; 218 | } 219 | 220 | public String getReason() { 221 | return reason; 222 | } 223 | 224 | public void setReason(String reason) { 225 | this.reason = reason; 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /tmpp-purchase/src/main/java/top/sl/tmpp/purchase/service/impl/PurchaseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.purchase.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.apache.commons.lang3.math.NumberUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import top.sl.tmpp.common.entity.Book; 10 | import top.sl.tmpp.common.entity.Plan; 11 | import top.sl.tmpp.common.entity.PlanBook; 12 | import top.sl.tmpp.common.exception.EmptyParameterException; 13 | import top.sl.tmpp.common.exception.IllegalParameterException; 14 | import top.sl.tmpp.common.mapper.BookMapper; 15 | import top.sl.tmpp.common.mapper.PlanBookMapper; 16 | import top.sl.tmpp.common.mapper.PlanMapper; 17 | import top.sl.tmpp.common.pojo.BookDTO; 18 | import top.sl.tmpp.common.util.ObjectUtils; 19 | import top.sl.tmpp.purchase.service.PurchaseService; 20 | 21 | import java.math.BigDecimal; 22 | import java.util.Date; 23 | import java.util.UUID; 24 | 25 | /** 26 | * @author itning 27 | * @date 2019/6/23 15:11 28 | */ 29 | @Service 30 | public class PurchaseServiceImpl implements PurchaseService { 31 | private final BookMapper bookMapper; 32 | private final PlanMapper planMapper; 33 | private final PlanBookMapper planBookMapper; 34 | 35 | @Autowired 36 | public PurchaseServiceImpl(BookMapper bookMapper, PlanMapper planMapper, PlanBookMapper planBookMapper) { 37 | this.bookMapper = bookMapper; 38 | this.planMapper = planMapper; 39 | this.planBookMapper = planBookMapper; 40 | } 41 | 42 | @Override 43 | public void buyBook(String loginUserId, String executePlanId, String courseCode, String isbn, String textBookName, Boolean textBookCategory, 44 | String press, String author, BigDecimal unitPrice, Integer teacherBookNumber, BigDecimal discount, 45 | String awardInformation, Date publicationDate, String subscriber, String subscriberTel, String bookId) { 46 | checkTel(subscriberTel); 47 | Book book = new Book(); 48 | book.setId(bookId); 49 | book.setIsbn(isbn); 50 | book.setTextBookName(textBookName); 51 | book.setTextBookCategory(textBookCategory); 52 | book.setPress(press); 53 | book.setAuthor(author); 54 | book.setUnitPrice(unitPrice); 55 | book.setTeacherBookNumber(teacherBookNumber); 56 | book.setDiscount(discount); 57 | book.setAwardInformation(awardInformation); 58 | book.setPublicationDate(publicationDate); 59 | book.setSubscriber(subscriber); 60 | book.setSubscriberTel(subscriberTel); 61 | book.setIsBookPurchase(true); 62 | book.setLoginUserId(loginUserId); 63 | book.setExecutePlanId(executePlanId); 64 | book.setStatus(0); 65 | //教务处购买样书默认false 66 | book.setIsBuyBook(false); 67 | Date date = new Date(); 68 | book.setGmtModified(date); 69 | book.setGmtCreate(date); 70 | if (bookId == null) { 71 | //新增图书 72 | book.setId(UUID.randomUUID().toString().replace("-", "")); 73 | ObjectUtils.checkObjectFieldsNotEmpty(book, "reason", "isBuyBook"); 74 | saveBookInfo(executePlanId, courseCode, book.getId(), book); 75 | } else { 76 | //修改图书 77 | ObjectUtils.checkObjectFieldsNotEmpty(book, "reason", "isBuyBook"); 78 | bookMapper.updateByPrimaryKey(book); 79 | } 80 | 81 | } 82 | 83 | /** 84 | * 检查电话号码正确性 85 | * 86 | * @param tel 电话号 87 | */ 88 | private void checkTel(String tel) { 89 | long telLong = NumberUtils.toLong(tel); 90 | if (telLong == 0L) { 91 | throw new IllegalParameterException("手机号不正确"); 92 | } 93 | if (tel.length() != 11) { 94 | throw new IllegalParameterException("手机号长度不正确,输入了" + tel.length() + "位"); 95 | } 96 | if (!tel.startsWith("1")) { 97 | throw new IllegalParameterException("手机号不正确"); 98 | } 99 | } 100 | 101 | @Override 102 | public void notBuyBook(String loginUserId, String executePlanId, String courseCode, String reason, String bookId) { 103 | if (StringUtils.isAnyBlank(reason, courseCode, executePlanId)) { 104 | throw new EmptyParameterException("原因或课程代码或执行计划ID为空"); 105 | } 106 | Book book = new Book(); 107 | book.setId(bookId); 108 | book.setIsBookPurchase(false); 109 | book.setReason(reason); 110 | book.setLoginUserId(loginUserId); 111 | book.setExecutePlanId(executePlanId); 112 | //0: 未审核 113 | book.setStatus(0); 114 | //教务处购买样书默认false 115 | book.setIsBuyBook(false); 116 | Date date = new Date(); 117 | book.setGmtModified(date); 118 | book.setGmtCreate(date); 119 | if (bookId == null) { 120 | book.setId(UUID.randomUUID().toString().replace("-", "")); 121 | saveBookInfo(executePlanId, courseCode, book.getId(), book); 122 | } else { 123 | bookMapper.updateByPrimaryKey(book); 124 | } 125 | } 126 | 127 | /** 128 | * 新增图书 129 | * 130 | * @param executePlanId 执行计划ID 131 | * @param courseCode 课程代码 132 | * @param newBookId 图书ID 133 | * @param book {@link Book} 134 | */ 135 | private void saveBookInfo(String executePlanId, String courseCode, String newBookId, Book book) { 136 | bookMapper.insertSelective(book); 137 | planMapper.selectByExecutePlanIdAndCourseCode(executePlanId, courseCode) 138 | .stream() 139 | .map(Plan::getId) 140 | .forEach(planId -> planBookMapper.insert(new PlanBook(planId, newBookId))); 141 | } 142 | 143 | 144 | @Override 145 | public PageInfo getAllTeacherBooks(String loginUserId, String executePlanId, int page, int size) { 146 | return PageHelper 147 | .startPage(page, size) 148 | .doSelectPageInfo(() -> bookMapper.selectMyBook(loginUserId, executePlanId)); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /tmpp-export/src/main/java/top/sl/tmpp/export/controller/ExportController.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.export.controller; 2 | 3 | import org.apache.commons.io.FileUtils; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import top.sl.tmpp.common.entity.LoginUser; 9 | import top.sl.tmpp.common.exception.EmptyParameterException; 10 | import top.sl.tmpp.export.service.ExportService; 11 | 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.io.File; 14 | import java.io.IOException; 15 | import java.nio.charset.StandardCharsets; 16 | 17 | /** 18 | * @author ShuLu 19 | * @date 2019/6/25 10:42 20 | */ 21 | @Controller 22 | public class ExportController { 23 | private final ExportService exportService; 24 | 25 | public ExportController(ExportService exportService) { 26 | this.exportService = exportService; 27 | } 28 | 29 | /** 30 | * 设置下载Excel文件响应头 31 | * 32 | * @param response {@link HttpServletResponse} 33 | * @param fileName 文件名 34 | */ 35 | private void setDownloadExcelHeader(HttpServletResponse response, String fileName) { 36 | response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(), StandardCharsets.ISO_8859_1)); 37 | response.setContentType("application/octet-stream"); 38 | } 39 | 40 | /** 41 | * 下载执行计划模板 42 | * 43 | * @param response {@link HttpServletResponse} 44 | */ 45 | @GetMapping("/download_execute_plan_template") 46 | public void downloadExecutePlanTemplate(LoginUser loginUser, HttpServletResponse response) throws IOException { 47 | setDownloadExcelHeader(response, "执行计划模板.xlsx"); 48 | String file = this.getClass().getResource("/").getFile() + "execute_plan_template.xlsx"; 49 | FileUtils.copyFile(new File(file), response.getOutputStream()); 50 | } 51 | 52 | /** 53 | * 导出采购教材汇总表 54 | * 55 | * @param executePlanId 执行计划id 56 | * @param response {@link HttpServletResponse} 57 | */ 58 | @GetMapping("/procurement_table") 59 | public void procurementTable(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 60 | setDownloadExcelHeader(response, "采购教材汇总表.xlsx"); 61 | exportService.procurementTable(executePlanId, response.getOutputStream()); 62 | } 63 | 64 | /** 65 | * 征订教材汇总表格 66 | * 67 | * @param year 年 68 | * @param college 学院 69 | * @param teachingDepartment 授课部门 70 | * @param term 学期 71 | * @param response {@link HttpServletResponse} 72 | */ 73 | @GetMapping("/down_book_materials") 74 | public void downBookMaterials(LoginUser loginUser, 75 | @RequestParam String year, 76 | @RequestParam String college, 77 | @RequestParam String teachingDepartment, 78 | @RequestParam Boolean term, 79 | HttpServletResponse response) throws IOException { 80 | if (StringUtils.isBlank(college)) { 81 | college = null; 82 | } 83 | if (StringUtils.isBlank(teachingDepartment)) { 84 | teachingDepartment = null; 85 | } 86 | if (college == null && teachingDepartment == null) { 87 | throw new EmptyParameterException("学院和开设院系部必须要选择一个"); 88 | } 89 | setDownloadExcelHeader(response, "征订教材汇总表.xlsx"); 90 | exportService.downBookMaterials(year, college, teachingDepartment, term, response.getOutputStream()); 91 | } 92 | 93 | /** 94 | * 考试/考查/总体订书率表 95 | * 96 | * @param executePlanId 执行计划id 97 | * @param response {@link HttpServletResponse} 98 | */ 99 | @GetMapping("/summary_table") 100 | public void summaryTable(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 101 | setDownloadExcelHeader(response, "考试-考查-总体订书率表.xlsx"); 102 | exportService.summaryTable(executePlanId, response.getOutputStream()); 103 | } 104 | 105 | /** 106 | * 征订教材计划统计表 107 | * 108 | * @param executePlanId 执行计划id 109 | * @param response {@link HttpServletResponse} 110 | */ 111 | @GetMapping("/textbook_execute_plan_statistics") 112 | public void textbookPlanStatistics(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 113 | setDownloadExcelHeader(response, "征订教材计划统计表.xlsx"); 114 | exportService.subscriptionBookPlan(executePlanId, response.getOutputStream()); 115 | } 116 | 117 | /** 118 | * 出版社统计数量表 119 | * 120 | * @param executePlanId 执行计划id 121 | * @param response {@link HttpServletResponse} 122 | */ 123 | @GetMapping("/publishing_house_statistics") 124 | public void publishingHouseStatistics(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 125 | setDownloadExcelHeader(response, "出版社统计数量表.xlsx"); 126 | exportService.publishingHouseStatistics(executePlanId, response.getOutputStream()); 127 | } 128 | 129 | /** 130 | * 征订教材样书统计表 131 | * 132 | * @param executePlanId 执行计划id 133 | * @param response {@link HttpServletResponse} 134 | */ 135 | @GetMapping("/subscription_book") 136 | public void subscriptionBook(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 137 | setDownloadExcelHeader(response, "征订教材样书统计表.xlsx"); 138 | exportService.subscriptionBook(executePlanId, response.getOutputStream()); 139 | } 140 | 141 | /** 142 | * 教师领取教材汇总表 143 | * 144 | * @param executePlanId 执行计划id 145 | * @param response {@link HttpServletResponse} 146 | */ 147 | @GetMapping("/teacher_receiving_textbook") 148 | public void teacherReceivingTextbook(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 149 | setDownloadExcelHeader(response, "教师领取教材汇总表.xlsx"); 150 | exportService.teacherReceiveBook(executePlanId, response.getOutputStream()); 151 | } 152 | 153 | /** 154 | * 学生班级领取教材反馈表 155 | * 156 | * @param executePlanId 执行计划id 157 | * @param response {@link HttpServletResponse} 158 | */ 159 | @GetMapping("/student_textbook") 160 | public void studentTextbook(LoginUser loginUser, @RequestParam("execute_plan_id") String executePlanId, HttpServletResponse response) throws IOException { 161 | setDownloadExcelHeader(response, "班级领取教材反馈表.xlsx"); 162 | exportService.studentClassBookTable(executePlanId, response.getOutputStream()); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /tmpp-security/src/main/java/top/sl/tmpp/security/cas/callback/JwtCasCallBackImpl.java: -------------------------------------------------------------------------------- 1 | package top.sl.tmpp.security.cas.callback; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.stereotype.Component; 9 | import top.itning.cas.CasProperties; 10 | import top.itning.cas.RestModel; 11 | import top.itning.cas.callback.login.ILoginFailureCallBack; 12 | import top.itning.cas.callback.login.ILoginNeverCallBack; 13 | import top.itning.cas.callback.login.ILoginSuccessCallBack; 14 | import top.sl.tmpp.common.entity.AdminUser; 15 | import top.sl.tmpp.common.entity.LoginUser; 16 | import top.sl.tmpp.common.mapper.CasMapper; 17 | import top.sl.tmpp.common.mapper.LoginUserMapper; 18 | import top.sl.tmpp.security.util.JwtUtils; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | import javax.servlet.http.HttpServletResponse; 22 | import java.io.IOException; 23 | import java.io.PrintWriter; 24 | import java.net.URLEncoder; 25 | import java.util.Date; 26 | import java.util.Map; 27 | 28 | import static org.springframework.http.HttpHeaders.*; 29 | 30 | /** 31 | * Jwt实现 32 | * 33 | * @author itning 34 | */ 35 | @Component 36 | public class JwtCasCallBackImpl implements ILoginSuccessCallBack, ILoginFailureCallBack, ILoginNeverCallBack { 37 | private final Logger logger = LoggerFactory.getLogger(JwtCasCallBackImpl.class); 38 | 39 | private static final ObjectMapper MAPPER = new ObjectMapper(); 40 | private static final String STUDENT_USER = "99"; 41 | 42 | private final CasProperties casProperties; 43 | private final LoginUserMapper loginUserMapper; 44 | private final CasMapper casMapper; 45 | 46 | public JwtCasCallBackImpl(CasProperties casProperties, LoginUserMapper loginUserMapper, CasMapper casMapper) { 47 | this.casProperties = casProperties; 48 | this.loginUserMapper = loginUserMapper; 49 | this.casMapper = casMapper; 50 | } 51 | 52 | @Override 53 | public void onLoginSuccess(HttpServletResponse resp, HttpServletRequest req, Map attributesMap) throws IOException { 54 | if (attributesMap.isEmpty()) { 55 | sendRefresh2Response(resp); 56 | return; 57 | } 58 | LoginUser loginUser = map2userLoginEntity(attributesMap); 59 | if (loginUser.getUserType().equals(STUDENT_USER)) { 60 | logger.debug("CheckRole FORBIDDEN And LoginUser Type Is Student. {}", loginUser); 61 | resp.setCharacterEncoding("utf-8"); 62 | PrintWriter writer = resp.getWriter(); 63 | writer.write("身份信息认证失败" + 64 | "学生用户无法访问该系统 学号:" + loginUser.getId() + " 姓名:" + loginUser.getName() + " 注销"); 65 | writer.flush(); 66 | writer.close(); 67 | return; 68 | } 69 | AdminUser adminUser = casMapper.selectByUserName(loginUser.getId()); 70 | if (adminUser != null) { 71 | loginUser.setUserType(adminUser.getType()); 72 | } else { 73 | loginUser.setUserType("T"); 74 | logger.debug("username {} is teacher", loginUser.getId()); 75 | } 76 | String jwt = JwtUtils.buildJwt(loginUser); 77 | if (loginUserMapper.selectByPrimaryKey(loginUser.getId()) == null) { 78 | Date date = new Date(); 79 | loginUser.setGmtCreate(date); 80 | loginUser.setGmtModified(date); 81 | loginUserMapper.insert(loginUser); 82 | } 83 | //重定向到登陆成功需要跳转的地址 84 | resp.sendRedirect(casProperties.getLoginSuccessUrl().toString() + "/token/" + jwt); 85 | } 86 | 87 | @Override 88 | public void onLoginFailure(HttpServletResponse resp, HttpServletRequest req, Exception e) throws IOException { 89 | sendRefresh2Response(resp); 90 | } 91 | 92 | @Override 93 | public void onNeverLogin(HttpServletResponse resp, HttpServletRequest req) throws IOException { 94 | allowCors(resp, req); 95 | writeJson2Response(resp, HttpStatus.UNAUTHORIZED, "请先登录"); 96 | } 97 | 98 | /** 99 | * 将Map集合转换成{@link LoginUser} 100 | * 101 | * @param map 要转换的Map集合 102 | * @return {@link LoginUser} 103 | */ 104 | private LoginUser map2userLoginEntity(Map map) { 105 | LoginUser loginUser = new LoginUser(); 106 | loginUser.setId(map.get("no")); 107 | loginUser.setName(map.get("name")); 108 | loginUser.setUserType(map.get("userType")); 109 | return loginUser; 110 | } 111 | 112 | /** 113 | * 登陆失败时 114 | * 115 | * @param resp {@link HttpServletResponse} 116 | * @throws IOException IOException 117 | */ 118 | private void sendRefresh2Response(HttpServletResponse resp) throws IOException { 119 | resp.setCharacterEncoding("utf-8"); 120 | String location = casProperties.getLoginUrl() + "?service=" + URLEncoder.encode(casProperties.getLocalServerUrl().toString(), "UTF-8"); 121 | PrintWriter writer = resp.getWriter(); 122 | writer.write("\n" + 123 | "" + 124 | "身份信息获取失败" + 125 | "身份信息获取失败,3秒后重试..." + 126 | ""); 127 | writer.flush(); 128 | writer.close(); 129 | } 130 | 131 | /** 132 | * 允许跨域(不管客户端地址是什么,全部允许) 133 | * 134 | * @param resp {@link HttpServletResponse} 135 | * @param req {@link HttpServletRequest} 136 | */ 137 | private void allowCors(HttpServletResponse resp, HttpServletRequest req) { 138 | String origin = req.getHeader(ORIGIN); 139 | resp.setHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); 140 | resp.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN, origin); 141 | resp.setHeader(ACCESS_CONTROL_ALLOW_METHODS, "POST,GET,OPTIONS,DELETE,PUT,PATCH"); 142 | resp.setHeader(ACCESS_CONTROL_ALLOW_HEADERS, req.getHeader(ACCESS_CONTROL_REQUEST_HEADERS)); 143 | resp.setIntHeader(ACCESS_CONTROL_MAX_AGE, 2592000); 144 | } 145 | 146 | /** 147 | * 将消息转换成JSON并写入到{@link HttpServletResponse}中 148 | * 149 | * @param resp {@link HttpServletResponse} 150 | * @param httpStatus {@link HttpStatus} 151 | * @param msg 消息 152 | * @throws IOException IOException 153 | */ 154 | @SuppressWarnings("SameParameterValue") 155 | private void writeJson2Response(HttpServletResponse resp, HttpStatus httpStatus, String msg) throws IOException { 156 | resp.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); 157 | resp.setStatus(httpStatus.value()); 158 | RestModel restModel = new RestModel<>(); 159 | restModel.setCode(httpStatus.value()); 160 | restModel.setMsg(msg); 161 | String json = MAPPER.writeValueAsString(restModel); 162 | PrintWriter writer = resp.getWriter(); 163 | writer.write(json); 164 | writer.flush(); 165 | writer.close(); 166 | } 167 | } 168 | --------------------------------------------------------------------------------