├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src └── main │ ├── java │ └── com │ │ └── repairsystem │ │ ├── dao │ │ ├── RoleMapper.java │ │ ├── BuildingMapper.java │ │ ├── AdministratorMapper.java │ │ ├── OrdersMapper.java │ │ ├── CompleteOrderMapper.java │ │ └── ClassMapper.java │ │ ├── ServletInitializer.java │ │ ├── service │ │ ├── RoleService.java │ │ ├── EmailService.java │ │ ├── Impl │ │ │ ├── RoleServiceImpl.java │ │ │ ├── EmailServiceImpl.java │ │ │ ├── OrdersServiceImpl.java │ │ │ ├── CompleteOrderServiceImpl.java │ │ │ ├── BuildingServiceImpl.java │ │ │ ├── ClassServiceImpl.java │ │ │ └── AdministratorServiceImpl.java │ │ ├── OrdersService.java │ │ ├── BuildingService.java │ │ ├── CompleteOrderService.java │ │ ├── ClassService.java │ │ └── AdministratorService.java │ │ ├── RepairsystemApplication.java │ │ ├── config │ │ ├── shiro │ │ │ ├── ShiroRedisCacheManager.java │ │ │ ├── MySessionIdGenerator.java │ │ │ ├── MySignOutFilter.java │ │ │ ├── MyRedisSessionDao.java │ │ │ ├── MyShiroRealm.java │ │ │ ├── ShiroRedisCache.java │ │ │ └── ShiroConfig.java │ │ ├── CorsConfig.java │ │ ├── SchedulerTask.java │ │ ├── LoginAdminContext.java │ │ ├── JacksonConfig.java │ │ ├── WebSocketStompConfig.java │ │ ├── DruidConfig.java │ │ └── Swagger2Config.java │ │ ├── exception │ │ ├── PageIsNullException.java │ │ ├── ClassIdIsNullException.java │ │ ├── OrderIdIsNullException.java │ │ ├── ClassNameIsNullException.java │ │ ├── BuildingIdIsNullException.java │ │ ├── BuildingNameIdIsNullException.java │ │ ├── AdministratorIdIsNullException.java │ │ ├── CompleteOrderIdIsNullException.java │ │ ├── AdministratorNameIsNullException.java │ │ ├── AdministratorPhoneIsNullException.java │ │ ├── AdministratorPasswordIsNullException.java │ │ └── handler │ │ │ └── GlobalExceptionHandler.java │ │ ├── utils │ │ ├── PasswordEncryptionUtils.java │ │ ├── MyMapper.java │ │ ├── Entity2VO.java │ │ ├── ConstantUtils.java │ │ ├── SerializeUtil.java │ │ ├── JsonResult.java │ │ ├── OrderUploadUtils.java │ │ ├── ZipUtils.java │ │ ├── PageUtils.java │ │ └── QRCodeUtils.java │ │ ├── entity │ │ ├── Role.java │ │ ├── vo │ │ │ ├── AdministratorVO.java │ │ │ ├── ClassVO.java │ │ │ ├── CompleteOrderVO.java │ │ │ └── OrderVO.java │ │ ├── Building.java │ │ ├── Administrator.java │ │ ├── Class.java │ │ ├── CompleteOrder.java │ │ └── Orders.java │ │ └── web │ │ └── controller │ │ ├── QRCodeController.java │ │ ├── BuildingController.java │ │ ├── CompleteOrderController.java │ │ ├── ClassController.java │ │ └── AdministratorController.java │ └── resources │ ├── mapper │ ├── RoleMapper.xml │ ├── BuildingMapper.xml │ ├── AdministratorMapper.xml │ ├── ClassMapper.xml │ ├── OrdersMapper.xml │ └── CompleteOrderMapper.xml │ └── application.properties ├── .gitignore ├── Dockerfile ├── LICENSE ├── mvnw.cmd ├── mvnw └── pom.xml /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CheungChingYin/RepairSystem/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/dao/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.dao; 2 | 3 | import com.repairsystem.entity.Role; 4 | import com.repairsystem.utils.MyMapper; 5 | 6 | public interface RoleMapper extends MyMapper { 7 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/dao/BuildingMapper.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.dao; 2 | 3 | import com.repairsystem.entity.Building; 4 | import com.repairsystem.utils.MyMapper; 5 | 6 | public interface BuildingMapper extends MyMapper { 7 | 8 | /** 9 | * 获得教学楼数量 10 | * 11 | * @return 教学楼数量 12 | */ 13 | Integer getBuildingCount(); 14 | } -------------------------------------------------------------------------------- /.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 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/dao/AdministratorMapper.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.dao; 2 | 3 | import com.repairsystem.entity.Administrator; 4 | import com.repairsystem.utils.MyMapper; 5 | 6 | public interface AdministratorMapper extends MyMapper { 7 | 8 | /** 9 | * 获得管理员数量 10 | * 11 | * @return 12 | */ 13 | Integer getAdministratorCount(); 14 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 5 | 6 | public class ServletInitializer extends SpringBootServletInitializer { 7 | 8 | @Override 9 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 10 | return application.sources(RepairsystemApplication.class); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import com.repairsystem.entity.Role; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author CheungChingYin 9 | * @date 2018/11/5 10 | * @time 9:59 11 | */ 12 | public interface RoleService { 13 | 14 | /** 15 | * 获得全部角色信息 16 | * @return 角色信息 17 | */ 18 | List searchAllRole(); 19 | 20 | /** 21 | * 通过角色ID获取角色信息 22 | * @param id 角色id 23 | * @return 24 | */ 25 | Role searchRoleById(Integer id); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/mapper/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # First stage: complete build environment 2 | FROM maven:3.5.0-jdk-8-alpine AS builder 3 | 4 | # add pom.xml and source code 5 | ADD ./pom.xml pom.xml 6 | ADD ./src src/ 7 | 8 | # package jar 9 | RUN mvn clean package 10 | 11 | FROM anapsix/alpine-java:8_server-jre_unlimited 12 | 13 | MAINTAINER CheungChingYin@outlook.com 14 | 15 | RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 16 | 17 | #RUN mkdir -p /jeecg-boot/config/jeecg/ 18 | 19 | EXPOSE 8081 20 | 21 | #ADD ./src/main/resources/jeecg ./config/jeecg 22 | ADD ./target/repairsystem-0.0.1-SNAPSHOT.jar ./ 23 | 24 | CMD ["java", "-jar", "repairsystem-0.0.1-SNAPSHOT.jar", "-Dfile.encoding=utf-8"] 25 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/RepairsystemApplication.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | import tk.mybatis.spring.annotation.MapperScan; 7 | 8 | @EnableScheduling 9 | @SpringBootApplication(scanBasePackages = {"com.repairsystem"}) 10 | @MapperScan(basePackages = {"com.repairsystem.dao"}) 11 | public class RepairsystemApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(RepairsystemApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/dao/OrdersMapper.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.dao; 2 | 3 | import com.repairsystem.entity.Orders; 4 | import com.repairsystem.entity.vo.OrderVO; 5 | import com.repairsystem.utils.MyMapper; 6 | 7 | import java.util.List; 8 | 9 | public interface OrdersMapper extends MyMapper { 10 | 11 | /** 12 | * 获得所有订单信息 13 | * 14 | * @return 订单信息 15 | */ 16 | List getAllOrder(); 17 | 18 | /** 19 | * 根据工单Id获得工单信息 20 | * 21 | * @param odrderId 工单id 22 | * @return 工单信息 23 | */ 24 | Orders getOrderById(Integer odrderId); 25 | 26 | /** 27 | * 获得工单数量 28 | * 29 | * @return 工单数量 30 | */ 31 | Integer getOrdersCount(); 32 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/EmailService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import org.springframework.mail.SimpleMailMessage; 4 | 5 | /** 6 | * 邮件服务 7 | * 8 | * @author CheungChingYin 9 | * @date 2018/11/18 10 | * @time 14:43 11 | */ 12 | public interface EmailService { 13 | 14 | /** 15 | * 接受工单邮件 16 | * 17 | * @param userName 用户名 18 | * @param userEmail 用户邮箱 19 | * @return 20 | */ 21 | String acceptOrderMail(String userName, String userEmail); 22 | 23 | /** 24 | * 完成工单发送邮件 25 | * 26 | * @param userName 用户名 27 | * @param userEmail 用户邮箱 28 | * @return 发送成功 29 | */ 30 | String completeOrderMail(String userName, String userEmail); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/mapper/BuildingMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/ShiroRedisCacheManager.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import org.apache.shiro.cache.AbstractCacheManager; 4 | import org.apache.shiro.cache.Cache; 5 | import org.apache.shiro.cache.CacheException; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | 8 | public class ShiroRedisCacheManager extends AbstractCacheManager { 9 | 10 | private RedisTemplate redisTemplate; 11 | 12 | public ShiroRedisCacheManager(RedisTemplate redisTemplate) { 13 | this.redisTemplate = redisTemplate; 14 | } 15 | 16 | @Override 17 | protected Cache createCache(String name) throws CacheException { 18 | return new ShiroRedisCache(redisTemplate, name); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/MySessionIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import org.apache.shiro.session.Session; 4 | import org.apache.shiro.session.mgt.eis.SessionIdGenerator; 5 | 6 | import java.io.Serializable; 7 | import java.util.UUID; 8 | 9 | public class MySessionIdGenerator implements SessionIdGenerator{ 10 | private String name; 11 | public MySessionIdGenerator(String name){ 12 | this.name = name; 13 | } 14 | 15 | /** 16 | * 生产sessionId 17 | * @param session 会话 18 | * @return 19 | */ 20 | @Override 21 | public Serializable generateId(Session session) { 22 | System.out.println("generator生成的sessionhost:"+session.getHost()); 23 | return name+ UUID.randomUUID().toString()+session.getHost(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * 跨域配置 9 | * 10 | * @author CheungChingYin 11 | * @date 2018/11/27 12 | * @time 21:39 13 | */ 14 | @Configuration 15 | public class CorsConfig implements WebMvcConfigurer { 16 | 17 | @Override 18 | public void addCorsMappings(CorsRegistry registry) { 19 | registry.addMapping("/**") 20 | .allowedOrigins("*") 21 | .allowCredentials(true) 22 | .allowedMethods("*"). 23 | allowedHeaders("*") 24 | .maxAge(3600); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/PageIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/11/7 6 | * @time 19:08 7 | */ 8 | public class PageIsNullException extends RuntimeException { 9 | public PageIsNullException() { 10 | super(); 11 | } 12 | 13 | public PageIsNullException(String message) { 14 | super(message); 15 | } 16 | 17 | public PageIsNullException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | public PageIsNullException(Throwable cause) { 22 | super(cause); 23 | } 24 | 25 | protected PageIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 26 | super(message, cause, enableSuppression, writableStackTrace); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/ClassIdIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/31 6 | * @time 12:43 7 | */ 8 | public class ClassIdIsNullException extends RuntimeException { 9 | 10 | public ClassIdIsNullException() { 11 | super(); 12 | } 13 | 14 | public ClassIdIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public ClassIdIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public ClassIdIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected ClassIdIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/OrderIdIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/31 6 | * @time 9:30 7 | */ 8 | public class OrderIdIsNullException extends RuntimeException { 9 | 10 | public OrderIdIsNullException() { 11 | super(); 12 | } 13 | 14 | public OrderIdIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public OrderIdIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public OrderIdIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected OrderIdIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/ClassNameIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/31 6 | * @time 12:45 7 | */ 8 | public class ClassNameIsNullException extends RuntimeException { 9 | 10 | public ClassNameIsNullException() { 11 | super(); 12 | } 13 | 14 | public ClassNameIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public ClassNameIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public ClassNameIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected ClassNameIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/BuildingIdIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/31 6 | * @time 9:44 7 | */ 8 | public class BuildingIdIsNullException extends RuntimeException { 9 | 10 | public BuildingIdIsNullException() { 11 | super(); 12 | } 13 | 14 | public BuildingIdIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public BuildingIdIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public BuildingIdIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected BuildingIdIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/BuildingNameIdIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/31 6 | * @time 9:46 7 | */ 8 | public class BuildingNameIdIsNullException extends RuntimeException { 9 | 10 | public BuildingNameIdIsNullException() { 11 | super(); 12 | } 13 | 14 | public BuildingNameIdIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public BuildingNameIdIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public BuildingNameIdIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected BuildingNameIdIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/dao/CompleteOrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.dao; 2 | 3 | import com.repairsystem.entity.CompleteOrder; 4 | import com.repairsystem.utils.MyMapper; 5 | 6 | import java.util.List; 7 | 8 | public interface CompleteOrderMapper extends MyMapper { 9 | 10 | /** 11 | * 获得所有已完成的工单 12 | * 13 | * @return 工单列表 14 | */ 15 | List getAllCompleteOrder(); 16 | 17 | /** 18 | * 根据工单id获得已完成的工单 19 | * 20 | * @param id 工单id 21 | * @return 已完成工单信息 22 | */ 23 | CompleteOrder getCompleteOrderById(Integer id); 24 | 25 | /** 26 | * 获得已完成工单总数 27 | * 28 | * @return 已完成工单信息 29 | */ 30 | Integer getCompleteOrderCount(); 31 | 32 | /** 33 | * 更具关键词获得已完成工单信息 34 | * 35 | * @param keyWord 关键词 36 | * @return 已完成工单信息 37 | */ 38 | List getCompleteOrderByKeyWord(String keyWord); 39 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/AdministratorIdIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/30 6 | * @time 22:18 7 | */ 8 | public class AdministratorIdIsNullException extends RuntimeException { 9 | 10 | public AdministratorIdIsNullException() { 11 | super(); 12 | } 13 | 14 | public AdministratorIdIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public AdministratorIdIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public AdministratorIdIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected AdministratorIdIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/CompleteOrderIdIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/30 6 | * @time 22:22 7 | */ 8 | public class CompleteOrderIdIsNullException extends RuntimeException { 9 | 10 | public CompleteOrderIdIsNullException() { 11 | super(); 12 | } 13 | 14 | public CompleteOrderIdIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public CompleteOrderIdIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public CompleteOrderIdIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected CompleteOrderIdIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/AdministratorNameIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/30 6 | * @time 21:52 7 | */ 8 | public class AdministratorNameIsNullException extends RuntimeException { 9 | 10 | public AdministratorNameIsNullException() { 11 | super(); 12 | } 13 | 14 | public AdministratorNameIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public AdministratorNameIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public AdministratorNameIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected AdministratorNameIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/PasswordEncryptionUtils.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | 5 | import java.security.MessageDigest; 6 | import java.security.NoSuchAlgorithmException; 7 | 8 | /** 9 | * @author CheungChingYin 10 | * @date 2018/10/28 11 | * @time 20:31 12 | */ 13 | public class PasswordEncryptionUtils { 14 | 15 | /** 16 | * MD5密码加密工具 17 | * 18 | * @param password 19 | * @return 20 | */ 21 | public static String plainText2MD5Encrypt(String password) { 22 | try { 23 | MessageDigest md = MessageDigest.getInstance("MD5"); 24 | byte[] output = md.digest(password.getBytes()); 25 | String ret = Base64.encodeBase64String(output); 26 | return ret; 27 | } catch (NoSuchAlgorithmException e) { 28 | e.printStackTrace(); 29 | return null; 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/AdministratorPhoneIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/30 6 | * @time 21:55 7 | */ 8 | public class AdministratorPhoneIsNullException extends RuntimeException { 9 | 10 | public AdministratorPhoneIsNullException() { 11 | super(); 12 | } 13 | 14 | public AdministratorPhoneIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public AdministratorPhoneIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public AdministratorPhoneIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected AdministratorPhoneIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/AdministratorPasswordIsNullException.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/30 6 | * @time 22:15 7 | */ 8 | public class AdministratorPasswordIsNullException extends RuntimeException { 9 | 10 | public AdministratorPasswordIsNullException() { 11 | super(); 12 | } 13 | 14 | public AdministratorPasswordIsNullException(String message) { 15 | super(message); 16 | } 17 | 18 | public AdministratorPasswordIsNullException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | public AdministratorPasswordIsNullException(Throwable cause) { 23 | super(cause); 24 | } 25 | 26 | protected AdministratorPasswordIsNullException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 27 | super(message, cause, enableSuppression, writableStackTrace); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/SchedulerTask.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import com.repairsystem.utils.ConstantUtils; 4 | import org.apache.commons.io.FileUtils; 5 | import org.springframework.scheduling.annotation.Scheduled; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | 11 | /** 12 | * 任务调度 13 | * 14 | * @author CheungChingYin 15 | * @date 2018/11/20 16 | * @time 10:55 17 | */ 18 | @Component 19 | public class SchedulerTask { 20 | 21 | /** 22 | * 每天凌晨3点删除生成的QRCode文件 23 | */ 24 | @Scheduled(cron = "0 0 3 * * ?") 25 | private void deleteQRCodeFile() { 26 | File file = new File(ConstantUtils.Path.DIRPATH + ConstantUtils.Path.QRCODEPATH); 27 | if (file.exists()) { 28 | try { 29 | FileUtils.cleanDirectory(file); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/exception/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.exception.handler; 2 | 3 | import com.repairsystem.exception.AdministratorIdIsNullException; 4 | import com.repairsystem.utils.JsonResult; 5 | import org.springframework.web.bind.annotation.ControllerAdvice; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | 9 | /** 10 | * 全局异常捕捉 11 | * 12 | * @author CheungChingYin 13 | * @date 2018/11/6 14 | * @time 22:19 15 | */ 16 | @ControllerAdvice 17 | public class GlobalExceptionHandler { 18 | 19 | @ExceptionHandler(AdministratorIdIsNullException.class) 20 | @ResponseBody 21 | public JsonResult administratorIdIsNullExceptionHandler() { 22 | return JsonResult.errorMsg("传入的管理员ID为空"); 23 | } 24 | 25 | @ExceptionHandler(Exception.class) 26 | @ResponseBody 27 | public JsonResult exceptionHandler() { 28 | return JsonResult.errorMsg("内部错误"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/dao/ClassMapper.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.dao; 2 | 3 | import com.repairsystem.entity.Class; 4 | import com.repairsystem.entity.vo.ClassVO; 5 | import com.repairsystem.utils.MyMapper; 6 | 7 | import java.util.List; 8 | 9 | public interface ClassMapper extends MyMapper { 10 | 11 | /** 12 | * 获得全部教室信息 13 | * 14 | * @return 15 | */ 16 | List getAllClass(); 17 | 18 | /** 19 | * 根据教室id获得教室信息 20 | * 21 | * @param id 教室Id 22 | * @return 教室信息 23 | */ 24 | Class getClassById(Integer id); 25 | 26 | /** 27 | * 根据教室名称获得教室信息 28 | * 29 | * @param name 教室名称 30 | * @return 教室信息 31 | */ 32 | List getClassByName(String name); 33 | 34 | /** 35 | * 通过教学楼Id获得该教学楼的教室信息 36 | * 37 | * @param buildingId 教学楼id 38 | * @return 教室信息 39 | */ 40 | List getClassByBuildingId(String buildingId); 41 | 42 | /** 43 | * 获得教室数量 44 | * 45 | * @return 教室数量 46 | */ 47 | Integer getClassCount(); 48 | } -------------------------------------------------------------------------------- /src/main/resources/mapper/AdministratorMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 张正贤 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.repairsystem.dao.RoleMapper; 4 | import com.repairsystem.entity.Role; 5 | import com.repairsystem.service.RoleService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Propagation; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author CheungChingYin 15 | * @date 2018/11/5 16 | * @time 10:43 17 | */ 18 | @Service 19 | public class RoleServiceImpl implements RoleService { 20 | 21 | @Autowired 22 | private RoleMapper roleMapper; 23 | 24 | @Transactional(propagation = Propagation.SUPPORTS) 25 | @Override 26 | public List searchAllRole() { 27 | return roleMapper.selectAll(); 28 | } 29 | 30 | @Transactional(propagation = Propagation.SUPPORTS) 31 | @Override 32 | public Role searchRoleById(Integer id) { 33 | return roleMapper.selectByPrimaryKey(id); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Id; 5 | 6 | public class Role { 7 | /** 8 | * 角色主键 9 | */ 10 | @Id 11 | @Column(name = "role_id") 12 | private Integer roleId; 13 | 14 | /** 15 | * 角色名称 16 | */ 17 | @Column(name = "role_name") 18 | private String roleName; 19 | 20 | /** 21 | * 获取角色主键 22 | * 23 | * @return role_id - 角色主键 24 | */ 25 | public Integer getRoleId() { 26 | return roleId; 27 | } 28 | 29 | /** 30 | * 设置角色主键 31 | * 32 | * @param roleId 角色主键 33 | */ 34 | public void setRoleId(Integer roleId) { 35 | this.roleId = roleId; 36 | } 37 | 38 | /** 39 | * 获取角色名称 40 | * 41 | * @return role_name - 角色名称 42 | */ 43 | public String getRoleName() { 44 | return roleName; 45 | } 46 | 47 | /** 48 | * 设置角色名称 49 | * 50 | * @param roleName 角色名称 51 | */ 52 | public void setRoleName(String roleName) { 53 | this.roleName = roleName; 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/OrdersService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import com.repairsystem.entity.Orders; 4 | import com.repairsystem.entity.vo.OrderVO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author CheungChingYin 10 | * @date 2018/10/29 11 | * @time 8:43 12 | */ 13 | public interface OrdersService { 14 | 15 | /** 16 | * 获取全部工单 17 | * 18 | * @return 工单信息 19 | */ 20 | List searchAllOrder(); 21 | 22 | /** 23 | * 按照工单号搜索工单 24 | * 25 | * @param id 工单Id 26 | * @return 工单信息 27 | */ 28 | Orders searchOrderById(Integer id); 29 | 30 | /** 31 | * 获得工单总数量 32 | * 33 | * @return 工单数量 34 | */ 35 | Integer getOrderCount(); 36 | 37 | /** 38 | * 添加工单 39 | * 40 | * @param order 工单信息 41 | */ 42 | void saveOrder(Orders order); 43 | 44 | /** 45 | * 更新工单 46 | * 47 | * @param order 工单信息 48 | */ 49 | void updateOrder(Orders order); 50 | 51 | /** 52 | * 删除工单 53 | * 54 | * @param id 工单id 55 | */ 56 | void deleteOrder(Integer id); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/LoginAdminContext.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import com.repairsystem.entity.Administrator; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * 当前登录用户信息 9 | * 10 | * @Author 张正贤 11 | * @Date 2022/12/10 1:06 12 | * @Version 1.0 13 | */ 14 | public class LoginAdminContext { 15 | private static final Logger log = LoggerFactory.getLogger(LoginAdminContext.class); 16 | private static ThreadLocal currentContext = new ThreadLocal(); 17 | 18 | public LoginAdminContext() { 19 | } 20 | 21 | /** 22 | * 设置当前登录用户到线程 23 | * 24 | * @param admin 25 | */ 26 | public static void setLoginAdminContext(Administrator admin) { 27 | log.info("当前登录用户加入到线程,用户ID为【" + admin.getAdminId() + "】"); 28 | currentContext.set(admin); 29 | } 30 | 31 | /** 32 | * 获取当前线程登录用户 33 | * 34 | * @return 当前用户 35 | */ 36 | public static Administrator getLoginAdminContext() { 37 | return (Administrator) currentContext.get(); 38 | } 39 | 40 | /** 41 | * 清除当前线程的登录用户信息 42 | */ 43 | public static void clear() { 44 | currentContext.remove(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/BuildingService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import com.repairsystem.entity.Building; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author CheungChingYin 9 | * @date 2018/10/30 10 | * @time 21:02 11 | */ 12 | public interface BuildingService { 13 | 14 | /** 15 | * 获取所有教学楼信息 16 | * 17 | * @return 教学楼信息 18 | */ 19 | List searchAllBuilding(); 20 | 21 | /** 22 | * 通过教学楼编号获取教学楼信息 23 | * 24 | * @param id 教学楼id 25 | * @return 教学楼信息 26 | */ 27 | Building searchBuildingById(Integer id); 28 | 29 | /** 30 | * 通过教学楼名字获取教学楼信息 31 | * 32 | * @param name 教学楼名称 33 | * @return 教学楼信息 34 | */ 35 | List searchBuildingByName(String name); 36 | 37 | /** 38 | * 获得实训楼总数 39 | * 40 | * @return 教学楼总数 41 | */ 42 | Integer getBuildingCount(); 43 | 44 | /** 45 | * 保存教学楼信息 46 | * 47 | * @param building 教学楼信息 48 | */ 49 | void savBuilding(Building building); 50 | 51 | /** 52 | * 更新教学楼信息 53 | * 54 | * @param building 教学楼信息 55 | */ 56 | void updateBuilding(Building building); 57 | 58 | /** 59 | * 删除教学楼信息 60 | * 61 | * @param id 教学楼id 62 | */ 63 | void deleteBuilding(Integer id); 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/CompleteOrderService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import com.repairsystem.entity.CompleteOrder; 4 | import com.repairsystem.entity.Orders; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author CheungChingYin 10 | * @date 2018/10/29 11 | * @time 20:41 12 | */ 13 | public interface CompleteOrderService { 14 | 15 | /** 16 | * 获取所有完成工单 17 | * @return 完成工单信息 18 | */ 19 | List searchAllCompleteOrder(); 20 | 21 | /** 22 | * 获取完成维修工单数量 23 | * @return 完成工单数量 24 | */ 25 | Integer getCompleteOrderCount(); 26 | 27 | /** 28 | * 通过工单Id获取工单信息 29 | * @param id 工单ID 30 | * @return 完成工单数量 31 | */ 32 | CompleteOrder searchCompleteOrderById(Integer id); 33 | 34 | /** 35 | * 通过关键字搜索完成维修工单 36 | * @param keyWord 关键词 37 | * @return 完成工单信息 38 | */ 39 | List searchCompleteOrderByKeyWord(String keyWord); 40 | 41 | /** 42 | * 保存已完成工单信息 43 | * @param completeOrder 完成工单信息 44 | */ 45 | void saveCompleteOrder(CompleteOrder completeOrder); 46 | 47 | /** 48 | * 更新完成工单信息 49 | * @param completeOrder 完成工单信息 50 | */ 51 | void updateCompleteOrder(CompleteOrder completeOrder); 52 | 53 | /** 54 | * 删除完成工单信息 55 | * @param id 工单Id 56 | */ 57 | void deleteCompleteOrder(Integer id); 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/MyMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014-2016 abel533@gmail.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | package com.repairsystem.utils; 26 | 27 | import tk.mybatis.mapper.common.Mapper; 28 | import tk.mybatis.mapper.common.MySqlMapper; 29 | 30 | public interface MyMapper extends Mapper, MySqlMapper { 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/JacksonConfig.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import com.fasterxml.jackson.databind.SerializerProvider; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.Primary; 11 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; 12 | 13 | import java.io.IOException; 14 | 15 | /** 16 | * 配置Jackson值为null的时候为空 17 | * 18 | * @author CheungChingYin 19 | * @date 2018/10/28 20 | * @time 15:19 21 | */ 22 | @Configuration 23 | public class JacksonConfig { 24 | @Bean 25 | @Primary 26 | @ConditionalOnMissingBean(ObjectMapper.class) 27 | public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { 28 | ObjectMapper objectMapper = builder.createXmlMapper(false).build(); 29 | objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer() { 30 | @Override 31 | public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { 32 | jsonGenerator.writeString(""); 33 | } 34 | }); 35 | return objectMapper; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/WebSocketStompConfig.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import com.repairsystem.utils.ConstantUtils; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 6 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 7 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 8 | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; 9 | 10 | /** 11 | * WebSocket 配置类 12 | * 13 | * @Author 张正贤 14 | * @Date 2022/12/10 10:26 15 | * @Version 1.0 16 | */ 17 | @Configuration 18 | @EnableWebSocketMessageBroker 19 | public class WebSocketStompConfig implements WebSocketMessageBrokerConfigurer { 20 | /** 21 | * 配置消息代理(message broker) 22 | * 23 | * @param registry 注册对象 24 | */ 25 | @Override 26 | public void configureMessageBroker(MessageBrokerRegistry registry) { 27 | 28 | //客户端订阅消息的请求前缀,topic一般用于广播推送,queue用于点对点推送 29 | registry.enableSimpleBroker(ConstantUtils.WebSocket.BROADCAST_PREFIX, ConstantUtils.WebSocket.PEER_TO_PEER_PREFIX); 30 | //服务端通知客户端的前缀 31 | registry.setUserDestinationPrefix("/ws"); 32 | } 33 | 34 | /** 35 | * 设置切点以及允许http和https的方式建立webSocket 36 | * 37 | * @param registry 注册对象 38 | */ 39 | @Override 40 | public void registerStompEndpoints(StompEndpointRegistry registry) { 41 | registry.addEndpoint("endpointOne") 42 | .setAllowedOrigins("*").withSockJS(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/Entity2VO.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | import org.springframework.beans.BeanUtils; 4 | 5 | import java.util.LinkedList; 6 | import java.util.List; 7 | 8 | /** 9 | * @author CheungChingYin 10 | * @date 2018/11/7 11 | * @time 10:17 12 | */ 13 | public class Entity2VO { 14 | 15 | /** 16 | * 实体类列表转换为 VO类列表 17 | * 18 | * @param entityList 19 | * @param voClass 20 | * @return 21 | */ 22 | public static List entityList2VOList(List entityList, Class voClass) { 23 | List voList = new LinkedList(); 24 | Object voObj = null; 25 | for (Object entityObj : entityList) { 26 | try { 27 | voObj = voClass.newInstance(); 28 | 29 | } catch (InstantiationException e) { 30 | e.printStackTrace(); 31 | } catch (IllegalAccessException e) { 32 | e.printStackTrace(); 33 | } 34 | BeanUtils.copyProperties(entityObj, voObj); 35 | voList.add(voObj); 36 | } 37 | return voList; 38 | } 39 | 40 | /** 41 | * 实体类转换为 VO类 42 | * 43 | * @param entity 44 | * @param voClass 45 | * @param 46 | * @return 47 | */ 48 | public static T entity2VO(Object entity, Class voClass) { 49 | T vo = null; 50 | try { 51 | vo = voClass.newInstance(); 52 | } catch (InstantiationException e) { 53 | e.printStackTrace(); 54 | } catch (IllegalAccessException e) { 55 | e.printStackTrace(); 56 | } 57 | BeanUtils.copyProperties(entity, vo); 58 | return vo; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/vo/AdministratorVO.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity.vo; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/11/3 6 | * @time 20:07 7 | */ 8 | public class AdministratorVO { 9 | 10 | private Integer adminId; 11 | private String adminName; 12 | private String adminPhone; 13 | private Integer roleId; 14 | private String adminEmail; 15 | 16 | public Integer getAdminId() { 17 | return adminId; 18 | } 19 | 20 | public void setAdminId(Integer adminId) { 21 | this.adminId = adminId; 22 | } 23 | 24 | public String getAdminName() { 25 | return adminName; 26 | } 27 | 28 | public void setAdminName(String adminName) { 29 | this.adminName = adminName; 30 | } 31 | 32 | public String getAdminPhone() { 33 | return adminPhone; 34 | } 35 | 36 | public void setAdminPhone(String adminPhone) { 37 | this.adminPhone = adminPhone; 38 | } 39 | 40 | public Integer getRoleId() { 41 | return roleId; 42 | } 43 | 44 | public void setRoleId(Integer roleId) { 45 | this.roleId = roleId; 46 | } 47 | 48 | public String getAdminEmail() { 49 | return adminEmail; 50 | } 51 | 52 | public void setAdminEmail(String adminEmail) { 53 | this.adminEmail = adminEmail; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "AdministratorVO{" + 59 | "adminId=" + adminId + 60 | ", adminName='" + adminName + '\'' + 61 | ", adminPhone='" + adminPhone + '\'' + 62 | ", roleId=" + roleId + 63 | ", adminEmail='" + adminEmail + '\'' + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/Building.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Id; 8 | 9 | @ApiModel(value = "实训楼对象",description = "这是实训楼对象") 10 | public class Building { 11 | /** 12 | * 实训楼ID 13 | */ 14 | @Id 15 | @Column(name = "building_id") 16 | @ApiModelProperty(value = "实训楼ID",name = "buildingId",example = "1",required = true) 17 | private Integer buildingId; 18 | 19 | /** 20 | * 实训楼名称 21 | */ 22 | @Column(name = "building_name") 23 | @ApiModelProperty(value = "实训楼名称",name = "buildingName",example = "实训楼A",required = true) 24 | private String buildingName; 25 | 26 | /** 27 | * 获取实训楼ID 28 | * 29 | * @return building_id - 实训楼ID 30 | */ 31 | public Integer getBuildingId() { 32 | return buildingId; 33 | } 34 | 35 | /** 36 | * 设置实训楼ID 37 | * 38 | * @param buildingId 实训楼ID 39 | */ 40 | public void setBuildingId(Integer buildingId) { 41 | this.buildingId = buildingId; 42 | } 43 | 44 | /** 45 | * 获取实训楼名称 46 | * 47 | * @return building_name - 实训楼名称 48 | */ 49 | public String getBuildingName() { 50 | return buildingName; 51 | } 52 | 53 | /** 54 | * 设置实训楼名称 55 | * 56 | * @param buildingName 实训楼名称 57 | */ 58 | public void setBuildingName(String buildingName) { 59 | this.buildingName = buildingName; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "Building{" + 65 | "buildingId=" + buildingId + 66 | ", buildingName='" + buildingName + '\'' + 67 | '}'; 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/EmailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.repairsystem.service.EmailService; 4 | import com.repairsystem.utils.ConstantUtils; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.mail.SimpleMailMessage; 7 | import org.springframework.mail.javamail.JavaMailSender; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * @author CheungChingYin 14 | * @date 2018/11/18 15 | * @time 14:52 16 | */ 17 | @Service 18 | public class EmailServiceImpl implements EmailService { 19 | 20 | @Autowired 21 | private JavaMailSender mailSender; 22 | 23 | @Override 24 | public String acceptOrderMail(String userName, String userEmail) { 25 | SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); 26 | simpleMailMessage.setFrom(ConstantUtils.Mail.FROM_MAIL); 27 | simpleMailMessage.setTo(userEmail); 28 | simpleMailMessage.setSubject("【维修中】感谢您反馈机房报修问题"); 29 | simpleMailMessage.setText("亲爱的" + userName + "先生/女生,您提交的报修工单机房管理员已确实收到,感谢您的反馈。机房管理员正在快马加鞭地解决您提交问题,维修完成后将会通过邮件通知您。"); 30 | simpleMailMessage.setSentDate(new Date()); 31 | mailSender.send(simpleMailMessage); 32 | return "OK"; 33 | } 34 | 35 | @Override 36 | public String completeOrderMail(String userName, String userEmail) { 37 | SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); 38 | simpleMailMessage.setFrom(ConstantUtils.Mail.FROM_MAIL); 39 | simpleMailMessage.setTo(userEmail); 40 | simpleMailMessage.setSubject("【维修完成】感谢您反馈机房报修问题已完成"); 41 | simpleMailMessage.setText("亲爱的" + userName + "先生/女生,您提交的报修机房工单已维修完成,感谢您的反馈,让我们的机房环境变得更好!"); 42 | simpleMailMessage.setSentDate(new Date()); 43 | mailSender.send(simpleMailMessage); 44 | return "OK"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/ClassService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException; 4 | import com.repairsystem.entity.Class; 5 | import com.repairsystem.entity.vo.ClassVO; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author CheungChingYin 11 | * @date 2018/10/31 12 | * @time 12:03 13 | */ 14 | public interface ClassService { 15 | 16 | /** 17 | * 获取全部机房信息 18 | * 19 | * @return 机房信息 20 | */ 21 | List searchAllClass(); 22 | 23 | /** 24 | * 通过机房ID获取机房信息 25 | * 26 | * @param id 机房Id 27 | * @return 机房信息 28 | */ 29 | Class searchClassById(Integer id); 30 | 31 | /** 32 | * 通过机房名称获取机房信息 33 | * 34 | * @param name 机房名称 35 | * @return 机房信息 36 | */ 37 | List searchClassByName(String name); 38 | 39 | /** 40 | * 通过实训楼ID称获取机房信息 41 | * 42 | * @param buildingId 教学楼id 43 | * @return 机房信息 44 | */ 45 | List searchClassByBuildingId(String buildingId); 46 | 47 | /** 48 | * 获得机房总数 49 | * 50 | * @return 机房总数量 51 | */ 52 | Integer getClassCount(); 53 | 54 | /** 55 | * 保存机房信息 56 | * 57 | * @param classes 机房信息 58 | */ 59 | void saveClass(Class classes); 60 | 61 | /** 62 | * 修改你机房信息 63 | * 64 | * @param classes 机房信息 65 | */ 66 | void updateClass(Class classes); 67 | 68 | /** 69 | * 删除机房信息 70 | * 71 | * @param id 机房Id 72 | */ 73 | void deleteClass(Integer id) throws MySQLIntegrityConstraintViolationException; 74 | 75 | /** 76 | * 增加实训室可用电脑 77 | * 78 | * @param id 机房ID 79 | */ 80 | void increaseComputerEnable(Integer id); 81 | 82 | /** 83 | * 减少实训室可用电脑 84 | * 85 | * @param id 机房ID 86 | */ 87 | void reduceComputerEnable(Integer id); 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/AdministratorService.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service; 2 | 3 | import com.repairsystem.entity.Administrator; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author CheungChingYin 9 | * @date 2018/10/28 10 | * @time 19:41 11 | */ 12 | public interface AdministratorService { 13 | 14 | /** 15 | * 查询所有管理员账户 16 | * 17 | * @return 18 | */ 19 | List searchAllAdministrator(); 20 | 21 | /** 22 | * 获得所有管理员数量 23 | * 24 | * @return 25 | */ 26 | String countAllAdministrator(); 27 | 28 | 29 | /** 30 | * 按管理员ID搜索管理员 31 | * 32 | * @param id 管理员id 33 | * @return 管理员信息 34 | */ 35 | Administrator searchAdministratorById(Integer id); 36 | 37 | /** 38 | * 按照管理员姓名搜索管理员 39 | * 40 | * @param name 管理员姓名 41 | * @return 管理员信息 42 | */ 43 | List searchAdministratorByName(String name); 44 | 45 | /** 46 | * 按照手机号搜索管理员 47 | * 48 | * @param phoneNum 手机号 49 | * @return 管理员信息 50 | */ 51 | Administrator searchAdministratorByPhoneNum(String phoneNum); 52 | 53 | /** 54 | * 管理员登录 55 | * 56 | * @param phone 手机号 57 | * @param password 密码 58 | * @return 管理员信息 59 | */ 60 | Administrator loginAdministrator(String phone, String password); 61 | 62 | /** 63 | * 查询管理员手机是否存在 64 | * 65 | * @param number 手机号 66 | * @return true为存在 67 | */ 68 | boolean administratorPhoneNumberIsExist(String number); 69 | 70 | /** 71 | * 添加管理员 72 | * 73 | * @param admin 管理员信息 74 | */ 75 | void saveAdministrator(Administrator admin); 76 | 77 | /** 78 | * 修改管理员 79 | * 80 | * @param admin 管理员信息 81 | */ 82 | void updateAdministrator(Administrator admin); 83 | 84 | /** 85 | * 删除管理员 86 | * 87 | * @param id 管理员id 88 | */ 89 | void deleteAdministrator(Integer id); 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/ConstantUtils.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/29 6 | * @time 15:25 7 | */ 8 | public interface ConstantUtils { 9 | 10 | /** 11 | * 维修单状态码 12 | */ 13 | public static class OrderStatus { 14 | 15 | /** 16 | * 未维修状态码:0 17 | */ 18 | public static final Integer NOTREPAIRED = 0; 19 | 20 | /** 21 | * 维修中状态码:1 22 | */ 23 | public static final Integer REPAIRING = 1; 24 | 25 | /** 26 | * 维修完成状态码:2 27 | */ 28 | public static final Integer REPAIRED = 2; 29 | } 30 | 31 | public static class Page { 32 | 33 | //一页展示多少条 34 | public static final Integer PAGESIZE = 10; 35 | 36 | //页码展示数量 37 | public static final Integer PAGESNUM = 4; 38 | } 39 | 40 | class Path { 41 | 42 | //虚拟目录地址 43 | public static final String DIRPATH = "E:/Images"; 44 | 45 | public static final String QRCODEPATH = "/QRCODE"; 46 | 47 | } 48 | 49 | class Cookie { 50 | 51 | /** 52 | * Cookie最长存活时间(单位:秒) 53 | */ 54 | public static final int COOKIE_MAX_TIME = 3 * 24 * 3600; 55 | } 56 | 57 | // class Redis{ 58 | // 59 | // public static final long REDIS_MAX_TIME = 3*24*3600; 60 | // } 61 | 62 | class Mail { 63 | public static final String FROM_MAIL = "FSPT_RepairManagement@outlook.com"; 64 | } 65 | 66 | class WebSocket { 67 | /** 68 | * WebSocket广播前缀 69 | */ 70 | public static final String BROADCAST_PREFIX = "/topic"; 71 | 72 | /** 73 | * WebSocket点对点前缀 74 | */ 75 | public static final String PEER_TO_PEER_PREFIX = "/queue"; 76 | 77 | /** 78 | * 接收到新工单WebSocket订阅队列 79 | */ 80 | public static final String RECEIVE_ORDER_TOPIC = "/receiveOrder"; 81 | 82 | /** 83 | * 接受新工单后的提示 84 | */ 85 | public static final String RECEIVE_ORDER_MESSAGE = "您有一张新工单,请及时查收"; 86 | 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/DruidConfig.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import com.alibaba.druid.pool.DruidDataSource; 4 | import com.alibaba.druid.support.http.StatViewServlet; 5 | import com.alibaba.druid.support.http.WebStatFilter; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 8 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | import javax.sql.DataSource; 13 | 14 | /** 15 | * Druid配置 16 | * 17 | * @author CheungChingYin 18 | * @date 2018/11/4 19 | * @time 10:13 20 | */ 21 | @Configuration 22 | public class DruidConfig { 23 | 24 | /** 25 | * Druid servlet 配置 26 | * 27 | * @return 28 | */ 29 | @Bean 30 | public ServletRegistrationBean druidServlet() { 31 | ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");//进行druid监控的配置处理操作 32 | servletRegistrationBean.addInitParameter("loginUsername", "CheungChingYin");//用户名 33 | servletRegistrationBean.addInitParameter("loginPassword", "test123456");//密码 34 | servletRegistrationBean.addInitParameter("resetEnable", "false");//是否能够重置数据源 35 | return servletRegistrationBean; 36 | } 37 | 38 | /** 39 | * 请求统计拦截 40 | * 41 | * @return 42 | */ 43 | @Bean 44 | public FilterRegistrationBean filterRegistrationBean() { 45 | FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); 46 | filterRegistrationBean.setFilter(new WebStatFilter()); 47 | 48 | filterRegistrationBean.addUrlPatterns("/*");//所有请求进行监控处理 49 | filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.css,/druid/*"); 50 | return filterRegistrationBean; 51 | } 52 | 53 | @Bean 54 | @ConfigurationProperties(prefix = "spring.datasource") 55 | public DataSource druidDataSource() { 56 | return new DruidDataSource(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/OrdersServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.repairsystem.dao.OrdersMapper; 4 | import com.repairsystem.entity.Orders; 5 | import com.repairsystem.entity.vo.OrderVO; 6 | import com.repairsystem.exception.OrderIdIsNullException; 7 | import com.repairsystem.service.OrdersService; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Propagation; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import tk.mybatis.mapper.entity.Example; 14 | 15 | import java.util.Collections; 16 | import java.util.List; 17 | 18 | /** 19 | * @author CheungChingYin 20 | * @date 2018/10/29 21 | * @time 15:15 22 | */ 23 | @Service 24 | public class OrdersServiceImpl implements OrdersService { 25 | 26 | @Autowired 27 | OrdersMapper ordersMapper; 28 | 29 | @Transactional(propagation = Propagation.SUPPORTS) 30 | @Override 31 | public List searchAllOrder() { 32 | return ordersMapper.getAllOrder(); 33 | } 34 | 35 | @Transactional(propagation = Propagation.SUPPORTS) 36 | @Override 37 | public Orders searchOrderById(Integer id) { 38 | if (StringUtils.isBlank(id.toString())) { 39 | throw new OrderIdIsNullException("传入的订单ID为空"); 40 | } 41 | return ordersMapper.getOrderById(id); 42 | } 43 | 44 | @Transactional(propagation = Propagation.SUPPORTS) 45 | @Override 46 | public Integer getOrderCount() { 47 | return ordersMapper.getOrdersCount(); 48 | } 49 | 50 | @Transactional(propagation = Propagation.REQUIRED) 51 | @Override 52 | public void saveOrder(Orders order) { 53 | ordersMapper.insertSelective(order); 54 | } 55 | 56 | @Transactional(propagation = Propagation.REQUIRED) 57 | @Override 58 | public void updateOrder(Orders order) { 59 | ordersMapper.updateByPrimaryKeySelective(order); 60 | } 61 | 62 | @Transactional(propagation = Propagation.REQUIRED) 63 | @Override 64 | public void deleteOrder(Integer id) { 65 | if (StringUtils.isBlank(id.toString())) { 66 | throw new OrderIdIsNullException("传入的订单ID为空"); 67 | } 68 | ordersMapper.deleteByPrimaryKey(id); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/vo/ClassVO.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity.vo; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/11/2 6 | * @time 21:30 7 | */ 8 | public class ClassVO { 9 | 10 | private Integer classId; 11 | private String className; 12 | private Integer buildingId; 13 | private String buildingName; 14 | private Integer computerTotal; 15 | private Integer computerEnable; 16 | private Integer computerDisable; 17 | 18 | public Integer getClassId() { 19 | return classId; 20 | } 21 | 22 | public void setClassId(Integer classId) { 23 | this.classId = classId; 24 | } 25 | 26 | public String getClassName() { 27 | return className; 28 | } 29 | 30 | public void setClassName(String className) { 31 | this.className = className; 32 | } 33 | 34 | public Integer getBuildingId() { 35 | return buildingId; 36 | } 37 | 38 | public void setBuildingId(Integer buildingId) { 39 | this.buildingId = buildingId; 40 | } 41 | 42 | public String getBuildingName() { 43 | return buildingName; 44 | } 45 | 46 | public void setBuildingName(String buildingName) { 47 | this.buildingName = buildingName; 48 | } 49 | 50 | public Integer getComputerTotal() { 51 | return computerTotal; 52 | } 53 | 54 | public void setComputerTotal(Integer computerTotal) { 55 | this.computerTotal = computerTotal; 56 | } 57 | 58 | public Integer getComputerEnable() { 59 | return computerEnable; 60 | } 61 | 62 | public void setComputerEnable(Integer computerEnable) { 63 | this.computerEnable = computerEnable; 64 | } 65 | 66 | public Integer getComputerDisable() { 67 | return computerDisable; 68 | } 69 | 70 | public void setComputerDisable(Integer computerDisable) { 71 | this.computerDisable = computerDisable; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "ClassVO{" + 77 | "classId=" + classId + 78 | ", className='" + className + '\'' + 79 | ", buildingId=" + buildingId + 80 | ", buildingName='" + buildingName + '\'' + 81 | ", computerTotal=" + computerTotal + 82 | ", computerEnable=" + computerEnable + 83 | ", computerDisable=" + computerDisable + 84 | '}'; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/SerializeUtil.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | 4 | import java.io.*; 5 | 6 | /** 7 | * 序列化工具 8 | */ 9 | public class SerializeUtil { 10 | public static Object deserialize(byte[] bytes) { 11 | Object result = null; 12 | if (isEmpty(bytes)) { 13 | return null; 14 | } 15 | try { 16 | ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes); 17 | try { 18 | ObjectInputStream objectInputStream = new ObjectInputStream(byteStream); 19 | try { 20 | result = objectInputStream.readObject(); 21 | } catch (ClassNotFoundException ex) { 22 | throw new Exception("Failed to deserialize object type", ex); 23 | } 24 | } catch (Throwable ex) { 25 | throw new Exception("Failed to deserialize", ex); 26 | } 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | } 30 | return result; 31 | } 32 | 33 | public static boolean isEmpty(byte[] data) { 34 | return data == null || data.length == 0; 35 | } 36 | 37 | /** 38 | * serialize 39 | * 40 | * @param object 41 | * @return 42 | */ 43 | public static byte[] serialize(Object object) { 44 | byte[] result = null; 45 | if (object == null) { 46 | return new byte[0]; 47 | } 48 | try { 49 | ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); 50 | try { 51 | if (!(object instanceof Serializable)) { 52 | throw new IllegalArgumentException( 53 | SerializeUtil.class.getSimpleName() + " requires a Serializable payload " 54 | + "but received an object of type [" + object.getClass().getName() + "]"); 55 | } 56 | ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream); 57 | objectOutputStream.writeObject(object); 58 | objectOutputStream.flush(); 59 | result = byteStream.toByteArray(); 60 | } catch (Throwable ex) { 61 | throw new Exception("Failed to serialize", ex); 62 | } 63 | } catch (Exception ex) { 64 | ex.printStackTrace(); 65 | } 66 | return result; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/JsonResult.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | /** 4 | * @author CheungChingYin 5 | * @date 2018/10/28 6 | * @time 15:10 7 | * @Description: 自定义响应数据结构 8 | * 门户接受此类数据后需要使用本类的方法转换成对于的数据类型格式(类,或者list) 9 | * 其他自行处理 10 | * 200:表示成功 11 | * 500:表示错误,错误信息在msg字段中 12 | * 501:bean验证错误,不管多少个错误都以map形式返回 13 | * 502:拦截器拦截到用户token出错 14 | * 555:异常抛出信息 15 | */ 16 | public class JsonResult { 17 | 18 | /** 19 | * 响应业务状态 20 | */ 21 | private Integer status; 22 | 23 | /** 24 | * 响应消息 25 | */ 26 | private String msg; 27 | 28 | /** 29 | * 响应中的数据 30 | */ 31 | private Object data; 32 | 33 | public JsonResult() { 34 | 35 | } 36 | 37 | public JsonResult(Object data) { 38 | this.status = 200; 39 | this.msg = "OK"; 40 | this.data = data; 41 | } 42 | 43 | public JsonResult(Integer status, String msg, Object data) { 44 | this.status = status; 45 | this.msg = msg; 46 | this.data = data; 47 | } 48 | 49 | public JsonResult build(Integer status, String msg, Object data) { 50 | return new JsonResult(status, msg, data); 51 | } 52 | 53 | public static JsonResult ok() { 54 | return new JsonResult(null); 55 | } 56 | 57 | public static JsonResult ok(Object data) { 58 | return new JsonResult(data); 59 | } 60 | 61 | public static JsonResult errorMsg(String msg) { 62 | return new JsonResult(500, msg, null); 63 | } 64 | 65 | public static JsonResult errorMap(Object data) { 66 | return new JsonResult(501, "BeanError", data); 67 | } 68 | 69 | public static JsonResult errorTokenMsg(String msg) { 70 | return new JsonResult(502, msg, null); 71 | } 72 | 73 | public static JsonResult errorException(String msg) { 74 | return new JsonResult(555, msg, null); 75 | } 76 | 77 | public Integer getStatus() { 78 | return status; 79 | } 80 | 81 | public void setStatus(Integer status) { 82 | this.status = status; 83 | } 84 | 85 | public String getMsg() { 86 | return msg; 87 | } 88 | 89 | public void setMsg(String msg) { 90 | this.msg = msg; 91 | } 92 | 93 | public Object getData() { 94 | return data; 95 | } 96 | 97 | public void setData(Object data) { 98 | this.data = data; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.ParameterBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.schema.ModelRef; 10 | import springfox.documentation.service.ApiInfo; 11 | import springfox.documentation.service.Contact; 12 | import springfox.documentation.service.Parameter; 13 | import springfox.documentation.spi.DocumentationType; 14 | import springfox.documentation.spring.web.plugins.Docket; 15 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * Swagger2配置 22 | * 23 | * @author CheungChingYin 24 | * @date 2018/11/4 25 | * @time 10:39 26 | */ 27 | @Configuration 28 | @EnableSwagger2 29 | public class Swagger2Config { 30 | 31 | @Bean 32 | public Docket createRestApi() { 33 | // 为swagger添加header参数可供输入 34 | ParameterBuilder userTokenHeader = new ParameterBuilder(); 35 | ParameterBuilder userIdHeader = new ParameterBuilder(); 36 | List pars = new ArrayList(); 37 | userTokenHeader.name("headerUserToken").description("userToken") 38 | .modelRef(new ModelRef("string")).parameterType("header") 39 | .required(false).build(); 40 | userIdHeader.name("headerUserId").description("userId") 41 | .modelRef(new ModelRef("string")).parameterType("header") 42 | .required(false).build(); 43 | pars.add(userTokenHeader.build()); 44 | pars.add(userIdHeader.build()); 45 | 46 | return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() 47 | .apis(RequestHandlerSelectors.basePackage("com.repairsystem.web.controller")) 48 | .paths(PathSelectors.any()).build() 49 | .globalOperationParameters(pars); 50 | } 51 | 52 | private ApiInfo apiInfo() { 53 | return new ApiInfoBuilder() 54 | // 设置页面标题 55 | .title("机房报修系统后台API") 56 | // 设置联系人 57 | .contact(new Contact("CheungChingYin-张正贤", "https://blog.csdn.net/qq_33596978", "CheungChingYin@outlook.com")) 58 | // 描述 59 | .description("欢迎访问机房报修系统接口文档") 60 | // 定义版本号 61 | .version("1.0").license("MIT").build(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ClassMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 27 | 37 | 38 | 49 | 50 | 61 | 62 | 66 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/CompleteOrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.repairsystem.dao.CompleteOrderMapper; 4 | import com.repairsystem.entity.CompleteOrder; 5 | import com.repairsystem.entity.Orders; 6 | import com.repairsystem.exception.CompleteOrderIdIsNullException; 7 | import com.repairsystem.service.CompleteOrderService; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Propagation; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import tk.mybatis.mapper.entity.Example; 14 | 15 | import java.util.Collections; 16 | import java.util.List; 17 | 18 | /** 19 | * @author CheungChingYin 20 | * @date 2018/10/29 21 | * @time 21:03 22 | */ 23 | @Service 24 | public class CompleteOrderServiceImpl implements CompleteOrderService { 25 | 26 | @Autowired 27 | private CompleteOrderMapper completeOrderMapper; 28 | 29 | @Transactional(propagation = Propagation.SUPPORTS) 30 | @Override 31 | public List searchAllCompleteOrder() { 32 | return completeOrderMapper.getAllCompleteOrder(); 33 | } 34 | 35 | @Transactional(propagation = Propagation.SUPPORTS) 36 | @Override 37 | public CompleteOrder searchCompleteOrderById(Integer id) { 38 | if (StringUtils.isBlank(id.toString())) { 39 | throw new CompleteOrderIdIsNullException("传入的完成表单ID不能为空"); 40 | } 41 | return completeOrderMapper.getCompleteOrderById(id); 42 | } 43 | 44 | @Transactional(propagation = Propagation.SUPPORTS) 45 | @Override 46 | public Integer getCompleteOrderCount() { 47 | return completeOrderMapper.getCompleteOrderCount(); 48 | } 49 | 50 | @Transactional(propagation = Propagation.SUPPORTS) 51 | @Override 52 | public List searchCompleteOrderByKeyWord(String keyWord) { 53 | return completeOrderMapper.getCompleteOrderByKeyWord(keyWord); 54 | } 55 | 56 | @Transactional(propagation = Propagation.REQUIRED) 57 | @Override 58 | public void saveCompleteOrder(CompleteOrder completeOrder) { 59 | completeOrderMapper.insertSelective(completeOrder); 60 | } 61 | 62 | @Transactional(propagation = Propagation.SUPPORTS) 63 | @Override 64 | public void updateCompleteOrder(CompleteOrder completeOrder) { 65 | completeOrderMapper.updateByPrimaryKeySelective(completeOrder); 66 | } 67 | 68 | @Transactional(propagation = Propagation.SUPPORTS) 69 | @Override 70 | public void deleteCompleteOrder(Integer id) { 71 | if (StringUtils.isBlank(id.toString())) { 72 | throw new CompleteOrderIdIsNullException("传入的用户名为空"); 73 | } 74 | completeOrderMapper.deleteByPrimaryKey(id); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/OrderUploadUtils.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | import org.apache.commons.io.FilenameUtils; 4 | import org.apache.commons.io.IOUtils; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.multipart.MultipartFile; 7 | 8 | import java.io.File; 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.UUID; 17 | 18 | /** 19 | * @author CheungChingYin 20 | * @date 2018/11/13 21 | * @time 10:40 22 | */ 23 | @Component 24 | public class OrderUploadUtils { 25 | 26 | 27 | private static String dir = ConstantUtils.Path.DIRPATH; 28 | 29 | public static Map upLoadOrderImage(MultipartFile file) { 30 | Map resultMap = new HashMap(); 31 | //检查传入的文件是否为空 32 | if (file.isEmpty()) { 33 | resultMap.put("failure", "传入的文件为空"); 34 | return resultMap; 35 | } 36 | SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("yyyy-MM-dd"); 37 | String currentDate = simpleDateFormatDate.format(new Date()); 38 | //上传的图片以“/opt/当前时间”为路径 39 | String fileName = file.getOriginalFilename(); 40 | String realPath = dir + "/" + currentDate + "/"; 41 | File fileDir = new File(realPath); 42 | if (!fileDir.exists()) { 43 | fileDir.mkdirs(); 44 | } 45 | //仅允许四中图像格式的文件上传,以防报修人传其他文件 46 | String extName = FilenameUtils.getExtension(fileName); 47 | String allowImgFormat = "gif,jpg,jpeg,png"; 48 | if (!allowImgFormat.contains(extName.toLowerCase())) { 49 | resultMap.put("failure", "传入的文件不是图像"); 50 | return resultMap; 51 | } 52 | 53 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd&HH-mm-ss"); 54 | String currentTime = simpleDateFormat.format(new Date()); 55 | 56 | //上传图像改名为“年-月-日&时-分-秒+UUID” 57 | fileName = currentTime + UUID.randomUUID() + ".jpg"; 58 | InputStream inputStream = null; 59 | FileOutputStream fileOutputStream = null; 60 | try { 61 | inputStream = file.getInputStream(); 62 | fileOutputStream = new FileOutputStream(realPath + fileName); 63 | IOUtils.copy(inputStream, fileOutputStream); 64 | } catch (IOException e) { 65 | resultMap.put("failure", "图片储存失败"); 66 | e.printStackTrace(); 67 | return resultMap; 68 | } finally { 69 | IOUtils.closeQuietly(inputStream); 70 | IOUtils.closeQuietly(fileOutputStream); 71 | } 72 | //如果成功返回Map,带图片的路径 73 | resultMap.put("success", "/" + currentDate + "/" + fileName); 74 | return resultMap; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/resources/mapper/OrdersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 36 | 37 | 49 | 50 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/MySignOutFilter.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import com.repairsystem.config.LoginAdminContext; 4 | import org.apache.shiro.session.SessionException; 5 | import org.apache.shiro.subject.Subject; 6 | import org.apache.shiro.web.filter.authc.LogoutFilter; 7 | import org.apache.shiro.web.util.WebUtils; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | 12 | import javax.servlet.ServletRequest; 13 | import javax.servlet.ServletResponse; 14 | import javax.servlet.http.Cookie; 15 | import javax.servlet.http.HttpServletRequest; 16 | import java.util.Locale; 17 | 18 | /** 19 | * 登出过滤器 20 | * 避免由于ajax请求导致发生302重定向的问题 21 | */ 22 | public class MySignOutFilter extends LogoutFilter { 23 | private static final Logger log = LoggerFactory.getLogger(MySignOutFilter.class); 24 | 25 | private RedisTemplate redisTemplate; 26 | 27 | public MySignOutFilter() { 28 | 29 | } 30 | 31 | public MySignOutFilter(RedisTemplate redisTemplate) { 32 | this.redisTemplate = redisTemplate; 33 | } 34 | 35 | /** 36 | * 用户登出操作 37 | * 38 | * @param request 39 | * @param response 40 | * @return 41 | * @throws Exception 42 | */ 43 | @Override 44 | protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception { 45 | Subject subject = getSubject(request, response); 46 | // Check if POST only logout is enabled 47 | if (isPostOnlyLogout()) { 48 | // check if the current request's method is a POST, if not redirect 49 | if (!WebUtils.toHttp(request).getMethod().toUpperCase(Locale.ENGLISH).equals("POST")) { 50 | return onLogoutRequestNotAPost(request, response); 51 | } 52 | } 53 | 54 | String redirectUrl = getRedirectUrl(request, response, subject); 55 | //try/catch added for SHIRO-298: 56 | try { 57 | //登出时从session获取的cookieId 58 | String cookieId = (String) subject.getSession().getId(); 59 | System.out.println(cookieId); 60 | Cookie[] cookies = ((HttpServletRequest) request).getCookies(); 61 | for (Cookie cookie : cookies) { 62 | //"登出时从cookie获取得到的cookieId 63 | if (cookieId.equals(cookie.getName())) { 64 | System.out.println(cookie.getValue()); 65 | redisTemplate.delete(cookie); 66 | // 清除线程的登录用户 67 | LoginAdminContext.clear(); 68 | } 69 | } 70 | subject.logout(); 71 | } catch (SessionException ise) { 72 | log.debug("Encountered session exception during logout. This can generally safely be ignored.", ise); 73 | } 74 | issueRedirect(request, response, redirectUrl); 75 | return false; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/ZipUtils.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | import net.lingala.zip4j.core.ZipFile; 4 | import net.lingala.zip4j.exception.ZipException; 5 | import net.lingala.zip4j.model.ZipParameters; 6 | import net.lingala.zip4j.util.Zip4jConstants; 7 | import org.apache.commons.lang3.StringUtils; 8 | 9 | import java.io.File; 10 | 11 | /** 12 | * 压缩包工具类 13 | * 14 | * @author CheungChingYin 15 | * @date 2018/11/19 16 | * @time 14:23 17 | */ 18 | public class ZipUtils { 19 | 20 | //声明压缩对象 21 | private static ZipParameters parameters; 22 | 23 | //解压文件对象 24 | private static ZipFile zipFile; 25 | 26 | /** 27 | * @param sourceFilePath 被压缩的文件的路径(单文件,文件夹) 28 | * @param zipFilePath 压缩文件路径 29 | * @param password 压缩密码 30 | * @return 压缩成功:true ,压缩失败:false 31 | */ 32 | public static Boolean singleFileCompress(String sourceFilePath, String zipFilePath, String password) { 33 | parameters = new ZipParameters(); 34 | parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // 压缩方式(默认方式) 35 | parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); // 压缩级别(默认级别) 36 | //压缩加密设置 37 | if (!StringUtils.isEmpty(password)) { 38 | parameters.setEncryptFiles(true);//是否设置文件加密(默认为否) 39 | parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD); // 加密方式(此处是标准压缩) 40 | parameters.setPassword(password.toCharArray()); 41 | } 42 | try { 43 | ZipFile zipFile = new ZipFile(zipFilePath); 44 | //如果是文件则直接压缩,若是文件夹,遍历文件全部压缩 45 | if (new File(sourceFilePath).isFile()) { 46 | zipFile.setFileNameCharset("GBK"); 47 | zipFile.addFile(new File(sourceFilePath), parameters); 48 | return true; 49 | } 50 | //File ff=new File(sourceFilePath); 51 | File[] flst = new File(sourceFilePath).listFiles(); 52 | System.out.println("文件个数=>" + flst.length); 53 | for (File f : flst) { 54 | zipFile.setFileNameCharset("GBK"); 55 | zipFile.addFile(f, parameters); 56 | } 57 | 58 | return true; 59 | } catch (ZipException e) { 60 | e.printStackTrace(); 61 | return false; 62 | } catch (Exception id) { 63 | id.printStackTrace(); 64 | return false; 65 | } 66 | } 67 | 68 | public static Boolean unZip(String zipFile, String unZipDir) { 69 | try { 70 | ZipUtils.zipFile = new ZipFile(zipFile); 71 | ZipUtils.zipFile.setFileNameCharset("GBK");//设置编码格式 72 | //用自带的方法检测一下zip文件是否合法,包括文件是否存在、是否为zip文件、是否被损坏等 73 | if (!ZipUtils.zipFile.isValidZipFile()) { 74 | throw new ZipException("文件不合法或不存在"); 75 | } 76 | // 跟java自带相比,这里文件路径会自动生成,不用判断 77 | ZipUtils.zipFile.extractAll(unZipDir); 78 | return true; 79 | } catch (ZipException e) { 80 | return false; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/BuildingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.repairsystem.dao.BuildingMapper; 4 | import com.repairsystem.entity.Building; 5 | import com.repairsystem.exception.BuildingIdIsNullException; 6 | import com.repairsystem.exception.BuildingNameIdIsNullException; 7 | import com.repairsystem.service.BuildingService; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Propagation; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import tk.mybatis.mapper.entity.Example; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * @author CheungChingYin 19 | * @date 2018/10/31 20 | * @time 9:37 21 | */ 22 | @Service 23 | public class BuildingServiceImpl implements BuildingService { 24 | 25 | @Autowired 26 | BuildingMapper buildingMapper; 27 | 28 | @Transactional(propagation = Propagation.SUPPORTS) 29 | @Override 30 | public List searchAllBuilding() { 31 | return buildingMapper.selectAll(); 32 | } 33 | 34 | @Transactional(propagation = Propagation.SUPPORTS) 35 | @Override 36 | public Building searchBuildingById(Integer id) { 37 | if (StringUtils.isBlank(id.toString())) { 38 | throw new BuildingIdIsNullException("传入的教学楼ID为空"); 39 | } 40 | return buildingMapper.selectByPrimaryKey(id); 41 | } 42 | 43 | @Transactional(propagation = Propagation.SUPPORTS) 44 | @Override 45 | public List searchBuildingByName(String name) { 46 | if (StringUtils.isBlank(name)) { 47 | throw new BuildingNameIdIsNullException("传入的教学楼名称为空"); 48 | } 49 | Example example = new Example(Building.class); 50 | Example.Criteria criteria = example.createCriteria(); 51 | criteria.andLike("buildingName", "%" + name + "%"); 52 | return buildingMapper.selectByExample(example); 53 | } 54 | 55 | @Transactional(propagation = Propagation.SUPPORTS) 56 | @Override 57 | public Integer getBuildingCount() { 58 | return buildingMapper.getBuildingCount(); 59 | } 60 | 61 | @Transactional(propagation = Propagation.REQUIRED) 62 | @Override 63 | public void savBuilding(Building building) { 64 | buildingMapper.insert(building); 65 | } 66 | 67 | @Transactional(propagation = Propagation.REQUIRED) 68 | @Override 69 | public void updateBuilding(Building building) { 70 | if (StringUtils.isBlank(building.getBuildingId().toString())) { 71 | throw new BuildingIdIsNullException("传入的教学楼ID为空"); 72 | } 73 | buildingMapper.updateByPrimaryKeySelective(building); 74 | } 75 | 76 | @Transactional(propagation = Propagation.REQUIRED) 77 | @Override 78 | public void deleteBuilding(Integer id) { 79 | if (StringUtils.isBlank(id.toString())) { 80 | throw new BuildingIdIsNullException("传入的教学楼ID为空"); 81 | } 82 | buildingMapper.deleteByPrimaryKey(id); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/MyRedisSessionDao.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import com.repairsystem.utils.ConstantUtils; 4 | import org.apache.shiro.session.Session; 5 | import org.apache.shiro.session.mgt.SimpleSession; 6 | import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO; 7 | import org.springframework.data.redis.core.RedisTemplate; 8 | 9 | import java.io.*; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | public class MyRedisSessionDao extends EnterpriseCacheSessionDAO { 13 | 14 | private RedisTemplate redisTemplate; 15 | 16 | public MyRedisSessionDao(RedisTemplate redisTemplate) { 17 | this.redisTemplate = redisTemplate; 18 | } 19 | 20 | /** 21 | * shrio专用在redis新增记录 22 | * 23 | * @param session 绘画 24 | * @return 25 | */ 26 | @Override 27 | protected Serializable doCreate(Session session) { 28 | Serializable sessionId = super.doCreate(session); 29 | redisTemplate.opsForValue().set(sessionId.toString().getBytes(), sessionToByte(session)); 30 | return sessionId; 31 | } 32 | 33 | @Override 34 | protected Session doReadSession(Serializable sessionId) { 35 | Session session = super.doReadSession(sessionId); 36 | if (session == null) { 37 | byte[] bytes = redisTemplate.opsForValue().get(sessionId.toString().getBytes()); 38 | if (bytes != null && bytes.length > 0) { 39 | session = byteToSession(bytes); 40 | } 41 | } 42 | return session; 43 | } 44 | 45 | //设置session的最后一次访问时间 46 | @Override 47 | protected void doUpdate(Session session) { 48 | super.doUpdate(session); 49 | redisTemplate.opsForValue().set(session.getId().toString().getBytes(), sessionToByte(session)); 50 | } 51 | 52 | // 删除session 53 | @Override 54 | protected void doDelete(Session session) { 55 | super.doDelete(session); 56 | redisTemplate.delete(session.getId().toString().getBytes()); 57 | } 58 | 59 | private byte[] sessionToByte(Session session) { 60 | if (null == session) { 61 | return null; 62 | } 63 | ByteArrayOutputStream bo = new ByteArrayOutputStream(); 64 | byte[] bytes = null; 65 | ObjectOutputStream oo; 66 | try { 67 | oo = new ObjectOutputStream(bo); 68 | oo.writeObject(session); 69 | bytes = bo.toByteArray(); 70 | } catch (Exception e) { 71 | e.printStackTrace(); 72 | } 73 | return bytes; 74 | 75 | } 76 | 77 | private Session byteToSession(byte[] bytes) { 78 | if (0 == bytes.length) { 79 | return null; 80 | } 81 | ByteArrayInputStream bi = new ByteArrayInputStream(bytes); 82 | ObjectInputStream in; 83 | SimpleSession session = null; 84 | try { 85 | in = new ObjectInputStream(bi); 86 | session = (SimpleSession) in.readObject(); 87 | } catch (Exception e) { 88 | e.printStackTrace(); 89 | } 90 | return session; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/MyShiroRealm.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import com.repairsystem.config.LoginAdminContext; 4 | import com.repairsystem.entity.Administrator; 5 | import com.repairsystem.entity.Role; 6 | import com.repairsystem.service.AdministratorService; 7 | import com.repairsystem.service.RoleService; 8 | import org.apache.shiro.SecurityUtils; 9 | import org.apache.shiro.authc.*; 10 | import org.apache.shiro.authz.AuthorizationInfo; 11 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 12 | import org.apache.shiro.realm.AuthorizingRealm; 13 | import org.apache.shiro.subject.PrincipalCollection; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | 16 | import javax.annotation.Resource; 17 | import java.util.HashSet; 18 | import java.util.List; 19 | import java.util.Set; 20 | 21 | /** 22 | * shiro 认证类 23 | * 24 | * @author CheungChingYin 25 | * @date 2018/11/4 26 | * @time 21:29 27 | */ 28 | public class MyShiroRealm extends AuthorizingRealm { 29 | 30 | @Autowired 31 | private AdministratorService adminService; 32 | 33 | @Autowired 34 | private RoleService roleService; 35 | 36 | public MyShiroRealm() { 37 | } 38 | 39 | /** 40 | * 为当前登录成功的用户授予权限和分配角色 41 | * 42 | * @param principalCollection 认证数据 43 | * @return 认证信息 44 | */ 45 | @Override 46 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { 47 | System.out.println("======授权认证======="); 48 | //获得用户手机好 49 | String phoneNum = (String) principalCollection.getPrimaryPrincipal(); 50 | SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); 51 | Administrator admin = adminService.searchAdministratorByPhoneNum(phoneNum); 52 | // 登录用户放入当前线程 53 | LoginAdminContext.setLoginAdminContext(admin); 54 | //获得该用户角色 55 | Role role = roleService.searchRoleById(admin.getRoleId()); 56 | //需要将 role 封装到 Set 作为 info.setRoles() 的参数 57 | Set set = new HashSet<>(); 58 | set.add(role.getRoleName()); 59 | //设置该用户拥有的角色 60 | info.addRoles(set); 61 | return info; 62 | } 63 | 64 | /** 65 | * 用来验证当前登录的用户,获取认证信息 66 | * 67 | * @param authenticationToken 认证token 68 | * @return 69 | * @throws AuthenticationException 70 | */ 71 | @Override 72 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { 73 | 74 | System.out.println("————身份认证方法————"); 75 | UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken; 76 | //从数据库获得对应的信息 77 | Administrator admin = adminService.searchAdministratorByPhoneNum(token.getUsername()); 78 | // 根据手机号找不到数据 79 | if (null == admin) { 80 | throw new AccountException("管理员手机号不正确"); 81 | } else if (admin.getAdminPassword().equals(token.getPassword())) { 82 | throw new AccountException("密码不正确"); 83 | } 84 | return new SimpleAuthenticationInfo(token.getUsername(), admin.getAdminPassword(), "adminRealm"); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/ShiroRedisCache.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import com.repairsystem.utils.SerializeUtil; 4 | import org.apache.shiro.cache.Cache; 5 | import org.apache.shiro.cache.CacheException; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | 8 | import java.util.*; 9 | 10 | 11 | public class ShiroRedisCache implements Cache { 12 | private RedisTemplate redisTemplate; 13 | private String prefix = "shiro_redis:"; 14 | 15 | public String getPrefix() { 16 | return prefix; 17 | } 18 | 19 | public void setPrefix(String prefix) { 20 | this.prefix = prefix; 21 | } 22 | 23 | public ShiroRedisCache(RedisTemplate redisTemplate) { 24 | this.redisTemplate = redisTemplate; 25 | } 26 | 27 | public ShiroRedisCache(RedisTemplate redisTemplate, String prefix) { 28 | this(redisTemplate); 29 | this.prefix = prefix; 30 | } 31 | 32 | @Override 33 | public V get(K k) throws CacheException { 34 | if (k == null) { 35 | return null; 36 | } 37 | byte[] bytes = getBytesKey(k); 38 | return (V) redisTemplate.opsForValue().get(bytes); 39 | 40 | } 41 | 42 | @Override 43 | public V put(K k, V v) throws CacheException { 44 | if (k == null || v == null) { 45 | return null; 46 | } 47 | 48 | byte[] bytes = getBytesKey(k); 49 | redisTemplate.opsForValue().set(bytes, v); 50 | return v; 51 | } 52 | 53 | @Override 54 | public V remove(K k) throws CacheException { 55 | if (k == null) { 56 | return null; 57 | } 58 | byte[] bytes = getBytesKey(k); 59 | V v = (V) redisTemplate.opsForValue().get(bytes); 60 | redisTemplate.delete(bytes); 61 | return v; 62 | } 63 | 64 | @Override 65 | public void clear() throws CacheException { 66 | redisTemplate.getConnectionFactory().getConnection().flushDb(); 67 | 68 | } 69 | 70 | @Override 71 | public int size() { 72 | return redisTemplate.getConnectionFactory().getConnection().dbSize().intValue(); 73 | } 74 | 75 | @Override 76 | public Set keys() { 77 | byte[] bytes = (prefix + "*").getBytes(); 78 | Set keys = redisTemplate.keys(bytes); 79 | Set sets = new HashSet<>(); 80 | for (byte[] key : keys) { 81 | sets.add((K) key); 82 | } 83 | return sets; 84 | } 85 | 86 | @Override 87 | public Collection values() { 88 | Set keys = keys(); 89 | List values = new ArrayList<>(keys.size()); 90 | for (K k : keys) { 91 | values.add(get(k)); 92 | } 93 | return values; 94 | } 95 | 96 | private byte[] getBytesKey(K key) { 97 | if (key instanceof String) { 98 | String prekey = this.prefix + key; 99 | return prekey.getBytes(); 100 | } else { 101 | return SerializeUtil.serialize(key); 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/PageUtils.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * @author CheungChingYin 10 | * @date 2018/11/7 11 | * @time 12:12 12 | */ 13 | public class PageUtils { 14 | 15 | public static Map pageHandler(String page, String count) { 16 | 17 | Integer tempPage = Integer.parseInt(page); 18 | Integer tempCount = Integer.parseInt(count); 19 | Map map = new HashMap(); 20 | Integer prePage = prePageHandler(tempPage); 21 | Integer nextPage = nextPageHandler(tempPage, tempCount); 22 | List pageList = pageHandler(tempPage, tempCount); 23 | Integer pages = pagesCount(tempCount); 24 | map.put("page", page); 25 | map.put("prePage", prePage); 26 | map.put("nextPage", nextPage); 27 | map.put("pages", pages); 28 | map.put("count", tempCount); 29 | map.put("pageList", pageList); 30 | return map; 31 | } 32 | 33 | /** 34 | * 上一页逻辑 35 | * 36 | * @param page 37 | * @return 38 | */ 39 | public static Integer prePageHandler(Integer page) { 40 | 41 | Integer prePage; 42 | if (page - 1 == 0) { 43 | prePage = 1; 44 | } else { 45 | prePage = page - 1; 46 | } 47 | return prePage; 48 | } 49 | 50 | /** 51 | * 下一页逻辑 52 | * 53 | * @param page 54 | * @param count 55 | * @return 56 | */ 57 | public static Integer nextPageHandler(Integer page, Integer count) { 58 | 59 | Integer PAGESIZE = ConstantUtils.Page.PAGESIZE; 60 | Integer pages = pagesCount(count); 61 | Integer nextPage; 62 | if (page == pages) { 63 | nextPage = pages; 64 | } else { 65 | nextPage = page + 1; 66 | } 67 | return nextPage; 68 | } 69 | 70 | /** 71 | * 展示出来的页码数 72 | * 73 | * @param page 74 | * @param count 75 | * @return 76 | */ 77 | public static List pageHandler(Integer page, Integer count) { 78 | 79 | List list = new LinkedList(); 80 | Integer PAGENUM = ConstantUtils.Page.PAGESNUM; 81 | 82 | Integer pages = pagesCount(count); 83 | Integer minPages = (page - PAGENUM > 0) ? (page - PAGENUM) : (1);//和上一页同理 84 | Integer maxPages = (page + PAGENUM >= pages) ? (pages) : (page + PAGENUM);//与下一页同理 85 | 86 | for (int i = minPages; i <= maxPages; i++) { 87 | list.add(i);//添加最小页到最大页之间的页码 88 | } 89 | return list; 90 | } 91 | 92 | /** 93 | * 页数总数 94 | * 95 | * @param count 96 | * @return 97 | */ 98 | public static Integer pagesCount(Integer count) { 99 | Integer PAGESIZE = ConstantUtils.Page.PAGESIZE; 100 | Integer pages = (count % PAGESIZE == 0) ? (count / PAGESIZE) : (count / PAGESIZE + 1); 101 | return pages; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/vo/CompleteOrderVO.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author CheungChingYin 9 | * @date 2018/11/2 10 | * @time 21:37 11 | */ 12 | public class CompleteOrderVO { 13 | 14 | private Integer orderId; 15 | private String problem; 16 | private String remark; 17 | private String adminName; 18 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 19 | private Date completeTime; 20 | private String imagePath; 21 | private String className; 22 | private String buildingName; 23 | private Integer computerNumber; 24 | 25 | public Integer getOrderId() { 26 | return orderId; 27 | } 28 | 29 | public void setOrderId(Integer orderId) { 30 | this.orderId = orderId; 31 | } 32 | 33 | public String getProblem() { 34 | return problem; 35 | } 36 | 37 | public void setProblem(String problem) { 38 | this.problem = problem; 39 | } 40 | 41 | public String getRemark() { 42 | return remark; 43 | } 44 | 45 | public void setRemark(String remark) { 46 | this.remark = remark; 47 | } 48 | 49 | public String getAdminName() { 50 | return adminName; 51 | } 52 | 53 | public void setAdminName(String adminName) { 54 | this.adminName = adminName; 55 | } 56 | 57 | public Date getCompleteTime() { 58 | return completeTime; 59 | } 60 | 61 | public void setCompleteTime(Date completeTime) { 62 | this.completeTime = completeTime; 63 | } 64 | 65 | public String getImagePath() { 66 | return imagePath; 67 | } 68 | 69 | public void setImagePath(String imagePath) { 70 | this.imagePath = imagePath; 71 | } 72 | 73 | public String getClassName() { 74 | return className; 75 | } 76 | 77 | public void setClassName(String className) { 78 | this.className = className; 79 | } 80 | 81 | public String getBuildingName() { 82 | return buildingName; 83 | } 84 | 85 | public void setBuildingName(String buildingName) { 86 | this.buildingName = buildingName; 87 | } 88 | 89 | public Integer getComputerNumber() { 90 | return computerNumber; 91 | } 92 | 93 | public void setComputerNumber(Integer computerNumber) { 94 | this.computerNumber = computerNumber; 95 | } 96 | 97 | @Override 98 | public String toString() { 99 | return "CompleteOrderVO{" + 100 | "orderId=" + orderId + 101 | ", problem='" + problem + '\'' + 102 | ", remark='" + remark + '\'' + 103 | ", adminName='" + adminName + '\'' + 104 | ", completeTime=" + completeTime + 105 | ", imagePath='" + imagePath + '\'' + 106 | ", className='" + className + '\'' + 107 | ", buildingName='" + buildingName + '\'' + 108 | ", computerNumber=" + computerNumber + 109 | '}'; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/resources/mapper/CompleteOrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 32 | 43 | 44 | 48 | 49 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #开发环境和生产环境的资源文件配置隔离 2 | #spring.profiles.active=dev 3 | 4 | ############################################################ 5 | # 6 | # 配置数据源相关 使用阿里巴巴的 druid 数据源 7 | # 8 | ############################################################ 9 | spring.datasource.url=jdbc:mysql://localhost:3306/machineroomsystem?rewriteBatchedStatements=true&characterEncoding=UTF-8&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true 10 | spring.datasource.username=root 11 | spring.datasource.password=123456 12 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 13 | spring.datasource.druid.initial-size=1 14 | spring.datasource.druid.min-idle=1 15 | spring.datasource.druid.max-active=20 16 | spring.datasource.druid.test-on-borrow=true 17 | spring.datasource.druid.stat-view-servlet.allow=true 18 | 19 | ############################################################ 20 | # 21 | # mybatis 配置 22 | # 23 | ############################################################ 24 | # mybatis 配置 25 | mybatis.type-aliases-package=com.repairsystem.entity 26 | mybatis.mapper-locations=classpath:mapper/*.xml 27 | # 通用 Mapper 配置 28 | mapper.mappers=com.repairsystem.utils.MyMapper 29 | mapper.not-empty=false 30 | mapper.identity=MYSQL 31 | # 分页插件配置 32 | pagehelper.helperDialect=mysql 33 | pagehelper.supportMethodsArguments=true 34 | pagehelper.params=count=countSql 35 | 36 | # 文件上传配置 37 | spring.servlet.multipart.max-file-size=100Mb 38 | spring.servlet.multipart.max-request-size=1000Mb 39 | # 维修工单图片虚拟目录 40 | order.img.dir=E:/Images 41 | # 所有的访问都经过静态资源路径 42 | spring.mvc.static-path-pattern=/** 43 | # 配置静态资源路径 44 | spring.resources.static-locations= \ 45 | classpath:/META-INF/resources/,\ 46 | classpath:/resources/,\ 47 | classpath:/static/,\ 48 | classpath:/public/,\ 49 | file:${order.img.dir} 50 | 51 | ############################################################ 52 | # 53 | # Server 服务端相关配置 54 | # 55 | ############################################################ 56 | # 配置服务器端号口 57 | server.port=8081 58 | 59 | ############################################################ 60 | # Server - tomcat 相关常用配置 61 | ############################################################ 62 | # tomcat的URI编码 63 | server.tomcat.uri-encoding=UTF-8 64 | 65 | ############################################################ 66 | # 67 | # REDIS 配置 68 | # 69 | ############################################################ 70 | # Redis数据库索引(默认为0) 71 | spring.redis.database=1 72 | # Redis服务器在址 73 | spring.redis.host=192.168.2.188 74 | # Redis服务器连接端口 75 | spring.redis.port=6379 76 | # Redis服务器连接密码 77 | spring.redis.password= 78 | # 连接池最大连接数(使用负值表示没限制) 79 | spring.redis.jedis.pool.max-active=1000 80 | # 连接池最大阻塞等待时间(使用负值表示没有限制) 81 | spring.redis.jedis.pool.max-wait=-1 82 | # 连接池最大空闲连接 83 | spring.redis.jedis.pool.max-idle=10 84 | # 连接池最小空闲连接 85 | spring.redis.jedis.pool.min-idle=2 86 | # 连接超时时间(毫秒) 87 | spring.redis.timeout=5000 88 | 89 | ############################################################ 90 | # 91 | # 邮箱 配置 92 | # 93 | ############################################################ 94 | spring.mail.host=smtp-mail.outlook.com 95 | spring.mail.port=587 96 | spring.mail.username= 97 | spring.mail.password= 98 | spring.mail.properties.mail.smtp.auth=true 99 | spring.mail.properties.mail.smtp.starttls.enable=true 100 | spring.mail.properties.mail.smtp.starttls.required=true 101 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/vo/OrderVO.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author CheungChingYin 9 | * @date 2018/11/2 10 | * @time 21:40 11 | */ 12 | public class OrderVO { 13 | 14 | private Integer orderId; 15 | private String problem; 16 | private Integer computerNumber; 17 | private String className; 18 | private String buildingName; 19 | private Integer status; 20 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 21 | private Date submitTime; 22 | private String imagesPath; 23 | private Integer adminId; 24 | private String adminName; 25 | private String userName; 26 | private String userPhone; 27 | private String userEmail; 28 | 29 | public Integer getOrderId() { 30 | return orderId; 31 | } 32 | 33 | public void setOrderId(Integer orderId) { 34 | this.orderId = orderId; 35 | } 36 | 37 | public String getProblem() { 38 | return problem; 39 | } 40 | 41 | public void setProblem(String problem) { 42 | this.problem = problem; 43 | } 44 | 45 | public Integer getComputerNumber() { 46 | return computerNumber; 47 | } 48 | 49 | public void setComputerNumber(Integer computerNumber) { 50 | this.computerNumber = computerNumber; 51 | } 52 | 53 | public String getClassName() { 54 | return className; 55 | } 56 | 57 | public void setClassName(String className) { 58 | this.className = className; 59 | } 60 | 61 | public String getBuildingName() { 62 | return buildingName; 63 | } 64 | 65 | public void setBuildingName(String buildingName) { 66 | this.buildingName = buildingName; 67 | } 68 | 69 | public Integer getStatus() { 70 | return status; 71 | } 72 | 73 | public void setStatus(Integer status) { 74 | this.status = status; 75 | } 76 | 77 | public Date getSubmitTime() { 78 | return submitTime; 79 | } 80 | 81 | public void setSubmitTime(Date submitTime) { 82 | this.submitTime = submitTime; 83 | } 84 | 85 | public String getImagesPath() { 86 | return imagesPath; 87 | } 88 | 89 | public void setImagesPath(String imagesPath) { 90 | this.imagesPath = imagesPath; 91 | } 92 | 93 | public String getAdminName() { 94 | return adminName; 95 | } 96 | 97 | public void setAdminName(String adminName) { 98 | this.adminName = adminName; 99 | } 100 | 101 | public String getUserName() { 102 | return userName; 103 | } 104 | 105 | public void setUserName(String userName) { 106 | this.userName = userName; 107 | } 108 | 109 | public String getUserPhone() { 110 | return userPhone; 111 | } 112 | 113 | public void setUserPhone(String userPhone) { 114 | this.userPhone = userPhone; 115 | } 116 | 117 | public String getUserEmail() { 118 | return userEmail; 119 | } 120 | 121 | public void setUserEmail(String userEmail) { 122 | this.userEmail = userEmail; 123 | } 124 | 125 | public Integer getAdminId() { 126 | return adminId; 127 | } 128 | 129 | public void setAdminId(Integer adminId) { 130 | this.adminId = adminId; 131 | } 132 | 133 | @Override 134 | public String toString() { 135 | return "OrderVO{" + 136 | "orderId=" + orderId + 137 | ", problem='" + problem + '\'' + 138 | ", computerNumber=" + computerNumber + 139 | ", className='" + className + '\'' + 140 | ", buildingName='" + buildingName + '\'' + 141 | ", status=" + status + 142 | ", submitTime=" + submitTime + 143 | ", imagesPath='" + imagesPath + '\'' + 144 | ", adminId=" + adminId + 145 | ", adminName='" + adminName + '\'' + 146 | ", userName='" + userName + '\'' + 147 | ", userPhone='" + userPhone + '\'' + 148 | ", userEmail='" + userEmail + '\'' + 149 | '}'; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/web/controller/QRCodeController.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.web.controller; 2 | 3 | import com.google.zxing.qrcode.encoder.QRCode; 4 | import com.repairsystem.entity.Class; 5 | import com.repairsystem.utils.QRCodeUtils; 6 | import com.repairsystem.utils.ZipUtils; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiImplicitParam; 9 | import io.swagger.annotations.ApiImplicitParams; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.apache.commons.io.IOUtils; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.io.*; 18 | 19 | /** 20 | * @author CheungChingYin 21 | * @date 2018/11/19 22 | * @time 20:10 23 | */ 24 | @Controller 25 | @Api(value = "二维码相关接口", tags = {"二维码相关接口"}) 26 | @RequestMapping("/QRCode") 27 | public class QRCodeController { 28 | 29 | @ApiOperation(value = "下载二维码图片") 30 | @ApiImplicitParams({ 31 | @ApiImplicitParam(name = "domain", value = "当前域名", required = true, dataType = "String", paramType = "query"), 32 | @ApiImplicitParam(name = "buildingId", value = "所属实训楼Id", required = true, dataType = "String", paramType = "query"), 33 | @ApiImplicitParam(name = "buildingName", value = "所属实训楼名称", required = true, dataType = "String", paramType = "query"), 34 | @ApiImplicitParam(name = "classId", value = "所属实训室ID", required = true, dataType = "String", paramType = "query"), 35 | @ApiImplicitParam(name = "className", value = "所属实训室名称", required = true, dataType = "String", paramType = "query"), 36 | @ApiImplicitParam(name = "computerStartNum", value = "电脑开始编号", required = true, dataType = "String", paramType = "query"), 37 | @ApiImplicitParam(name = "computerEndNum", value = "电脑结束编号", required = true, dataType = "String", paramType = "query"), 38 | 39 | }) 40 | @GetMapping("/QRCodeDownLoad") 41 | public String downloadQRCode(String domain, Integer buildingId, String buildingName, Integer classId, String className, 42 | Integer computerStartNum, Integer computerEndNum, HttpServletResponse response) { 43 | Class clazz = new Class(); 44 | clazz.setBuildingId(buildingId); 45 | clazz.setBuildingName(buildingName); 46 | clazz.setClassId(classId); 47 | clazz.setClassName(className); 48 | 49 | String dirPath = QRCodeUtils.generateQRCode(domain, clazz, computerStartNum, computerEndNum); 50 | String zipFileName = buildingName + "&" + className + ".zip"; 51 | String zipFilePath = dirPath + zipFileName; 52 | boolean zipResult = ZipUtils.singleFileCompress(dirPath, zipFilePath, null); 53 | if (zipResult) { 54 | response.setContentType("application/force-download");// 设置强制下载不打开 55 | response.addHeader("Content-Disposition", "attachment;fileName=QRCode.zip");// 设置文件名 56 | File file = new File(zipFilePath); 57 | if (file.exists()) { 58 | 59 | byte[] buffer = new byte[1024]; 60 | FileInputStream fis = null; 61 | BufferedInputStream bis = null; 62 | try { 63 | fis = new FileInputStream(file); 64 | IOUtils.copy(fis, response.getOutputStream()); 65 | response.flushBuffer(); 66 | System.out.println("success"); 67 | } catch (FileNotFoundException e) { 68 | e.printStackTrace(); 69 | } catch (IOException e) { 70 | e.printStackTrace(); 71 | } finally { 72 | if (bis != null) { 73 | try { 74 | bis.close(); 75 | } catch (IOException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | if (fis != null) { 80 | try { 81 | fis.close(); 82 | } catch (IOException e) { 83 | e.printStackTrace(); 84 | } 85 | } 86 | } 87 | } 88 | 89 | 90 | } 91 | return null; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/Administrator.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Id; 8 | 9 | @ApiModel(value = "管理员对象", description = "这是管理员对象") 10 | public class Administrator { 11 | /** 12 | * 管理员ID 13 | */ 14 | @Id 15 | @Column(name = "admin_id") 16 | @ApiModelProperty(value = "管理员ID", name = "adminId", example = "1", required = true) 17 | private Integer adminId; 18 | 19 | /** 20 | * 管理员密码 21 | */ 22 | @Column(name = "admin_password") 23 | @ApiModelProperty(value = "管理员密码", name = "adminPassword", example = "test123456", required = true) 24 | private String adminPassword; 25 | 26 | /** 27 | * 管理员姓名 28 | */ 29 | @Column(name = "admin_name") 30 | @ApiModelProperty(value = "管理员姓名", name = "adminName", example = "李四", required = true) 31 | private String adminName; 32 | 33 | /** 34 | * 管理员电话 35 | */ 36 | @Column(name = "admin_phone") 37 | @ApiModelProperty(value = "管理员电话", name = "adminPhone", example = "13283497593", required = true) 38 | private String adminPhone; 39 | 40 | /** 41 | * 管理员权限 42 | */ 43 | @Column(name = "role_id") 44 | @ApiModelProperty(value = "管理员权限", name = "roleId", example = "0", required = true) 45 | private Integer roleId; 46 | 47 | /** 48 | * 管理员邮箱 49 | */ 50 | @Column(name = "admin_email") 51 | @ApiModelProperty(value = "管理员邮箱", name = "adminEmail", example = "test@gmail.com", required = true) 52 | private String adminEmail; 53 | 54 | /** 55 | * 获取管理员ID 56 | * 57 | * @return admin_id - 管理员ID 58 | */ 59 | public Integer getAdminId() { 60 | return adminId; 61 | } 62 | 63 | /** 64 | * 设置管理员ID 65 | * 66 | * @param adminId 管理员ID 67 | */ 68 | public void setAdminId(Integer adminId) { 69 | this.adminId = adminId; 70 | } 71 | 72 | /** 73 | * 获取管理员密码 74 | * 75 | * @return admin_password - 管理员密码 76 | */ 77 | public String getAdminPassword() { 78 | return adminPassword; 79 | } 80 | 81 | /** 82 | * 设置管理员密码 83 | * 84 | * @param adminPassword 管理员密码 85 | */ 86 | public void setAdminPassword(String adminPassword) { 87 | this.adminPassword = adminPassword; 88 | } 89 | 90 | /** 91 | * 获取管理员姓名 92 | * 93 | * @return admin_name - 管理员姓名 94 | */ 95 | public String getAdminName() { 96 | return adminName; 97 | } 98 | 99 | /** 100 | * 设置管理员姓名 101 | * 102 | * @param adminName 管理员姓名 103 | */ 104 | public void setAdminName(String adminName) { 105 | this.adminName = adminName; 106 | } 107 | 108 | /** 109 | * 获取管理员电话 110 | * 111 | * @return admin_phone - 管理员电话 112 | */ 113 | public String getAdminPhone() { 114 | return adminPhone; 115 | } 116 | 117 | /** 118 | * 设置管理员电话 119 | * 120 | * @param adminPhone 管理员电话 121 | */ 122 | public void setAdminPhone(String adminPhone) { 123 | this.adminPhone = adminPhone; 124 | } 125 | 126 | /** 127 | * 获取管理员权限 128 | * 129 | * @return role_id - 管理员权限 130 | */ 131 | public Integer getRoleId() { 132 | return roleId; 133 | } 134 | 135 | /** 136 | * 设置管理员权限 137 | * 138 | * @param roleId 管理员权限 139 | */ 140 | public void setRoleId(Integer roleId) { 141 | this.roleId = roleId; 142 | } 143 | 144 | /** 145 | * 获取管理员邮箱 146 | * 147 | * @return admin_email - 管理员邮箱 148 | */ 149 | public String getAdminEmail() { 150 | return adminEmail; 151 | } 152 | 153 | /** 154 | * 设置管理员邮箱 155 | * 156 | * @param adminEmail 管理员邮箱 157 | */ 158 | public void setAdminEmail(String adminEmail) { 159 | this.adminEmail = adminEmail; 160 | } 161 | 162 | @Override 163 | public String toString() { 164 | return "Administrator{" + 165 | "adminId=" + adminId + 166 | ", adminPassword='" + adminPassword + '\'' + 167 | ", adminName='" + adminName + '\'' + 168 | ", adminPhone='" + adminPhone + '\'' + 169 | ", roleId=" + roleId + 170 | ", adminEmail='" + adminEmail + '\'' + 171 | '}'; 172 | } 173 | } -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/ClassServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException; 4 | import com.repairsystem.dao.ClassMapper; 5 | import com.repairsystem.entity.Class; 6 | import com.repairsystem.entity.vo.ClassVO; 7 | import com.repairsystem.exception.BuildingIdIsNullException; 8 | import com.repairsystem.exception.ClassIdIsNullException; 9 | import com.repairsystem.exception.ClassNameIsNullException; 10 | import com.repairsystem.service.ClassService; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.transaction.annotation.Propagation; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import tk.mybatis.mapper.entity.Example; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * @author CheungChingYin 22 | * @date 2018/10/31 23 | * @time 12:08 24 | */ 25 | @Service 26 | public class ClassServiceImpl implements ClassService { 27 | 28 | @Autowired 29 | private ClassMapper classMapper; 30 | 31 | @Transactional(propagation = Propagation.SUPPORTS) 32 | @Override 33 | public List searchAllClass() { 34 | return classMapper.getAllClass(); 35 | } 36 | 37 | @Transactional(propagation = Propagation.SUPPORTS) 38 | @Override 39 | public Class searchClassById(Integer id) { 40 | if (StringUtils.isBlank(id.toString())) { 41 | throw new ClassIdIsNullException("传入的实训室ID为空"); 42 | } 43 | return classMapper.getClassById(id); 44 | } 45 | 46 | @Transactional(propagation = Propagation.SUPPORTS) 47 | @Override 48 | public List searchClassByName(String name) { 49 | if (StringUtils.isBlank(name)) { 50 | throw new ClassNameIsNullException("传入的实训室名称为空"); 51 | } 52 | return classMapper.getClassByName(name); 53 | } 54 | 55 | @Transactional(propagation = Propagation.SUPPORTS) 56 | @Override 57 | public List searchClassByBuildingId(String buildingId) { 58 | if(StringUtils.isBlank(buildingId)){ 59 | throw new BuildingIdIsNullException("传入的实训楼ID不能为空"); 60 | } 61 | return classMapper.getClassByBuildingId(buildingId); 62 | } 63 | 64 | @Transactional(propagation = Propagation.SUPPORTS) 65 | @Override 66 | public Integer getClassCount() { 67 | return classMapper.getClassCount(); 68 | } 69 | 70 | @Transactional(propagation = Propagation.REQUIRED) 71 | @Override 72 | public void saveClass(Class classes) { 73 | classMapper.insertSelective(classes); 74 | } 75 | 76 | @Transactional(propagation = Propagation.REQUIRED) 77 | @Override 78 | public void updateClass(Class classes) { 79 | if (StringUtils.isBlank(classes.getClassId().toString())) { 80 | throw new ClassIdIsNullException("传入的实训室ID为空"); 81 | } 82 | classMapper.updateByPrimaryKeySelective(classes); 83 | } 84 | 85 | @Transactional(propagation = Propagation.REQUIRED) 86 | @Override 87 | public void deleteClass(Integer id) throws MySQLIntegrityConstraintViolationException { 88 | if (StringUtils.isBlank(id.toString())) { 89 | throw new ClassIdIsNullException("传入的实训室ID为空"); 90 | } 91 | classMapper.deleteByPrimaryKey(id); 92 | } 93 | 94 | @Transactional(propagation = Propagation.REQUIRED) 95 | @Override 96 | public void increaseComputerEnable(Integer classId) { 97 | Class classes = classMapper.getClassById(classId); 98 | Integer computerEnable = classes.getComputerEnable() + 1; 99 | Integer computerDisable = classes.getComputerDisable() - 1; 100 | classes.setComputerEnable(computerEnable); 101 | classes.setComputerDisable(computerDisable); 102 | classMapper.updateByPrimaryKeySelective(classes); 103 | } 104 | 105 | @Transactional(propagation = Propagation.REQUIRED) 106 | @Override 107 | public void reduceComputerEnable(Integer classId) { 108 | Class classes = classMapper.getClassById(classId); 109 | Integer computerEnable = classes.getComputerEnable() - 1; 110 | Integer computerDisable = classes.getComputerDisable() + 1; 111 | classes.setBuildingName(null); 112 | classes.setComputerEnable(computerEnable); 113 | classes.setComputerDisable(computerDisable); 114 | classMapper.updateByPrimaryKeySelective(classes); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/service/Impl/AdministratorServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.service.Impl; 2 | 3 | import com.repairsystem.dao.AdministratorMapper; 4 | import com.repairsystem.entity.Administrator; 5 | import com.repairsystem.exception.AdministratorIdIsNullException; 6 | import com.repairsystem.exception.AdministratorNameIsNullException; 7 | import com.repairsystem.exception.AdministratorPasswordIsNullException; 8 | import com.repairsystem.exception.AdministratorPhoneIsNullException; 9 | import com.repairsystem.service.AdministratorService; 10 | import com.repairsystem.utils.PasswordEncryptionUtils; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.transaction.annotation.Propagation; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import tk.mybatis.mapper.entity.Example; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * @author CheungChingYin 22 | * @date 2018/10/28 23 | * @time 19:54 24 | */ 25 | @Service 26 | public class AdministratorServiceImpl implements AdministratorService { 27 | 28 | @Autowired 29 | private AdministratorMapper adminMapper; 30 | 31 | @Transactional(propagation = Propagation.SUPPORTS) 32 | @Override 33 | public List searchAllAdministrator() { 34 | return adminMapper.selectAll(); 35 | } 36 | 37 | @Transactional(propagation = Propagation.SUPPORTS) 38 | @Override 39 | public String countAllAdministrator() { 40 | return adminMapper.getAdministratorCount().toString(); 41 | } 42 | 43 | @Transactional(propagation = Propagation.SUPPORTS) 44 | @Override 45 | public Administrator searchAdministratorById(Integer id) { 46 | if (StringUtils.isBlank(id.toString())) { 47 | throw new AdministratorIdIsNullException("传入的管理员ID为空"); 48 | } 49 | return adminMapper.selectByPrimaryKey(id); 50 | } 51 | 52 | @Transactional(propagation = Propagation.SUPPORTS) 53 | @Override 54 | public List searchAdministratorByName(String name) { 55 | if (StringUtils.isBlank(name)) { 56 | throw new AdministratorNameIsNullException("传入的管理员姓名为空"); 57 | } 58 | Example example = new Example(Administrator.class); 59 | example.createCriteria().andLike("adminName", "%" + name + "%"); 60 | return adminMapper.selectByExample(example); 61 | } 62 | 63 | @Transactional(propagation = Propagation.SUPPORTS) 64 | @Override 65 | public Administrator searchAdministratorByPhoneNum(String phoneNum) { 66 | Example example = new Example(Administrator.class); 67 | example.createCriteria().andEqualTo("adminPhone", phoneNum); 68 | return adminMapper.selectOneByExample(example); 69 | } 70 | 71 | @Transactional(propagation = Propagation.SUPPORTS) 72 | @Override 73 | public Administrator loginAdministrator(String phone, String password) { 74 | if (StringUtils.isBlank(phone)) { 75 | throw new AdministratorPhoneIsNullException("传入的管理员电话号码为空"); 76 | } 77 | 78 | if (StringUtils.isBlank(password)) { 79 | throw new AdministratorPasswordIsNullException("传入的管理员密码为空"); 80 | } 81 | password = PasswordEncryptionUtils.plainText2MD5Encrypt(password); 82 | Example example = new Example(Administrator.class); 83 | example.createCriteria().andEqualTo("adminPhone", phone).andEqualTo("adminPassword", password); 84 | return adminMapper.selectOneByExample(example); 85 | } 86 | 87 | @Transactional(propagation = Propagation.SUPPORTS) 88 | @Override 89 | public boolean administratorPhoneNumberIsExist(String number) { 90 | if (StringUtils.isBlank(number)) { 91 | throw new AdministratorPhoneIsNullException("传入的管理员密码为空"); 92 | } 93 | Administrator admin = new Administrator(); 94 | admin.setAdminPhone(number); 95 | Administrator result = adminMapper.selectOne(admin); 96 | return result != null; 97 | } 98 | 99 | @Transactional(propagation = Propagation.REQUIRED) 100 | @Override 101 | public void saveAdministrator(Administrator admin) { 102 | String password = admin.getAdminPassword(); 103 | admin.setAdminPassword(PasswordEncryptionUtils.plainText2MD5Encrypt(password)); 104 | adminMapper.insert(admin); 105 | } 106 | 107 | @Transactional(propagation = Propagation.REQUIRED) 108 | @Override 109 | public void updateAdministrator(Administrator admin) { 110 | if (StringUtils.isBlank(admin.getAdminId().toString())) { 111 | throw new AdministratorIdIsNullException("传入的管理员ID为空"); 112 | } 113 | adminMapper.updateByPrimaryKeySelective(admin); 114 | 115 | } 116 | 117 | @Transactional(propagation = Propagation.REQUIRED) 118 | @Override 119 | public void deleteAdministrator(Integer id) { 120 | if (StringUtils.isBlank(id.toString())) { 121 | throw new AdministratorIdIsNullException("传入的管理员ID为空"); 122 | } 123 | adminMapper.deleteByPrimaryKey(id); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/Class.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Id; 8 | import javax.persistence.Transient; 9 | 10 | @ApiModel(value = "实训室对象", description = "这个是实训室对象") 11 | public class Class { 12 | /** 13 | * 实训室ID 14 | */ 15 | @Id 16 | @Column(name = "class_id") 17 | @ApiModelProperty(value = "实训室ID", name = "classId", example = "1", required = true) 18 | private Integer classId; 19 | 20 | /** 21 | * 实训室名称 22 | */ 23 | @Column(name = "class_name") 24 | @ApiModelProperty(value = "实训室名称", name = "className", example = "A101", required = true) 25 | private String className; 26 | 27 | /** 28 | * 所属实训楼 29 | */ 30 | @Column(name = "building_id") 31 | @ApiModelProperty(value = "所属实训楼ID", name = "buildingId", example = "1", required = true) 32 | private Integer buildingId; 33 | 34 | /** 35 | * 所属教学楼名称 36 | */ 37 | @ApiModelProperty(hidden = true) 38 | @Transient 39 | private String buildingName; 40 | 41 | /** 42 | * 电脑总数 43 | */ 44 | @Column(name = "computer_total") 45 | @ApiModelProperty(value = "实训室电脑总数", name = "computerTotal", example = "60") 46 | private Integer computerTotal; 47 | 48 | /** 49 | * 可用电脑总数 50 | */ 51 | @Column(name = "computer_enable") 52 | @ApiModelProperty(value = "实训室可用电脑数", name = "computerEnable", example = "50") 53 | private Integer computerEnable; 54 | 55 | /** 56 | * 不可用电脑总数 57 | */ 58 | @Column(name = "computer_disable") 59 | @ApiModelProperty(value = "实训室不可用电脑数", name = "computerDisable", example = "10") 60 | private Integer computerDisable; 61 | 62 | 63 | /** 64 | * 获取实训室ID 65 | * 66 | * @return class_id - 实训室ID 67 | */ 68 | public Integer getClassId() { 69 | return classId; 70 | } 71 | 72 | /** 73 | * 设置实训室ID 74 | * 75 | * @param classId 实训室ID 76 | */ 77 | public void setClassId(Integer classId) { 78 | this.classId = classId; 79 | } 80 | 81 | /** 82 | * 获取实训室名称 83 | * 84 | * @return class_name - 实训室名称 85 | */ 86 | public String getClassName() { 87 | return className; 88 | } 89 | 90 | /** 91 | * 设置实训室名称 92 | * 93 | * @param className 实训室名称 94 | */ 95 | public void setClassName(String className) { 96 | this.className = className; 97 | } 98 | 99 | /** 100 | * 获取所属实训楼 101 | * 102 | * @return building_id - 所属实训楼 103 | */ 104 | public Integer getBuildingId() { 105 | return buildingId; 106 | } 107 | 108 | /** 109 | * 设置所属实训楼 110 | * 111 | * @param buildingId 所属实训楼 112 | */ 113 | public void setBuildingId(Integer buildingId) { 114 | this.buildingId = buildingId; 115 | } 116 | 117 | /** 118 | * 获得教学楼名称 119 | * 120 | * @return 121 | */ 122 | public String getBuildingName() { 123 | return buildingName; 124 | } 125 | 126 | /** 127 | * 设置教学楼名称 128 | * 129 | * @param buildingName 130 | */ 131 | public void setBuildingName(String buildingName) { 132 | this.buildingName = buildingName; 133 | } 134 | 135 | /** 136 | * 获取电脑总数 137 | * 138 | * @return computer_total - 电脑总数 139 | */ 140 | public Integer getComputerTotal() { 141 | return computerTotal; 142 | } 143 | 144 | /** 145 | * 设置电脑总数 146 | * 147 | * @param computerTotal 电脑总数 148 | */ 149 | public void setComputerTotal(Integer computerTotal) { 150 | this.computerTotal = computerTotal; 151 | } 152 | 153 | /** 154 | * 获取可用电脑总数 155 | * 156 | * @return computer_enable - 可用电脑总数 157 | */ 158 | public Integer getComputerEnable() { 159 | return computerEnable; 160 | } 161 | 162 | /** 163 | * 设置可用电脑总数 164 | * 165 | * @param computerEnable 可用电脑总数 166 | */ 167 | public void setComputerEnable(Integer computerEnable) { 168 | this.computerEnable = computerEnable; 169 | } 170 | 171 | /** 172 | * 获取不可用电脑总数 173 | * 174 | * @return computer_disable - 不可用电脑总数 175 | */ 176 | public Integer getComputerDisable() { 177 | return computerDisable; 178 | } 179 | 180 | /** 181 | * 设置不可用电脑总数 182 | * 183 | * @param computerDisable 不可用电脑总数 184 | */ 185 | public void setComputerDisable(Integer computerDisable) { 186 | this.computerDisable = computerDisable; 187 | } 188 | 189 | @Override 190 | public String toString() { 191 | return "Class{" + 192 | "classId=" + classId + 193 | ", className='" + className + '\'' + 194 | ", buildingId=" + buildingId + 195 | ", buildingName='" + buildingName + '\'' + 196 | ", computerTotal=" + computerTotal + 197 | ", computerEnable=" + computerEnable + 198 | ", computerDisable=" + computerDisable + 199 | '}'; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /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 http://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 enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/web/controller/BuildingController.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.web.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.repairsystem.entity.Building; 5 | import com.repairsystem.service.BuildingService; 6 | import com.repairsystem.utils.ConstantUtils; 7 | import com.repairsystem.utils.JsonResult; 8 | import com.repairsystem.utils.PageUtils; 9 | import io.swagger.annotations.Api; 10 | import io.swagger.annotations.ApiImplicitParam; 11 | import io.swagger.annotations.ApiImplicitParams; 12 | import io.swagger.annotations.ApiOperation; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | import java.util.HashMap; 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | /** 22 | * @author CheungChingYin 23 | * @date 2018/11/11 24 | * @time 21:44 25 | */ 26 | @RestController 27 | @Api(value = "实训楼业务相关接口", tags = {"实训楼业务相关接口"}) 28 | @RequestMapping("/building") 29 | public class BuildingController { 30 | 31 | @Autowired 32 | private BuildingService buildingService; 33 | 34 | @ApiOperation(value = "获得全部实训楼信息") 35 | @GetMapping("/getBuildingInfo") 36 | public JsonResult getBuildingInfo() { 37 | List list = buildingService.searchAllBuilding(); 38 | Map resultMap = new HashMap(); 39 | resultMap.put("Info", list); 40 | return JsonResult.ok(resultMap); 41 | } 42 | 43 | @ApiOperation(value = "获得十条实训楼信息") 44 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query") 45 | @GetMapping("/getAllBuildingInfo") 46 | public JsonResult getAllBuildingInfo(String page) { 47 | if (StringUtils.isBlank(page)) { 48 | return JsonResult.errorMsg("传入当前页不能为空"); 49 | } 50 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 51 | List list = buildingService.searchAllBuilding(); 52 | 53 | Integer count = buildingService.getBuildingCount(); 54 | Map pageMap = PageUtils.pageHandler(page, count.toString()); 55 | 56 | Map resultMap = new HashMap(); 57 | resultMap.put("pageMap", pageMap); 58 | resultMap.put("Info", list); 59 | return JsonResult.ok(resultMap); 60 | } 61 | 62 | @ApiOperation(value = "通过实训楼ID获得实训楼信息") 63 | @ApiImplicitParams({ 64 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 65 | @ApiImplicitParam(name = "buildingId", value = "实训楼ID", required = true, dataType = "String", paramType = "query") 66 | 67 | }) 68 | @GetMapping("/getBuildingInfoById") 69 | public JsonResult getBuildingInfoById(String page, Integer buildingId) { 70 | if (StringUtils.isBlank(page)) { 71 | return JsonResult.errorMsg("传入当前页page参数不能为空"); 72 | } 73 | if (StringUtils.isBlank(buildingId.toString())) { 74 | return JsonResult.errorMsg("传入实训楼ID参数不能为空"); 75 | } 76 | 77 | Map pageMap = PageUtils.pageHandler(page, "1"); 78 | 79 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 80 | Building building = buildingService.searchBuildingById(buildingId); 81 | 82 | Map resultMap = new HashMap(); 83 | resultMap.put("pageMap", pageMap); 84 | resultMap.put("Info", building); 85 | 86 | return JsonResult.ok(resultMap); 87 | 88 | } 89 | 90 | @ApiOperation(value = "通过实训楼名称获得实训楼信息") 91 | @ApiImplicitParams({ 92 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 93 | @ApiImplicitParam(name = "buildingName", value = "实训楼名称", required = true, dataType = "String", paramType = "query") 94 | }) 95 | @GetMapping("/getBuildingInfoByName") 96 | public JsonResult getBuildingInfoByName(String page, String buildingName) { 97 | if (StringUtils.isBlank(page)) { 98 | return JsonResult.errorMsg("传入当前页page参数不能为空"); 99 | } 100 | if (StringUtils.isBlank(buildingName)) { 101 | return JsonResult.errorMsg("传入实训楼名称buildingName参数不能为空"); 102 | } 103 | 104 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 105 | List list = buildingService.searchBuildingByName(buildingName); 106 | 107 | Map pageMap = PageUtils.pageHandler(page, list.size() + ""); 108 | 109 | Map resultMap = new HashMap(); 110 | resultMap.put("pageMap", pageMap); 111 | resultMap.put("Info", list); 112 | 113 | return JsonResult.ok(resultMap); 114 | } 115 | 116 | @ApiOperation(value = "保存实训楼信息") 117 | @PostMapping("/saveBuildingInfo") 118 | public JsonResult saveBuildingInfo(@RequestBody Building building) { 119 | buildingService.savBuilding(building); 120 | return JsonResult.ok(); 121 | } 122 | 123 | @ApiOperation(value = "修改实训楼信息") 124 | @PostMapping("/updateBuildingInfo") 125 | public JsonResult updateBuildingInfo(@RequestBody Building building) { 126 | buildingService.updateBuilding(building); 127 | return JsonResult.ok(); 128 | } 129 | 130 | @ApiOperation("删除实训楼信息") 131 | @ApiImplicitParam(name = "buildingId", value = "实训楼ID", required = true, dataType = "String", paramType = "query") 132 | @GetMapping("/deleteBuildingInfo") 133 | public JsonResult deleteBuildingInfo(Integer buildingId) { 134 | buildingService.deleteBuilding(buildingId); 135 | return JsonResult.ok(); 136 | } 137 | } 138 | 139 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/utils/QRCodeUtils.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.utils; 2 | 3 | import com.github.hui.quick.plugin.qrcode.wrapper.QrCodeGenWrapper; 4 | import com.google.zxing.WriterException; 5 | import com.repairsystem.entity.Class; 6 | 7 | import javax.imageio.ImageIO; 8 | import java.awt.*; 9 | import java.awt.image.BufferedImage; 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.LinkedList; 15 | import java.util.List; 16 | import java.util.UUID; 17 | 18 | /** 19 | * @author CheungChingYin 20 | * @date 2018/11/18 21 | * @time 21:37 22 | */ 23 | public class QRCodeUtils { 24 | 25 | /** 26 | * @param domain 27 | * @param clazz 28 | * @param computerStartNum 29 | * @param computerEndNum 30 | * @return存储图片的文件夹地址 31 | */ 32 | public static String generateQRCode(String domain, Class clazz, Integer computerStartNum, Integer computerEndNum) { 33 | if (computerStartNum.equals(computerEndNum)) {//如果只生成一台电脑的二维码时(即开始编号和结束编号一致) 34 | BufferedImage bufferedImage = null; 35 | try { 36 | //调用第三方二维码生成工具,记录二维码信息 37 | bufferedImage = QrCodeGenWrapper.of("http://" + domain + "?buildingId=" + clazz.getBuildingId() + "&buildingName=" + clazz.getBuildingName() + "&classId=" + clazz.getClassId() + "&className=" + clazz.getClassName() + "&computerNum=" + computerStartNum) 38 | .setW(300) 39 | .setH(300) 40 | .asBufferedImage(); 41 | } catch (IOException e) { 42 | e.printStackTrace(); 43 | } catch (WriterException e) { 44 | e.printStackTrace(); 45 | } 46 | 47 | //新建画布,重画二维码 48 | BufferedImage picture = new BufferedImage(700, 300, BufferedImage.TYPE_INT_RGB); 49 | Graphics2D g = (Graphics2D) picture.getGraphics(); 50 | g.setColor(Color.WHITE); 51 | g.fillRect(0, 0, 700, 300); 52 | g.drawImage(bufferedImage, 0, 0, null); 53 | g.setColor(Color.BLACK); 54 | g.setFont(new Font("微软雅黑", Font.PLAIN, 20)); 55 | g.drawString("所在实训楼:" + clazz.getBuildingName(), 350, 50); 56 | g.drawString("所在实训室:" + clazz.getClassName(), 350, 100); 57 | g.drawString("电脑编号:" + computerStartNum, 350, 150); 58 | g.drawString("若当前电脑出现问题", 350, 200); 59 | g.drawString("请扫描左侧二维码进行报修", 350, 250); 60 | g.dispose(); 61 | 62 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 63 | String currentDate = simpleDateFormat.format(new Date()); 64 | 65 | //新建文件夹存储二维码图像,文件夹路径为"/opt/QRCode/当前日期年-月-日/UUID" 66 | String realPath = ConstantUtils.Path.DIRPATH + ConstantUtils.Path.QRCODEPATH + "/" + currentDate + "/" + UUID.randomUUID() + "/"; 67 | String fileName = clazz.getBuildingName() + "-" + clazz.getClassName() + "-" + computerStartNum + ".jpg"; 68 | 69 | File outPutFileDir = new File(realPath); 70 | if (!outPutFileDir.exists()) { 71 | outPutFileDir.mkdirs(); 72 | } 73 | 74 | File outPutFile = new File(realPath + fileName); 75 | try { 76 | ImageIO.write(picture, "jpg", outPutFile); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | return realPath; 81 | 82 | } else { 83 | BufferedImage bufferedImage = null; 84 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 85 | String currentDate = simpleDateFormat.format(new Date()); 86 | String realPath = ConstantUtils.Path.DIRPATH + ConstantUtils.Path.QRCODEPATH + "/" + currentDate + "/" + UUID.randomUUID() + "/"; 87 | 88 | File outPutFileDir = new File(realPath); 89 | if (!outPutFileDir.exists()) { 90 | outPutFileDir.mkdirs(); 91 | } 92 | 93 | for (int i = computerStartNum; i <= computerEndNum; i++) { 94 | 95 | try { 96 | bufferedImage = QrCodeGenWrapper.of("http://" + domain + "?buildingId=" + clazz.getBuildingId() + "&buildingName=" + clazz.getBuildingName() + "&classId=" + clazz.getClassId() + "&className=" + clazz.getClassName() + "&computerNum=" + i) 97 | .setW(300) 98 | .setH(300) 99 | .asBufferedImage(); 100 | BufferedImage picture = new BufferedImage(700, 300, BufferedImage.TYPE_INT_RGB); 101 | Graphics2D g = (Graphics2D) picture.getGraphics(); 102 | g.setColor(Color.WHITE); 103 | g.fillRect(0, 0, 700, 300); 104 | g.drawImage(bufferedImage, 0, 0, null); 105 | g.setColor(Color.BLACK); 106 | g.setFont(new Font("微软雅黑", Font.PLAIN, 20)); 107 | g.drawString("所在实训楼:" + clazz.getBuildingName(), 350, 50); 108 | g.drawString("所在实训室:" + clazz.getClassName(), 350, 100); 109 | g.drawString("电脑编号:" + i, 350, 150); 110 | g.drawString("若当前电脑出现问题", 350, 200); 111 | g.drawString("请扫描左侧二维码进行报修", 350, 250); 112 | g.dispose(); 113 | String fileName = clazz.getBuildingName() + "-" + clazz.getClassName() + "-" + i + ".jpg"; 114 | File outPutFile = new File(realPath + fileName); 115 | ImageIO.write(picture, "jpg", outPutFile); 116 | } catch (IOException e) { 117 | e.printStackTrace(); 118 | } catch (WriterException e) { 119 | e.printStackTrace(); 120 | } 121 | 122 | } 123 | return realPath; 124 | } 125 | } 126 | 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/web/controller/CompleteOrderController.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.web.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.repairsystem.entity.CompleteOrder; 5 | import com.repairsystem.entity.vo.CompleteOrderVO; 6 | import com.repairsystem.service.CompleteOrderService; 7 | import com.repairsystem.utils.ConstantUtils; 8 | import com.repairsystem.utils.Entity2VO; 9 | import com.repairsystem.utils.JsonResult; 10 | import com.repairsystem.utils.PageUtils; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiImplicitParam; 13 | import io.swagger.annotations.ApiImplicitParams; 14 | import io.swagger.annotations.ApiOperation; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.web.bind.annotation.*; 18 | 19 | import java.util.HashMap; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | /** 24 | * @author CheungChingYin 25 | * @date 2018/11/14 26 | * @time 16:35 27 | */ 28 | @RestController 29 | @Api(value = "完成维修工单相关接口", tags = {"完成维修工单业务相关接口"}) 30 | @RequestMapping("/completeOrders") 31 | public class CompleteOrderController { 32 | 33 | @Autowired 34 | private CompleteOrderService completeOrderService; 35 | 36 | @ApiOperation(value = "获得所有已完成的维修工单") 37 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query") 38 | @GetMapping("getAllCompleteOrderInfo") 39 | public JsonResult getAllCompleteOrderInfo(String page) { 40 | if (StringUtils.isBlank(page)) { 41 | return JsonResult.errorMsg("传入的当前页(page)不能为空"); 42 | } 43 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 44 | List listCompleteOrder = completeOrderService.searchAllCompleteOrder(); 45 | List listVO = Entity2VO.entityList2VOList(listCompleteOrder, CompleteOrderVO.class); 46 | Integer count = completeOrderService.getCompleteOrderCount(); 47 | Map pageMap = PageUtils.pageHandler(page, count.toString()); 48 | 49 | Map resultMap = new HashMap(); 50 | resultMap.put("pageMap", pageMap); 51 | resultMap.put("Info", listVO); 52 | return JsonResult.ok(resultMap); 53 | } 54 | 55 | @ApiOperation(value = "通过已完成维修工单ID获得工单信息") 56 | @ApiImplicitParams({ 57 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 58 | @ApiImplicitParam(name = "completeOrderId", value = "已完成维修工单ID", required = true, dataType = "String", paramType = "query") 59 | }) 60 | @GetMapping("getCompleteOrderInfoById") 61 | public JsonResult getCompleteOrderInfoById(String page, Integer completeOrderId) { 62 | if (StringUtils.isBlank(page)) { 63 | return JsonResult.errorMsg("传入的当前页(page)不能为空"); 64 | } 65 | if (StringUtils.isBlank(completeOrderId.toString())) { 66 | return JsonResult.errorMsg("传入的维修工单ID(orderId)不能为空"); 67 | } 68 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 69 | CompleteOrder completeOrder = completeOrderService.searchCompleteOrderById(completeOrderId); 70 | 71 | Map pageMap = PageUtils.pageHandler(page, "1"); 72 | Map resultMap = new HashMap(); 73 | resultMap.put("pageMap", pageMap); 74 | resultMap.put("Info", completeOrder); 75 | 76 | return JsonResult.ok(resultMap); 77 | } 78 | 79 | @ApiOperation(value = "通过关键词搜索已完成维修工单问题") 80 | @ApiImplicitParams({ 81 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 82 | @ApiImplicitParam(name = "keyWord", value = "搜索关键词", required = true, dataType = "String", paramType = "query") 83 | }) 84 | @GetMapping("getCompleteOrderInfoByKeyWord") 85 | public JsonResult getCompleteOrderInfoByKeyWord(String page, String keyWord) { 86 | if (StringUtils.isBlank(page)) { 87 | return JsonResult.errorMsg("传入的当前页(page)不能为空"); 88 | } 89 | if (StringUtils.isBlank(keyWord)) { 90 | return JsonResult.errorMsg("传入的查询关键字(keyWord)不能为空"); 91 | } 92 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 93 | List listCompleteOrder = completeOrderService.searchCompleteOrderByKeyWord(keyWord); 94 | List listVO = Entity2VO.entityList2VOList(listCompleteOrder, CompleteOrderVO.class); 95 | 96 | Map pageMap = PageUtils.pageHandler(page, listCompleteOrder.size() + ""); 97 | 98 | Map resultMap = new HashMap(); 99 | resultMap.put("pageMap", pageMap); 100 | resultMap.put("Info", listVO); 101 | return JsonResult.ok(resultMap); 102 | } 103 | 104 | @ApiOperation(value = "更新完成维修工单") 105 | @PostMapping("/updateCompleteOrder") 106 | public JsonResult updateCompleteOrder(@RequestBody CompleteOrder completeOrder) { 107 | if (StringUtils.isBlank(completeOrder.getOrderId().toString())) { 108 | JsonResult.errorMsg("传入的完成维修工单Id(orderId)不能为空"); 109 | } 110 | completeOrderService.updateCompleteOrder(completeOrder); 111 | return JsonResult.ok(); 112 | } 113 | 114 | @ApiOperation(value = "删除完成维修工单") 115 | @ApiImplicitParam(name = "completeOrderId", value = "已完成维修工单ID", required = true, dataType = "String", paramType = "query") 116 | @GetMapping("deleteCompleteOrder") 117 | public JsonResult deleteCompleteOrder(Integer completeOrderId) { 118 | if (StringUtils.isBlank(completeOrderId.toString())) { 119 | return JsonResult.errorMsg("传入的维修工单ID(orderId)不能为空"); 120 | } 121 | completeOrderService.deleteCompleteOrder(completeOrderId); 122 | return JsonResult.ok(); 123 | } 124 | 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/web/controller/ClassController.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.web.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException; 5 | import com.repairsystem.entity.Class; 6 | import com.repairsystem.entity.vo.ClassVO; 7 | import com.repairsystem.service.ClassService; 8 | import com.repairsystem.utils.ConstantUtils; 9 | import com.repairsystem.utils.Entity2VO; 10 | import com.repairsystem.utils.JsonResult; 11 | import com.repairsystem.utils.PageUtils; 12 | import io.swagger.annotations.Api; 13 | import io.swagger.annotations.ApiImplicitParam; 14 | import io.swagger.annotations.ApiImplicitParams; 15 | import io.swagger.annotations.ApiOperation; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.*; 19 | 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * @author CheungChingYin 26 | * @date 2018/11/12 27 | * @time 9:47 28 | */ 29 | @RestController 30 | @Api(value = "实训室业务相关接口", tags = {"实训室业务相关接口"}) 31 | @RequestMapping("/class") 32 | public class ClassController { 33 | 34 | @Autowired 35 | private ClassService classService; 36 | 37 | @ApiOperation(value = "获得所有实训室信息") 38 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query") 39 | @GetMapping("/getAllClassInfo") 40 | public JsonResult getAllClassInfo(String page) { 41 | if (StringUtils.isBlank(page)) { 42 | return JsonResult.errorMsg("传入当前页不能为空"); 43 | } 44 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 45 | List classList = classService.searchAllClass(); 46 | 47 | List voList = Entity2VO.entityList2VOList(classList, ClassVO.class); 48 | 49 | Integer count = classService.getClassCount(); 50 | Map pageMap = PageUtils.pageHandler(page, count.toString()); 51 | 52 | Map resultMap = new HashMap(); 53 | resultMap.put("pageMap", pageMap); 54 | resultMap.put("Info", voList); 55 | return JsonResult.ok(resultMap); 56 | 57 | } 58 | 59 | @ApiOperation(value = "通过实训室ID获得实训室信息") 60 | @ApiImplicitParams({ 61 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 62 | @ApiImplicitParam(name = "classId", value = "实训室ID", required = true, dataType = "String", paramType = "query") 63 | }) 64 | @GetMapping("/getClassInfoById") 65 | public JsonResult getClassInfoById(String page, Integer classId) { 66 | 67 | if (StringUtils.isBlank(page)) { 68 | return JsonResult.errorMsg("传入当前页不能为空"); 69 | } 70 | if (StringUtils.isBlank(classId.toString())) { 71 | return JsonResult.errorMsg("传入的实训室Id(classId)不能为空"); 72 | } 73 | 74 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 75 | Class clazz = classService.searchClassById(classId); 76 | 77 | Map pageMap = PageUtils.pageHandler(page, "1"); 78 | 79 | Map resultMap = new HashMap(); 80 | resultMap.put("pageMap", pageMap); 81 | resultMap.put("Info", clazz); 82 | 83 | return JsonResult.ok(resultMap); 84 | } 85 | 86 | @ApiOperation(value = "通过实训室名称获得实训室和信息") 87 | @ApiImplicitParams({ 88 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 89 | @ApiImplicitParam(name = "className", value = "实训室名称", required = true, dataType = "String", paramType = "query") 90 | }) 91 | @GetMapping("/getClassInfoByName") 92 | public JsonResult getClassInfoByName(String page, String className) { 93 | 94 | if (StringUtils.isBlank(page)) { 95 | return JsonResult.errorMsg("传入当前页不能为空"); 96 | } 97 | if (StringUtils.isBlank(className)) { 98 | return JsonResult.errorMsg("传入的实训室名称(className)不能为空"); 99 | } 100 | 101 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 102 | List listClass = classService.searchClassByName(className); 103 | List listVO = Entity2VO.entityList2VOList(listClass, ClassVO.class); 104 | 105 | Map pageMap = PageUtils.pageHandler(page, listVO.size() + ""); 106 | 107 | Map resultMap = new HashMap(); 108 | resultMap.put("pageMap", pageMap); 109 | resultMap.put("Info", listVO); 110 | 111 | return JsonResult.ok(resultMap); 112 | } 113 | 114 | @ApiOperation(value = "通过实训楼ID获得实训室信息") 115 | @ApiImplicitParam(name = "buildingId", value = "实训室ID", required = true, dataType = "String", paramType = "query") 116 | @GetMapping("/getClassInfoByBuildingId") 117 | public JsonResult getClassInfoByBuildingId(String buildingId) { 118 | if (StringUtils.isBlank(buildingId)) { 119 | return JsonResult.errorMsg("传入的实训楼Id不能为空!"); 120 | } 121 | List listClass = classService.searchClassByBuildingId(buildingId); 122 | List listVO = Entity2VO.entityList2VOList(listClass, ClassVO.class); 123 | 124 | Map resultMap = new HashMap(); 125 | resultMap.put("Info", listVO); 126 | return JsonResult.ok(resultMap); 127 | } 128 | 129 | @ApiOperation("保存班级信息") 130 | @PostMapping("/saveClassInfo") 131 | public JsonResult saveClassInfo(@RequestBody Class clazz) { 132 | classService.saveClass(clazz); 133 | return JsonResult.ok(); 134 | } 135 | 136 | @ApiOperation("修改班级信息") 137 | @PostMapping("/updateClassInfo") 138 | public JsonResult updateClassInfo(@RequestBody Class clazz) { 139 | if (StringUtils.isBlank(clazz.getClassId().toString())) { 140 | return JsonResult.errorMsg("传入的班级ID(classId)不能为空"); 141 | } 142 | classService.updateClass(clazz); 143 | return JsonResult.ok(); 144 | } 145 | 146 | @ApiOperation("删除班级信息") 147 | @ApiImplicitParam(name = "classId", value = "实训室ID", required = true, dataType = "String", paramType = "query") 148 | @GetMapping("/deleteClassInfo") 149 | public JsonResult deleteClassInfo(Integer classId) { 150 | if (StringUtils.isBlank(classId.toString())) { 151 | return JsonResult.errorMsg("传入的班级ID(classId)不能为空"); 152 | } 153 | try { 154 | classService.deleteClass(classId); 155 | } catch (MySQLIntegrityConstraintViolationException e) { 156 | return JsonResult.errorException("由于班级信息和工单绑定,请删除和当前班级相关工单后再进行删除"); 157 | } 158 | return JsonResult.ok(); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/CompleteOrder.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import io.swagger.annotations.Api; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | 8 | import javax.persistence.Column; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | import javax.persistence.Transient; 12 | import java.util.Date; 13 | @ApiModel(value = "完成工单对象",description = "这是完成工单对象") 14 | @Table(name = "complete_order") 15 | public class CompleteOrder { 16 | /** 17 | * 完成工单ID 18 | */ 19 | @Id 20 | @Column(name = "order_id") 21 | @ApiModelProperty(value = "完成工单ID",name = "orderId") 22 | private Integer orderId; 23 | 24 | /** 25 | * 管理员ID 26 | */ 27 | @Column(name = "admin_id") 28 | @ApiModelProperty(value = "管理员ID",name = "adminName",example = "1",required = true) 29 | private Integer adminId; 30 | 31 | /** 32 | * 管理员姓名 33 | */ 34 | @ApiModelProperty(hidden = true) 35 | private String adminName; 36 | 37 | /** 38 | * 完成时间 39 | */ 40 | @Column(name = "complete_time") 41 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 42 | @ApiModelProperty(hidden = true) 43 | private Date completeTime; 44 | 45 | /** 46 | * 故障图片 47 | */ 48 | @Column(name = "image_path") 49 | @ApiModelProperty(value = "上传图片路径") 50 | private String imagePath; 51 | 52 | /** 53 | * 工单问题 54 | */ 55 | @ApiModelProperty(value = "工单问题",name = "problem",example = "电脑出现问题",required = true) 56 | private String problem; 57 | 58 | /** 59 | * 记录 60 | */ 61 | @ApiModelProperty(value = "解决问题记录",name = "remark",example = "电脑解决问题") 62 | private String remark; 63 | 64 | /** 65 | * 所属教室ID 66 | */ 67 | @Column(name = "class_id") 68 | @ApiModelProperty(value = "实训室ID",name = "classId",example = "1",required = true) 69 | private Integer classId; 70 | 71 | /** 72 | * 所属实训室名称 73 | */ 74 | @ApiModelProperty(hidden = true) 75 | @Transient 76 | private String className; 77 | 78 | /** 79 | * 所属实训楼ID 80 | */ 81 | @Column(name = "building_id") 82 | @ApiModelProperty(value = "所属实训楼ID",name = "buildingId",example = "1",required = true) 83 | private Integer buildingId; 84 | 85 | /** 86 | * 所属实训楼名称 87 | */ 88 | @ApiModelProperty(hidden = true) 89 | @Transient 90 | private String buildingName; 91 | 92 | @Column(name = "computer_number") 93 | @ApiModelProperty(value = "出现问题的电脑编号", name = "computerNumber", example = "1", required = true) 94 | private Integer computerNumber; 95 | 96 | /** 97 | * 获取完成工单ID 98 | * 99 | * @return order_id - 完成工单ID 100 | */ 101 | public Integer getOrderId() { 102 | return orderId; 103 | } 104 | 105 | /** 106 | * 设置完成工单ID 107 | * 108 | * @param orderId 完成工单ID 109 | */ 110 | public void setOrderId(Integer orderId) { 111 | this.orderId = orderId; 112 | } 113 | 114 | /** 115 | * 获取管理员ID 116 | * 117 | * @return admin_id - 管理员ID 118 | */ 119 | public Integer getAdminId() { 120 | return adminId; 121 | } 122 | 123 | /** 124 | * 设置管理员ID 125 | * 126 | * @param adminId 管理员ID 127 | */ 128 | public void setAdminId(Integer adminId) { 129 | this.adminId = adminId; 130 | } 131 | 132 | /** 133 | * 获取管理员名称 134 | * @return 135 | */ 136 | public String getAdminName() { 137 | return adminName; 138 | } 139 | 140 | /** 141 | * 设置管理员名称 142 | * @param adminName 143 | */ 144 | public void setAdminName(String adminName) { 145 | this.adminName = adminName; 146 | } 147 | 148 | /** 149 | * 获取完成时间 150 | * 151 | * @return complete_time - 完成时间 152 | */ 153 | public Date getCompleteTime() { 154 | return completeTime; 155 | } 156 | 157 | /** 158 | * 设置完成时间 159 | * 160 | * @param completeTime 完成时间 161 | */ 162 | public void setCompleteTime(Date completeTime) { 163 | this.completeTime = completeTime; 164 | } 165 | 166 | /** 167 | * 获取故障图片 168 | * 169 | * @return image_path - 故障图片 170 | */ 171 | public String getImagePath() { 172 | return imagePath; 173 | } 174 | 175 | /** 176 | * 设置故障图片 177 | * 178 | * @param imagePath 故障图片 179 | */ 180 | public void setImagePath(String imagePath) { 181 | this.imagePath = imagePath; 182 | } 183 | 184 | /** 185 | * 获取工单问题 186 | * 187 | * @return problem - 工单问题 188 | */ 189 | public String getProblem() { 190 | return problem; 191 | } 192 | 193 | /** 194 | * 设置工单问题 195 | * 196 | * @param problem 工单问题 197 | */ 198 | public void setProblem(String problem) { 199 | this.problem = problem; 200 | } 201 | 202 | /** 203 | * 获取记录 204 | * 205 | * @return remark - 记录 206 | */ 207 | public String getRemark() { 208 | return remark; 209 | } 210 | 211 | /** 212 | * 设置记录 213 | * 214 | * @param remark 记录 215 | */ 216 | public void setRemark(String remark) { 217 | this.remark = remark; 218 | } 219 | 220 | public Integer getClassId() { 221 | return classId; 222 | } 223 | 224 | public void setClassId(Integer classId) { 225 | this.classId = classId; 226 | } 227 | 228 | public String getClassName() { 229 | return className; 230 | } 231 | 232 | public void setClassName(String className) { 233 | this.className = className; 234 | } 235 | 236 | public Integer getBuildingId() { 237 | return buildingId; 238 | } 239 | 240 | public void setBuildingId(Integer buildingId) { 241 | this.buildingId = buildingId; 242 | } 243 | 244 | public String getBuildingName() { 245 | return buildingName; 246 | } 247 | 248 | public void setBuildingName(String buildingName) { 249 | this.buildingName = buildingName; 250 | } 251 | 252 | /** 253 | * 获取电脑序号 254 | * 255 | * @return computer_number - 电脑序号 256 | */ 257 | public Integer getComputerNumber() { 258 | return computerNumber; 259 | } 260 | 261 | /** 262 | * 设置电脑序号 263 | * 264 | * @param computerNumber 电脑序号 265 | */ 266 | public void setComputerNumber(Integer computerNumber) { 267 | this.computerNumber = computerNumber; 268 | } 269 | 270 | @Override 271 | public String toString() { 272 | return "CompleteOrder{" + 273 | "orderId=" + orderId + 274 | ", adminId=" + adminId + 275 | ", adminName='" + adminName + '\'' + 276 | ", completeTime=" + completeTime + 277 | ", imagePath='" + imagePath + '\'' + 278 | ", problem='" + problem + '\'' + 279 | ", remark='" + remark + '\'' + 280 | ", classId=" + classId + 281 | ", className='" + className + '\'' + 282 | ", buildingId=" + buildingId + 283 | ", buildingName='" + buildingName + '\'' + 284 | ", computerNumber=" + computerNumber + 285 | '}'; 286 | } 287 | } 288 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.repairsystem 7 | repairsystem 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | repairsystem 12 | 基于SpringBoot的机房报修系统,实现前后端分离。 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.6.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | 30 | jitpack.io 31 | https://jitpack.io 32 | 33 | 34 | yihui-maven-repo 35 | https://raw.githubusercontent.com/liuyueyi/maven-repository/master/repository 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-aop 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-validation 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-starter-web 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-devtools 56 | true 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-mail 62 | 63 | 64 | 65 | 66 | 67 | org.mybatis.spring.boot 68 | mybatis-spring-boot-starter 69 | 1.3.2 70 | 71 | 72 | mysql 73 | mysql-connector-java 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-starter-data-redis 78 | 79 | 80 | 81 | 82 | tk.mybatis 83 | mapper-spring-boot-starter 84 | 1.2.4 85 | 86 | 87 | 88 | 89 | com.github.pagehelper 90 | pagehelper-spring-boot-starter 91 | 1.2.3 92 | 93 | 94 | 95 | 96 | com.alibaba 97 | druid 98 | 1.1.10 99 | 100 | 101 | 102 | com.alibaba 103 | druid-spring-boot-starter 104 | 1.1.9 105 | 106 | 107 | 108 | 109 | org.springframework.boot 110 | spring-boot-starter-tomcat 111 | provided 112 | 113 | 114 | 115 | 116 | org.springframework.boot 117 | spring-boot-starter-test 118 | test 119 | 120 | 121 | 122 | 123 | commons-codec 124 | commons-codec 125 | 1.11 126 | 127 | 128 | org.apache.commons 129 | commons-lang3 130 | 3.4 131 | 132 | 133 | org.apache.commons 134 | commons-io 135 | 1.3.2 136 | 137 | 138 | commons-beanutils 139 | commons-beanutils 140 | 1.9.4 141 | 142 | 143 | 144 | 145 | 146 | io.springfox 147 | springfox-swagger2 148 | 2.4.0 149 | 150 | 151 | io.springfox 152 | springfox-swagger-ui 153 | 2.4.0 154 | 155 | 156 | 157 | 158 | org.apache.shiro 159 | shiro-spring 160 | 1.7.1 161 | 162 | 163 | 164 | 165 | com.github.liuyueyi.quick-media 166 | qrcode-plugin 167 | 2.2 168 | 169 | 170 | 171 | 172 | net.lingala.zip4j 173 | zip4j 174 | 1.3.2 175 | 176 | 177 | 178 | org.springframework.boot 179 | spring-boot-starter-websocket 180 | 2.0.6.RELEASE 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | org.springframework.boot 189 | spring-boot-maven-plugin 190 | 191 | 192 | org.apache.maven.plugins 193 | maven-compiler-plugin 194 | 195 | 1.8 196 | 1.8 197 | 198 | D:/Program Files/Java/jdk1.8.0_172/jre/lib/rt.jar 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/web/controller/AdministratorController.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.web.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.repairsystem.entity.Administrator; 5 | import com.repairsystem.entity.vo.AdministratorVO; 6 | import com.repairsystem.exception.AdministratorIdIsNullException; 7 | import com.repairsystem.exception.PageIsNullException; 8 | import com.repairsystem.service.AdministratorService; 9 | import com.repairsystem.utils.*; 10 | import io.swagger.annotations.*; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.apache.shiro.SecurityUtils; 13 | import org.apache.shiro.authc.AccountException; 14 | import org.apache.shiro.authc.IncorrectCredentialsException; 15 | import org.apache.shiro.authc.UsernamePasswordToken; 16 | import org.apache.shiro.subject.Subject; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.*; 19 | 20 | import java.util.*; 21 | 22 | 23 | /** 24 | * @author CheungChingYin 25 | * @date 2018/11/5 26 | * @time 17:10 27 | */ 28 | @RestController 29 | @Api(value = "管理员业务相关接口", tags = {"管理员业务相关接口",}) 30 | @RequestMapping("/admin") 31 | public class AdministratorController { 32 | 33 | @Autowired 34 | private AdministratorService adminService; 35 | 36 | @ApiOperation(value = "管理员登录", notes = "管理员登录验证") 37 | @ApiImplicitParams({ 38 | @ApiImplicitParam(name = "adminPhoneNum", value = "管理员手机", required = true, dataType = "String", paramType = "query"), 39 | @ApiImplicitParam(name = "adminPassword", value = "管理员密码", required = true, dataType = "String", paramType = "query") 40 | 41 | }) 42 | @PostMapping("/login") 43 | public JsonResult login(String adminPhoneNum, String adminPassword) { 44 | if (StringUtils.isBlank(adminPhoneNum)) { 45 | return JsonResult.errorMsg("输入的管理员手机号不能为空"); 46 | } 47 | if (StringUtils.isBlank(adminPassword)) { 48 | return JsonResult.errorMsg("输入的管理员密码不能为空"); 49 | } 50 | adminPassword = PasswordEncryptionUtils.plainText2MD5Encrypt(adminPassword); 51 | //根据管理员手机号和密码创建token 52 | UsernamePasswordToken token = new UsernamePasswordToken(adminPhoneNum, adminPassword); 53 | Subject subject = SecurityUtils.getSubject(); 54 | try { 55 | subject.login(token); 56 | } catch (AccountException e) { 57 | return JsonResult.errorException(e.getMessage()); 58 | } catch (IncorrectCredentialsException e1) { 59 | return JsonResult.errorException(e1.getMessage()); 60 | } 61 | Administrator admin = adminService.searchAdministratorByPhoneNum(adminPhoneNum); 62 | AdministratorVO adminVO = Entity2VO.entity2VO(admin, AdministratorVO.class); 63 | Map resultMap = new HashMap(); 64 | resultMap.put("adminInfo", adminVO); 65 | return JsonResult.ok(resultMap); 66 | } 67 | 68 | @ApiOperation(value = "管理员登出") 69 | @PostMapping("/logout") 70 | public JsonResult logout() { 71 | return JsonResult.ok(); 72 | } 73 | 74 | @ApiOperation(value = "获得全部管理员资料") 75 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query") 76 | @GetMapping("/getAllAdminInfo") 77 | public JsonResult getAllAdminInfo(String page) { 78 | 79 | if (StringUtils.isBlank(page)) { 80 | throw new PageIsNullException(); 81 | } 82 | 83 | String count = adminService.countAllAdministrator(); 84 | 85 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 86 | List list = adminService.searchAllAdministrator(); 87 | 88 | Map pageMap = PageUtils.pageHandler(page, count); 89 | List listVO = Entity2VO.entityList2VOList(list, AdministratorVO.class); 90 | 91 | Map map = new HashMap(); 92 | map.put("pageMap", pageMap); 93 | map.put("Info", listVO); 94 | 95 | return JsonResult.ok(map); 96 | } 97 | 98 | @ApiOperation(value = "通过管理员ID获得管理员信息") 99 | @ApiImplicitParams({ 100 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 101 | @ApiImplicitParam(name = "id", value = "管理员ID", required = true, dataType = "String", paramType = "query") 102 | }) 103 | @GetMapping("/getAdminInfoById") 104 | public JsonResult getAdminInfoById(String page, Integer id) { 105 | if (StringUtils.isBlank(id.toString())) { 106 | throw new AdministratorIdIsNullException("传入的管理员ID为空"); 107 | } 108 | if (StringUtils.isBlank(page)) { 109 | throw new PageIsNullException(); 110 | } 111 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 112 | Administrator admin = adminService.searchAdministratorById(id); 113 | 114 | AdministratorVO adminVO = Entity2VO.entity2VO(admin, AdministratorVO.class); 115 | Map pageMap = PageUtils.pageHandler(page, "1"); 116 | Map map = new HashMap(); 117 | map.put("pageMap", pageMap); 118 | map.put("Info", adminVO); 119 | return JsonResult.ok(map); 120 | } 121 | 122 | @ApiOperation(value = "通过管理员名称获得管理员信息") 123 | @ApiImplicitParams({ 124 | @ApiImplicitParam(name = "page", value = "当前页", required = true, dataType = "String", paramType = "query"), 125 | @ApiImplicitParam(name = "adminName", value = "实训楼ID", required = true, dataType = "String", paramType = "query") 126 | }) 127 | @GetMapping("/getAdminInfoByName") 128 | public JsonResult getAdminInfoByName(String page, String adminName) { 129 | if (StringUtils.isBlank(page)) { 130 | return JsonResult.errorMsg("传入当前页page参数不能为空"); 131 | } 132 | if (StringUtils.isBlank(adminName)) { 133 | return JsonResult.errorMsg("传入管理员名称adminName参数不能为空"); 134 | } 135 | PageHelper.startPage(Integer.parseInt(page), ConstantUtils.Page.PAGESIZE); 136 | List adminList = adminService.searchAdministratorByName(adminName); 137 | 138 | Map pageMap = PageUtils.pageHandler(page, adminList.size() + ""); 139 | List listVO = Entity2VO.entityList2VOList(adminList, AdministratorVO.class); 140 | 141 | Map map = new HashMap(); 142 | map.put("pageMap", pageMap); 143 | map.put("Info", listVO); 144 | return JsonResult.ok(map); 145 | 146 | } 147 | 148 | @ApiOperation(value = "保存管理员信息") 149 | @PostMapping("/saveAdministratorInfo") 150 | public JsonResult saveAdministratorInfo(@RequestBody Administrator admin) { 151 | adminService.saveAdministrator(admin); 152 | return JsonResult.ok(); 153 | } 154 | 155 | @ApiOperation(value = "修改管理员信息") 156 | @PostMapping("updateAdministratorInfo") 157 | public JsonResult updateAdministratorInfo(@RequestBody Administrator admin) { 158 | if (StringUtils.isBlank(admin.getAdminId().toString())) { 159 | return JsonResult.errorMsg("更新失败,传入的管理员ID不能为空"); 160 | } 161 | if (StringUtils.isNotBlank(admin.getAdminPassword())) { 162 | String password = admin.getAdminPassword(); 163 | admin.setAdminPassword(PasswordEncryptionUtils.plainText2MD5Encrypt(password)); 164 | } 165 | adminService.updateAdministrator(admin); 166 | return JsonResult.ok(); 167 | } 168 | 169 | @ApiOperation(value = "删除管理员信息") 170 | @GetMapping("deleteAdministratorInfo") 171 | @ApiImplicitParam(name = "adminId", value = "管理员ID", required = true, dataType = "String", paramType = "query") 172 | public JsonResult deleteAdministratorInfo(Integer adminId) { 173 | if (StringUtils.isBlank(adminId.toString())) { 174 | return JsonResult.errorMsg("删除失败,传入的管理员ID不能为空"); 175 | } 176 | adminService.deleteAdministrator(adminId); 177 | return JsonResult.ok(); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/config/shiro/ShiroConfig.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.config.shiro; 2 | 3 | import com.repairsystem.utils.ConstantUtils; 4 | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; 5 | import org.apache.shiro.codec.Base64; 6 | import org.apache.shiro.mgt.SecurityManager; 7 | import org.apache.shiro.spring.LifecycleBeanPostProcessor; 8 | import org.apache.shiro.spring.web.ShiroFilterFactoryBean; 9 | import org.apache.shiro.web.mgt.CookieRememberMeManager; 10 | import org.apache.shiro.web.mgt.DefaultWebSecurityManager; 11 | import org.apache.shiro.web.servlet.SimpleCookie; 12 | import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.beans.factory.annotation.Qualifier; 16 | import org.springframework.context.annotation.Bean; 17 | import org.springframework.context.annotation.Configuration; 18 | import org.springframework.context.annotation.DependsOn; 19 | import org.springframework.data.redis.core.RedisTemplate; 20 | 21 | import javax.servlet.Filter; 22 | import java.util.LinkedHashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | * @author CheungChingYin 27 | * @date 2018/11/5 28 | * @time 14:20 29 | */ 30 | @Configuration 31 | public class ShiroConfig { 32 | 33 | private static final Logger LOGGER = LoggerFactory.getLogger(ShiroConfig.class); 34 | 35 | /** 36 | * shiro管理生命周期的东西 37 | * 38 | * @return 39 | */ 40 | @Bean(name = "lifecycleBeanPostProcessor") 41 | public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { 42 | return new LifecycleBeanPostProcessor(); 43 | } 44 | 45 | @Bean(name = "shiroFilter") 46 | public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager, RedisTemplate redisTemplate) { 47 | //定义shiroFilterFactoryBean 48 | ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); 49 | 50 | //设置自定义的 securityManager 51 | shiroFilterFactoryBean.setSecurityManager(securityManager); 52 | 53 | // 设置默认登录的 URL,身份认证失败会访问该 URL;配置拦截需要user/authc身份的跳转路径。 54 | shiroFilterFactoryBean.setLoginUrl("/login"); 55 | // 设置成功之后要跳转的链接 56 | shiroFilterFactoryBean.setSuccessUrl("/main"); 57 | // 设置未授权界面,权限认证失败会访问该 URL 58 | shiroFilterFactoryBean.setUnauthorizedUrl("/unauthorized"); 59 | 60 | Map filters = new LinkedHashMap(); 61 | filters.put("logout", new MySignOutFilter(redisTemplate)); 62 | shiroFilterFactoryBean.setFilters(filters); 63 | 64 | // LinkedHashMap 是有序的,进行顺序拦截器配置 65 | Map filterChainMap = new LinkedHashMap(); 66 | 67 | // TODO 配置可以匿名访问的地址,可以根据实际情况自己添加,放行一些静态资源等,anon 表示放行 68 | filterChainMap.put("/css/**", "anon"); 69 | filterChainMap.put("/imgs/**", "anon"); 70 | filterChainMap.put("/js/**", "anon"); 71 | filterChainMap.put("/swagger-ui.html", "anon"); 72 | filterChainMap.put("/swagger-*/**", "anon"); 73 | filterChainMap.put("/swagger-ui.html/**", "anon"); 74 | // 登录 URL 放行 75 | filterChainMap.put("/admin/login", "anon"); 76 | filterChainMap.put("/login", "anon"); 77 | filterChainMap.put("/orders/saveOrders", "anon"); 78 | filterChainMap.put("/orders/uploadImage", "anon"); 79 | 80 | //需要认证的接口 81 | filterChainMap.put("/building/**", "authc"); 82 | filterChainMap.put("/class/**", "authc"); 83 | filterChainMap.put("/completeOrders/**", "authc"); 84 | filterChainMap.put("/orders/**", "authc"); 85 | filterChainMap.put("/QRCode/**", "authc"); 86 | // webSocket接口 87 | filterChainMap.put("/endpointOne/**", "authc"); 88 | // 配置 logout 过滤器 89 | filterChainMap.put("/admin/logout", "logout"); 90 | //管理员接口只有超级管理员才能使用 91 | filterChainMap.put("/admin/**", "authc,roles[超级管理员]"); 92 | 93 | shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainMap); 94 | 95 | LOGGER.info("====shiroFilterFactoryBean注册完成===="); 96 | return shiroFilterFactoryBean; 97 | 98 | } 99 | 100 | 101 | /** 102 | * 注入自定义Realm 103 | * 104 | * @return 105 | */ 106 | @Bean(name = "myShiroRealm") 107 | public MyShiroRealm getAdminRealm() { 108 | MyShiroRealm adminRealm = new MyShiroRealm(); 109 | LOGGER.info("====AdminRealm注册完成====="); 110 | return adminRealm; 111 | } 112 | 113 | /** 114 | * 注入安全管理器 115 | * 116 | * @return 117 | */ 118 | @Bean(name = "securityManager") 119 | public SecurityManager getSecurityManager(@Qualifier("myShiroRealm") MyShiroRealm adminRealm, RedisTemplate redisTemplate) { 120 | DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); 121 | securityManager.setRealm(adminRealm); 122 | //自定义session管理 使用redis 123 | securityManager.setSessionManager(sessionManager(redisTemplate)); 124 | //注入记住我管理器; 125 | securityManager.setRememberMeManager(rememberMeManager()); 126 | LOGGER.info("====securityManager注册完成===="); 127 | return securityManager; 128 | } 129 | 130 | @Bean(name = "myShiroRealm") 131 | @DependsOn(value = {"lifecycleBeanPostProcessor", "ShiroRedisCacheManager"}) 132 | public MyShiroRealm myShiroRealm(RedisTemplate redisTemplate) { 133 | MyShiroRealm shiroRealm = new MyShiroRealm(); 134 | shiroRealm.setCacheManager(redisCacheManager(redisTemplate)); 135 | shiroRealm.setCachingEnabled(true); 136 | //设置认证密码算法及迭代复杂度 137 | // shiroRealm.setCredentialsMatcher(credentialsMatcher()); 138 | //认证 139 | shiroRealm.setAuthenticationCachingEnabled(false); 140 | //授权 141 | shiroRealm.setAuthorizationCachingEnabled(false); 142 | return shiroRealm; 143 | } 144 | 145 | /** 146 | * realm的认证算法 147 | * 148 | * @return 149 | */ 150 | @Bean(name = "hashedCredentialsMatcher") 151 | public HashedCredentialsMatcher credentialsMatcher() { 152 | HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher("md5"); 153 | //迭代次数 154 | credentialsMatcher.setHashIterations(2); 155 | credentialsMatcher.setStoredCredentialsHexEncoded(true); 156 | return credentialsMatcher; 157 | } 158 | 159 | /** 160 | * 缓存管理器的配置 161 | * 162 | * @param redisTemplate 163 | * @return 164 | */ 165 | @Bean(name = "ShiroRedisCacheManager") 166 | public ShiroRedisCacheManager redisCacheManager(RedisTemplate redisTemplate) { 167 | ShiroRedisCacheManager redisCacheManager = new ShiroRedisCacheManager(redisTemplate); 168 | //name是key的前缀,可以设置任何值,无影响,可以设置带项目特色的值 169 | redisCacheManager.createCache("shiro_redis"); 170 | return redisCacheManager; 171 | } 172 | 173 | /** 174 | * 配置sessionmanager,由redis存储数据 175 | */ 176 | @Bean(name = "sessionManager") 177 | @DependsOn(value = "lifecycleBeanPostProcessor") 178 | public DefaultWebSessionManager sessionManager(RedisTemplate redisTemplate) { 179 | DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); 180 | MyRedisSessionDao redisSessionDao = new MyRedisSessionDao(redisTemplate); 181 | //这个name的作用也不大,只是有特色的cookie的名称。 182 | redisSessionDao.setSessionIdGenerator(sessionIdGenerator("starrkCookie")); 183 | sessionManager.setSessionDAO(redisSessionDao); 184 | sessionManager.setDeleteInvalidSessions(true); 185 | SimpleCookie cookie = new SimpleCookie(); 186 | cookie.setName("starrkCookie"); 187 | sessionManager.setSessionIdCookie(cookie); 188 | sessionManager.setSessionIdCookieEnabled(true); 189 | return sessionManager; 190 | } 191 | 192 | /** 193 | * 自定义的SessionId生成器 194 | * 195 | * @param name 196 | * @return 197 | */ 198 | public MySessionIdGenerator sessionIdGenerator(String name) { 199 | return new MySessionIdGenerator(name); 200 | } 201 | 202 | /** 203 | * 这个参数是RememberMecookie的名称,随便起。 204 | * remenberMeCookie是一个实现了将用户名保存在客户端的一个cookie,与登陆时的cookie是两个simpleCookie。 205 | * 登陆时会根据权限去匹配,如是user权限,则不会先去认证模块认证,而是先去搜索cookie中是否有rememberMeCookie, 206 | * 如果存在该cookie,则可以绕过认证模块,直接寻找授权模块获取角色权限信息。 207 | * 如果权限是authc,则仍会跳转到登陆页面去进行登陆认证. 208 | * 209 | * @return 210 | */ 211 | public SimpleCookie rememberMeCookie() { 212 | SimpleCookie simpleCookie = new SimpleCookie("remenbermeCookie"); 213 | // 214 | simpleCookie.setMaxAge(ConstantUtils.Cookie.COOKIE_MAX_TIME); 215 | return simpleCookie; 216 | } 217 | 218 | /** 219 | * cookie管理对象;记住我功能 220 | */ 221 | public CookieRememberMeManager rememberMeManager() { 222 | CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); 223 | cookieRememberMeManager.setCookie(rememberMeCookie()); 224 | //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位) 225 | cookieRememberMeManager.setCipherKey(Base64.decode("3AvVhmFLUs0KTA3Kprsdag==")); 226 | return cookieRememberMeManager; 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /src/main/java/com/repairsystem/entity/Orders.java: -------------------------------------------------------------------------------- 1 | package com.repairsystem.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Id; 8 | import javax.persistence.Transient; 9 | import java.util.Date; 10 | 11 | public class Orders { 12 | /** 13 | * 工单ID 14 | */ 15 | @Id 16 | @Column(name = "order_id") 17 | @ApiModelProperty(value = "维修工单ID", name = "orderId", required = true) 18 | private Integer orderId; 19 | 20 | /** 21 | * 电脑序号 22 | */ 23 | @Column(name = "computer_number") 24 | @ApiModelProperty(value = "出现问题的电脑编号", name = "computerNumber", example = "1", required = true) 25 | private Integer computerNumber; 26 | 27 | /** 28 | * 所属教室ID 29 | */ 30 | @Column(name = "class_id") 31 | @ApiModelProperty(value = "所属实训室ID", name = "classId", example = "1", required = true) 32 | private Integer classId; 33 | 34 | /** 35 | * 所属实训室名称 36 | */ 37 | @ApiModelProperty(hidden = true) 38 | @Transient 39 | private String className; 40 | 41 | /** 42 | * 所属实训楼ID 43 | */ 44 | @Column(name = "building_id") 45 | @ApiModelProperty(value = "所属实训楼ID",name = "buildingId",example = "1",required = true) 46 | private Integer buildingId; 47 | 48 | /** 49 | * 所属实训楼名称 50 | */ 51 | @ApiModelProperty(hidden = true) 52 | @Transient 53 | private String buildingName; 54 | 55 | /** 56 | * 维修状态 57 | */ 58 | @ApiModelProperty(value = "维修状态",name = "status",example = "0",required = true) 59 | private Integer status; 60 | 61 | /** 62 | * 提交时间 63 | */ 64 | @Column(name = "submit_time") 65 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 66 | @ApiModelProperty(hidden = true) 67 | private Date submitTime; 68 | 69 | 70 | /** 71 | * 故障图片上传 72 | */ 73 | @Column(name = "images_path") 74 | @ApiModelProperty(value = "故障图片",name = "imagesPath") 75 | private String imagesPath; 76 | 77 | /** 78 | * 接手管理员ID 79 | */ 80 | @Column(name = "admin_id") 81 | @ApiModelProperty(value = "经手管理员ID",name = "adminId",example = "1",required = true) 82 | private Integer adminId; 83 | 84 | /** 85 | * 接收管理员名称 86 | */ 87 | @ApiModelProperty(hidden = true) 88 | private String adminName; 89 | 90 | /** 91 | * 报修人名称 92 | */ 93 | @ApiModelProperty(value = "报修人名称",name = "userName",example = "王翠花",required = true) 94 | @Column(name = "user_name") 95 | private String userName; 96 | 97 | /** 98 | * 报修人电话 99 | */ 100 | @ApiModelProperty(value = "报修人电话号码" ,name = "userPhone",example = "13525874610",required = true) 101 | @Column(name = "user_phone") 102 | private String userPhone; 103 | 104 | /** 105 | * 报修人邮箱 106 | */ 107 | @Column(name = "user_email") 108 | @ApiModelProperty(value = "报修人邮箱",name = "userEmail",example = "user@abc.com",required = true) 109 | private String userEmail; 110 | 111 | /** 112 | * 工单问题 113 | */ 114 | @ApiModelProperty(value = "维修工单问题",name = "problem",example = "电脑出现问题",required = true) 115 | private String problem; 116 | 117 | /** 118 | * 获取工单ID 119 | * 120 | * @return order_id - 工单ID 121 | */ 122 | public Integer getOrderId() { 123 | return orderId; 124 | } 125 | 126 | /** 127 | * 设置工单ID 128 | * 129 | * @param orderId 工单ID 130 | */ 131 | public void setOrderId(Integer orderId) { 132 | this.orderId = orderId; 133 | } 134 | 135 | /** 136 | * 获取电脑序号 137 | * 138 | * @return computer_number - 电脑序号 139 | */ 140 | public Integer getComputerNumber() { 141 | return computerNumber; 142 | } 143 | 144 | /** 145 | * 设置电脑序号 146 | * 147 | * @param computerNumber 电脑序号 148 | */ 149 | public void setComputerNumber(Integer computerNumber) { 150 | this.computerNumber = computerNumber; 151 | } 152 | 153 | /** 154 | * 获取所属教室ID 155 | * 156 | * @return class_id - 所属教室ID 157 | */ 158 | public Integer getClassId() { 159 | return classId; 160 | } 161 | 162 | /** 163 | * 设置所属教室ID 164 | * 165 | * @param classId 所属教室ID 166 | */ 167 | public void setClassId(Integer classId) { 168 | this.classId = classId; 169 | } 170 | 171 | /** 172 | * 获得所属实训室名称 173 | * 174 | * @return 175 | */ 176 | public String getClassName() { 177 | return className; 178 | } 179 | 180 | /** 181 | * 设置所属实训室名称 182 | * 183 | * @param className 184 | */ 185 | public void setClassName(String className) { 186 | this.className = className; 187 | } 188 | 189 | /** 190 | * 获取所属实训楼ID 191 | * 192 | * @return building_id - 所属实训楼ID 193 | */ 194 | public Integer getBuildingId() { 195 | return buildingId; 196 | } 197 | 198 | /** 199 | * 设置所属实训楼ID 200 | * 201 | * @param buildingId 所属实训楼ID 202 | */ 203 | public void setBuildingId(Integer buildingId) { 204 | this.buildingId = buildingId; 205 | } 206 | 207 | /** 208 | * 获得所属实训楼名称 209 | * 210 | * @return 211 | */ 212 | public String getBuildingName() { 213 | return buildingName; 214 | } 215 | 216 | /** 217 | * 设置所属实训楼名称 218 | * 219 | * @param buildingName 220 | */ 221 | public void setBuildingName(String buildingName) { 222 | this.buildingName = buildingName; 223 | } 224 | 225 | /** 226 | * 获取状态 227 | * 228 | * @return status - 状态 229 | */ 230 | public Integer getStatus() { 231 | return status; 232 | } 233 | 234 | /** 235 | * 设置状态 236 | * 237 | * @param status 状态 238 | */ 239 | public void setStatus(Integer status) { 240 | this.status = status; 241 | } 242 | 243 | /** 244 | * 获取提交时间 245 | * 246 | * @return submit_time - 提交时间 247 | */ 248 | public Date getSubmitTime() { 249 | return submitTime; 250 | } 251 | 252 | /** 253 | * 设置提交时间 254 | * 255 | * @param submitTime 提交时间 256 | */ 257 | public void setSubmitTime(Date submitTime) { 258 | this.submitTime = submitTime; 259 | } 260 | 261 | /** 262 | * 获取故障图片上传 263 | * 264 | * @return images_path - 故障图片上传 265 | */ 266 | public String getImagesPath() { 267 | return imagesPath; 268 | } 269 | 270 | /** 271 | * 设置故障图片上传 272 | * 273 | * @param imagesPath 故障图片上传 274 | */ 275 | public void setImagesPath(String imagesPath) { 276 | this.imagesPath = imagesPath; 277 | } 278 | 279 | /** 280 | * 获取接手管理员ID 281 | * 282 | * @return admin_id - 接手管理员ID 283 | */ 284 | public Integer getAdminId() { 285 | return adminId; 286 | } 287 | 288 | /** 289 | * 设置接手管理员ID 290 | * 291 | * @param adminId 接手管理员ID 292 | */ 293 | public void setAdminId(Integer adminId) { 294 | this.adminId = adminId; 295 | } 296 | 297 | /** 298 | * 获得接收管理员名称 299 | * 300 | * @return adminName 301 | */ 302 | public String getAdminName() { 303 | return adminName; 304 | } 305 | 306 | /** 307 | * 设置接手管理员名称 308 | * 309 | * @param adminName 310 | */ 311 | public void setAdminName(String adminName) { 312 | this.adminName = adminName; 313 | } 314 | 315 | /** 316 | * 获取报修人名称 317 | * 318 | * @return user_name - 报修人名称 319 | */ 320 | public String getUserName() { 321 | return userName; 322 | } 323 | 324 | /** 325 | * 设置报修人名称 326 | * 327 | * @param userName 报修人名称 328 | */ 329 | public void setUserName(String userName) { 330 | this.userName = userName; 331 | } 332 | 333 | /** 334 | * 获取报修人电话 335 | * 336 | * @return user_phone - 报修人电话 337 | */ 338 | public String getUserPhone() { 339 | return userPhone; 340 | } 341 | 342 | /** 343 | * 设置报修人电话 344 | * 345 | * @param userPhone 报修人电话 346 | */ 347 | public void setUserPhone(String userPhone) { 348 | this.userPhone = userPhone; 349 | } 350 | 351 | /** 352 | * 获取报修人邮箱 353 | * 354 | * @return user_email - 报修人邮箱 355 | */ 356 | public String getUserEmail() { 357 | return userEmail; 358 | } 359 | 360 | /** 361 | * 设置报修人邮箱 362 | * 363 | * @param userEmail 报修人邮箱 364 | */ 365 | public void setUserEmail(String userEmail) { 366 | this.userEmail = userEmail; 367 | } 368 | 369 | /** 370 | * 获取工单问题 371 | * 372 | * @return problem - 工单问题 373 | */ 374 | public String getProblem() { 375 | return problem; 376 | } 377 | 378 | /** 379 | * 设置工单问题 380 | * 381 | * @param problem 工单问题 382 | */ 383 | public void setProblem(String problem) { 384 | this.problem = problem; 385 | } 386 | 387 | @Override 388 | public String toString() { 389 | return "Orders{" + 390 | "orderId=" + orderId + 391 | ", computerNumber=" + computerNumber + 392 | ", classId=" + classId + 393 | ", className='" + className + '\'' + 394 | ", buildingId=" + buildingId + 395 | ", buildingName='" + buildingName + '\'' + 396 | ", status=" + status + 397 | ", submitTime=" + submitTime + 398 | ", imagesPath='" + imagesPath + '\'' + 399 | ", adminId=" + adminId + 400 | ", adminName='" + adminName + '\'' + 401 | ", userName='" + userName + '\'' + 402 | ", userPhone='" + userPhone + '\'' + 403 | ", userEmail='" + userEmail + '\'' + 404 | ", problem='" + problem + '\'' + 405 | '}'; 406 | } 407 | } 408 | --------------------------------------------------------------------------------