├── .gitignore ├── ReadMe.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main ├── java │ └── com │ │ └── fzy │ │ └── pms │ │ ├── PmsApplication.java │ │ ├── cache │ │ └── TokenCache.java │ │ ├── dao │ │ ├── AccountDetailRepository.java │ │ ├── CostSettingRepository.java │ │ ├── DoorRepository.java │ │ ├── HouseRepository.java │ │ ├── MenuRepository.java │ │ ├── ParkRepository.java │ │ ├── RepairsRepository.java │ │ ├── RoleRepository.java │ │ ├── SettleRepository.java │ │ └── UserRepository.java │ │ ├── entity │ │ ├── dto │ │ │ ├── AccountDetailDto.java │ │ │ ├── AccountDto.java │ │ │ ├── DoorDto.java │ │ │ ├── MenuDto.java │ │ │ ├── ParkDto.java │ │ │ ├── RepairsDto.java │ │ │ ├── RepairsReportDto.java │ │ │ ├── RoleDto.java │ │ │ ├── SettleDto.java │ │ │ └── UserDto.java │ │ ├── enums │ │ │ ├── Constants.java │ │ │ ├── DoorType.java │ │ │ ├── ParkType.java │ │ │ ├── RechargeType.java │ │ │ ├── RepairsStatus.java │ │ │ ├── RestCode.java │ │ │ ├── Storey.java │ │ │ └── UseStatus.java │ │ ├── mapper │ │ │ ├── EntityMapper.java │ │ │ ├── MenuMapper.java │ │ │ ├── RoleMapper.java │ │ │ └── UserMapper.java │ │ ├── pms │ │ │ ├── AccountDetail.java │ │ │ ├── CostSetting.java │ │ │ ├── Door.java │ │ │ ├── House.java │ │ │ ├── Park.java │ │ │ ├── Repairs.java │ │ │ └── Settle.java │ │ ├── rest │ │ │ └── Result.java │ │ ├── security │ │ │ ├── Base.java │ │ │ ├── JwtToken.java │ │ │ ├── Menu.java │ │ │ ├── Role.java │ │ │ └── User.java │ │ └── vo │ │ │ ├── RepairVo.java │ │ │ └── UserVo.java │ │ ├── exception │ │ ├── BaseException.java │ │ ├── ExceptionProcessor.java │ │ └── SystemErrorException.java │ │ ├── service │ │ ├── AccountService.java │ │ ├── BaseService.java │ │ ├── BuckerService.java │ │ ├── CostSettingService.java │ │ ├── DoorService.java │ │ ├── DownloadFileService.java │ │ ├── FileManageService.java │ │ ├── HouseService.java │ │ ├── MenuService.java │ │ ├── ParkService.java │ │ ├── RepairsService.java │ │ ├── RoleService.java │ │ ├── SettleService.java │ │ ├── UploadFileService.java │ │ ├── UserService.java │ │ ├── impl │ │ │ ├── AccountServiceImpl.java │ │ │ ├── CostSettingServiceImpl.java │ │ │ ├── DoorServiceImpl.java │ │ │ ├── FileServiceImpl.java │ │ │ ├── HouseServiceImpl.java │ │ │ ├── MenuServiceImpl.java │ │ │ ├── ParkServiceImpl.java │ │ │ ├── RepairsServiceImpl.java │ │ │ ├── RoleServiceImpl.java │ │ │ ├── SettleServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ └── job │ │ │ └── HelloWordJob.java │ │ ├── utils │ │ ├── CalculatorUnit.java │ │ ├── JwtTokenUtil.java │ │ └── ResponseUtil.java │ │ └── web │ │ ├── config │ │ ├── InterceptorConfig.java │ │ ├── QuartzConfig.java │ │ ├── TimeInterceptor.java │ │ ├── redis │ │ │ └── RedisConfig.java │ │ ├── security │ │ │ ├── JwtTokenFilter.java │ │ │ ├── LoginUrlAuthentication.java │ │ │ ├── LogoutSuccessHandler.java │ │ │ ├── RestAccessDeniedHandler.java │ │ │ ├── SecurityFailureHandler.java │ │ │ ├── SecuritySuccessHandler.java │ │ │ └── WebSecurityConfig.java │ │ └── swagger │ │ │ └── SwaggerConfig.java │ │ └── controller │ │ ├── AccountController.java │ │ ├── AuthController.java │ │ ├── CostSettingController.java │ │ ├── DoorController.java │ │ ├── DownloadController.java │ │ ├── HouseController.java │ │ ├── MenuController.java │ │ ├── ParkController.java │ │ ├── RepairsController.java │ │ ├── RoleController.java │ │ ├── SettleController.java │ │ ├── UploadController.java │ │ └── UserController.java └── resources │ ├── application.yml │ ├── banner.txt │ └── logback-test.xml └── test └── java └── com └── fzy └── pms ├── DoorTest.java ├── JwtTokenTest.java ├── MenuTest.java ├── RedisTest.java ├── RoleTest.java └── UserPwdTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | /build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | /out/ 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # 物业管理系统 2 | 3 | 基于前后端分离开发
4 | 1. 前端地址:https://github.com/zy88866/pms-front 5 | 2. 后端地址:https://github.com/zy88866/pms 6 | 7 | 8 | ## 前端技术栈 9 | 1. vue cli + elementUI + Vuex 10 | 11 | 12 | ## 后端技术栈 13 | 1. springBoot+springSecurity+JPA+Redis 14 | 15 | 16 | ## 初始化脚本 17 | 使用JPA,项目启动自动创建表 18 | 19 | ```sql 20 | INSERT INTO t_role(`id`, `create_time`, `delete_flag`, `update_time`, `name`, `remark`) VALUES (1, '2019-04-05 14:14:45', 0, '2019-04-05 14:14:45', '超级管理员', '权限最大,不建议分配,~~~'); 21 | INSERT INTO t_role(`id`, `create_time`, `delete_flag`, `update_time`, `name`, `remark`) VALUES (2, '2019-04-05 14:15:45', 0, '2019-04-05 14:15:45', '业主', '缴费,保修等功能'); 22 | -- 用户名:admin 密码:admin 23 | INSERT INTO t_user(`id`, `create_time`, `delete_flag`, `update_time`, `email`, `password`, `phone`, `real_name`, `username`, `role_id`, `balance`, `use_status`) 24 | VALUES ('1', '2019-03-23 19:55:36', '0', '2019-05-23 08:22:06', '1010101010@qq.com', '$2a$10$APNEPFSMvKglR0xTN8KijegsOQ9iHggiq63uW.40EX3T7XDnGAEdm', '18788779966', '物业总部', 'admin', '1', '0.00', 'ENABLED'); 25 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (100,now(),0,now(),'Layout' ,'pms-icon-xitongguanli' ,'系统管理','/sysSteam',0 ); 26 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (101,now(),0,now(),'Sys/User' ,'pms-icon-userguanli' ,'用户管理','/sysSteam/user',100 ); 27 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (102,now(),0,now(),'Sys/Role' ,'pms-icon-jiaoseguanli' ,'角色管理','/sysSteam/role',100 ); 28 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (200,now(),0,now(),'Layout' ,'pms-icon-shoufeiguanli' ,'收费管理','/cost',0 ); 29 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (201,now(),0,now(),'Cost/Set' ,'pms-icon-feiyongshezhi' ,'费用设置','/cost/setting',200 ); 30 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (202,now(),0,now(),'Cost/Recharge' ,'pms-icon-chongczhi' ,'充值缴费','/cost/recharge',200 ); 31 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (203,now(),0,now(),'Cost/Settle' ,'pms-icon-jiesuan' ,'费用结算','/cost/settle',200 ); 32 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (300,now(),0,now(),'Layout' ,'pms-icon-ziyuanguanli' ,'资源管理','/resource',0 ); 33 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (301,now(),0,now(),'Resource/House' ,'pms-icon-fangchan' ,'房产管理','/resource/house',300 ); 34 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (302,now(),0,now(),'Resource/Park' ,'pms-icon-chewei' ,'车位管理','/resource/park',300 ); 35 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (303,now(),0,now(),'Resource/Door' ,'pms-icon-menjin' ,'门禁管理','/resource/door',300 ); 36 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (400,now(),0,now(),'Layout' ,'pms-icon-baoxiu' ,'报修管理','/repairs',0 ); 37 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (401,now(),0,now(),'Repairs/Apply' ,'pms-icon-weixiu' ,'报修申请','/repairs/apply',400 ); 38 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (402,now(),0,now(),'Repairs/Center' ,'pms-icon-zongbu' ,'报修中心','/repairs/center',400 ); 39 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (500,now(),0,now(),'Layout' ,'pms-icon-baobiao' ,'报表中心','/report',0 ); 40 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (501,now(),0,now(),'Report/Payment' ,'pms-icon-chongzhi' ,'充值报表','/report/payment',500 ); 41 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (502,now(),0,now(),'Report/Settle' ,'pms-icon-jiaofei' ,'缴费报表','/report/settle',500 ); 42 | INSERT INTO t_menu(id, create_time, delete_flag, update_time, component, icon, name, path, pid)VALUES (503,now(),0,now(),'Report/Maintain' ,'pms-icon-baoxiu1' ,'维修报表','/report/maintain',500 ); 43 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,100); 44 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,101); 45 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,102); 46 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,200); 47 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,201); 48 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,202); 49 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,300); 50 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,301); 51 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,302); 52 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,400); 53 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,401); 54 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,402); 55 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,500); 56 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,501); 57 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,502); 58 | INSERT INTO roles_menus(role_id, menu_id) VALUES (1,503); 59 | 60 | ``` 61 | 62 | ## 项目笔记 63 | ### Validator 常用的检验规则 64 | - @NotNull 值不能为空 65 | - @Null 值必须为空 66 | - @pattern(regex=) 字符串必须匹配正则表达式 67 | - @Size(min= max=) 集合元素的数量必须在min 和max之间 68 | - @CreditCardNumber 字符串必须是信用卡 69 | - @Email 字符串必须是Email地址 70 | - @Length(min= max=) 字符串长度 71 | - @NotBlank 字符串必须有字符 72 | - @NotEmpty 字符串不为null 集合有元素 73 | - @Range(min= max=) 数字必须大于等于 min 小于max 74 | - @SafeHtml 字符串是安全的Html 75 | - @URL 字符串是URL 76 | - @AssertFalse 值是false 77 | - @AssertTrue 值是true 78 | - @DecimalMax(value inclusive) 可以放在字符串 小于等于value 79 | - @DecimalMin(value inclusive) 可以放在字符串 大于等于value 80 | - @past 必须是一个过去的日期 81 | - @Digits(integer= inclusive=) 数字格式检查 integer 整数部分最大长度 inclusive小数部分最大长度 82 | - @Max(value=) 值必须小于value,不能放在字符串上 83 | - @Min(value=) 值必须大于value,不能放在字符串上 84 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.1.3.RELEASE' 3 | id 'net.ltgt.apt' version '0.9' 4 | id("io.freefair.lombok") version "3.1.4" 5 | id 'java' 6 | } 7 | 8 | apply plugin: 'io.spring.dependency-management' 9 | 10 | group = 'com.fzy' 11 | version = '1.0.0-SNAPSHOT' 12 | sourceCompatibility = '1.8' 13 | 14 | configurations { 15 | compileOnly { 16 | extendsFrom annotationProcessor 17 | } 18 | } 19 | 20 | repositories { 21 | mavenLocal() 22 | maven { url "http://maven.aliyun.com/nexus/content/groups/public/"} 23 | mavenCentral() 24 | } 25 | 26 | dependencies { 27 | implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' 28 | implementation group: 'com.google.guava', name: 'guava', version: '27.1-jre' 29 | implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2' 30 | implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2' 31 | implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0' 32 | implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.56' 33 | implementation group: 'org.mapstruct', name: 'mapstruct-jdk8', version: '1.3.0.Final' 34 | implementation group: 'org.mapstruct', name: 'mapstruct-processor', version: '1.3.0.Final' 35 | annotationProcessor "org.mapstruct:mapstruct-processor:1.3.0.Final" 36 | implementation 'org.springframework.boot:spring-boot-starter-quartz' 37 | implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' 38 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 39 | implementation 'org.springframework.boot:spring-boot-starter-data-redis' 40 | implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 41 | implementation 'org.springframework.boot:spring-boot-starter-security' 42 | implementation 'org.springframework.boot:spring-boot-starter-web' 43 | implementation 'org.springframework.boot:spring-boot-starter-test' 44 | implementation 'com.qiniu:qiniu-java-sdk:7.2.+' 45 | runtimeOnly 'mysql:mysql-connector-java' 46 | compile 'org.projectlombok:lombok:1.18.2' 47 | } 48 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zy88866/pms/c28c5dd678776f0cfd1e0fb9d858168f5a67f630/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | } 5 | } 6 | rootProject.name = 'pms' 7 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/PmsApplication.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @Slf4j 9 | public class PmsApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(PmsApplication.class, args); 13 | log.debug("----------启动完成----------"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/cache/TokenCache.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.cache; 2 | 3 | import com.fzy.pms.entity.security.JwtToken; 4 | import com.fzy.pms.entity.security.User; 5 | import com.fzy.pms.utils.JwtTokenUtil; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | import java.util.Objects; 13 | 14 | /** 15 | * @program: TokenCache 16 | * @description: 模拟redis 使用 17 | * @author: fzy 18 | * @date: 2019-04-20 19:07 19 | **/ 20 | @Component 21 | public class TokenCache { 22 | 23 | @Autowired 24 | private JwtTokenUtil jwtTokenUtil; 25 | 26 | private static final Map userMap = new HashMap<>(); 27 | 28 | public String getUsername(JwtToken jwtToken){ 29 | String username = jwtTokenUtil.getUsernameFromToken(jwtToken); 30 | if(StringUtils.isNotBlank(username)){ 31 | JwtToken token = userMap.get(username); 32 | return Objects.isNull(token)?null:token.getAccessToken().equals(jwtToken.getAccessToken())?username:null; 33 | } 34 | return null; 35 | } 36 | 37 | public JwtToken add(User user){ 38 | JwtToken jwtToken = jwtTokenUtil.generateToken(user); 39 | return this.add(jwtToken); 40 | } 41 | 42 | public JwtToken add(JwtToken jwtToken){ 43 | String username = jwtTokenUtil.getUsernameFromToken(jwtToken); 44 | userMap.put(username,jwtToken); 45 | return jwtToken; 46 | } 47 | 48 | public void remove(String username){ 49 | userMap.remove(username); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/AccountDetailRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.AccountDetailDto; 4 | import com.fzy.pms.entity.pms.AccountDetail; 5 | import org.springframework.data.domain.Sort; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @program: AccountDetailRepository 15 | * @description: 16 | * @author: fzy 17 | * @date: 2019/05/21 22:07:56 18 | **/ 19 | @Repository 20 | public interface AccountDetailRepository extends JpaRepository{ 21 | 22 | @Query("select new com.fzy.pms.entity.dto.AccountDetailDto(user.id,user.username,user.realName,user.phone,acc.money,acc.rechargeTime,acc.rechargeType) " + 23 | "from AccountDetail acc left join User user on user.id=acc.user") 24 | List findAllDto(Sort sort); 25 | 26 | 27 | @Query("select new com.fzy.pms.entity.dto.AccountDetailDto(user.id,user.username,user.realName,user.phone,acc.money,acc.rechargeTime,acc.rechargeType) " + 28 | "from AccountDetail acc left join User user on user.id=acc.user where user.id= :userId") 29 | List search(@Param("userId") Long userId, Sort sort); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/CostSettingRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.RepairsReportDto; 4 | import com.fzy.pms.entity.dto.SettleDto; 5 | import com.fzy.pms.entity.pms.CostSetting; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.data.jpa.repository.JpaRepository; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.query.Param; 12 | import org.springframework.stereotype.Repository; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @program: CostSettingRepository 18 | * @description: 19 | * @author: fzy 20 | * @date: 2019/04/17 23:27:29 21 | **/ 22 | @Repository 23 | public interface CostSettingRepository extends JpaRepository { 24 | 25 | Page findCostSettingByCostNameLike(String name, Pageable pageable); 26 | 27 | @Query("select new com.fzy.pms.entity.dto.SettleDto(user.id,user.username,user.realName," + 28 | "cost.costName,settle.totalPrice,settle.settingDate) FROM Settle settle " + 29 | "left join User user on user.id=settle.user " + 30 | "left join CostSetting cost on cost.id=settle.costSetting") 31 | List findAllReportDto(Sort sort); 32 | 33 | 34 | @Query("select new com.fzy.pms.entity.dto.SettleDto(user.id,user.username,user.realName," + 35 | "cost.costName,settle.totalPrice,settle.settingDate) FROM Settle settle " + 36 | "left join User user on user.id=settle.user " + 37 | "left join CostSetting cost on cost.id=settle.costSetting where user.id= :userId") 38 | List report(@Param("userId") Long userId, Sort sort); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/DoorRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.DoorDto; 4 | import com.fzy.pms.entity.pms.Door; 5 | import org.springframework.data.domain.Example; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.jpa.repository.JpaRepository; 9 | import org.springframework.data.jpa.repository.Modifying; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.query.Param; 12 | import org.springframework.stereotype.Repository; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | 16 | /** 17 | * @program: DoorRepository 18 | * @description: 19 | * @author: fzy 20 | * @date: 2019/05/19 09:43:24 21 | **/ 22 | @Repository 23 | public interface DoorRepository extends JpaRepository { 24 | 25 | @Transactional 26 | @Modifying 27 | @Query(value = "update Door door set door.useStatus= :#{#door.useStatus} where id= :#{#door.id}") 28 | void updateuseStatus(@Param("door") Door door); 29 | 30 | @Query("SELECT new com.fzy.pms.entity.dto.DoorDto(door.id ,user.username,door.useStatus,door.expireDate,door.doorType) FROM Door door " + 31 | "left join User user on user.id=door.user where door.id= :id") 32 | DoorDto findOneById(@Param("id") Long id); 33 | 34 | @Query("SELECT new com.fzy.pms.entity.dto.DoorDto(door.id ,user.username,door.useStatus,door.expireDate,door.doorType) FROM Door door " + 35 | "left join User user on user.id=door.user ") 36 | Page findAllDto(Pageable pageable); 37 | 38 | @Query("SELECT new com.fzy.pms.entity.dto.DoorDto(door.id ,user.username,door.useStatus,door.expireDate,door.doorType) FROM Door door " + 39 | "left join User user on user.id=door.user where user.id= :userId") 40 | Page search(@Param("userId") Long userId, Pageable pageable); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/HouseRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.pms.House; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Modifying; 8 | import org.springframework.data.jpa.repository.Query; 9 | import org.springframework.data.repository.query.Param; 10 | import org.springframework.stereotype.Repository; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.Set; 14 | 15 | /** 16 | * @program: HouseRepository 17 | * @description: 18 | * @author: fzy 19 | * @date: 2019/05/09 13:35:22 20 | **/ 21 | @Repository 22 | public interface HouseRepository extends JpaRepository { 23 | 24 | @Transactional 25 | @Modifying 26 | @Query(value = "update t_house set delete_flag=1 where id in :ids",nativeQuery = true) 27 | void deleteInBatch(@Param("ids") Set ids); 28 | 29 | Page findHouseByUserId(Long id, Pageable pageable); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/MenuRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.security.Menu; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @program: MenuRepository 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019-03-30 21:26 16 | **/ 17 | @Repository 18 | public interface MenuRepository extends JpaRepository, JpaSpecificationExecutor { 19 | 20 | /** 21 | * 根据父id 查询 22 | * @param Pid 23 | * @return 24 | */ 25 | List findByPid(Long Pid); 26 | 27 | /** 28 | * 根据角色查询菜单列表 29 | * @param id 30 | * @return 31 | */ 32 | @Query(value = "select b.* from roles_menus a left join t_menu b on a.menu_id=b.id where a.role_id=?1",nativeQuery=true) 33 | List findByRole(Long id); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/ParkRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.ParkDto; 4 | import com.fzy.pms.entity.pms.Door; 5 | import com.fzy.pms.entity.pms.Park; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.jpa.repository.JpaRepository; 9 | import org.springframework.data.jpa.repository.Modifying; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.query.Param; 12 | import org.springframework.stereotype.Repository; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | /** 16 | * @program: ParkRepository 17 | * @description: 18 | * @author: fzy 19 | * @date: 2019/05/20 19:03:24 20 | **/ 21 | @Repository 22 | public interface ParkRepository extends JpaRepository { 23 | 24 | @Query("SELECT new com.fzy.pms.entity.dto.ParkDto(park.id ,user.username,park.useStatus,park.expireDate,park.parkType,park.position) FROM Park park " + 25 | "left join User user on user.id=park.user ") 26 | Page findAllDto(Pageable pageable); 27 | 28 | @Query("SELECT new com.fzy.pms.entity.dto.ParkDto(park.id ,user.username,park.useStatus,park.expireDate,park.parkType,park.position) FROM Park park " + 29 | "left join User user on user.id=park.user where user.id= :userId") 30 | Page search(@Param("userId") Long userId, Pageable pageable); 31 | 32 | @Transactional 33 | @Modifying 34 | @Query(value = "update Park park set park.useStatus= :#{#park.useStatus} where id= :#{#park.id}") 35 | void updateUseStatus(@Param("park") Park park); 36 | 37 | @Query("SELECT new com.fzy.pms.entity.dto.ParkDto(park.id ,user.username,park.useStatus,park.expireDate,park.parkType,park.position) FROM Park park " + 38 | "left join User user on user.id=park.user where park.id=?1") 39 | ParkDto findOne(Long id); 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/RepairsRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.RepairsDto; 4 | import com.fzy.pms.entity.dto.RepairsReportDto; 5 | import com.fzy.pms.entity.pms.Repairs; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.data.jpa.repository.JpaRepository; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.query.Param; 12 | import org.springframework.stereotype.Repository; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @program: RepairsRepository 18 | * @description: 19 | * @author: fzy 20 | * @date: 2019/05/22 12:06:21 21 | **/ 22 | @Repository 23 | public interface RepairsRepository extends JpaRepository { 24 | 25 | @Query("select new com.fzy.pms.entity.dto.RepairsDto(repairs.id,user.realName, repairs.repairsBillNo," + 26 | "repairs.repairsType,repairs.repairsDate,repairs.repairsStatus) from Repairs repairs " + 27 | "left join User user on user.id=repairs.user where repairs.repairsStatus='NOT' or repairs.repairsStatus='ING'") 28 | Page findAllDto(Pageable pageable); 29 | 30 | 31 | @Query("select new com.fzy.pms.entity.dto.RepairsDto(repairs.id,user.realName,repairs.repairsBillNo," + 32 | "repairs.repairsType,repairs.repairsDate,repairs.repairsStatus) from Repairs repairs " + 33 | "left join User user on user.id=repairs.user where user.id= :userId and (repairs.repairsStatus='NOT' or repairs.repairsStatus='ING')") 34 | Page search(@Param("userId") Long userId, Pageable pageable); 35 | 36 | @Query("select new com.fzy.pms.entity.dto.RepairsReportDto(repairs.id,user.realName,repairs.repairsBillNo," + 37 | "repairs.repairsPrice,repairs.repairsType,repairs.repairsDate,repairs.finishDate) from Repairs repairs " + 38 | "left join User user on user.id=repairs.user where repairs.repairsStatus='YES'") 39 | List findAllReportDto(Sort sort); 40 | 41 | @Query("select new com.fzy.pms.entity.dto.RepairsReportDto(repairs.id,user.realName,repairs.repairsBillNo," + 42 | "repairs.repairsPrice,repairs.repairsType,repairs.repairsDate,repairs.finishDate) from Repairs repairs " + 43 | "left join User user on user.id=repairs.user where repairs.repairsStatus='YES' AND user.id= :userId") 44 | List report(@Param("userId") Long userId,Sort sort); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.RoleDto; 4 | import com.fzy.pms.entity.security.Role; 5 | import jdk.nashorn.internal.runtime.options.Option; 6 | import org.springframework.data.domain.Sort; 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.data.jpa.repository.Modifying; 9 | import org.springframework.data.jpa.repository.Query; 10 | import org.springframework.data.repository.query.Param; 11 | import org.springframework.stereotype.Repository; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import java.nio.file.OpenOption; 15 | import java.util.List; 16 | import java.util.Optional; 17 | import java.util.Set; 18 | 19 | /** 20 | * @program: RoleRepository 21 | * @description: 22 | * @author: fzy 23 | * @date: 2019-04-05 10:45 24 | **/ 25 | @Repository 26 | public interface RoleRepository extends JpaRepository { 27 | 28 | @Transactional 29 | @Modifying 30 | @Query(value = "update t_role set delete_flag=1 where id in :ids",nativeQuery = true) 31 | int deleteRoleByIdIn(@Param("ids") Set ids); 32 | 33 | List findRoleByNameLike(String name, Sort sort); 34 | 35 | Optional findRoleByName(String name); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/SettleRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.pms.Settle; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @program: SettleRepository 9 | * @description: 10 | * @author: fzy 11 | * @date: 2019/05/23 08:31:49 12 | **/ 13 | @Repository 14 | public interface SettleRepository extends JpaRepository { 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/dao/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.dao; 2 | 3 | import com.fzy.pms.entity.dto.AccountDto; 4 | import com.fzy.pms.entity.security.User; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 9 | import org.springframework.data.jpa.repository.Modifying; 10 | import org.springframework.data.jpa.repository.Query; 11 | import org.springframework.data.repository.query.Param; 12 | import org.springframework.stereotype.Repository; 13 | 14 | import java.util.Optional; 15 | 16 | @Repository 17 | public interface UserRepository extends JpaRepository, JpaSpecificationExecutor { 18 | 19 | Optional findByUsername(String username); 20 | 21 | @Modifying 22 | @Query(value ="update User set deleteFlag=1 where id=:id") 23 | int lockUser(@Param("id") Long id); 24 | 25 | @Query(value ="select new com.fzy.pms.entity.dto.AccountDto(user.id,user.username,user.realName,user.balance) from User user") 26 | Page findAccountAll(Pageable pageable); 27 | 28 | @Query(value ="select new com.fzy.pms.entity.dto.AccountDto(user.id,user.username,user.realName,user.balance) from User user where username= :username") 29 | Page findAccountByUserId(@Param("username") String username,Pageable pageable); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/AccountDetailDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.RechargeType; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.Date; 10 | 11 | /** 12 | * @program: AccountDetailDto 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/05/22 08:22:01 16 | **/ 17 | @Data 18 | @AllArgsConstructor 19 | public class AccountDetailDto { 20 | 21 | private Long userId; 22 | 23 | private String username; 24 | 25 | private String realName; 26 | 27 | private String phone; 28 | 29 | private BigDecimal money; 30 | 31 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",locale = "zh", timezone = "GMT+8") 32 | private Date rechargeTime ; 33 | 34 | private RechargeType rechargeType; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/AccountDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * @program: AccountDto 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/21 21:55:41 13 | **/ 14 | @Data 15 | @AllArgsConstructor 16 | public class AccountDto { 17 | 18 | private Long userId; 19 | 20 | private String username; 21 | 22 | private String realName; 23 | 24 | private BigDecimal balance; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/DoorDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.UseStatus; 5 | import com.fzy.pms.entity.enums.DoorType; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * @program: DoorDto 15 | * @description: 16 | * @author: fzy 17 | * @date: 2019/05/20 15:03:43 18 | **/ 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class DoorDto implements Serializable{ 23 | 24 | private Long id; 25 | 26 | private String username; 27 | 28 | private UseStatus useStatus; 29 | 30 | @JsonFormat(pattern="yyyy-MM-dd",locale = "zh", timezone = "GMT+8") 31 | private Date expireDate; 32 | 33 | private DoorType doorType; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/MenuDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * @program: MenuDto 9 | * @description: 10 | * @author: fzy 11 | * @date: 2019-03-30 21:18 12 | **/ 13 | @Data 14 | public class MenuDto implements Comparable { 15 | 16 | private Long id; 17 | 18 | private String name; 19 | 20 | private String path; 21 | 22 | private String component; 23 | 24 | private String icon; 25 | 26 | private Set children; 27 | 28 | @Override 29 | public int compareTo(Object obj) { 30 | //判断是否属于Student类型,否则抛异常 31 | if (! (obj instanceof MenuDto)) throw new RuntimeException("NotSuchTypeException"); 32 | 33 | MenuDto m= (MenuDto) obj; 34 | return this.id.compareTo(m.id); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/ParkDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.ParkType; 5 | import com.fzy.pms.entity.enums.UseStatus; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @program: ParkDto 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/05/20 23:16:21 16 | **/ 17 | @Data 18 | @AllArgsConstructor 19 | public class ParkDto { 20 | 21 | private Long id; 22 | 23 | private String username; 24 | 25 | private UseStatus useStatus; 26 | 27 | @JsonFormat(pattern="yyyy-MM-dd",locale = "zh", timezone = "GMT+8") 28 | private Date expireDate; 29 | 30 | private ParkType parkType; 31 | 32 | private String position; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/RepairsDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.RepairsStatus; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @program: RepairsDto 12 | * @description: 13 | * @author: fzy 14 | * @date: 2019/05/22 20:59:13 15 | **/ 16 | @Data 17 | @AllArgsConstructor 18 | public class RepairsDto { 19 | 20 | private Long id; 21 | 22 | private String realName; 23 | 24 | private String repairsBillNo; 25 | 26 | private String repairsType; 27 | 28 | @JsonFormat(pattern="yyyy-MM-dd",locale = "zh", timezone = "GMT+8") 29 | private Date repairsDate; 30 | 31 | private RepairsStatus repairsStatus; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/RepairsReportDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.RepairsStatus; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.Date; 10 | 11 | /** 12 | * @program: RepairsDto 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/05/22 20:59:13 16 | **/ 17 | @Data 18 | @AllArgsConstructor 19 | public class RepairsReportDto { 20 | 21 | private Long id; 22 | 23 | private String realName; 24 | 25 | private String repairsBillNo; 26 | 27 | private BigDecimal repairsPrice; 28 | 29 | private String repairsType; 30 | 31 | @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss",locale = "zh", timezone = "GMT+8") 32 | private Date repairsDate; 33 | 34 | @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss",locale = "zh", timezone = "GMT+8") 35 | private Date finishDate; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/RoleDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | import lombok.experimental.Accessors; 6 | 7 | import java.util.Set; 8 | 9 | /** 10 | * @program: RoleDto 11 | * @description: 12 | * @author: fzy 13 | * @date: 2019/04/06 16:02:07 14 | **/ 15 | @Data 16 | public class RoleDto { 17 | 18 | private Long id; 19 | 20 | private String name; 21 | 22 | private String remark; 23 | 24 | @ApiModelProperty("权限所包含的用户数") 25 | private int citeNum; 26 | 27 | //@ApiModelProperty("菜单列表") 28 | //private Set menus; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/SettleDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.Date; 10 | 11 | /** 12 | * @program: SettleDto 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/05/28 22:24:45 16 | **/ 17 | @Data 18 | @AllArgsConstructor 19 | public class SettleDto { 20 | 21 | private Long userId; 22 | 23 | private String username; 24 | 25 | private String realName; 26 | 27 | private String costName; 28 | 29 | private BigDecimal totalPrice; 30 | 31 | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",locale = "zh", timezone = "GMT+8") 32 | private Date settingDate; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.dto; 2 | 3 | import com.fzy.pms.entity.enums.UseStatus; 4 | import com.fzy.pms.entity.security.Role; 5 | import lombok.Data; 6 | import lombok.experimental.Accessors; 7 | 8 | /** 9 | * @program: UserDto 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019-04-05 15:40 13 | **/ 14 | @Data 15 | public class UserDto { 16 | 17 | private Long id; 18 | 19 | private String username; 20 | 21 | private String email; 22 | 23 | private String phone; 24 | 25 | private String realName; 26 | 27 | private RoleDto role; 28 | 29 | private UseStatus useStatus; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/Constants.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | /** 4 | * @program: Constants 5 | * @description: 6 | * @author: fzy 7 | * @date: 2019-04-05 11:51 8 | **/ 9 | public interface Constants { 10 | String NORMEL="0"; 11 | String DELETED="1"; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/DoorType.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @program: DoorType 7 | * @description: 开门方式 8 | * @author: fzy 9 | * @date: 2019/05/18 22:27:29 10 | **/ 11 | @Getter 12 | public enum DoorType { 13 | 14 | QR("二维码"), 15 | NFC("门禁卡"); 16 | 17 | private String name; 18 | 19 | DoorType(String name){ 20 | this.name=name; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/ParkType.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @program: ParkType 7 | * @description: 8 | * @author: fzy 9 | * @date: 2019/05/20 18:51:58 10 | **/ 11 | @Getter 12 | public enum ParkType { 13 | 14 | SMALL_CAR("小车"), 15 | BIG_CAR("大车"); 16 | 17 | private String name; 18 | 19 | ParkType(String name){ 20 | this.name=name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/RechargeType.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | /** 6 | * @program: RechargeType 7 | * @description: 8 | * @author: fzy 9 | * @date: 2019/05/21 16:49:20 10 | **/ 11 | @AllArgsConstructor 12 | public enum RechargeType { 13 | WECHART("微信支付"), 14 | ALIPAY("支付宝"), 15 | CASH("现金"), 16 | CARD("银行卡"); 17 | 18 | private String name; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/RepairsStatus.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | /** 6 | * @program: RepairsStatus 7 | * @description: 8 | * @author: fzy 9 | * @date: 2019/05/22 12:01:04 10 | **/ 11 | @AllArgsConstructor 12 | public enum RepairsStatus { 13 | 14 | NOT("未完成"), 15 | ING("进行中"), 16 | YES("已完成"); 17 | 18 | private String name; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/RestCode.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @program: RestCode 7 | * @description: 全局错误码 8 | * @author: fzy 9 | * @date: 2019/03/17 09:00:51 10 | **/ 11 | @Getter 12 | public enum RestCode { 13 | SUCCESS(200,"SUCCESS"), 14 | TOKEN_EXPIRE(401,"Token 过期,请重新登陆"), 15 | SYS_ERROR_EXCEPTION(500,"系统异常,请联系管理员"),; 16 | 17 | private Integer code; 18 | 19 | private String message; 20 | 21 | RestCode(Integer code, String message) { 22 | this.code = code; 23 | this.message = message; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/Storey.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @program: Storey 7 | * @description: 8 | * @author: fzy 9 | * @date: 2019/05/09 10:10:23 10 | **/ 11 | @Getter 12 | public enum Storey { 13 | HEIGHT, 14 | LOW 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/enums/UseStatus.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.enums; 2 | 3 | /** 4 | * @program: UseStatus 5 | * @description: 6 | * @author: fzy 7 | * @date: 2019/05/18 22:12:07 8 | **/ 9 | public enum UseStatus { 10 | DISABLED, 11 | ENABLED 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/mapper/EntityMapper.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.mapper; 2 | 3 | import com.fzy.pms.entity.security.Role; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @program: EntityMapper 9 | * @description: 10 | * @author: fzy 11 | * @date: 2019-03-30 21:54 12 | **/ 13 | public interface EntityMapper { 14 | 15 | /** 16 | * Dto 转 Entity 17 | * @param dto 18 | * @return 19 | */ 20 | E toEntity(D dto); 21 | 22 | /** 23 | * entity 转 dto 24 | * @param entity 25 | * @return 26 | */ 27 | D toDto(E entity); 28 | 29 | /** 30 | * DTO集合转Entity集合 31 | * @param dtoList 32 | * @return 33 | */ 34 | List toEntity(List dtoList); 35 | 36 | /** 37 | * Entity集合转DTO集合 38 | * @param entityList 39 | * @return 40 | */ 41 | List toDto(List entityList); 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/mapper/MenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.mapper; 2 | 3 | import com.fzy.pms.entity.dto.MenuDto; 4 | import com.fzy.pms.entity.security.Menu; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.ReportingPolicy; 7 | 8 | /** 9 | * @program: MenuMapper 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019-03-30 21:57 13 | **/ 14 | @Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE) 15 | public interface MenuMapper extends EntityMapper { 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.mapper; 2 | 3 | import com.fzy.pms.entity.dto.RoleDto; 4 | import com.fzy.pms.entity.security.Role; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.ReportingPolicy; 7 | 8 | /** 9 | * @program: RoleMapper 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/04 15:40:47 13 | **/ 14 | @Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE) 15 | public interface RoleMapper extends EntityMapper { 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.mapper; 2 | 3 | import com.fzy.pms.entity.dto.UserDto; 4 | import com.fzy.pms.entity.security.User; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.ReportingPolicy; 7 | 8 | /** 9 | * @program: UserMapper 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019-04-05 15:45 13 | **/ 14 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) 15 | public interface UserMapper extends EntityMapper { 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/AccountDetail.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fzy.pms.entity.enums.Constants; 4 | import com.fzy.pms.entity.enums.RechargeType; 5 | import com.fzy.pms.entity.security.Base; 6 | import com.fzy.pms.entity.security.User; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | import org.hibernate.annotations.SQLDelete; 12 | import org.hibernate.annotations.Where; 13 | 14 | import javax.persistence.*; 15 | import javax.validation.constraints.NotNull; 16 | import java.math.BigDecimal; 17 | import java.util.Date; 18 | 19 | /** 20 | * @program: AccountDetail 21 | * @description: 22 | * @author: fzy 23 | * @date: 2019/05/21 15:04:02 24 | **/ 25 | @EqualsAndHashCode(callSuper = true) 26 | @Data 27 | @ApiModel("账户") 28 | @Table(name = "t_account_detail") 29 | @Entity 30 | @SQLDelete(sql = "update t_account_detail set delete_flag="+ Constants.DELETED+" where id= ?") 31 | @Where(clause = "delete_flag="+ Constants.NORMEL) 32 | public class AccountDetail extends Base { 33 | 34 | @ManyToOne 35 | @JoinColumn(name = "user_id") 36 | private User user; 37 | 38 | @ApiModelProperty("充值金额") 39 | @NotNull(message = "充值金额不能为空") 40 | private BigDecimal money; 41 | 42 | @Temporal(TemporalType.TIMESTAMP) 43 | @ApiModelProperty("充值时间") 44 | @NotNull(message = "充值时间不能为空") 45 | private Date rechargeTime ; 46 | 47 | @ApiModelProperty("充值方式") 48 | @NotNull(message = "充值方式不能为空") 49 | @Enumerated(EnumType.STRING) 50 | private RechargeType rechargeType; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/CostSetting.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fzy.pms.entity.enums.Constants; 4 | import com.fzy.pms.entity.security.Base; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | import org.hibernate.annotations.SQLDelete; 10 | import org.hibernate.annotations.Where; 11 | 12 | import javax.persistence.Column; 13 | import javax.persistence.Entity; 14 | import javax.persistence.Table; 15 | import javax.validation.constraints.NotBlank; 16 | import javax.validation.constraints.NotNull; 17 | import java.math.BigDecimal; 18 | 19 | /** 20 | * @program: CostSetting 21 | * @description: 费用设置 22 | * @author: fzy 23 | * @date: 2019/04/17 23:10:40 24 | **/ 25 | @EqualsAndHashCode(callSuper = true) 26 | @Data 27 | @ApiModel("费用设置") 28 | @Table(name = "t_cost") 29 | @Entity 30 | @SQLDelete(sql = "update t_cost set delete_flag="+ Constants.DELETED+" where id= ?") 31 | @Where(clause = "delete_flag="+ Constants.NORMEL) 32 | public class CostSetting extends Base { 33 | 34 | @ApiModelProperty("费用名称") 35 | @NotBlank(groups = {Update.class,Save.class},message = "费用名称不能为空") 36 | private String costName; 37 | 38 | @ApiModelProperty("费用价格") 39 | @NotNull(groups = {Update.class,Save.class},message = "费用价格不能为空") 40 | @Column(precision=19,scale=8) 41 | private BigDecimal costPrice; 42 | 43 | @ApiModelProperty("计费规则") 44 | @NotBlank(groups = {Update.class,Save.class},message = "计费规则不能为空") 45 | private String regular; 46 | 47 | public interface Save { 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/Door.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.Constants; 5 | import com.fzy.pms.entity.enums.UseStatus; 6 | import com.fzy.pms.entity.enums.DoorType; 7 | import com.fzy.pms.entity.security.Base; 8 | import com.fzy.pms.entity.security.User; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import org.hibernate.annotations.SQLDelete; 14 | import org.hibernate.annotations.Where; 15 | 16 | import javax.persistence.*; 17 | import javax.validation.constraints.NotNull; 18 | import java.util.Date; 19 | 20 | /** 21 | * @program: Door 22 | * @description: 门禁 23 | * @author: fzy 24 | * @date: 2019/05/18 22:08:32 25 | **/ 26 | @Data 27 | @ApiModel("门禁管理") 28 | @Table(name = "t_door") 29 | @Entity 30 | @SQLDelete(sql = "update t_door set delete_flag="+ Constants.DELETED+" where id= ?") 31 | @Where(clause = "delete_flag="+ Constants.NORMEL) 32 | @EqualsAndHashCode(callSuper=false) 33 | public class Door extends Base { 34 | 35 | @ApiModelProperty("使用状态") 36 | @Enumerated(EnumType.STRING) 37 | private UseStatus useStatus= UseStatus.ENABLED; 38 | 39 | @ApiModelProperty("开门方式") 40 | @Enumerated(EnumType.STRING) 41 | private DoorType doorType; 42 | 43 | @ApiModelProperty("用户") 44 | @NotNull(groups = {Update.class, Save.class},message = "用户不能为空") 45 | @ManyToOne(fetch = FetchType.EAGER,optional = false) 46 | @JoinColumn(name = "user_id") 47 | private User user; 48 | 49 | @ApiModelProperty("到期日期") 50 | @JsonFormat(pattern="yyyy-MM-dd",locale = "zh", timezone = "GMT+8") 51 | @Temporal(TemporalType.DATE) 52 | private Date expireDate; 53 | 54 | public interface Save { 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/House.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import com.fzy.pms.entity.enums.Constants; 6 | import com.fzy.pms.entity.enums.Storey; 7 | import com.fzy.pms.entity.security.Base; 8 | import com.fzy.pms.entity.security.User; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import org.hibernate.annotations.SQLDelete; 14 | import org.hibernate.annotations.Where; 15 | 16 | import javax.persistence.*; 17 | import javax.validation.constraints.NotNull; 18 | 19 | /** 20 | * @program: House 21 | * @description: 房产 22 | * @author: fzy 23 | * @date: 2019/05/09 10:01:00 24 | **/ 25 | @Data 26 | @ApiModel("房产管理") 27 | @Table(name = "t_house") 28 | @Entity 29 | @SQLDelete(sql = "update t_house set delete_flag="+ Constants.DELETED+" where id= ?") 30 | @Where(clause = "delete_flag="+ Constants.NORMEL) 31 | @EqualsAndHashCode(callSuper=false) 32 | public class House extends Base { 33 | 34 | /** 35 | * optional 属性是定义该关联类对是否必须存在,值为false时, 36 | * 关联类双方都必须存在,如果关系被维护端不存在,查询的结果为null。 37 | * 值为true 时, 关系被维护端可以不存在,查询的结果仍然会返回关系维护端, 38 | * 在关系维护端中指向关系被维护端的属性为null。 39 | * optional 属性的默认值是true。 40 | */ 41 | 42 | @ApiModelProperty("用户") 43 | @NotNull(groups = {Update.class, CostSetting.Save.class},message = "用户不能为空") 44 | @ManyToOne(fetch =FetchType.EAGER,optional = false) 45 | @JoinColumn(name = "user_id") 46 | private User user; 47 | 48 | @ApiModelProperty("位置") 49 | private String position; 50 | 51 | /** 52 | * EnumType: ORDINAL 枚举序数 默认选项(int)。eg:TEACHER 数据库存储的是 0 53 | * STRING:枚举名称 (String)。eg:TEACHER 数据库存储的是 "TEACHER" 54 | */ 55 | @ApiModelProperty("类型") 56 | @Enumerated(EnumType.STRING) 57 | private Storey storey; 58 | 59 | @ApiModelProperty("小区名称") 60 | private String cellName; 61 | 62 | public interface Save { 63 | } 64 | 65 | @JsonIgnore 66 | public User getUser() { 67 | return user; 68 | } 69 | 70 | @JsonProperty 71 | public void setUser(User user) { 72 | this.user = user; 73 | } 74 | 75 | @ApiModelProperty("用户名") 76 | @Transient 77 | private String username; 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/Park.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fzy.pms.entity.enums.Constants; 5 | import com.fzy.pms.entity.enums.ParkType; 6 | import com.fzy.pms.entity.enums.UseStatus; 7 | import com.fzy.pms.entity.security.Base; 8 | import com.fzy.pms.entity.security.User; 9 | import io.swagger.annotations.ApiModel; 10 | import io.swagger.annotations.ApiModelProperty; 11 | import lombok.Data; 12 | import lombok.EqualsAndHashCode; 13 | import org.hibernate.annotations.SQLDelete; 14 | import org.hibernate.annotations.Where; 15 | 16 | import javax.persistence.*; 17 | import javax.validation.constraints.NotBlank; 18 | import javax.validation.constraints.NotNull; 19 | import java.util.Date; 20 | 21 | /** 22 | * @program: Park 23 | * @description: 车位管理 24 | * @author: fzy 25 | * @date: 2019/05/18 22:11:04 26 | **/ 27 | @Data 28 | @ApiModel("车位管理") 29 | @Table(name = "t_park") 30 | @Entity 31 | @SQLDelete(sql = "update t_park set delete_flag="+ Constants.DELETED+" where id= ?") 32 | @Where(clause = "delete_flag="+ Constants.NORMEL) 33 | @EqualsAndHashCode(callSuper=false) 34 | public class Park extends Base { 35 | 36 | @ApiModelProperty("用户") 37 | @NotNull(groups = {Update.class, Park.Save.class},message = "用户不能为空") 38 | @ManyToOne 39 | @JoinColumn(name = "user_id") 40 | private User user; 41 | 42 | @ApiModelProperty("位置") 43 | @NotBlank(message = "位置不能为空") 44 | private String position; 45 | 46 | @ApiModelProperty("车位类型") 47 | @Enumerated(EnumType.STRING) 48 | private ParkType parkType; 49 | 50 | @ApiModelProperty("到期日期") 51 | @JsonFormat(pattern="yyyy-MM-dd",locale = "zh", timezone = "GMT+8") 52 | @Temporal(TemporalType.DATE) 53 | private Date expireDate; 54 | 55 | @ApiModelProperty("使用状态") 56 | @Enumerated(EnumType.STRING) 57 | private UseStatus useStatus; 58 | 59 | public interface Save { 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/Repairs.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fzy.pms.entity.enums.Constants; 4 | import com.fzy.pms.entity.enums.RepairsStatus; 5 | import com.fzy.pms.entity.security.Base; 6 | import com.fzy.pms.entity.security.User; 7 | import io.swagger.annotations.ApiModel; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import lombok.Data; 10 | import lombok.EqualsAndHashCode; 11 | import org.hibernate.annotations.SQLDelete; 12 | import org.hibernate.annotations.Where; 13 | 14 | import javax.persistence.*; 15 | import javax.validation.constraints.NotBlank; 16 | import javax.validation.constraints.NotNull; 17 | import java.math.BigDecimal; 18 | import java.util.Date; 19 | 20 | /** 21 | * @program: Repairs 22 | * @description: 23 | * @author: fzy 24 | * @date: 2019/05/22 11:56:36 25 | **/ 26 | @Data 27 | @ApiModel("报修管理") 28 | @Table(name = "t_repairs") 29 | @Entity 30 | @SQLDelete(sql = "update t_repairs set delete_flag="+ Constants.DELETED+" where id= ?") 31 | @Where(clause = "delete_flag="+ Constants.NORMEL) 32 | @EqualsAndHashCode(callSuper=false) 33 | public class Repairs extends Base{ 34 | 35 | @ApiModelProperty("报修人") 36 | @NotNull(message = "报修人不能为空") 37 | @ManyToOne 38 | @JoinColumn(name = "user_id") 39 | private User user; 40 | 41 | @ApiModelProperty("报修项目") 42 | @NotBlank(message = "报修项目不能为空") 43 | private String repairsType; 44 | 45 | @ApiModelProperty("备注") 46 | private String remark; 47 | 48 | @ApiModelProperty("联系人") 49 | @NotBlank(message = "联系人不能为空") 50 | private String linkman; 51 | 52 | @ApiModelProperty("联系电话") 53 | @NotBlank(message = "联系电话不能为空") 54 | private String linkPhone; 55 | 56 | @ApiModelProperty("联系地址") 57 | @NotBlank(message = "联系地址不能为空") 58 | private String linkAddress; 59 | 60 | @ApiModelProperty("报修时间") 61 | @Temporal(TemporalType.TIMESTAMP) 62 | private Date repairsDate; 63 | 64 | @ApiModelProperty("完成时间") 65 | @Temporal(TemporalType.TIMESTAMP) 66 | private Date finishDate; 67 | 68 | @ApiModelProperty("报修单号") 69 | private String repairsBillNo; 70 | 71 | @ApiModelProperty("维修价格") 72 | private BigDecimal repairsPrice; 73 | 74 | @Enumerated(EnumType.STRING) 75 | @ApiModelProperty("维修状态") 76 | private RepairsStatus repairsStatus; 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/pms/Settle.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.pms; 2 | 3 | import com.fzy.pms.entity.enums.Constants; 4 | import com.fzy.pms.entity.security.Base; 5 | import com.fzy.pms.entity.security.User; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | import org.hibernate.annotations.SQLDelete; 11 | import org.hibernate.annotations.Where; 12 | 13 | import javax.persistence.Entity; 14 | import javax.persistence.JoinColumn; 15 | import javax.persistence.ManyToOne; 16 | import javax.persistence.Table; 17 | import javax.validation.constraints.NotNull; 18 | import java.math.BigDecimal; 19 | import java.util.Date; 20 | 21 | /** 22 | * @program: Settle 23 | * @description: 24 | * @author: fzy 25 | * @date: 2019/05/23 08:24:34 26 | **/ 27 | @Data 28 | @ApiModel("结算表") 29 | @Table(name = "t_settle") 30 | @Entity 31 | @SQLDelete(sql = "update t_settle set delete_flag="+ Constants.DELETED+" where id= ?") 32 | @Where(clause = "delete_flag="+ Constants.NORMEL) 33 | @EqualsAndHashCode(callSuper=false) 34 | public class Settle extends Base { 35 | 36 | @ApiModelProperty("结算账户") 37 | @NotNull(message = "结算账户不能为空") 38 | @ManyToOne 39 | @JoinColumn(name = "user_id") 40 | private User user; 41 | 42 | @ApiModelProperty("费用类型") 43 | @NotNull(message = "费用类型不能为空") 44 | @ManyToOne 45 | @JoinColumn(name = "cost_id") 46 | private CostSetting costSetting; 47 | 48 | @ApiModelProperty("倍数") 49 | private BigDecimal multiple; 50 | 51 | @ApiModelProperty("结算时间") 52 | private Date settingDate; 53 | 54 | @ApiModelProperty("扣除金额") 55 | private BigDecimal totalPrice; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/rest/Result.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.rest; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fzy.pms.entity.enums.RestCode; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | /** 10 | * @program: Result 11 | * @description: 12 | * @author: fzy 13 | * @date: 2019/03/17 08:56:50 14 | **/ 15 | @Data 16 | @JsonInclude(JsonInclude.Include.NON_NULL) 17 | @ApiModel("统一返回结果实体") 18 | public class Result { 19 | 20 | @ApiModelProperty(value = "返回代码",example="200") 21 | private Integer code; 22 | 23 | @ApiModelProperty("失败消息") 24 | private String message; 25 | 26 | @ApiModelProperty("结果对象") 27 | private T data; 28 | 29 | @ApiModelProperty("时间戳") 30 | private long timestamp = System.currentTimeMillis(); 31 | 32 | public static Result success(){ 33 | Result result=new Result(); 34 | result.setRestCode(RestCode.SUCCESS); 35 | return result; 36 | } 37 | 38 | public static Result success(T data){ 39 | Result result=new Result<>(); 40 | result.setRestCode(RestCode.SUCCESS); 41 | result.setData(data); 42 | return result; 43 | } 44 | 45 | public static Result failure(RestCode code){ 46 | Result result=new Result(); 47 | result.setRestCode(code); 48 | return result; 49 | } 50 | 51 | 52 | public static Result failure(String message){ 53 | Result result=new Result(); 54 | result.setCode(RestCode.SYS_ERROR_EXCEPTION.getCode()); 55 | result.setMessage(message); 56 | return result; 57 | } 58 | 59 | 60 | public static Result failure(Integer code, String message){ 61 | Result result=new Result(); 62 | result.setCode(code); 63 | result.setMessage(message); 64 | return result; 65 | } 66 | 67 | public static Result failure(Integer code,T data){ 68 | Result result=new Result<>(); 69 | result.setCode(code); 70 | result.setData(data); 71 | return result; 72 | } 73 | 74 | private void setRestCode(RestCode restCode){ 75 | this.code=restCode.getCode(); 76 | this.message=restCode.getMessage(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/security/Base.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.security; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.experimental.Accessors; 8 | import org.hibernate.annotations.CreationTimestamp; 9 | import org.hibernate.annotations.UpdateTimestamp; 10 | 11 | import javax.persistence.GeneratedValue; 12 | import javax.persistence.GenerationType; 13 | import javax.persistence.Id; 14 | import javax.persistence.MappedSuperclass; 15 | import javax.validation.constraints.NotNull; 16 | import java.io.Serializable; 17 | import java.util.Date; 18 | 19 | @Data 20 | @MappedSuperclass 21 | @ApiModel("Base") 22 | public class Base implements Serializable { 23 | 24 | @Id 25 | @ApiModelProperty("id") 26 | @NotNull(groups = {Update.class},message = "ID 不能为空") 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | private Long id; 29 | 30 | @ApiModelProperty(value = "创建时间",hidden = true) 31 | @JsonIgnore 32 | @CreationTimestamp 33 | private Date createTime; 34 | 35 | @ApiModelProperty(value ="更新时间",hidden = true) 36 | @JsonIgnore 37 | @UpdateTimestamp 38 | private Date updateTime; 39 | 40 | @ApiModelProperty(value ="删除标志位 0 为删除 1删除",hidden = true) 41 | @JsonIgnore 42 | @NotNull 43 | private int deleteFlag; 44 | 45 | public interface Update{} 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/security/JwtToken.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.security; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | import lombok.experimental.Accessors; 6 | 7 | /** 8 | * @program: JwtToken 9 | * @description: 10 | * @author: fzy 11 | * @date: 2019-04-21 11:09 12 | **/ 13 | @Data 14 | @Accessors(chain = true) 15 | public class JwtToken { 16 | 17 | @ApiModelProperty("请求时携带的token") 18 | private String accessToken; 19 | 20 | @ApiModelProperty("刷新token") 21 | private String refreshToken; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/security/Menu.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.security; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fzy.pms.entity.enums.Constants; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | import org.hibernate.annotations.SQLDelete; 10 | import org.hibernate.annotations.Where; 11 | 12 | import javax.persistence.Column; 13 | import javax.persistence.Entity; 14 | import javax.persistence.ManyToMany; 15 | import javax.persistence.Table; 16 | import javax.validation.constraints.NotBlank; 17 | import java.util.Set; 18 | 19 | /** 20 | * @program: Menu 21 | * @description: 22 | * @author: fzy 23 | * @date: 2019/03/18 22:16:27 24 | **/ 25 | @Entity 26 | @Getter 27 | @Setter 28 | @Table(name = "t_menu") 29 | @ApiModel("菜单") 30 | @SQLDelete(sql = "update t_menu set delete_flag="+Constants.DELETED+" where id= ?") 31 | @Where(clause = "delete_flag="+ Constants.NORMEL) 32 | public class Menu extends Base { 33 | 34 | @NotBlank(message = "菜单名称不能为空") 35 | @ApiModelProperty("菜单名称") 36 | private String name; 37 | 38 | @NotBlank(message = "url 不能为空") 39 | @ApiModelProperty("跳转路径") 40 | private String path; 41 | 42 | @NotBlank(message = "图标不能为空") 43 | @ApiModelProperty("图标") 44 | private String icon; 45 | 46 | @ApiModelProperty("路由组件") 47 | @NotBlank(message = "组件不能为空") 48 | private String component; 49 | 50 | @ApiModelProperty("父id") 51 | @Column(columnDefinition="bigint default 0",nullable = false) 52 | private Long pid; 53 | 54 | @ManyToMany(mappedBy = "menus") 55 | @JsonIgnore 56 | private Set roles; 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/security/Role.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.security; 2 | 3 | import com.fzy.pms.entity.enums.Constants; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | import lombok.experimental.Accessors; 11 | import org.hibernate.annotations.SQLDelete; 12 | import org.hibernate.annotations.Where; 13 | import javax.persistence.*; 14 | import javax.validation.constraints.NotBlank; 15 | import java.util.Set; 16 | 17 | /** 18 | * @program: Role 19 | * @description: 角色表 20 | * @author: fzy 21 | * @date: 2019/03/17 12:13:14 22 | **/ 23 | 24 | 25 | @Entity 26 | @Table(name="t_role") 27 | @Getter 28 | @Setter 29 | @ApiModel("角色") 30 | @SQLDelete(sql = "update t_role set delete_flag="+ Constants.DELETED+" where id= ?") 31 | @Where(clause = "delete_flag="+ Constants.NORMEL) 32 | public class Role extends Base { 33 | 34 | @Column(length = 25) 35 | @ApiModelProperty("名称") 36 | @NotBlank(message = "角色名称不能为空") 37 | private String name; 38 | 39 | @ApiModelProperty("备注") 40 | @NotBlank(message = "描述不能为空") 41 | private String remark; 42 | 43 | @ManyToMany(fetch = FetchType.EAGER) 44 | @JoinTable( 45 | name = "roles_menus", 46 | joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, 47 | inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")}) 48 | private Set menus; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/security/User.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.security; 2 | 3 | import com.fzy.pms.entity.enums.Constants; 4 | import com.fzy.pms.entity.enums.UseStatus; 5 | import com.google.common.collect.Sets; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | import lombok.EqualsAndHashCode; 10 | import org.hibernate.annotations.SQLDelete; 11 | import org.hibernate.annotations.Where; 12 | import org.springframework.security.core.GrantedAuthority; 13 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 14 | import org.springframework.security.core.userdetails.UserDetails; 15 | 16 | import javax.persistence.*; 17 | import javax.validation.constraints.Email; 18 | import javax.validation.constraints.NotBlank; 19 | import javax.validation.constraints.Pattern; 20 | import java.math.BigDecimal; 21 | import java.util.Collection; 22 | 23 | /** 24 | * @program: User 25 | * @description: 用户表 26 | * @author: fzy 27 | * @date: 2019/03/17 12:13:14 28 | **/ 29 | @EqualsAndHashCode(callSuper = true) 30 | @Data 31 | @Entity 32 | @Table(name="t_user") 33 | @ApiModel("用户") 34 | @SQLDelete(sql = "update t_user set delete_flag="+ Constants.DELETED+" where id= ?") 35 | @Where(clause = "delete_flag="+ Constants.NORMEL) 36 | public class User extends Base implements UserDetails { 37 | 38 | @NotBlank(message = "用户名不能为空") 39 | //@Column(unique = true) 40 | private String username; 41 | 42 | @NotBlank(message = "密码不能为空") 43 | private String password; 44 | 45 | @Email(message = "邮箱不符合规则") 46 | private String email; 47 | 48 | @Pattern(regexp = "^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\\d{8}$", message = "手机号码不符合规范") 49 | @NotBlank(message = "手机号码不能为空") 50 | private String phone; 51 | 52 | @NotBlank(message = "名字不能为空") 53 | private String realName; 54 | 55 | @ApiModelProperty("账户余额") 56 | @Column(columnDefinition = "decimal(19,2) default 0") 57 | private BigDecimal balance=BigDecimal.ZERO; 58 | 59 | @ApiModelProperty("激活用户状态") 60 | @Enumerated(EnumType.STRING) 61 | private UseStatus useStatus= UseStatus.ENABLED; 62 | 63 | @ManyToOne(cascade = CascadeType.REFRESH,fetch = FetchType.EAGER) 64 | @JoinColumn(name = "role_id", referencedColumnName="id",nullable = false) 65 | private Role role; 66 | 67 | @Override 68 | public Collection getAuthorities() { 69 | return Sets.newHashSet(new SimpleGrantedAuthority(role.getName())); 70 | } 71 | 72 | @Override 73 | public String getUsername() { 74 | return this.username; 75 | } 76 | 77 | @Override 78 | public boolean isAccountNonExpired() { 79 | return true; 80 | } 81 | 82 | @Override 83 | public boolean isAccountNonLocked() { 84 | return true; 85 | } 86 | 87 | @Override 88 | public boolean isCredentialsNonExpired() { 89 | return true; 90 | } 91 | 92 | @Override 93 | public boolean isEnabled() { 94 | return useStatus.equals(UseStatus.ENABLED); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/vo/RepairVo.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.vo; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotNull; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * @program: RepairVo 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/22 22:40:35 13 | **/ 14 | @Data 15 | public class RepairVo { 16 | 17 | @NotNull(message = "id 不能为空") 18 | private Long id; 19 | 20 | private BigDecimal RepairsPrice; 21 | 22 | private String repairsBillNo; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/entity/vo/UserVo.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.entity.vo; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * @program: UserVo 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/22 11:06:12 13 | **/ 14 | @Data 15 | public class UserVo { 16 | 17 | @NotNull(message = "用户id不能为空") 18 | public Long id; 19 | 20 | @NotBlank(message = "旧密码不能为空") 21 | public String oldPassword; 22 | 23 | @NotBlank(message = "新密码不能为空") 24 | public String newPassword; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.exception; 2 | 3 | import com.fzy.pms.entity.enums.RestCode; 4 | import lombok.Getter; 5 | 6 | /** 7 | * @program: BaseException 8 | * @description: 9 | * @author: fzy 10 | * @date: 2019/03/23 18:53:36 11 | **/ 12 | @Getter 13 | public class BaseException extends RuntimeException{ 14 | protected Integer code; 15 | 16 | BaseException(String message) { 17 | super(message); 18 | } 19 | 20 | BaseException(RestCode restCode){ 21 | super(restCode.getMessage()); 22 | this.code = restCode.getCode(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/exception/ExceptionProcessor.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.exception; 2 | 3 | import com.fzy.pms.entity.enums.RestCode; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.google.common.collect.Sets; 6 | import com.qiniu.common.QiniuException; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.apache.commons.lang3.exception.ExceptionUtils; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.web.HttpRequestMethodNotSupportedException; 11 | import org.springframework.web.bind.MethodArgumentNotValidException; 12 | import org.springframework.web.bind.annotation.ExceptionHandler; 13 | import org.springframework.web.bind.annotation.ResponseStatus; 14 | import org.springframework.web.bind.annotation.RestControllerAdvice; 15 | import javax.servlet.http.HttpServletRequest; 16 | import java.util.HashSet; 17 | 18 | 19 | /** 20 | * @program: ExceptionHandler 21 | * @description: 权限异常处理 22 | * @author: fzy 23 | * @date: 2019/03/17 08:54:32 24 | **/ 25 | @Slf4j 26 | @RestControllerAdvice 27 | public class ExceptionProcessor { 28 | /** 29 | * 处理所有不可知的异常 30 | * @param e 31 | * @return 32 | */ 33 | @ExceptionHandler(Exception.class) 34 | @ResponseStatus(value = HttpStatus.OK) 35 | public Result handleException(Exception e){ 36 | // 打印堆栈信息 37 | log.error(ExceptionUtils.getStackTrace(e)); 38 | return Result.failure(RestCode.SYS_ERROR_EXCEPTION); 39 | } 40 | 41 | /** 42 | * 处理所有接口数据验证异常 43 | * @param e 44 | * @returns 45 | */ 46 | @ExceptionHandler(MethodArgumentNotValidException.class) 47 | @ResponseStatus(value = HttpStatus.OK) 48 | public Result validationBodyException(MethodArgumentNotValidException e){ 49 | HashSet set= Sets.newHashSet(); 50 | e.getBindingResult().getAllErrors().forEach(p->set.add(p.getDefaultMessage())); 51 | return Result.failure(HttpStatus.INTERNAL_SERVER_ERROR.value(),set.toString()); 52 | } 53 | 54 | /** 55 | * 接口不存在异常 56 | * @param 57 | * @return 58 | */ 59 | @ExceptionHandler(HttpRequestMethodNotSupportedException.class) 60 | @ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED) 61 | public Result interfaceNotFoundException(HttpServletRequest request){ 62 | return Result.failure(HttpStatus.METHOD_NOT_ALLOWED.value(),request.getRequestURI()+" 无效的请求"); 63 | } 64 | 65 | /** 66 | * 处理自定义异常 67 | * @param e 68 | * @return 69 | */ 70 | @ExceptionHandler({SystemErrorException.class}) 71 | @ResponseStatus(value = HttpStatus.OK) 72 | public Result baseException(BaseException e) { 73 | // 打印堆栈信息 74 | log.error(ExceptionUtils.getStackTrace(e)); 75 | return Result.failure(e.getCode(),e.getMessage()); 76 | } 77 | 78 | /** 79 | * 七牛云文件上传异常 80 | * @param e 81 | * @return 82 | */ 83 | @ExceptionHandler({QiniuException.class}) 84 | @ResponseStatus(value = HttpStatus.OK) 85 | public Result qiniuException(QiniuException e){ 86 | log.error(ExceptionUtils.getStackTrace(e)); 87 | return Result.failure(RestCode.SYS_ERROR_EXCEPTION.getCode(),e.response.getInfo()); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/exception/SystemErrorException.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.exception; 2 | 3 | import com.fzy.pms.entity.enums.RestCode; 4 | 5 | import java.util.Optional; 6 | 7 | /** 8 | * @program: SystemErrorException 9 | * @description: 异常内部异常 10 | * @author: fzy 11 | * @date: 2019/03/17 09:01:29 12 | **/ 13 | public class SystemErrorException extends BaseException { 14 | 15 | public SystemErrorException(String message) { 16 | super(Optional.ofNullable(message).orElse(RestCode.SYS_ERROR_EXCEPTION.getMessage())); 17 | this.code = RestCode.SYS_ERROR_EXCEPTION.getCode(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/AccountService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.AccountDetailDto; 4 | import com.fzy.pms.entity.dto.AccountDto; 5 | import com.fzy.pms.entity.pms.AccountDetail; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @program: AccountService 13 | * @description: 账户接口 14 | * @author: fzy 15 | * @date: 2019/05/21 21:52:50 16 | **/ 17 | public interface AccountService { 18 | 19 | /** 20 | * 查询全部账户 21 | * @param pageable 22 | * @return 23 | */ 24 | Page findAll(Pageable pageable); 25 | 26 | /** 27 | * 根据用户id 查询用户账户 28 | * @param userId 29 | * @return 30 | */ 31 | Page search(Long userId,Pageable pageable); 32 | 33 | /** 34 | * 账户充值 35 | * @param accountDetail 36 | */ 37 | void payment(AccountDetail accountDetail); 38 | 39 | /** 40 | * 充值报表查询 41 | * @param userId 42 | * @return 43 | */ 44 | List report(String userId); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * @program: BaseService 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/19 08:27:29 13 | **/ 14 | public interface BaseService { 15 | 16 | default Page findAll(Pageable pageableDefault){return null;} 17 | 18 | void create(T t); 19 | 20 | default void update(T t){} 21 | 22 | default void delete(Long t){} 23 | 24 | default T findOne(Long id){ return null;} 25 | 26 | default void batchDelete(Set ids){} 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/BuckerService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | /** 4 | * @program: BuckerService 5 | * @description: 6 | * @author: fzy 7 | * @date: 2019/07/20 08:30:33 8 | **/ 9 | public interface BuckerService { 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/CostSettingService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.pms.CostSetting; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @program: CostSettingService 11 | * @description: 12 | * @author: fzy 13 | * @date: 2019/04/17 23:19:51 14 | **/ 15 | public interface CostSettingService extends BaseService { 16 | 17 | Page findCostSetByNameLike(String name,Pageable pageable); 18 | 19 | List findAll(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/DoorService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.DoorDto; 4 | import com.fzy.pms.entity.pms.Door; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | /** 9 | * @program: DoorService 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/19 08:44:10 13 | **/ 14 | public interface DoorService extends BaseService { 15 | 16 | /** 17 | * 更新门禁状态 18 | * @param door 19 | * @return 20 | */ 21 | DoorDto updateDoorStatus(Door door); 22 | 23 | /** 24 | * 查询全部 25 | * @param pageable 26 | * @return 27 | */ 28 | Page findAllDto(Pageable pageable); 29 | 30 | /** 31 | * 查询用户的门禁 32 | * @param id 33 | * @param pageable 34 | * @return 35 | */ 36 | Page search(Long id,Pageable pageable); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/DownloadFileService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * @program: DownloadFileService 7 | * @description: 文件下载 8 | * @author: fzy 9 | * @date: 2019/07/20 08:12:20 10 | **/ 11 | public interface DownloadFileService { 12 | 13 | File downloadFile(String fileName); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/FileManageService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | /** 4 | * @program: FileManageService 5 | * @description: 6 | * @author: fzy 7 | * @date: 2019/07/21 11:40:47 8 | **/ 9 | public interface FileManageService { 10 | 11 | /** 12 | * 查看文件属性 13 | * @return 14 | */ 15 | String findProperties(); 16 | 17 | /** 18 | * 删除文件 19 | */ 20 | void deleteFile(); 21 | 22 | /** 23 | * 移动文件 24 | */ 25 | void moveFile(); 26 | 27 | /** 28 | * 复制文件 29 | */ 30 | void CopeyFile(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/HouseService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.pms.House; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | 7 | 8 | /** 9 | * @program: HouseService 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/09 13:37:37 13 | **/ 14 | public interface HouseService extends BaseService { 15 | 16 | Page findHouseByUserId(Long id,Pageable pageable); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.MenuDto; 4 | import com.fzy.pms.entity.security.Menu; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * @program: MenuService 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019-03-30 21:17 13 | **/ 14 | public interface MenuService { 15 | 16 | /** 17 | * 查询全部用户列表 18 | * @return 19 | */ 20 | Set findAllByMenuTree(); 21 | 22 | /** 23 | * 查询当前用户菜单列表 24 | * @return 25 | */ 26 | Set getCurrMenuTree(); 27 | 28 | /** 29 | * 创建菜单 30 | * @param menu 31 | * @return 32 | */ 33 | MenuDto create(Menu menu); 34 | 35 | /** 36 | * 更新菜单 37 | * @param menu 38 | */ 39 | void update(Menu menu); 40 | 41 | /** 42 | * 删除id 43 | * @param id 44 | */ 45 | void delete(Long id); 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/ParkService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.ParkDto; 4 | import com.fzy.pms.entity.pms.Park; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | /** 9 | * @program: ParkService 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/19 08:45:01 13 | **/ 14 | public interface ParkService extends BaseService { 15 | 16 | Page findAllDto(Pageable pageable); 17 | 18 | Page search(Long userId,Pageable pageable); 19 | 20 | ParkDto updateUseStatus(Park park); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/RepairsService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.RepairsDto; 4 | import com.fzy.pms.entity.dto.RepairsReportDto; 5 | import com.fzy.pms.entity.pms.Repairs; 6 | import com.fzy.pms.entity.vo.RepairVo; 7 | import org.springframework.data.domain.Page; 8 | import org.springframework.data.domain.Pageable; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @program: RepairsService 14 | * @description: 15 | * @author: fzy 16 | * @date: 2019/05/22 12:09:05 17 | **/ 18 | public interface RepairsService extends BaseService { 19 | 20 | Page findAllDto(Pageable pageable); 21 | 22 | /** 23 | * 开始派单 24 | * @param repairVo 25 | */ 26 | void startDispatch(RepairVo repairVo); 27 | 28 | /** 29 | * 结束订单 30 | * @param repairVo 31 | */ 32 | void endDispatch(RepairVo repairVo); 33 | 34 | /** 35 | * 订单中心搜索 36 | * @param userId 37 | * @param pageable 38 | * @return 39 | */ 40 | Page search(Long userId, Pageable pageable); 41 | 42 | /** 43 | * 报表查询 44 | * @param userId 45 | * @return 46 | */ 47 | List report(String userId); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.RoleDto; 4 | import com.fzy.pms.entity.security.Role; 5 | 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | /** 10 | * @program: RoleService 11 | * @description: 12 | * @author: fzy 13 | * @date: 2019-04-05 11:04 14 | **/ 15 | public interface RoleService { 16 | 17 | /** 18 | * 创建角色 19 | * @param role 20 | * @return 21 | */ 22 | Role create(Role role); 23 | 24 | /** 25 | * 更新角色 26 | * @param role 27 | */ 28 | void update(Role role); 29 | 30 | /** 31 | * 根据id 删除 菜单 32 | * @param id 33 | */ 34 | void delete(Long id); 35 | 36 | /** 37 | * 查询全部的角色 38 | * @return 39 | */ 40 | List findAll(); 41 | 42 | /** 43 | * 批量删除角色 44 | * @return 45 | */ 46 | int batchDelete(Set ids); 47 | 48 | /** 49 | * 角色模糊搜索 50 | * @param role 51 | * @return 52 | */ 53 | List search(String role); 54 | 55 | /** 56 | * 根据id 查询用户 57 | * @param id 58 | * @return 59 | */ 60 | Role findOne(Long id); 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/SettleService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.SettleDto; 4 | import com.fzy.pms.entity.pms.Settle; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @program: SettleService 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/05/23 08:32:41 13 | **/ 14 | public interface SettleService extends BaseService { 15 | 16 | /** 17 | * 充值报表查询 18 | * @param userId 19 | * @return 20 | */ 21 | List report(String userId); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/UploadFileService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.qiniu.common.QiniuException; 4 | 5 | /** 6 | * @program: uploadFileService 7 | * @description: 文件上传服务 8 | * @author: fzy 9 | * @date: 2019/07/19 23:38:47 10 | **/ 11 | public interface UploadFileService { 12 | 13 | 14 | /** 15 | * 后台返回文件上传时必须使用的token 16 | * 前端直接调用七牛云的服务器 17 | * @return 18 | */ 19 | String getAccessToken(); 20 | 21 | 22 | /** 23 | * 图片上传 24 | */ 25 | void uploadImage(); 26 | 27 | /** 28 | * 本地文件上传 29 | */ 30 | void localUpload(String filePath, String fileName) throws QiniuException; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service; 2 | 3 | import com.fzy.pms.entity.dto.UserDto; 4 | import com.fzy.pms.entity.security.User; 5 | import com.fzy.pms.entity.vo.UserVo; 6 | import org.springframework.security.core.userdetails.UserDetailsService; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | /** 12 | * @program: UserService 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019-04-05 15:23 16 | **/ 17 | public interface UserService extends UserDetailsService { 18 | 19 | /** 20 | * 查询当前用户信息 21 | * 22 | * @return 23 | */ 24 | Optional getCurrUserInfo(); 25 | 26 | /** 27 | * 注册用户 28 | * 29 | * @param user 30 | * @return 31 | */ 32 | User registerUser(User user); 33 | 34 | /** 35 | * 锁定用户 36 | * 37 | * @param id 38 | */ 39 | void lockUser(Long id); 40 | 41 | /** 42 | * 根据用户名查询用户 43 | * 44 | * @param Username 45 | * @return 46 | */ 47 | Optional getUserByUsername(String Username); 48 | 49 | /** 50 | * 查询全部用户列表 51 | * 52 | * @return 53 | */ 54 | List findAllListSortCreateTime(); 55 | 56 | /** 57 | * 更新用户信息 58 | * @param user 59 | * @return 60 | */ 61 | Boolean updateUserInfo(User user); 62 | 63 | /** 64 | * 模糊搜索 65 | * @param user 66 | * @return 67 | */ 68 | List search(User user); 69 | 70 | /** 71 | * 通过id 查询用户 72 | * @param id 73 | * @return 74 | */ 75 | Optional findUser(Long id); 76 | 77 | /** 78 | * 更新密码 79 | * @param userVo 80 | */ 81 | int updatePassword(UserVo userVo); 82 | 83 | 84 | /** 85 | * 重值密码 86 | * @param userId 87 | */ 88 | void resetPassword(Long userId); 89 | } -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/AccountServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.AccountDetailRepository; 4 | import com.fzy.pms.dao.UserRepository; 5 | import com.fzy.pms.entity.dto.AccountDetailDto; 6 | import com.fzy.pms.entity.dto.AccountDto; 7 | import com.fzy.pms.entity.pms.AccountDetail; 8 | import com.fzy.pms.entity.security.User; 9 | import com.fzy.pms.exception.SystemErrorException; 10 | import com.fzy.pms.service.AccountService; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.data.domain.Page; 14 | import org.springframework.data.domain.Pageable; 15 | import org.springframework.data.domain.Sort; 16 | import org.springframework.stereotype.Service; 17 | 18 | import javax.transaction.Transactional; 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | /** 23 | * @program: AccountServiceImpl 24 | * @description: 25 | * @author: fzy 26 | * @date: 2019/05/21 21:53:23 27 | **/ 28 | @Service 29 | public class AccountServiceImpl implements AccountService { 30 | 31 | @Autowired 32 | private UserRepository userRepository; 33 | 34 | @Autowired 35 | private AccountDetailRepository accountDetailRepository; 36 | 37 | @Override 38 | public Page findAll(Pageable pageable) { 39 | return userRepository.findAccountAll(pageable); 40 | } 41 | 42 | @Override 43 | public Page search(Long userId,Pageable pageable) { 44 | User user = userRepository.findById(userId).orElseThrow(() -> new SystemErrorException("用户不存在")); 45 | return userRepository.findAccountByUserId(user.getUsername(),pageable); 46 | } 47 | 48 | @Override 49 | @Transactional 50 | public synchronized void payment(AccountDetail accountDetail) { 51 | userRepository.findById(accountDetail.getUser().getId()).ifPresent(detail->{ 52 | detail.setBalance(detail.getBalance().add(accountDetail.getMoney())); 53 | userRepository.save(detail); 54 | }); 55 | //设置充值时间 56 | accountDetail.setRechargeTime(new Date()); 57 | accountDetailRepository.save(accountDetail); 58 | } 59 | 60 | @Override 61 | public List report(String userId) { 62 | Sort sort=new Sort(Sort.Direction.DESC,"createTime"); 63 | if(StringUtils.isBlank(userId) || userId.equals("null")){ 64 | return accountDetailRepository.findAllDto(sort); 65 | }else{ 66 | return accountDetailRepository.search(Long.parseLong(userId),sort); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/CostSettingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.CostSettingRepository; 4 | import com.fzy.pms.entity.pms.CostSetting; 5 | import com.fzy.pms.exception.SystemErrorException; 6 | import com.fzy.pms.service.CostSettingService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.domain.Page; 9 | import org.springframework.data.domain.Pageable; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @program: CostSettingServiceImpl 16 | * @description: 17 | * @author: fzy 18 | * @date: 2019/04/17 23:22:35 19 | **/ 20 | @Service 21 | public class CostSettingServiceImpl implements CostSettingService { 22 | 23 | @Autowired 24 | private CostSettingRepository costSettingRepository; 25 | 26 | @Override 27 | public Page findAll(Pageable pageableDefault) { 28 | return costSettingRepository.findAll(pageableDefault); 29 | } 30 | 31 | @Override 32 | public void create(CostSetting costSetting) { 33 | costSettingRepository.save(costSetting); 34 | } 35 | 36 | @Override 37 | public void update(CostSetting costSetting) { 38 | costSettingRepository.findById(costSetting.getId()).ifPresent(e->{ 39 | e.setCostName(costSetting.getCostName()); 40 | e.setCostPrice(costSetting.getCostPrice()); 41 | e.setRegular(costSetting.getRegular()); 42 | costSettingRepository.save(e); 43 | }); 44 | } 45 | 46 | @Override 47 | public void delete(Long id) { 48 | costSettingRepository.deleteById(id); 49 | } 50 | 51 | @Override 52 | public Page findCostSetByNameLike(String name,Pageable pageable) { 53 | Page costData = costSettingRepository.findCostSettingByCostNameLike("%" + name + "%", pageable); 54 | return costData; 55 | } 56 | 57 | @Override 58 | public CostSetting findOne(Long id) { 59 | return costSettingRepository.findById(id).orElseThrow(()->new SystemErrorException("费用不存在")); 60 | } 61 | 62 | @Override 63 | public List findAll() { 64 | return costSettingRepository.findAll(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/DoorServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.DoorRepository; 4 | import com.fzy.pms.entity.dto.DoorDto; 5 | import com.fzy.pms.entity.enums.UseStatus; 6 | import com.fzy.pms.entity.pms.Door; 7 | import com.fzy.pms.service.DoorService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.Objects; 14 | 15 | /** 16 | * @program: DoorServiceImpl 17 | * @description: 18 | * @author: fzy 19 | * @date: 2019/05/19 09:19:15 20 | **/ 21 | @Service 22 | public class DoorServiceImpl implements DoorService { 23 | 24 | @Autowired 25 | private DoorRepository doorRepository; 26 | 27 | @Override 28 | public Page findAllDto(Pageable pageable) { 29 | return doorRepository.findAllDto(pageable); 30 | } 31 | 32 | @Override 33 | public void create(Door door) { 34 | door.setUseStatus(UseStatus.ENABLED); 35 | doorRepository.save(door); 36 | } 37 | 38 | @Override 39 | public DoorDto updateDoorStatus(Door door) { 40 | doorRepository.updateuseStatus(door); 41 | return doorRepository.findOneById(door.getId()); 42 | } 43 | 44 | @Override 45 | public Page search(Long id, Pageable pageable) { 46 | return Objects.isNull(id)?findAllDto(pageable):doorRepository.search(id,pageable); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/FileServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.service.DownloadFileService; 4 | import com.fzy.pms.service.UploadFileService; 5 | import com.google.gson.Gson; 6 | import com.qiniu.common.QiniuException; 7 | import com.qiniu.common.Zone; 8 | import com.qiniu.http.Response; 9 | import com.qiniu.storage.Configuration; 10 | import com.qiniu.storage.UploadManager; 11 | import com.qiniu.storage.model.DefaultPutRet; 12 | import com.qiniu.util.Auth; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.springframework.beans.factory.annotation.Value; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.io.File; 18 | import java.io.UnsupportedEncodingException; 19 | import java.net.URLEncoder; 20 | 21 | /** 22 | * @program: UploadFileServiceImpl 23 | * @description: 24 | * @author: fzy 25 | * @date: 2019/07/19 23:40:03 26 | **/ 27 | @Service("fileService") 28 | @Slf4j 29 | public class FileServiceImpl implements UploadFileService, DownloadFileService { 30 | 31 | @Value("${qiniu.oos.AccessKey}") 32 | private String AccessKey; 33 | 34 | @Value("${qiniu.oos.SecretKey}") 35 | private String SecretKey; 36 | 37 | @Value("${qiniu.oos.bucket}") 38 | private String bucket; 39 | 40 | @Value("${qiniu.oos.domain}") 41 | private String domain; 42 | 43 | private Auth createAuth(){ 44 | Auth auth = Auth.create(AccessKey, SecretKey); 45 | return auth; 46 | } 47 | 48 | @Override 49 | public String getAccessToken(){ 50 | Auth auth = this.createAuth(); 51 | return auth.uploadToken(bucket); 52 | } 53 | @Override 54 | public void uploadImage() { 55 | String token = this.getAccessToken(); 56 | log.info(token); 57 | } 58 | 59 | @Override 60 | public void localUpload(String filePath, String fileName) throws QiniuException { 61 | Configuration cfg=new Configuration(Zone.zone0()); 62 | UploadManager uploadManager=new UploadManager(cfg); 63 | String accessToken = this.getAccessToken(); 64 | Response response = uploadManager.put(filePath, fileName, accessToken); 65 | DefaultPutRet defaultPutRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); 66 | log.debug("upload success key: {} , value: {} ",defaultPutRet.key,defaultPutRet.hash); 67 | } 68 | 69 | @Override 70 | public File downloadFile(String fileName) { 71 | Auth auth = this.createAuth(); 72 | try { 73 | String encodedFileName = URLEncoder.encode(fileName, "utf-8").replace("+", "%20"); 74 | String downUrl = String.format("%s/%s", domain, encodedFileName); 75 | String downloadUrl = auth.privateDownloadUrl(downUrl,60); 76 | log.info(downloadUrl); 77 | } catch (UnsupportedEncodingException e) { 78 | e.printStackTrace(); 79 | } 80 | return null; 81 | } 82 | 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/HouseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.HouseRepository; 4 | import com.fzy.pms.entity.pms.House; 5 | import com.fzy.pms.exception.SystemErrorException; 6 | import com.fzy.pms.service.HouseService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.domain.Page; 9 | import org.springframework.data.domain.Pageable; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.util.CollectionUtils; 12 | 13 | import java.util.Set; 14 | 15 | /** 16 | * @program: HouseServiceImpl 17 | * @description: 18 | * @author: fzy 19 | * @date: 2019/05/09 13:38:02 20 | **/ 21 | @Service 22 | public class HouseServiceImpl implements HouseService { 23 | 24 | @Autowired 25 | private HouseRepository houseRepository; 26 | 27 | @Override 28 | public Page findAll(Pageable pageableDefault) { 29 | Page all = houseRepository.findAll(pageableDefault); 30 | if(!CollectionUtils.isEmpty(all.getContent())){ 31 | all.getContent().forEach(detail->{ 32 | detail.setUsername(detail.getUser().getUsername()); 33 | }); 34 | } 35 | return all; 36 | } 37 | 38 | @Override 39 | public void create(House house) { 40 | houseRepository.save(house); 41 | } 42 | 43 | @Override 44 | public void update(House house) { 45 | houseRepository.findById(house.getId()).ifPresent(detail -> { 46 | detail.setUser(house.getUser()); 47 | detail.setStorey(house.getStorey()); 48 | detail.setCellName(house.getCellName()); 49 | detail.setPosition(house.getPosition()); 50 | houseRepository.save(detail); 51 | } 52 | ); 53 | } 54 | 55 | @Override 56 | public void delete(Long id) { 57 | houseRepository.deleteById(id); 58 | } 59 | 60 | @Override 61 | public Page findHouseByUserId(Long id,Pageable pageable) { 62 | Page all = houseRepository.findHouseByUserId(id,pageable); 63 | if(!CollectionUtils.isEmpty(all.getContent())){ 64 | all.getContent().forEach(detail->{ 65 | detail.setUsername(detail.getUser().getUsername()); 66 | }); 67 | } 68 | return all; 69 | } 70 | 71 | @Override 72 | public House findOne(Long id) { 73 | House house = houseRepository.findById(id).orElseThrow(() -> new SystemErrorException("房产信息不存在")); 74 | house.setUsername(house.getUser().getId()+""); 75 | return house; 76 | } 77 | 78 | @Override 79 | public void batchDelete(Set ids) { 80 | houseRepository.deleteInBatch(ids); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/MenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.MenuRepository; 4 | import com.fzy.pms.entity.dto.MenuDto; 5 | import com.fzy.pms.entity.dto.UserDto; 6 | import com.fzy.pms.entity.mapper.MenuMapper; 7 | import com.fzy.pms.entity.security.Menu; 8 | import com.fzy.pms.exception.SystemErrorException; 9 | import com.fzy.pms.service.MenuService; 10 | import com.fzy.pms.service.UserService; 11 | import org.springframework.beans.BeanUtils; 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 org.springframework.util.CollectionUtils; 17 | import org.thymeleaf.util.ListUtils; 18 | 19 | import javax.annotation.Resource; 20 | import java.util.*; 21 | import java.util.stream.Collectors; 22 | 23 | /** 24 | * @program: MenuServiceImpl 25 | * @description: 26 | * @author: fzy 27 | * @date: 2019-03-30 21:24 28 | **/ 29 | @Service 30 | @Transactional(propagation = Propagation.SUPPORTS,readOnly = true,rollbackFor ={RuntimeException.class,Exception.class}) 31 | public class MenuServiceImpl implements MenuService { 32 | 33 | @Autowired 34 | private MenuRepository menuRepository; 35 | 36 | @Resource 37 | private MenuMapper menuMapper; 38 | 39 | @Autowired 40 | private UserService userService; 41 | 42 | @Override 43 | public Set findAllByMenuTree() { 44 | //分组后的menu列表 45 | Map> menuList = menuRepository.findAll() 46 | .stream().collect(Collectors.groupingBy(Menu::getPid)); 47 | return createTree(0L,menuList); 48 | } 49 | 50 | @Override 51 | public Set getCurrMenuTree() { 52 | if(userService.getCurrUserInfo().isPresent()){ 53 | UserDto userInfo = userService.getCurrUserInfo().get(); 54 | List menus = menuRepository.findByRole(userInfo.getRole().getId()); 55 | if(!ListUtils.isEmpty(menus)){ 56 | Map> listMenu = menus.stream().collect(Collectors.groupingBy(Menu::getPid)); 57 | return createTree(0L, listMenu); 58 | }else { 59 | return Collections.emptySet(); 60 | } 61 | } 62 | throw new SystemErrorException("当前用户不存在!!!"); 63 | } 64 | 65 | @Override 66 | public MenuDto create(Menu menu) { 67 | return menuMapper.toDto(menuRepository.save(menu)); 68 | } 69 | 70 | @Override 71 | public void update(Menu menu) { 72 | Optional optional = menuRepository.findById(menu.getId()); 73 | optional.ifPresent(e->{ 74 | e.setComponent(menu.getComponent()); 75 | e.setIcon(menu.getIcon()); 76 | e.setName(menu.getName()); 77 | e.setPath(menu.getPath()); 78 | e.setPid(menu.getPid()); 79 | menuRepository.save(e); 80 | }); 81 | } 82 | 83 | @Override 84 | public void delete(Long id) { 85 | //1.查询全部子菜单 86 | List menuList = menuRepository.findByPid(id); 87 | //2.删除子菜单 88 | menuList.forEach(e->{ 89 | menuRepository.delete(e); 90 | }); 91 | //3.删除父菜单 92 | menuRepository.deleteById(id); 93 | } 94 | 95 | /** 96 | * 构建菜单树 97 | * @param parentId 98 | * @param menus 99 | * @return 100 | */ 101 | private Set createTree(Long parentId, Map> menus){ 102 | return menus.get(parentId).stream().map(e -> { 103 | MenuDto menuDTO = new MenuDto(); 104 | BeanUtils.copyProperties(e, menuDTO); 105 | if (!Objects.isNull(menus.get(e.getId()))) { 106 | menuDTO.setChildren(createTree(e.getId(), menus)); 107 | } 108 | return menuDTO; 109 | }).collect(Collectors.toCollection(TreeSet::new)); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/ParkServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.ParkRepository; 4 | import com.fzy.pms.entity.dto.ParkDto; 5 | import com.fzy.pms.entity.enums.UseStatus; 6 | import com.fzy.pms.entity.pms.Park; 7 | import com.fzy.pms.service.ParkService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.stereotype.Service; 12 | 13 | /** 14 | * @program: ParkServiceImpl 15 | * @description: 16 | * @author: fzy 17 | * @date: 2019/05/20 19:05:12 18 | **/ 19 | @Service 20 | public class ParkServiceImpl implements ParkService { 21 | 22 | @Autowired 23 | private ParkRepository parkRepository; 24 | 25 | @Override 26 | public void create(Park park) { 27 | park.setUseStatus(UseStatus.ENABLED); 28 | parkRepository.save(park); 29 | } 30 | 31 | @Override 32 | public Page findAllDto(Pageable pageable) { 33 | return parkRepository.findAllDto(pageable); 34 | } 35 | 36 | @Override 37 | public Page search(Long userId, Pageable pageable) { 38 | return parkRepository.search(userId,pageable); 39 | } 40 | 41 | @Override 42 | public ParkDto updateUseStatus(Park park) { 43 | parkRepository.updateUseStatus(park); 44 | return parkRepository.findOne(park.getId()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/RepairsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.RepairsRepository; 4 | import com.fzy.pms.dao.UserRepository; 5 | import com.fzy.pms.entity.dto.RepairsDto; 6 | import com.fzy.pms.entity.dto.RepairsReportDto; 7 | import com.fzy.pms.entity.enums.RepairsStatus; 8 | import com.fzy.pms.entity.pms.Repairs; 9 | import com.fzy.pms.entity.vo.RepairVo; 10 | import com.fzy.pms.service.RepairsService; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.data.domain.Page; 14 | import org.springframework.data.domain.Pageable; 15 | import org.springframework.data.domain.Sort; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.transaction.annotation.Transactional; 18 | 19 | import java.util.Date; 20 | import java.util.List; 21 | 22 | /** 23 | * @program: RepairsServiceImpl 24 | * @description: 25 | * @author: fzy 26 | * @date: 2019/05/22 12:09:25 27 | **/ 28 | @Service 29 | public class RepairsServiceImpl implements RepairsService { 30 | 31 | @Autowired 32 | private RepairsRepository repairsRepository; 33 | 34 | @Autowired 35 | private UserRepository userRepository; 36 | 37 | @Override 38 | public void create(Repairs repairs) { 39 | repairs.setRepairsStatus(RepairsStatus.NOT); 40 | repairs.setRepairsDate(new Date()); 41 | repairs.setRepairsBillNo("BX"+System.currentTimeMillis()); 42 | repairsRepository.save(repairs); 43 | } 44 | 45 | @Override 46 | public Page findAllDto(Pageable pageable) { 47 | return repairsRepository.findAllDto(pageable); 48 | } 49 | 50 | @Override 51 | public void startDispatch(RepairVo repairVo) { 52 | repairsRepository.findById(repairVo.getId()).ifPresent(detail ->{ 53 | detail.setRepairsStatus(RepairsStatus.ING); 54 | detail.setRepairsPrice(repairVo.getRepairsPrice()); 55 | repairsRepository.save(detail); 56 | }); 57 | } 58 | 59 | @Override 60 | @Transactional 61 | public void endDispatch(RepairVo repairVo) { 62 | repairsRepository.findById(repairVo.getId()).ifPresent(detail ->{ 63 | detail.setRepairsStatus(RepairsStatus.YES); 64 | detail.setFinishDate(new Date()); 65 | userRepository.findById(detail.getUser().getId()).ifPresent(user ->{ 66 | user.setBalance(user.getBalance().subtract(detail.getRepairsPrice())); 67 | userRepository.save(user); 68 | }); 69 | repairsRepository.save(detail); 70 | }); 71 | } 72 | 73 | @Override 74 | public Page search(Long userId, Pageable pageable) { 75 | return repairsRepository.search(userId,pageable); 76 | } 77 | 78 | @Override 79 | public List report(String userId) { 80 | Sort sort = new Sort(Sort.Direction.DESC, "createTime"); 81 | if(StringUtils.isBlank(userId)||userId.equals("null")){ 82 | return repairsRepository.findAllReportDto(sort); 83 | }else { 84 | return repairsRepository.report(Long.parseLong(userId),sort); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.RoleRepository; 4 | import com.fzy.pms.dao.UserRepository; 5 | import com.fzy.pms.entity.dto.MenuDto; 6 | import com.fzy.pms.entity.dto.RoleDto; 7 | import com.fzy.pms.entity.mapper.RoleMapper; 8 | import com.fzy.pms.entity.security.Menu; 9 | import com.fzy.pms.entity.security.Role; 10 | import com.fzy.pms.entity.security.User; 11 | import com.fzy.pms.exception.SystemErrorException; 12 | import com.fzy.pms.service.MenuService; 13 | import com.fzy.pms.service.RoleService; 14 | import com.google.common.collect.Lists; 15 | import com.google.common.collect.Maps; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.data.domain.Sort; 18 | import org.springframework.stereotype.Service; 19 | import org.springframework.transaction.annotation.Transactional; 20 | import org.thymeleaf.util.ListUtils; 21 | import org.thymeleaf.util.SetUtils; 22 | 23 | import javax.annotation.Resource; 24 | import java.util.*; 25 | import java.util.stream.Collectors; 26 | import java.util.stream.Stream; 27 | 28 | /** 29 | * @program: RoleServiceImpl 30 | * @description: 31 | * @author: fzy 32 | * @date: 2019-04-05 11:10 33 | **/ 34 | @Service 35 | public class RoleServiceImpl implements RoleService { 36 | 37 | @Autowired 38 | private RoleRepository roleRepository; 39 | 40 | @Autowired 41 | private UserRepository userRepository; 42 | 43 | @Autowired 44 | private MenuService menuService; 45 | 46 | @Resource 47 | private RoleMapper roleMapper; 48 | 49 | @Override 50 | public Role create(Role role) { 51 | if(roleRepository.findRoleByName(role.getName()).isPresent()){ 52 | throw new SystemErrorException("角色名称已存在"); 53 | } 54 | return roleRepository.save(role); 55 | } 56 | 57 | @Override 58 | public void update(Role role) { 59 | roleRepository.findRoleByName(role.getName()).ifPresent(dbRole ->{ 60 | if(!dbRole.getId().equals(role.getId())){ 61 | throw new SystemErrorException("角色名称已存在"); 62 | } 63 | }); 64 | roleRepository.findById(role.getId()).ifPresent(roles ->{ 65 | roles.setName(role.getName()); 66 | roles.setRemark(role.getRemark()); 67 | roles.setMenus(role.getMenus()); 68 | roleRepository.save(roles); 69 | }); 70 | } 71 | 72 | @Override 73 | public void delete(Long id) { 74 | roleRepository.deleteById(id); 75 | } 76 | 77 | @Override 78 | public List findAll() { 79 | Sort sort=new Sort(Sort.Direction.DESC, Collections.singletonList("id")); 80 | List list = roleMapper.toDto(roleRepository.findAll(sort)); 81 | Map map = getCiteNum(list); 82 | list.forEach(role->{ 83 | role.setCiteNum(Objects.isNull(map.get(role.getId()))?0:map.get(role.getId())); 84 | }); 85 | return list; 86 | } 87 | 88 | @Override 89 | public int batchDelete(Set ids) { 90 | if(SetUtils.isEmpty(ids)){ 91 | throw new SystemErrorException("ids 不能为空"); 92 | } 93 | return roleRepository.deleteRoleByIdIn(ids)==ids.size()?ids.size():0; 94 | } 95 | 96 | @Override 97 | public List search(String name) { 98 | Sort sort=new Sort(Sort.Direction.DESC, Collections.singletonList("id")); 99 | List list = roleMapper.toDto(roleRepository.findRoleByNameLike("%" + name + "%",sort)); 100 | Map map = getCiteNum(list); 101 | list.forEach(roles->{ 102 | roles.setCiteNum(Objects.isNull(map.get(roles.getId()))?0:map.get(roles.getId())); 103 | }); 104 | return list; 105 | } 106 | 107 | /** 108 | * 获取当前角色的用户应用数 109 | * @return 110 | */ 111 | private Map getCiteNum(List list){ 112 | List userList = userRepository.findAll(); 113 | Map map= Maps.newHashMapWithExpectedSize(list.size()); 114 | userList.forEach(user->{ 115 | Long id=user.getRole().getId(); 116 | Integer num = map.get(id); 117 | map.put(id, num == null ? 1 : num + 1); 118 | }); 119 | return map; 120 | } 121 | 122 | @Override 123 | public Role findOne(Long id) { 124 | if(Objects.isNull(id)){ 125 | throw new SystemErrorException("id 不能为空"); 126 | } 127 | Role role = roleRepository.findById(id).orElseThrow(() ->new SystemErrorException("用户不存在")); 128 | if(!SetUtils.isEmpty(role.getMenus())){ 129 | Set menus = role.getMenus().stream().filter(item -> item.getPid() != 0L).collect(Collectors.toSet()); 130 | role.setMenus(menus); 131 | } 132 | return role; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/SettleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.CostSettingRepository; 4 | import com.fzy.pms.dao.SettleRepository; 5 | import com.fzy.pms.dao.UserRepository; 6 | import com.fzy.pms.entity.dto.AccountDetailDto; 7 | import com.fzy.pms.entity.dto.SettleDto; 8 | import com.fzy.pms.entity.pms.CostSetting; 9 | import com.fzy.pms.entity.pms.Settle; 10 | import com.fzy.pms.exception.SystemErrorException; 11 | import com.fzy.pms.service.SettleService; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.data.domain.Sort; 15 | import org.springframework.stereotype.Service; 16 | import org.springframework.transaction.annotation.Transactional; 17 | 18 | import java.math.BigDecimal; 19 | import java.util.Collections; 20 | import java.util.Date; 21 | import java.util.List; 22 | 23 | /** 24 | * @program: SettleServiceImpl 25 | * @description: 26 | * @author: fzy 27 | * @date: 2019/05/23 08:32:51 28 | **/ 29 | @Service 30 | public class SettleServiceImpl implements SettleService { 31 | 32 | @Autowired 33 | private SettleRepository settleRepository; 34 | 35 | @Autowired 36 | private UserRepository userRepository; 37 | 38 | @Autowired 39 | private CostSettingRepository costSettingRepository; 40 | 41 | @Override 42 | @Transactional 43 | public synchronized void create(Settle settle) { 44 | userRepository.findById(settle.getUser().getId()).ifPresent(user ->{ 45 | CostSetting costSetting = costSettingRepository.findById(settle.getCostSetting().getId()).orElseThrow(() -> new SystemErrorException("费用不存在")); 46 | BigDecimal total = costSetting.getCostPrice().multiply(settle.getMultiple()); 47 | settle.setTotalPrice(total); 48 | user.setBalance(user.getBalance().subtract(total)); 49 | userRepository.save(user); 50 | }); 51 | settle.setSettingDate(new Date()); 52 | settleRepository.save(settle); 53 | } 54 | 55 | @Override 56 | public List report(String userId) { 57 | Sort sort=new Sort(Sort.Direction.DESC,"createTime"); 58 | if(StringUtils.isBlank(userId) || userId.equals("null")){ 59 | return costSettingRepository.findAllReportDto(sort); 60 | }else{ 61 | return costSettingRepository.report(Long.parseLong(userId),sort); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.impl; 2 | 3 | import com.fzy.pms.dao.RoleRepository; 4 | import com.fzy.pms.dao.UserRepository; 5 | import com.fzy.pms.entity.dto.UserDto; 6 | import com.fzy.pms.entity.enums.UseStatus; 7 | import com.fzy.pms.entity.mapper.UserMapper; 8 | import com.fzy.pms.entity.security.User; 9 | import com.fzy.pms.entity.vo.UserVo; 10 | import com.fzy.pms.exception.SystemErrorException; 11 | import com.fzy.pms.service.UserService; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.beans.factory.annotation.Value; 15 | import org.springframework.data.domain.Sort; 16 | import org.springframework.data.jpa.domain.Specification; 17 | import org.springframework.security.core.Authentication; 18 | import org.springframework.security.core.context.SecurityContextHolder; 19 | import org.springframework.security.core.userdetails.UserDetails; 20 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 21 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 22 | import org.springframework.stereotype.Service; 23 | 24 | import javax.annotation.Resource; 25 | import javax.persistence.criteria.Predicate; 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import java.util.Objects; 29 | import java.util.Optional; 30 | 31 | /** 32 | * @program: UserServiceImpl 33 | * @description: 34 | * @author: fzy 35 | * @date: 2019/03/16 18:46:52 36 | **/ 37 | 38 | @Service("userService") 39 | public class UserServiceImpl implements UserService { 40 | 41 | @Autowired 42 | private UserRepository userRepository; 43 | 44 | @Autowired 45 | private RoleRepository roleRepository; 46 | 47 | @Autowired 48 | private BCryptPasswordEncoder bCryptPasswordEncoder; 49 | 50 | @Resource 51 | private UserMapper userMapper; 52 | 53 | @Value("${sys.initPassword}") 54 | private String INIT_PASSWORD; 55 | 56 | @Override 57 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 58 | return userRepository.findByUsername(username).orElseGet(()-> { 59 | throw new UsernameNotFoundException("用户名不存在"); 60 | }); 61 | } 62 | 63 | @Override 64 | public Optional getCurrUserInfo(){ 65 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); 66 | if(!Objects.isNull(authentication)){ 67 | return Optional.ofNullable(userMapper.toDto((User) authentication.getPrincipal())); 68 | } 69 | return Optional.empty(); 70 | } 71 | 72 | @Override 73 | public User registerUser(User user){ 74 | //密码加密 75 | user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); 76 | if (userRepository.findByUsername(user.getUsername()).isPresent()){ 77 | throw new SystemErrorException("用户名已存在"); 78 | } 79 | 80 | if(Objects.isNull(user.getRole())){ 81 | throw new SystemErrorException("角色不能为空"); 82 | } 83 | roleRepository.findById(user.getRole().getId()) 84 | .orElseThrow(()->new SystemErrorException("角色不存在")); 85 | return userRepository.save(user); 86 | } 87 | 88 | @Override 89 | public void lockUser(Long id){ 90 | userRepository.findById(id).ifPresent(user->{ 91 | switch (user.getUseStatus()){ 92 | case ENABLED: 93 | user.setUseStatus(UseStatus.DISABLED); 94 | break; 95 | case DISABLED: 96 | user.setUseStatus(UseStatus.ENABLED); 97 | break; 98 | } 99 | userRepository.save(user); 100 | }); 101 | } 102 | 103 | @Override 104 | public Optional getUserByUsername(String Username){ 105 | if (StringUtils.isNotBlank(Username)){ 106 | return userRepository.findByUsername(Username); 107 | } 108 | return Optional.empty(); 109 | } 110 | 111 | @Override 112 | public List findAllListSortCreateTime() { 113 | Sort sort=new Sort(Sort.Direction.DESC,"createTime"); 114 | return userMapper.toDto(userRepository.findAll(sort)); 115 | } 116 | 117 | @Override 118 | public Boolean updateUserInfo(User user) { 119 | //查询用户名是否存在 120 | Optional dbUser = userRepository.findByUsername(user.getUsername()); 121 | if(dbUser.isPresent()){ 122 | if(!dbUser.get().getId().equals(user.getId())){ 123 | return false; 124 | } 125 | } 126 | userRepository.findById(user.getId()).ifPresent(detail ->{ 127 | detail.setUsername(user.getUsername()); 128 | detail.setRealName(user.getRealName()); 129 | detail.setPhone(user.getPhone()); 130 | detail.setEmail(user.getEmail()); 131 | detail.setRole(user.getRole()); 132 | userRepository.save(detail); 133 | }); 134 | return true; 135 | } 136 | 137 | @Override 138 | public List search(User user) { 139 | List list = userRepository.findAll((Specification) (root, query, criteriaBuilder) -> { 140 | List predicates = new ArrayList<>(); 141 | if (StringUtils.isNotBlank(user.getRealName())) { 142 | predicates.add(criteriaBuilder.like(root.get("realName"), "%" + user.getRealName() + "%")); 143 | } 144 | 145 | if (StringUtils.isNotBlank((user.getPhone()))){ 146 | predicates.add(criteriaBuilder.like(root.get("phone"), user.getPhone() + "%")); 147 | } 148 | 149 | if (StringUtils.isNotBlank((user.getEmail()))){ 150 | predicates.add(criteriaBuilder.like(root.get("email"), user.getEmail() + "%")); 151 | } 152 | 153 | if(!Objects.isNull(user.getRole().getId())){ 154 | predicates.add((criteriaBuilder.equal(root.get("role"), user.getRole()))); 155 | } 156 | 157 | return criteriaBuilder.and(predicates.toArray(new Predicate[0])); 158 | }, new Sort(Sort.Direction.DESC, "createTime")); 159 | return userMapper.toDto(list); 160 | } 161 | 162 | @Override 163 | public Optional findUser(Long id) { 164 | Optional user = userRepository.findById(id); 165 | return user.map(userMapper::toDto); 166 | } 167 | 168 | @Override 169 | public int updatePassword(UserVo userVo) { 170 | User user = userRepository.findById(userVo.getId()).orElseThrow(()-> new SystemErrorException("用户不存在")); 171 | if(bCryptPasswordEncoder.matches(userVo.oldPassword,user.getPassword())){ 172 | //密码加密 173 | user.setPassword(bCryptPasswordEncoder.encode(userVo.getNewPassword())); 174 | userRepository.save(user); 175 | return 0; 176 | }else { 177 | return -1; 178 | } 179 | } 180 | 181 | @Override 182 | public void resetPassword(Long userId) { 183 | userRepository.findById(userId).ifPresent(user ->{ 184 | user.setPassword(bCryptPasswordEncoder.encode(INIT_PASSWORD)); 185 | userRepository.save(user); 186 | }); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/service/job/HelloWordJob.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.service.job; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.quartz.JobExecutionContext; 5 | import org.springframework.scheduling.quartz.QuartzJobBean; 6 | 7 | /** 8 | * @program: HelloWordJob 9 | * @description: 10 | * @author: fzy 11 | * @date: 2019/06/13 11:40:16 12 | **/ 13 | @Slf4j 14 | public class HelloWordJob extends QuartzJobBean { 15 | 16 | @Override 17 | protected void executeInternal(JobExecutionContext context){ 18 | log.info("say Hello {}",context); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/utils/CalculatorUnit.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.utils; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * @program: CalculatorUnit 7 | * @description: 数据计算工具类 8 | * @author: fzy 9 | * @date: 2019-04-19 20:18 10 | **/ 11 | public class CalculatorUnit { 12 | 13 | /** 14 | * 计算两个数之和 15 | * @param sum 16 | * @param addend 17 | * @return 和值 18 | */ 19 | public static BigDecimal sum (BigDecimal sum, BigDecimal addend) { 20 | return sum.add(addend); 21 | } 22 | 23 | /** 24 | * 计算两个数之差 25 | * @param minuend 26 | * @param subtrahend 27 | * @return 28 | */ 29 | public static BigDecimal sub (BigDecimal minuend, BigDecimal subtrahend) { 30 | return minuend.subtract(subtrahend); 31 | } 32 | 33 | /** 34 | * 计算两个数积 35 | * @param multiplicand 36 | * @param multiplier 37 | * @return 38 | */ 39 | public static BigDecimal mulPlus(BigDecimal multiplicand, BigDecimal multiplier) { 40 | return multiplicand.multiply(multiplier); 41 | } 42 | 43 | /** 44 | * 计算两个数商 45 | * @param dividend 46 | * @param divisor 47 | * @return 48 | */ 49 | public static BigDecimal div(BigDecimal dividend, BigDecimal divisor) { 50 | if(0 == divisor.compareTo(BigDecimal.ZERO)){ 51 | return BigDecimal.ZERO; 52 | } 53 | return dividend.divide(divisor); 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/utils/JwtTokenUtil.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.utils; 2 | 3 | import com.fzy.pms.entity.security.JwtToken; 4 | import com.fzy.pms.entity.security.User; 5 | import io.jsonwebtoken.Claims; 6 | import io.jsonwebtoken.Jwts; 7 | import io.jsonwebtoken.SignatureAlgorithm; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.io.Serializable; 13 | import java.time.LocalDate; 14 | import java.time.LocalDateTime; 15 | import java.time.LocalTime; 16 | import java.util.Calendar; 17 | import java.util.Date; 18 | import java.util.Objects; 19 | 20 | /** 21 | * @program: JwtTokenUtil 22 | * @description: jwt 工具类 23 | * @author: fzy 24 | * @date: 2019/03/23 10:41:23 25 | **/ 26 | @Component 27 | @Slf4j 28 | public class JwtTokenUtil implements Serializable { 29 | 30 | @Value("${jwt.expiration}") 31 | private int expiration; 32 | 33 | @Value("${jwt.time-out}") 34 | private int timeOUt; 35 | 36 | @Value("${jwt.secret}") 37 | private String SECRET; 38 | 39 | public JwtToken generateToken(User user) { 40 | return generateToken(user.getUsername()); 41 | } 42 | 43 | /** 44 | * 生成 Token 45 | * @param username 数据 46 | * @return 令牌 47 | */ 48 | private JwtToken generateToken(String username){ 49 | 50 | Calendar instance = Calendar.getInstance(); 51 | 52 | instance.add(Calendar.MINUTE,expiration); 53 | 54 | String accessToken = Jwts.builder() 55 | .setHeaderParam("typ", "JWT") 56 | .setSubject(username) 57 | .setExpiration(instance.getTime()) 58 | .setIssuedAt(new Date(System.currentTimeMillis())) //签发时间 59 | .signWith(SignatureAlgorithm.HS512, SECRET) 60 | .compact(); 61 | 62 | instance.add(Calendar.MINUTE,timeOUt); 63 | String refreshToken = Jwts.builder() 64 | .setHeaderParam("typ", "JWT") 65 | .setSubject(username) 66 | .setExpiration(instance.getTime()) 67 | .setIssuedAt(new Date(System.currentTimeMillis())) //签发时间 68 | .signWith(SignatureAlgorithm.HS512, SECRET) 69 | .compact(); 70 | 71 | return new JwtToken().setAccessToken(accessToken).setRefreshToken(refreshToken); 72 | } 73 | 74 | /** 75 | * 查询用户名 76 | * @param jwtToken 77 | * @return 78 | */ 79 | public String getUsernameFromToken(JwtToken jwtToken){ 80 | Claims claims = this.parseToken(jwtToken.getAccessToken()); 81 | if(!Objects.isNull(claims)){ 82 | return claims.getSubject(); 83 | } 84 | return null; 85 | } 86 | 87 | /** 88 | * 解析Token 89 | * @param token 90 | * @return 91 | */ 92 | private Claims parseToken(String token){ 93 | try { 94 | return Jwts.parser() 95 | .setSigningKey(SECRET) 96 | .parseClaimsJws(token) 97 | .getBody(); 98 | }catch (Exception e){ 99 | return null; 100 | } 101 | } 102 | 103 | /** 104 | * 刷新token 105 | * @param token 106 | * @return 107 | */ 108 | public JwtToken refreshToken(JwtToken token){ 109 | Claims claims = parseToken(token.getRefreshToken()); 110 | if(!Objects.isNull(claims)){ 111 | return this.generateToken(claims.getSubject()); 112 | } 113 | return null; 114 | } 115 | 116 | /** 117 | * 判断token是否过期 118 | * @param token 119 | * @return 120 | */ 121 | public Boolean isTokenExpired(String token) { 122 | Claims claims = parseToken(token); 123 | if(!Objects.isNull(claims)){ 124 | return claims.getExpiration().before(new Date()); 125 | } 126 | return true; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/utils/ResponseUtil.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.fzy.pms.entity.rest.Result; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import javax.servlet.ServletResponse; 8 | import java.io.PrintWriter; 9 | 10 | /** 11 | * @program: ResponseUtil 12 | * @description: 13 | * @author: fzy 14 | * @date: 2019/03/23 18:32:39 15 | **/ 16 | @Slf4j 17 | public class ResponseUtil { 18 | 19 | /** 20 | * 使用response输出JSON 21 | * @param response 22 | * @param result 23 | */ 24 | public static void out(ServletResponse response,Result result){ 25 | PrintWriter out = null; 26 | try { 27 | response.setContentType("application/json;charset=UTF-8"); 28 | out = response.getWriter(); 29 | out.println(JSON.toJSON(result)); 30 | } catch (Exception e) { 31 | log.error(e + "输出JSON出错"); 32 | }finally{ 33 | if(out!=null){ 34 | out.flush(); 35 | out.close(); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.web.PageableHandlerMethodArgumentResolver; 6 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 7 | import org.springframework.web.servlet.config.annotation.*; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @program: InterceptorConfig 13 | * @description: 配置拦截器 14 | * @author: fzy 15 | * @date: 2019/03/16 21:26:27 16 | **/ 17 | @Configuration 18 | public class InterceptorConfig extends WebMvcConfigurationSupport { 19 | 20 | @Autowired 21 | private TimeInterceptor timeInterceptor; 22 | 23 | @Override 24 | public void addInterceptors(InterceptorRegistry registry) { 25 | registry.addInterceptor(timeInterceptor); 26 | } 27 | 28 | @Override 29 | protected void addResourceHandlers(ResourceHandlerRegistry registry) { 30 | registry.addResourceHandler("/**") 31 | .addResourceLocations("classpath:/static/"); 32 | registry.addResourceHandler("swagger-ui.html") 33 | .addResourceLocations("classpath:/META-INF/resources/"); 34 | registry.addResourceHandler("/webjars/**") 35 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 36 | } 37 | 38 | @Override 39 | protected void addViewControllers(ViewControllerRegistry registry) { 40 | registry.addViewController("/login").setViewName("login"); 41 | } 42 | 43 | @Override 44 | protected void addCorsMappings(CorsRegistry registry) { 45 | //设置允许跨域的路径 46 | registry.addMapping("/**") 47 | //设置允许跨域请求的域名 48 | .allowedOrigins("*") 49 | //是否允许证书 不再默认开启 50 | .allowCredentials(true) 51 | //设置允许的方法 52 | .allowedMethods("GET", "POST", "PUT", "DELETE") 53 | //允许所有的请求header访问 54 | .allowedHeaders("*") 55 | //跨域允许时间 56 | .maxAge(3600); 57 | } 58 | 59 | @Override 60 | protected void addArgumentResolvers(List argumentResolvers) { 61 | // 注册Spring data jpa pageable的参数分解器 62 | argumentResolvers.add(new PageableHandlerMethodArgumentResolver()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/QuartzConfig.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config; 2 | 3 | import com.fzy.pms.service.job.HelloWordJob; 4 | import org.quartz.*; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @program: QuartzConfig 10 | * @description: 11 | * @author: fzy 12 | * @date: 2019/06/13 11:13:47 13 | **/ 14 | @Configuration 15 | public class QuartzConfig { 16 | 17 | @Bean 18 | public JobDetail helloJobDetail(){ 19 | return JobBuilder.newJob(HelloWordJob.class) 20 | .withIdentity("myJob","myGroup") 21 | .usingJobData("","") 22 | .storeDurably() 23 | .build(); 24 | } 25 | 26 | //@Bean 27 | public Trigger helloJobTrigger(){ 28 | return TriggerBuilder.newTrigger().forJob(helloJobDetail()) 29 | .startNow() 30 | .withSchedule(CronScheduleBuilder.cronSchedule("1/5 * * * * ?")) 31 | .build(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/TimeInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.servlet.HandlerInterceptor; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * @program: TimeInterceptor 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/03/16 20:43:27 16 | **/ 17 | @Component 18 | @Slf4j 19 | public class TimeInterceptor implements HandlerInterceptor { 20 | 21 | @Override 22 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 23 | request.setAttribute("statTime",System.currentTimeMillis()); 24 | return true; 25 | } 26 | 27 | @Override 28 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 29 | Long statTime = (Long) request.getAttribute("statTime"); 30 | log.info(request.getRequestURI()+"总共耗时"+ (System.currentTimeMillis()-statTime)+"ms"); 31 | } 32 | 33 | @Override 34 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/redis/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.redis; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.PropertyAccessor; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.redis.connection.RedisConnectionFactory; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 12 | import org.springframework.data.redis.serializer.StringRedisSerializer; 13 | 14 | /** 15 | * @program: RedisConfig 16 | * @description: 17 | * @author: fzy 18 | * @date: 2019/03/29 22:29:58 19 | **/ 20 | @Configuration 21 | public class RedisConfig { 22 | 23 | /** 24 | * 设置 redisTemplate 的序列化设置 25 | * @param redisConnectionFactory 26 | * @return 27 | */ 28 | @Bean 29 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { 30 | // 1.创建 redisTemplate 模版 31 | RedisTemplate template = new RedisTemplate<>(); 32 | // 2.关联 redisConnectionFactory 33 | template.setConnectionFactory(redisConnectionFactory); 34 | // 3.创建 序列化类 35 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 36 | ObjectMapper om = new ObjectMapper(); 37 | // 4.设置可见度 38 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 39 | // 5.启动默认的类型 40 | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 41 | // 6.序列化类,对象映射设置 42 | jackson2JsonRedisSerializer.setObjectMapper(om); 43 | // 7.设置 value 的转化格式和 key 的转化格式 44 | template.setValueSerializer(jackson2JsonRedisSerializer); 45 | template.setKeySerializer(new StringRedisSerializer()); 46 | template.afterPropertiesSet(); 47 | return template; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/JwtTokenFilter.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.cache.TokenCache; 4 | import com.fzy.pms.entity.enums.RestCode; 5 | import com.fzy.pms.entity.rest.Result; 6 | import com.fzy.pms.entity.security.JwtToken; 7 | import com.fzy.pms.entity.security.User; 8 | import com.fzy.pms.exception.SystemErrorException; 9 | import com.fzy.pms.service.UserService; 10 | import com.fzy.pms.utils.ResponseUtil; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 14 | import org.springframework.security.core.context.SecurityContextHolder; 15 | import org.springframework.stereotype.Component; 16 | import org.springframework.web.filter.OncePerRequestFilter; 17 | 18 | import javax.servlet.FilterChain; 19 | import javax.servlet.ServletException; 20 | import javax.servlet.http.HttpServletRequest; 21 | import javax.servlet.http.HttpServletResponse; 22 | import java.io.IOException; 23 | import java.util.Objects; 24 | 25 | /** 26 | * @program: JwtAuthenticationTokenFilter 27 | * @description: 28 | * @author: fzy 29 | * @date: 2019/03/23 11:50:41 30 | **/ 31 | @Component 32 | public class JwtTokenFilter extends OncePerRequestFilter { 33 | 34 | private static final String TOKEN_HEADER = "Authorization"; 35 | private static final String TOKEN_PREFIX = "Bearer "; 36 | 37 | @Autowired 38 | private UserService userService; 39 | 40 | @Autowired 41 | private TokenCache tokenCache; 42 | 43 | @Override 44 | protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws ServletException, IOException { 45 | if(req.getServletPath().equals("/auth/token")){ 46 | chain.doFilter(req, res); 47 | return; 48 | } 49 | 50 | String token = getToken(req); 51 | 52 | String username=null; 53 | if(!StringUtils.isEmpty(token)){ 54 | username = tokenCache.getUsername(new JwtToken().setAccessToken(token)); 55 | if(StringUtils.isBlank(username)){ 56 | ResponseUtil.out(res, Result.failure(RestCode.TOKEN_EXPIRE)); 57 | return; 58 | } 59 | } 60 | 61 | if(StringUtils.isNotBlank(username)&&Objects.isNull(SecurityContextHolder.getContext().getAuthentication())){ 62 | //数据库查询当前用户信息 63 | User user = userService.getUserByUsername(username) 64 | .orElseThrow(() -> new SystemErrorException("用户异常")); 65 | SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(user,null,user.getAuthorities())); 66 | } 67 | chain.doFilter(req, res); 68 | } 69 | 70 | /** 71 | * 从请求头重获取token 72 | * @param request 73 | * @return 74 | */ 75 | private static String getToken(HttpServletRequest request){ 76 | String header = request.getHeader(TOKEN_HEADER); 77 | if(StringUtils.isNotBlank(header) && header.startsWith(TOKEN_PREFIX)){ 78 | return StringUtils.removeStart(header,TOKEN_PREFIX); 79 | } 80 | return null; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/LoginUrlAuthentication.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.entity.enums.RestCode; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.utils.ResponseUtil; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | /** 15 | * @program: LoginUrlAuthentication 16 | * @description: 17 | * @author: fzy 18 | * @date: 2019/03/25 00:25:30 19 | **/ 20 | public class LoginUrlAuthentication extends LoginUrlAuthenticationEntryPoint { 21 | 22 | /** 23 | * @param loginFormUrl URL where the login page can be found. Should either be 24 | * relative to the web-app context path (include a leading {@code /}) or an absolute 25 | * URL. 26 | */ 27 | public LoginUrlAuthentication(String loginFormUrl) { 28 | super(loginFormUrl); 29 | } 30 | 31 | @Override 32 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { 33 | ResponseUtil.out(response,Result.failure(RestCode.TOKEN_EXPIRE.getCode(),"非法访问,请先登陆!!!")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/LogoutSuccessHandler.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.cache.TokenCache; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.entity.security.User; 6 | import com.fzy.pms.utils.ResponseUtil; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.security.core.Authentication; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.servlet.ServletException; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | 16 | /** 17 | * @program: LogoutSuccessHandler 18 | * @description: 登出成功Handler 19 | * @author: fzy 20 | * @date: 2019-04-20 19:01 21 | **/ 22 | @Component 23 | public class LogoutSuccessHandler implements org.springframework.security.web.authentication.logout.LogoutSuccessHandler { 24 | 25 | @Autowired 26 | private TokenCache tokenCache; 27 | 28 | @Override 29 | public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { 30 | User details = (User) authentication.getPrincipal(); 31 | tokenCache.remove(details.getUsername()); 32 | ResponseUtil.out(response, Result.success("恭喜你成功退出登陆")); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/RestAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.entity.rest.Result; 4 | import com.fzy.pms.utils.ResponseUtil; 5 | import org.springframework.security.access.AccessDeniedException; 6 | import org.springframework.security.web.access.AccessDeniedHandler; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | /** 15 | * @program: RestAccessDeniedHandler 16 | * @description: 权限拦截器 17 | * @author: fzy 18 | * @date: 2019/03/23 21:12:00 19 | **/ 20 | @Component 21 | public class RestAccessDeniedHandler implements AccessDeniedHandler { 22 | @Override 23 | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { 24 | ResponseUtil.out(response, Result.failure("该用户没有权限")); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/SecurityFailureHandler.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.entity.rest.Result; 4 | import com.fzy.pms.utils.ResponseUtil; 5 | import org.springframework.security.authentication.BadCredentialsException; 6 | import org.springframework.security.authentication.DisabledException; 7 | import org.springframework.security.core.AuthenticationException; 8 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 9 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; 10 | import org.springframework.stereotype.Component; 11 | 12 | import javax.servlet.ServletException; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | 17 | /** 18 | * @program: SecurityFailureHandler 19 | * @description: 登陆失败拦截器 20 | * @author: fzy 21 | * @date: 2019/03/23 20:58:31 22 | **/ 23 | @Component 24 | public class SecurityFailureHandler implements AuthenticationFailureHandler { 25 | 26 | @Override 27 | public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException { 28 | if (e instanceof UsernameNotFoundException || e instanceof BadCredentialsException) { 29 | ResponseUtil.out(response, Result.failure("用户名或密码错误")); 30 | }else if(e instanceof DisabledException) { 31 | ResponseUtil.out(response, Result.failure("账户被禁用,请联系管理员")); 32 | }else { 33 | ResponseUtil.out(response, Result.failure("登录失败")); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/SecuritySuccessHandler.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.cache.TokenCache; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.entity.security.JwtToken; 6 | import com.fzy.pms.entity.security.User; 7 | import com.fzy.pms.utils.ResponseUtil; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.core.context.SecurityContextHolder; 11 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 12 | import org.springframework.stereotype.Component; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | /** 18 | * @program: AuthenticationSuccessHandler 19 | * @description: 登陆成功拦截器 20 | * @author: fzy 21 | * @date: 2019/03/23 20:05:56 22 | **/ 23 | @Component 24 | public class SecuritySuccessHandler implements AuthenticationSuccessHandler { 25 | 26 | @Autowired 27 | private TokenCache tokenCache; 28 | 29 | @Override 30 | public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { 31 | User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 32 | JwtToken jwtToken = tokenCache.add(principal); 33 | ResponseUtil.out(response, Result.success(jwtToken)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/security/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.security; 2 | 3 | import com.fzy.pms.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.HttpMethod; 8 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 11 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 12 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 13 | import org.springframework.security.config.http.SessionCreationPolicy; 14 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 15 | import org.springframework.security.web.AuthenticationEntryPoint; 16 | import org.springframework.security.web.authentication.logout.LogoutFilter; 17 | 18 | /** 19 | * @program: WebSecurityConfig 20 | * @description: 21 | * @author: fzy 22 | * @date: 2019/03/16 18:15:36 23 | **/ 24 | @Configuration 25 | @EnableWebSecurity 26 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 27 | 28 | @Autowired 29 | private UserService userService; 30 | 31 | @Autowired 32 | private SecuritySuccessHandler securitySuccessHandler; 33 | 34 | @Autowired 35 | private SecurityFailureHandler securityFailureHandler; 36 | 37 | @Autowired 38 | private RestAccessDeniedHandler accessDeniedHandler; 39 | 40 | @Autowired 41 | private LogoutSuccessHandler logoutSuccessHandler; 42 | 43 | @Autowired 44 | private JwtTokenFilter jwtTokenFilter; 45 | 46 | @Override //配置策略 47 | protected void configure(HttpSecurity http) throws Exception { 48 | http 49 | .formLogin().loginProcessingUrl("/login") 50 | .successHandler(securitySuccessHandler) 51 | .failureHandler(securityFailureHandler).and() 52 | .logout().logoutSuccessHandler(logoutSuccessHandler).and() 53 | //拦截全部请求 54 | .authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll().and() 55 | //跨域支持 56 | .cors().and() 57 | //关闭跨站请求防护 58 | .csrf().disable() 59 | //前后端分离采用JWT 不需要session 60 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() 61 | //自定义权限拒绝处理类 62 | .exceptionHandling().authenticationEntryPoint(macLoginUrlAuthenticationEntryPoint()).accessDeniedHandler(accessDeniedHandler).and() 63 | //添加JWT过滤器 除/login其它请求都需经过此过滤器 64 | .addFilterBefore(jwtTokenFilter, LogoutFilter.class); 65 | // 禁用缓存 66 | http.headers().cacheControl(); 67 | } 68 | 69 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 70 | auth.userDetailsService(userService); 71 | } 72 | 73 | @Override 74 | public void configure(WebSecurity web) throws Exception { 75 | //每一个请求对应一个空的filter链,这里一般不要配置过多, 76 | web.ignoring().antMatchers("/static/**", 77 | "/v2/api-docs", 78 | "/configuration/**", 79 | "/swagger-resources/**", 80 | "/webjars/**", 81 | "/swagger-ui.html"); 82 | } 83 | 84 | //密码加密 85 | @Bean 86 | public BCryptPasswordEncoder passwordEncoder(){ 87 | return new BCryptPasswordEncoder(); 88 | } 89 | 90 | @Bean 91 | public AuthenticationEntryPoint macLoginUrlAuthenticationEntryPoint() { 92 | return new LoginUrlAuthentication("/login"); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/config/swagger/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.config.swagger; 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.Parameter; 12 | import springfox.documentation.spi.DocumentationType; 13 | import springfox.documentation.spring.web.plugins.Docket; 14 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * @program: SwaggerConfig 21 | * @description: 22 | * @author: fzy 23 | * @date: 2019/03/22 23:59:54 24 | **/ 25 | @Configuration 26 | @EnableSwagger2 27 | public class SwaggerConfig { 28 | 29 | @Bean 30 | public Docket createRestApi() { 31 | ParameterBuilder tokenPar = new ParameterBuilder(); 32 | List pars = new ArrayList<>(); 33 | tokenPar.name("Authorization").description("令牌") 34 | .modelRef(new ModelRef("string")).parameterType("query").required(false).build(); 35 | pars.add(tokenPar.build()); 36 | return new Docket(DocumentationType.SWAGGER_2) 37 | .apiInfo(apiInfo()) 38 | .select() 39 | .apis(RequestHandlerSelectors.basePackage("com.fzy.pms.web.controller")) 40 | .paths(PathSelectors.any()) 41 | .build().globalOperationParameters(pars); 42 | } 43 | 44 | private ApiInfo apiInfo() { 45 | return new ApiInfoBuilder() 46 | .title("pms 接口文档") 47 | .version("1.0") 48 | .build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/AccountController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.dto.AccountDto; 4 | import com.fzy.pms.entity.pms.AccountDetail; 5 | import com.fzy.pms.entity.rest.Result; 6 | import com.fzy.pms.service.AccountService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.data.domain.Page; 12 | import org.springframework.data.domain.Pageable; 13 | import org.springframework.data.domain.Sort; 14 | import org.springframework.data.web.PageableDefault; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | /** 18 | * @program: AccountController 19 | * @description: 20 | * @author: fzy 21 | * @date: 2019/05/21 22:09:49 22 | **/ 23 | @RestController 24 | @RequestMapping("/account") 25 | @Api(value = "账户接口",description = "账户相关的接口") 26 | public class AccountController { 27 | 28 | @Autowired 29 | private AccountService accountService; 30 | 31 | @GetMapping("/all") 32 | @ApiOperation(value = "查询全部账户余额",notes = "查询全部账户余额") 33 | public Result getAllAccount(@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 34 | Page allData = accountService.findAll(pageable); 35 | return Result.success(allData); 36 | } 37 | 38 | @GetMapping("/search") 39 | @ApiOperation(value = "查询全部账户余额",notes = "根据id查询全部账户余额") 40 | public Result search(@RequestParam("userId") String userId,@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 41 | if(StringUtils.isBlank(userId) ||"null".equals(userId) ){ 42 | return this.getAllAccount(pageable); 43 | }else { 44 | return Result.success(accountService.search(Long.parseLong(userId),pageable)); 45 | } 46 | } 47 | 48 | @PostMapping 49 | @ApiOperation(value = "账户充值",notes = "账户充值") 50 | public Result payment(@RequestBody AccountDetail accountDetail){ 51 | accountService.payment(accountDetail); 52 | return Result.success(); 53 | } 54 | 55 | @GetMapping("/report") 56 | @ApiOperation(value = "查询充值报表",notes = "查询充值报表") 57 | public Result report(@RequestParam("userId") String userId){ 58 | return Result.success(accountService.report(userId)); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/AuthController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.cache.TokenCache; 4 | import com.fzy.pms.entity.enums.RestCode; 5 | import com.fzy.pms.entity.rest.Result; 6 | import com.fzy.pms.entity.security.JwtToken; 7 | import com.fzy.pms.utils.JwtTokenUtil; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.util.Objects; 15 | 16 | /** 17 | * @program: LogoutController 18 | * @description: 19 | * @author: fzy 20 | * @date: 2019-04-20 19:40 21 | **/ 22 | @RestController 23 | @RequestMapping("/auth") 24 | public class AuthController { 25 | 26 | @Autowired 27 | private JwtTokenUtil jwtTokenUtil; 28 | 29 | @Autowired 30 | private TokenCache tokenCache; 31 | 32 | @PostMapping("/token") 33 | public Result refreshToken(@RequestBody JwtToken jwtToken){ 34 | JwtToken token = jwtTokenUtil.refreshToken(jwtToken); 35 | if(Objects.isNull(token)){ 36 | return Result.failure(RestCode.TOKEN_EXPIRE); 37 | } 38 | tokenCache.add(token); 39 | return Result.success(token); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/CostSettingController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.pms.CostSetting; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.service.CostSettingService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.Pageable; 12 | import org.springframework.data.domain.Sort; 13 | import org.springframework.data.web.PageableDefault; 14 | import org.springframework.validation.annotation.Validated; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | /** 18 | * @program: ConstSettingController 19 | * @description: 20 | * @author: fzy 21 | * @date: 2019/04/17 23:45:11 22 | **/ 23 | @RestController 24 | @RequestMapping("/cost") 25 | @Api(value = "费用接口",description = "费用相关的接口") 26 | public class CostSettingController { 27 | 28 | @Autowired 29 | private CostSettingService costSettingService; 30 | 31 | @GetMapping("/all") 32 | @ApiOperation(value = "查询全部费用",notes = "查询全部费用") 33 | public Result getCost(@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 34 | Page allData = costSettingService.findAll(pageable); 35 | return Result.success(allData); 36 | } 37 | 38 | @GetMapping("/costAll") 39 | @ApiOperation(value = "查询全部费用",notes = "查询全部费用") 40 | public Result getCostAll(){ 41 | return Result.success( costSettingService.findAll()); 42 | } 43 | 44 | @GetMapping("/search") 45 | @ApiOperation(value = "根据费用名称模糊搜索",notes = "根据费用名称模糊搜索") 46 | public Result searchCostName(@RequestParam("costName")String costName,@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 47 | Page allData = costSettingService.findCostSetByNameLike(costName,pageable); 48 | return Result.success(allData); 49 | } 50 | 51 | @GetMapping("/{id:\\d+}") 52 | public Result findOne(@PathVariable Long id){ 53 | CostSetting costSetting = costSettingService.findOne(id); 54 | return Result.success(costSetting); 55 | } 56 | 57 | @PostMapping 58 | @ApiOperation(value = "添加费用",notes = "添加费用") 59 | public Result create(@Validated(CostSetting.Save.class) @RequestBody CostSetting costSetting){ 60 | costSettingService.create(costSetting); 61 | return Result.success(); 62 | } 63 | 64 | @PutMapping 65 | @ApiOperation(value = "修改费用",notes = "修改费用") 66 | public Result updateCost(@Validated(CostSetting.Update.class) @RequestBody CostSetting cost){ 67 | costSettingService.update(cost); 68 | return Result.success(); 69 | } 70 | 71 | @DeleteMapping("{id:\\d+}") 72 | @ApiOperation(value = "删除费用",notes = "根据id 删除费用") 73 | public Result deleteCost(@PathVariable Long id){ 74 | costSettingService.delete(id); 75 | return Result.success(); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/DoorController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.dto.DoorDto; 4 | import com.fzy.pms.entity.pms.Door; 5 | import com.fzy.pms.entity.pms.House; 6 | import com.fzy.pms.entity.rest.Result; 7 | import com.fzy.pms.service.DoorService; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.domain.Page; 13 | import org.springframework.data.domain.Pageable; 14 | import org.springframework.data.domain.Sort; 15 | import org.springframework.data.web.PageableDefault; 16 | import org.springframework.validation.annotation.Validated; 17 | import org.springframework.web.bind.annotation.*; 18 | 19 | /** 20 | * @program: DoorController 21 | * @description: 门禁管理 22 | * @author: fzy 23 | * @date: 2019/05/20 09:57:15 24 | **/ 25 | @RestController 26 | @RequestMapping("/door") 27 | @Api(value = "门禁管理",description = "门禁管理相关的接口") 28 | public class DoorController { 29 | 30 | @Autowired 31 | private DoorService doorService; 32 | 33 | @PostMapping 34 | @ApiOperation(value = "添加门禁",notes = "添加门禁") 35 | public Result create(@Validated(Door.Save.class) @RequestBody Door door){ 36 | doorService.create(door); 37 | return Result.success(); 38 | } 39 | 40 | @GetMapping("/all") 41 | @ApiOperation(value = "查询全部门禁",notes = "查询全部门禁") 42 | public Result getAllDoor(@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 43 | Page all = doorService.findAllDto(pageable); 44 | return Result.success(all); 45 | } 46 | 47 | @GetMapping("/search") 48 | @ApiOperation(value = "根据用户id 查询全部门禁",notes = "根据用户id 查询全部门禁") 49 | public Result search(@RequestParam("userId") String userId,@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 50 | if(StringUtils.isBlank(userId) || userId.equals("null")){ 51 | return this.getAllDoor(pageable); 52 | }else { 53 | return Result.success(doorService.search(Long.parseLong(userId),pageable)); 54 | } 55 | } 56 | 57 | @PutMapping("/updateStatus") 58 | @ApiOperation(value = "修改门禁状态",notes = "根据id修改门禁状态") 59 | public Result updateStatus(@RequestBody Door door){ 60 | return Result.success(doorService.updateDoorStatus(door)); 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/DownloadController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.rest.Result; 4 | import com.fzy.pms.service.DownloadFileService; 5 | import com.qiniu.common.QiniuException; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | * @program: DownloadController 16 | * @description: 文件下载 17 | * @author: fzy 18 | * @date: 2019/07/20 09:18:00 19 | **/ 20 | 21 | @Api(value = "文件下载接口",description = "文件下载相关的接口") 22 | @RestController 23 | @RequestMapping("/download") 24 | public class DownloadController { 25 | 26 | @Resource(name="fileService") 27 | private DownloadFileService downloadFileService; 28 | 29 | @GetMapping 30 | @ApiOperation(value = "文件下载",notes = "文件下载") 31 | public Result downloadFile(){ 32 | downloadFileService.downloadFile("banner.txt"); 33 | return Result.success(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/HouseController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.pms.CostSetting; 4 | import com.fzy.pms.entity.pms.Door; 5 | import com.fzy.pms.entity.pms.House; 6 | import com.fzy.pms.entity.rest.Result; 7 | import com.fzy.pms.service.HouseService; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.data.domain.Page; 12 | import org.springframework.data.domain.Pageable; 13 | import org.springframework.data.domain.Sort; 14 | import org.springframework.data.web.PageableDefault; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import java.util.Set; 19 | 20 | /** 21 | * @program: HouseController 22 | * @description: 23 | * @author: fzy 24 | * @date: 2019/05/10 10:03:49 25 | **/ 26 | @RestController 27 | @RequestMapping("/house") 28 | @Api(value = "房产接口",description = "房产相关的接口") 29 | public class HouseController { 30 | 31 | @Autowired 32 | private HouseService houseService; 33 | 34 | @GetMapping("/all") 35 | @ApiOperation(value = "查询全部房产",notes = "查询全部房产") 36 | public Result getAllHouse(@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 37 | Page allData = houseService.findAll(pageable); 38 | return Result.success(allData); 39 | } 40 | 41 | @GetMapping("/{id:\\d+}") 42 | @ApiOperation(value = "查找房产",notes = "根据 id 查找房产") 43 | public Result findOne(@PathVariable Long id){ 44 | House house = houseService.findOne(id); 45 | return Result.success(house); 46 | } 47 | 48 | @PostMapping 49 | @ApiOperation(value = "添加房产",notes = "添加房产") 50 | public Result create(@Validated(House.Save.class) @RequestBody House house){ 51 | houseService.create(house); 52 | return Result.success(); 53 | } 54 | 55 | @PutMapping 56 | @ApiOperation(value = "修改房产",notes = "修改房产") 57 | public Result updateCost(@Validated(CostSetting.Update.class) @RequestBody House house){ 58 | houseService.update(house); 59 | return Result.success(); 60 | } 61 | 62 | @DeleteMapping("{id:\\d+}") 63 | @ApiOperation(value = "删除房产",notes = "根据id 删除房产") 64 | public Result deleteHouse(@PathVariable Long id){ 65 | houseService.delete(id); 66 | return Result.success(); 67 | } 68 | 69 | @DeleteMapping 70 | @ApiOperation(value = "删除房产",notes = "批量删除房产信息") 71 | public Result batchDelete(@RequestBody Set ids){ 72 | houseService.batchDelete(ids); 73 | return Result.success(); 74 | } 75 | 76 | @GetMapping("/search") 77 | public Result search(@RequestParam("userId")Long id,@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 78 | Page house = houseService.findHouseByUserId(id,pageable); 79 | return Result.success(house); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/MenuController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.dto.MenuDto; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.entity.security.Menu; 6 | import com.fzy.pms.service.MenuService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.annotation.Validated; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | /** 14 | * @program: MenuController 15 | * @description: 16 | * @author: fzy 17 | * @date: 2019-03-30 21:10 18 | **/ 19 | @RestController 20 | @RequestMapping("/menus") 21 | @Api(value = "菜单接口",description = "菜单相关的接口") 22 | public class MenuController { 23 | 24 | @Autowired 25 | private MenuService menuService; 26 | 27 | @PostMapping 28 | @ApiOperation(value = "添加菜单",notes = "添加菜单") 29 | public Result create(@Validated @RequestBody Menu menu){ 30 | MenuDto menuDTO = menuService.create(menu); 31 | return Result.success(menuDTO); 32 | } 33 | 34 | @PutMapping 35 | @ApiOperation(value = "修改菜单",notes = "修改菜单") 36 | public Result update(@Validated(Menu.Update.class) @RequestBody Menu menu){ 37 | menuService.update(menu); 38 | return Result.success(); 39 | } 40 | 41 | @DeleteMapping("{id:\\d+}") 42 | @ApiOperation(value = "删除菜单",notes = "根据id 删除菜单") 43 | public Result deleteMenu(@PathVariable Long id){ 44 | menuService.delete(id); 45 | return Result.success(); 46 | } 47 | 48 | @GetMapping("/menuList") 49 | @ApiOperation(value = "查询当前用户菜单列表",notes = "查询当前用户菜单列表") 50 | public Result getCurrMenuList(){ 51 | return Result.success(menuService.getCurrMenuTree()); 52 | } 53 | 54 | @GetMapping("/findAllMenus") 55 | @ApiOperation(value = "查询全部菜单列表",notes = "查询全部菜单列表") 56 | public Result findAllMenus(){ 57 | return Result.success(menuService.findAllByMenuTree()); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/ParkController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.dto.ParkDto; 4 | import com.fzy.pms.entity.pms.Park; 5 | import com.fzy.pms.entity.rest.Result; 6 | import com.fzy.pms.service.ParkService; 7 | import io.swagger.annotations.Api; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.Pageable; 12 | import org.springframework.data.domain.Sort; 13 | import org.springframework.data.repository.query.Param; 14 | import org.springframework.data.web.PageableDefault; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | /** 19 | * @program: ParkController 20 | * @description: 21 | * @author: fzy 22 | * @date: 2019/05/20 19:07:03 23 | **/ 24 | @RestController 25 | @RequestMapping("/park") 26 | @Api(value = "停车位接口",description = "停车位相关的接口") 27 | public class ParkController { 28 | 29 | @Autowired 30 | private ParkService parkService; 31 | 32 | @PostMapping 33 | @ApiOperation(value = "添加停车位",notes = "添加停车位") 34 | public Result create(@Validated(Park.Save.class) @RequestBody Park park){ 35 | parkService.create(park); 36 | return Result.success(); 37 | } 38 | 39 | @GetMapping("/all") 40 | @ApiOperation(value = "查询全部停车位",notes = "查询全部停车位") 41 | public Result getAllPark(@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 42 | Page all = parkService.findAllDto(pageable); 43 | return Result.success(all); 44 | } 45 | 46 | @GetMapping("/search") 47 | @ApiOperation(value = "gen",notes = "查询全部门禁") 48 | public Result search(@RequestParam ()String userId, @PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 49 | if(!userId.equals("null")){ 50 | return Result.success(parkService.search(Long.parseLong(userId),pageable)); 51 | }else { 52 | return this.getAllPark(pageable); 53 | } 54 | } 55 | 56 | @PutMapping("/updateStatus") 57 | @ApiOperation(value = "修改停车位状态",notes = "根据id修改停车位状态") 58 | public Result updateStatus(@RequestBody Park park){ 59 | return Result.success(parkService.updateUseStatus(park)); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/RepairsController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.pms.Park; 4 | import com.fzy.pms.entity.pms.Repairs; 5 | import com.fzy.pms.entity.rest.Result; 6 | import com.fzy.pms.entity.vo.RepairVo; 7 | import com.fzy.pms.service.RepairsService; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.domain.Pageable; 13 | import org.springframework.data.domain.Sort; 14 | import org.springframework.data.web.PageableDefault; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | /** 19 | * @program: RepairsController 20 | * @description: 21 | * @author: fzy 22 | * @date: 2019/05/22 19:57:28 23 | **/ 24 | @RestController 25 | @RequestMapping("/repairs") 26 | @Api(value = "报修接口",description = "报修相关的接口") 27 | public class RepairsController { 28 | 29 | @Autowired 30 | private RepairsService repairsService; 31 | 32 | @PostMapping 33 | @ApiOperation(value = "添加报修单",notes = "添加报修单") 34 | public Result create(@Validated(Park.Save.class) @RequestBody Repairs repairs){ 35 | repairsService.create(repairs); 36 | return Result.success(); 37 | } 38 | 39 | @GetMapping 40 | @ApiOperation(value = "查询全部报修单",notes = "查询全部报修单") 41 | public Result findAllDto(@PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 42 | return Result.success(repairsService.findAllDto(pageable)); 43 | } 44 | 45 | @GetMapping("/search") 46 | @ApiOperation(value = "查询全部报修单",notes = "查询全部报修单") 47 | public Result search(@RequestParam ("userId")String userId, @PageableDefault(sort = {"createTime"},direction = Sort.Direction.DESC) Pageable pageable){ 48 | if(StringUtils.isBlank(userId)||userId.equals("null")){ 49 | return this.findAllDto(pageable); 50 | }else { 51 | return Result.success(repairsService.search(Long.parseLong(userId),pageable)); 52 | } 53 | } 54 | 55 | @PutMapping("/startDispatch") 56 | @ApiOperation(value = "开始派单",notes = "开始派单") 57 | public Result startDispatch(@RequestBody RepairVo repairVo){ 58 | repairsService.startDispatch(repairVo); 59 | return Result.success(); 60 | } 61 | 62 | @PutMapping("/endDispatch") 63 | @ApiOperation(value = "关闭订单",notes = "关闭订单") 64 | public Result endDispatch(@RequestBody RepairVo repairVo){ 65 | repairsService.endDispatch(repairVo); 66 | return Result.success(); 67 | } 68 | 69 | @GetMapping("/report") 70 | @ApiOperation(value = "报表查询",notes = "报表查询") 71 | public Result report(@RequestParam ("userId")String userId){ 72 | return Result.success(repairsService.report(userId)); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.dao.RoleRepository; 4 | import com.fzy.pms.entity.dto.RoleDto; 5 | import com.fzy.pms.entity.rest.Result; 6 | import com.fzy.pms.entity.security.Menu; 7 | import com.fzy.pms.entity.security.Role; 8 | import com.fzy.pms.service.RoleService; 9 | import io.swagger.annotations.Api; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.validation.annotation.Validated; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.List; 16 | import java.util.Objects; 17 | import java.util.Optional; 18 | import java.util.Set; 19 | 20 | /** 21 | * @program: RoleController 22 | * @description: 23 | * @author: fzy 24 | * @date: 2019-04-05 11:12 25 | **/ 26 | @RestController 27 | @RequestMapping("/role") 28 | @Api(value = "角色接口",description = "角色相关的接口") 29 | public class RoleController { 30 | 31 | @Autowired 32 | private RoleService roleService; 33 | 34 | @PostMapping 35 | @ApiOperation(value = "添加角色",notes = "添加角色") 36 | public Result create(@Validated @RequestBody Role role){ 37 | roleService.create(role); 38 | return Result.success(); 39 | } 40 | 41 | @PutMapping 42 | @ApiOperation(value = "修改角色",notes = "修改角色") 43 | public Result update(@Validated(Menu.Update.class) @RequestBody Role role){ 44 | roleService.update(role); 45 | return Result.success(); 46 | } 47 | 48 | @DeleteMapping("/{id:\\d+}") 49 | @ApiOperation(value = "删除角色",notes = "根据id 删除角色") 50 | public Result deleteRole(@PathVariable Long id){ 51 | roleService.delete(id); 52 | return Result.success(); 53 | } 54 | 55 | @GetMapping 56 | @ApiOperation(value = "查询全部角色",notes = "查询全部角色") 57 | public Result findAll(){ 58 | return Result.success(roleService.findAll()); 59 | } 60 | 61 | @DeleteMapping("/batchDelete") 62 | @ApiOperation(value = "批量删除",notes = "批量删除") 63 | public Result batchDelete(@RequestBody Set ids){ 64 | roleService.batchDelete(ids); 65 | return Result.success(); 66 | } 67 | 68 | @GetMapping("/search") 69 | @ApiOperation(value = "模糊搜索",notes="模糊搜索") 70 | public Result search(@RequestParam("name") String name){ 71 | return Result.success(roleService.search(name)); 72 | } 73 | 74 | @GetMapping("/{id:\\d+}") 75 | @ApiOperation(value = "查询角色",notes = "根据id 查询角色") 76 | public Result findOne(@PathVariable Long id){ 77 | Role role = roleService.findOne(id); 78 | return Result.success(role); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/SettleController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.pms.Settle; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.service.SettleService; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | /** 12 | * @program: SettleController 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/05/23 08:34:08 16 | **/ 17 | 18 | @RestController 19 | @RequestMapping("/settle") 20 | @Api(value = "结算接口",description = "结算相关的接口") 21 | public class SettleController { 22 | 23 | @Autowired 24 | private SettleService settleService; 25 | 26 | @PostMapping 27 | @ApiOperation("创建结算") 28 | public Result create(@RequestBody Settle settle){ 29 | settleService.create(settle); 30 | return Result.success(); 31 | } 32 | 33 | @GetMapping("/report") 34 | public Result report(@RequestParam("userId") String userId){ 35 | return Result.success(settleService.report(userId)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.rest.Result; 4 | import com.fzy.pms.service.UploadFileService; 5 | import com.qiniu.common.QiniuException; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @program: UploadController 15 | * @description: 16 | * @author: fzy 17 | * @date: 2019/07/19 23:56:02 18 | **/ 19 | @Api(value = "文件上传接口",description = "文件上传相关的接口") 20 | @RestController 21 | @RequestMapping("/upload") 22 | public class UploadController { 23 | 24 | @Autowired 25 | private UploadFileService uploadFileService; 26 | 27 | @GetMapping("/token") 28 | @ApiOperation(value = "获取文件上传token", notes = "获取文件上传token") 29 | public Result getToken(){ 30 | String accessToken = uploadFileService.getAccessToken(); 31 | return Result.success(accessToken); 32 | } 33 | 34 | 35 | @GetMapping 36 | @ApiOperation(value = "文件上传",notes = "文件上传") 37 | public Result uploadImages()throws QiniuException { 38 | uploadFileService.localUpload("C:\\GraduateProject\\pms\\src\\main\\resources\\banner.txt","banner.txt"); 39 | return Result.success(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/fzy/pms/web/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms.web.controller; 2 | 3 | import com.fzy.pms.entity.dto.UserDto; 4 | import com.fzy.pms.entity.rest.Result; 5 | import com.fzy.pms.entity.security.Role; 6 | import com.fzy.pms.entity.security.User; 7 | import com.fzy.pms.entity.vo.UserVo; 8 | import com.fzy.pms.service.UserService; 9 | import io.swagger.annotations.Api; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.validation.annotation.Validated; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import javax.validation.Valid; 16 | import java.util.List; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @Api(value = "用户接口",description = "用户相关的接口") 21 | @RestController 22 | @RequestMapping("/user") 23 | public class UserController { 24 | 25 | @Autowired 26 | private UserService userService; 27 | 28 | @GetMapping("/{id:\\d+}") 29 | @ApiOperation(value = "查询用户",notes = "根据用户id查询用户信息") 30 | public Result getUser(@PathVariable Long id){ 31 | Optional user = userService.findUser(id); 32 | return user.isPresent()? Result.success(user.get()):Result.failure("获取用户信息失败"); 33 | } 34 | 35 | @ApiOperation(value="添加用户", notes="用户实体") 36 | @PostMapping 37 | public Result createUser(@Valid @RequestBody User user){ 38 | return Objects.isNull(userService.registerUser(user))?Result.failure("添加用户失败"): Result.success(); 39 | } 40 | 41 | @ApiOperation( "获取当前登录用户信息") 42 | @GetMapping("/info") 43 | public Result getUserInfo(){ 44 | Optional currUserInfo = userService.getCurrUserInfo(); 45 | return currUserInfo.isPresent()? Result.success(currUserInfo.get()):Result.failure("获取用户信息失败"); 46 | } 47 | 48 | @DeleteMapping("/{id:\\d+}") 49 | @ApiOperation(value = "删除用户",notes = "根据id 删除用户") 50 | public Result deleteUser(@PathVariable Long id){ 51 | userService.lockUser(id); 52 | return Result.success(); 53 | } 54 | 55 | @GetMapping("/list") 56 | @ApiOperation(value = "查询当前用户列表", notes = "查询当前用户列表") 57 | public Result getUserList(){ 58 | List List = userService.findAllListSortCreateTime(); 59 | return Result.success(List); 60 | } 61 | 62 | @PutMapping("/edit") 63 | @ApiOperation(value = "编辑用户信息", notes="编辑用户信息") 64 | public Result editUserInfo(@Validated(User.Update.class) @RequestBody User user){ 65 | Boolean success = userService.updateUserInfo(user); 66 | return success?Result.success(): Result.failure("用户名已存在"); 67 | } 68 | 69 | @GetMapping("/search") 70 | @ApiOperation(value = "根据条件查询用户信息", notes = "根据条件查询用户信息") 71 | public Result search(@RequestParam(name = "realName",required = false) String realName, 72 | @RequestParam(name = "phone",required = false) String phone, 73 | @RequestParam(name = "email",required = false) String email, 74 | @RequestParam(name = "roleId",required = false) Long roleId){ 75 | User user=new User(); 76 | Role role=new Role(); 77 | user.setRealName(realName); 78 | user.setPhone(phone); 79 | user.setEmail(email); 80 | role.setId(roleId); 81 | user.setRole(role); 82 | return Result.success(userService.search(user)); 83 | } 84 | 85 | @PostMapping("/updatePassword") 86 | @ApiOperation(value = "修改密码", notes = "修改密码") 87 | public Result updatePassword(@RequestBody UserVo userVo){ 88 | int i = userService.updatePassword(userVo); 89 | return i==0?Result.success():Result.failure("旧密码错误"); 90 | } 91 | 92 | @PutMapping("/{id:\\d+}") 93 | @ApiOperation(value = "重置密码", notes = "重置密码") 94 | public Result resetPassword(@PathVariable("id") Long userId){ 95 | userService.resetPassword(userId); 96 | return Result.success(); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | servlet: 4 | context-path: /pms 5 | spring: 6 | datasource: 7 | url: jdbc:mysql://192.168.163.10:3306/pms?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false 8 | username: root 9 | password: admin 10 | driver-class-name: com.mysql.cj.jdbc.Driver 11 | hikari: 12 | connection-timeout: 5000 13 | maximum-pool-size: 200 14 | minimum-idle: 5 15 | jpa: 16 | show-sql: true 17 | hibernate: 18 | ddl-auto: update 19 | naming: 20 | physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy #开启驼峰命名 21 | database-platform: org.hibernate.dialect.MySQL5InnoDBDialect #建表时指定使用innodb 引擎 22 | thymeleaf: 23 | cache: false 24 | mode: HTML5 25 | quartz: 26 | job-store-type: memory 27 | properties: 28 | org: 29 | quartz: 30 | threadPool: 31 | class: org.quartz.simpl.SimpleThreadPool 32 | threadCount: 2 33 | jwt: 34 | expiration: 30 # 过期时间 单位分钟 35 | time-out: 30 # 超时时间 单位分钟 36 | secret: uKd?J|tt9wE[._U+$==X?-@#NZ\,Um=@ 37 | sys: 38 | initPassword: 123123 39 | 40 | logging: 41 | config: classpath:logback-test.xml 42 | 43 | qiniu: 44 | oos: 45 | AccessKey: 1c611FXpkgS-Pn72mOEO2Qpi2SjH1BvunKnuGV4W 46 | SecretKey: svnb40h-tDXlJEvMkAwQmtMt77B3bBef0zxyhaSZ 47 | bucket: pms 48 | domain: http://pux0w2a64.bkt.clouddn.com 49 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | _ _ __ 2 | __ _ _ _ | |_ | |__ ___ _ __ _ / _| ____ _ _ 3 | / _` | | | | | | __| | '_ \ / _ \ | '__| (_) | |_ |_ / | | | | 4 | | (_| | | |_| | | |_ | | | | | (_) | | | _ | _| / / | |_| | 5 | \__,_| \__,_| \__| |_| |_| \___/ |_| (_) |_| /___| \__, | 6 | |___/ 7 | -------------------------------------------------------------------------------- /src/main/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ${CONSOLE_LOG_PATTERN} 18 | utf8 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/test/java/com/fzy/pms/DoorTest.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import com.fzy.pms.dao.DoorRepository; 4 | import com.fzy.pms.entity.dto.DoorDto; 5 | import com.fzy.pms.entity.pms.Door; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import javax.transaction.Transactional; 14 | import java.util.Optional; 15 | 16 | /** 17 | * @program: DoorTest 18 | * @description: 19 | * @author: fzy 20 | * @date: 2019/05/20 15:11:02 21 | **/ 22 | @RunWith(SpringRunner.class) 23 | @SpringBootTest 24 | @Slf4j 25 | public class DoorTest { 26 | 27 | @Autowired 28 | private DoorRepository doorRepository; 29 | 30 | @Test 31 | public void findOne(){ 32 | DoorDto oneById = doorRepository.findOneById(1L); 33 | System.out.println(oneById); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/fzy/pms/JwtTokenTest.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import com.fzy.pms.entity.security.JwtToken; 4 | import com.fzy.pms.entity.security.User; 5 | import com.fzy.pms.utils.JwtTokenUtil; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | /** 14 | * @program: JwtTokenTest 15 | * @description: jwt toekn 测试 16 | * @author: fzy 17 | * @date: 2019/03/23 11:32:23 18 | **/ 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest 21 | @Slf4j 22 | public class JwtTokenTest { 23 | 24 | @Autowired 25 | private JwtTokenUtil jwtTokenUtil; 26 | 27 | @Test 28 | public void createJwtToken(){ 29 | User user=new User(); 30 | user.setUsername("admin"); 31 | log.info("token={}",jwtTokenUtil.generateToken(user)); 32 | } 33 | 34 | @Test 35 | public void paramJwtToken(){ 36 | String username = jwtTokenUtil.getUsernameFromToken 37 | (new JwtToken().setAccessToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTU1NDU0NzMxMSwiaWF0IjoxNTU0NTQzNzExfQ.yr8RBtq1EC-YJQj7z4bJV8I92Tsui4aEg7LvYrH_CDxupPjw1ScrbKC1iD8YHt5DLk5nhXG75-qH24WhkDgVQQ")); 38 | System.out.println(username); 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/fzy/pms/MenuTest.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import com.fzy.pms.entity.dto.MenuDto; 4 | import com.fzy.pms.service.MenuService; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.Set; 12 | 13 | /** 14 | * @program: MenuTest 15 | * @description: 16 | * @author: fzy 17 | * @date: 2019/04/06 14:44:51 18 | **/ 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest 21 | public class MenuTest { 22 | 23 | @Autowired 24 | private MenuService menuService; 25 | 26 | @Test 27 | public void testMenuTree(){ 28 | Set menuTree = menuService.findAllByMenuTree(); 29 | System.out.println(menuTree); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/fzy/pms/RedisTest.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.junit4.SpringRunner; 6 | 7 | /** 8 | * @program: RedisTest 9 | * @description: 10 | * @author: fzy 11 | * @date: 2019/03/29 21:07:46 12 | **/ 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class RedisTest { 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/fzy/pms/RoleTest.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import com.fzy.pms.entity.security.Role; 4 | import com.fzy.pms.service.RoleService; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * @program: RoleTest 13 | * @description: 14 | * @author: fzy 15 | * @date: 2019/05/07 16:12:04 16 | **/ 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest 19 | public class RoleTest { 20 | 21 | @Autowired 22 | private RoleService roleService; 23 | 24 | @Test 25 | public void testCreate(){ 26 | Role role=new Role(); 27 | role.setName("测试角色"); 28 | role.setRemark("我只是简单的做下测试"); 29 | roleService.create(role); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/fzy/pms/UserPwdTest.java: -------------------------------------------------------------------------------- 1 | package com.fzy.pms; 2 | 3 | import com.fzy.pms.dao.UserRepository; 4 | import com.fzy.pms.entity.security.Role; 5 | import com.fzy.pms.entity.security.User; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.security.crypto.password.PasswordEncoder; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | /** 15 | * @program: UserPwdTest 16 | * @description: 17 | * @author: fzy 18 | * @date: 2019/03/17 13:01:10 19 | **/ 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest 22 | public class UserPwdTest { 23 | 24 | @Autowired 25 | private UserRepository userRepository; 26 | 27 | @Autowired 28 | private PasswordEncoder passwordEncoder; 29 | 30 | @Test 31 | public void encodeTest(){ 32 | System.out.println(passwordEncoder.encode("admin")); 33 | } 34 | 35 | @Test 36 | //@Transactional 37 | public void addUser(){ 38 | Role role=new Role(); 39 | role.setId(1L); 40 | role.setName("管理员"); 41 | role.setDeleteFlag(0); 42 | 43 | User user=new User(); 44 | user.setUsername("admin22"); 45 | user.setPassword(passwordEncoder.encode("admin")); 46 | user.setRealName("张三"); 47 | 48 | user.setDeleteFlag(0); 49 | user.setRole(role); 50 | userRepository.save(user); 51 | } 52 | 53 | @Test 54 | public void findUser(){ 55 | userRepository.findByUsername("admin").ifPresent(System.out::println); 56 | } 57 | 58 | @Test 59 | @Transactional 60 | public void lock(){ 61 | userRepository.lockUser(23L); 62 | } 63 | } 64 | --------------------------------------------------------------------------------