├── .gitignore ├── README.md ├── deployment.sh ├── document ├── images │ ├── 1.PNG │ ├── 2.PNG │ ├── 3.PNG │ ├── 4.PNG │ └── logo.png └── xinguan.sql ├── pom.xml ├── xinguan-business ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── com │ │ └── coderman │ │ └── business │ │ ├── converter │ │ ├── ConsumerConverter.java │ │ ├── InStockConverter.java │ │ ├── OutStockConverter.java │ │ ├── ProductCategoryConverter.java │ │ ├── ProductConverter.java │ │ └── SupplierConverter.java │ │ ├── mapper │ │ ├── ConsumerMapper.java │ │ ├── HealthMapper.java │ │ ├── InStockInfoMapper.java │ │ ├── InStockMapper.java │ │ ├── OutStockInfoMapper.java │ │ ├── OutStockMapper.java │ │ ├── ProductCategoryMapper.java │ │ ├── ProductMapper.java │ │ ├── ProductStockMapper.java │ │ └── SupplierMapper.java │ │ └── service │ │ ├── ConsumerService.java │ │ ├── HealthService.java │ │ ├── InStockService.java │ │ ├── OutStockService.java │ │ ├── ProductCategoryService.java │ │ ├── ProductService.java │ │ ├── SupplierService.java │ │ └── imp │ │ ├── ConsumerServiceImpl.java │ │ ├── HealthServiceImpl.java │ │ ├── InStockServiceImpl.java │ │ ├── OutStockServiceImpl.java │ │ ├── ProductCategoryServiceImpl.java │ │ ├── ProductServiceImpl.java │ │ └── SupplierServiceImpl.java └── xinguan-business.iml ├── xinguan-common ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── coderman │ │ │ └── common │ │ │ ├── annotation │ │ │ └── ControllerEndpoint.java │ │ │ ├── dto │ │ │ └── UserLoginDTO.java │ │ │ ├── enums │ │ │ ├── buisiness │ │ │ │ └── BizUserTypeEnum.java │ │ │ └── system │ │ │ │ ├── RoleStatusEnum.java │ │ │ │ ├── UserStatusEnum.java │ │ │ │ └── UserTypeEnum.java │ │ │ ├── error │ │ │ ├── BaseError.java │ │ │ ├── BusinessCodeEnum.java │ │ │ ├── BusinessException.java │ │ │ ├── SystemCodeEnum.java │ │ │ └── SystemException.java │ │ │ ├── model │ │ │ ├── business │ │ │ │ ├── Consumer.java │ │ │ │ ├── Health.java │ │ │ │ ├── InStock.java │ │ │ │ ├── InStockInfo.java │ │ │ │ ├── OutStock.java │ │ │ │ ├── OutStockInfo.java │ │ │ │ ├── Product.java │ │ │ │ ├── ProductCategory.java │ │ │ │ ├── ProductStock.java │ │ │ │ └── Supplier.java │ │ │ └── system │ │ │ │ ├── Department.java │ │ │ │ ├── ImageAttachment.java │ │ │ │ ├── Log.java │ │ │ │ ├── LoginLog.java │ │ │ │ ├── Menu.java │ │ │ │ ├── Role.java │ │ │ │ ├── RoleMenu.java │ │ │ │ ├── User.java │ │ │ │ └── UserRole.java │ │ │ ├── response │ │ │ ├── ActiveUser.java │ │ │ └── ResponseBean.java │ │ │ ├── utils │ │ │ ├── AddressUtil.java │ │ │ ├── BrowserUtil.java │ │ │ ├── CategoryTreeBuilder.java │ │ │ ├── CreateVerifyCode.java │ │ │ ├── FdfsUtil.java │ │ │ ├── IPUtil.java │ │ │ ├── JWTUtils.java │ │ │ ├── ListPageUtils.java │ │ │ └── MenuTreeBuilder.java │ │ │ └── vo │ │ │ ├── business │ │ │ ├── ConsumerVO.java │ │ │ ├── HealthVO.java │ │ │ ├── InStockDetailVO.java │ │ │ ├── InStockItemVO.java │ │ │ ├── InStockVO.java │ │ │ ├── MusicVO.java │ │ │ ├── OutStockDetailVO.java │ │ │ ├── OutStockItemVO.java │ │ │ ├── OutStockVO.java │ │ │ ├── ProductCategoryTreeNodeVO.java │ │ │ ├── ProductCategoryVO.java │ │ │ ├── ProductStockVO.java │ │ │ ├── ProductVO.java │ │ │ └── SupplierVO.java │ │ │ └── system │ │ │ ├── DeanVO.java │ │ │ ├── DepartmentVO.java │ │ │ ├── ImageAttachmentVO.java │ │ │ ├── LogVO.java │ │ │ ├── LoginLogVO.java │ │ │ ├── MenuNodeVO.java │ │ │ ├── MenuVO.java │ │ │ ├── PageVO.java │ │ │ ├── RoleTransferItemVO.java │ │ │ ├── RoleVO.java │ │ │ ├── UserEditVO.java │ │ │ ├── UserInfoVO.java │ │ │ └── UserVO.java │ │ └── resources │ │ └── ip2region │ │ └── ip2region.db └── xinguan-common.iml ├── xinguan-generator ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── coderman │ │ └── generator │ │ └── MybatisGenerator.java │ └── resources │ └── mybatis-generator.xml ├── xinguan-system ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── com │ │ └── coderman │ │ └── system │ │ ├── aspect │ │ ├── AspectSupport.java │ │ └── ControllerEndpointAspect.java │ │ ├── converter │ │ ├── DepartmentConverter.java │ │ ├── MenuConverter.java │ │ ├── RoleConverter.java │ │ └── UserConverter.java │ │ ├── mapper │ │ ├── DepartmentMapper.java │ │ ├── ImageAttachmentMapper.java │ │ ├── LogMapper.java │ │ ├── LoginLogMapper.java │ │ ├── MenuMapper.java │ │ ├── RoleMapper.java │ │ ├── RoleMenuMapper.java │ │ ├── UserMapper.java │ │ └── UserRoleMapper.java │ │ ├── service │ │ ├── DepartmentService.java │ │ ├── LogService.java │ │ ├── LoginLogService.java │ │ ├── MenuService.java │ │ ├── RoleService.java │ │ ├── UploadService.java │ │ ├── UserService.java │ │ └── impl │ │ │ ├── DepartmentServiceImpl.java │ │ │ ├── LogServiceImpl.java │ │ │ ├── LoginLogServiceImpl.java │ │ │ ├── MenuServiceImpl.java │ │ │ ├── RoleServiceImpl.java │ │ │ ├── UploadServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ ├── shiro │ │ ├── JWTFilter.java │ │ ├── JWTToken.java │ │ ├── ShiroConfig.java │ │ └── UserRealm.java │ │ └── util │ │ └── MD5Utils.java └── xinguan-system.iml └── xinguan-web ├── pom.xml ├── src └── main │ ├── java │ └── com │ │ └── coderman │ │ ├── XinguanApplication.java │ │ ├── config │ │ ├── FdfsConfig.java │ │ ├── FdfsConfiguration.java │ │ ├── MyMebMvcConfigurer.java │ │ └── SwaggerConfig.java │ │ └── controller │ │ ├── business │ │ ├── ConsumerController.java │ │ ├── HealthController.java │ │ ├── InStockController.java │ │ ├── OutStockController.java │ │ ├── ProductCategoryController.java │ │ ├── ProductController.java │ │ └── SupplierController.java │ │ └── system │ │ ├── DepartmentController.java │ │ ├── LogController.java │ │ ├── LoginLogController.java │ │ ├── MenuController.java │ │ ├── RoleController.java │ │ ├── UploadController.java │ │ └── UserController.java │ └── resources │ ├── 3828034_www.zykhome.club.pfx │ ├── application-dev.yml │ ├── application-prod.yml │ ├── application.yml │ ├── mapper │ ├── biz │ │ └── ProductStockMapper.xml │ └── system │ │ └── LoginLogExtMapper.xml │ ├── pfx-password.txt │ └── static │ └── json │ └── provinces.json └── xinguan-web.iml /.gitignore: -------------------------------------------------------------------------------- 1 | xinguan-vue/ 2 | .idea 3 | *.iml 4 | target 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

logo

2 |

xinguan   🚀   新冠-物资管理系统

3 |

2020新冠疫情期间, 寂寞消遣之作~

4 |

https://www.zykhome.club

5 | 6 | 7 | --- 8 | 9 |

10 | jdk 8+ 11 | 12 | 13 | 14 | GitHub stars 15 | GitHub forks 16 | size 17 |

18 | 19 | 20 | --- 21 | 22 | >该项目是一个以新冠疫情为主题开发的一个物资管理系统,主要分为系统模块和业务模块,业务模块是处理疫情期间,物资的发放,物资入库,以及查看物资的库存等. 23 | 系统模块是一个后台通用的RBAC权限模块,可以精确的控制到后台API级别的权限控制,项目不定期更新中.武汉加油~~ 24 | 开发模式:前后端分离,前端负责数据渲染,后端返回数据。 25 | 26 | 27 | ### [在线预览](https://www.zykhome.club/#/login "在线预览") & [后端项目](https://github.com/zykzhangyukang/Xinguan "后端项目") & [前端项目](https://github.com/zykzhangyukang/xinguan-vue "前端项目") 28 | 29 | #### 模块划分 30 | 31 | - xinguan-business: 业务模块,所有与业务相关的代码放在此工程中。 32 | - xinguan-system: 系统模块,权限控制相关的代码放在此工程中。 33 | - xinguan-common: 公共模块,存放工具类、领域模型(DTO)、数据模型对象(DO)一些通用的类。 34 | - xinguan-generator: 代码生成器,生成Controller,Service,ServiceImpl,以及前端代码。 35 | - xinguan-vue: 前端项目, npm install 安装依赖后, npm run serve 启动该项目。 36 | - xinguan-web: 处理前端请求的Controller,放在此工程中。 37 | 38 | #### 技术栈 39 | 40 | SpringBoot, Shiro ,Swagger-UI,mybatis,JWT,Mysql,通用mapper,Vue.js+element-ui,FastDFS,Nginx,Node.js(v12.9.1版本) 41 | 42 | #### 演示页面 43 | 44 | 45 | - 后台系统首页 46 | 47 | ![2](https://www.zykhome.club/group1/M00/00/13/rBofMmAT9W2AfurCAAbpCxg4Ryw771.PNG) 48 | 49 | 50 | - 附件管理 51 | 52 | ![3](https://www.zykhome.club/group1/M00/00/13/rBofMmAT9Z-AAZx3AAmL5u2dO1U985.PNG) 53 | 54 | - 物资库存管理 55 | 56 | ![5](https://www.zykhome.club/group1/M00/00/13/rBofMmAT9TSAELlUAAM8r-W_KnQ759.PNG) 57 | 58 | - 物资入库管理 59 | 60 | ![6](https://coderman-blog.oss-cn-beijing.aliyuncs.com/6_1588596788146.PNG) 61 | 62 | ### 打赏作者 63 | 64 | > 一分一毛也是爱,用于服务器维护. 欢迎大家提意哦见~ 65 | 66 | 67 | ![](http://myforum.oss-cn-beijing.aliyuncs.com/postImages/15906789481049ab74aee-3679-4de1-b252-d9fbdda90a08pay.PNG?Expires=1685286948&OSSAccessKeyId=LTAI4FsV5R1tnt8W8kqFqBYh&Signature=yvXZZiVP1pYWeIMkKBILRcHWkHg%3D) 68 | 69 | 70 | ### QQ交流群: 830790908 71 | 72 | 73 | -------------------------------------------------------------------------------- /deployment.sh: -------------------------------------------------------------------------------- 1 | #打包完后的jar名称,替换成你自己项目的名称,该名称可以在maven项目的pom中配置 2 | proc="xinguan-web-0.0.1-SNAPSHOT.jar" 3 | #项目源码的目录地址(初始可能需要自己从Git拉下来) 4 | SOURCE_HOME="/root/application/xinguan-api/xinguan-web" 5 | #项目父工程的目录地址 6 | PARENT_HOME="/root/application/xinguan-api" 7 | #日志地址 8 | APP_LOG="$SOURCE_HOME/target/log_info.log" 9 | #环境配置 用户配置开发(dev),测试(test),生产(prod)的配置文件,避免频繁改动 10 | PROFILES_ACTIVE="spring.profiles.active=prod" 11 | 12 | #JVM启动参数,关于JVM调优这里不介绍,感兴趣的可以自行百度 JVM调优 13 | JAVA_OPTS="-server -Xms512M -Xmx512M -Xss256k -Xmn256m -XX:SurvivorRatio=4 -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -XX:CMSInitiatingOccupancyFraction=90 -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=0 -XX:CMSFullGCsBeforeCompaction=100 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true" 14 | 15 | psid=0 16 | 17 | #检查进程是否存在 18 | checkpid() { 19 | javaps=$(pgrep -f "$proc") 20 | if [ -n "$javaps" ]; then 21 | psid=$javaps 22 | else 23 | psid=0 24 | fi 25 | } 26 | 27 | 28 | #编写启动方法 29 | start() { 30 | checkpid 31 | 32 | if [ $psid -ne 0 ]; then 33 | echo "================================" 34 | echo "warn: $proc already started! (pid=$psid)" 35 | echo "================================" 36 | else 37 | echo "Starting $proc ..." 38 | #到项目源码目录 39 | cd $SOURCE_HOME 40 | #输出,准备获取最新代码 41 | echo -n "git pull source ,please wait ....." 42 | #获取最新代码,此列只在目录所在分支pull 43 | #若想部署指定分支代码,可以在脚本调用参数中添加一个变量,用git checkout ${targer_branch} 44 | git pull 45 | 46 | #输出,最新代码已拉取完毕,准备打包 47 | echo -n "mvn package source ,please wait ....." 48 | 49 | #maven打包命令,此处特别注意是 —U ,是指引用快照版本的jar(引用自己的项目)每次都更新最新的。 50 | cd $PARENT_HOME 51 | echo "======================================进入父工程中打包============================================" 52 | mvn clean package -Dmaven.test.skip=true 53 | echo "======================================项目打包完成================================================" 54 | #打包成功后默认是在父工程中 55 | #到项目源码目录 56 | cd $SOURCE_HOME 57 | cd target 58 | #输出,准备启动 59 | echo -n $"Starting $proc:" 60 | 61 | #循环加载所需的jar,此处和2的pom配置有关 62 | for name in *.jar 63 | do 64 | APP_CLASS="$name" 65 | done 66 | 67 | #启动脚本,--spring.profiles.active= 用于设置环境所使用的配置文件 68 | JAVA_CMD="java "$JAVA_OPTS" -jar "$APP_CLASS" --"$PROFILES_ACTIVE" &" 69 | #后台运行 70 | 71 | $JAVA_CMD & 72 | sleep 1 73 | checkpid 74 | if [ $psid -ne 0 ]; then 75 | echo "======================================" 76 | echo "$proc Start Success! (pid=$psid)[OK]" 77 | echo "======================================" 78 | else 79 | echo "[Failed]" 80 | fi 81 | fi 82 | 83 | } 84 | 85 | 86 | #查看日志 87 | showlog() { 88 | tail -f $APP_LOG 89 | } 90 | 91 | 92 | 93 | #停用项目 94 | stop() { 95 | checkpid 96 | 97 | if [ $psid -ne 0 ]; then 98 | echo -n "Stopping $proc ...(pid=$psid) " 99 | kill -9 $psid 100 | 101 | if [ $? -eq 0 ]; then 102 | echo "[OK]" 103 | else 104 | echo "[Failed]" 105 | fi 106 | 107 | checkpid 108 | if [ $psid -ne 0 ]; then 109 | stop 110 | fi 111 | else 112 | echo "================================" 113 | echo "warn: $proc is not running" 114 | echo "================================" 115 | fi 116 | } 117 | 118 | 119 | #项目状态 120 | status() { 121 | checkpid 122 | if [ $psid -ne 0 ]; then 123 | echo "$proc is running! (pid=$psid)" 124 | else 125 | echo "$proc is not running" 126 | fi 127 | } 128 | 129 | 130 | #设置脚本参数,启动的时候可以采用./脚本名称.sh start/stop/restart/log/status等参数 131 | case "$1" in 132 | start) 133 | start 134 | ;; 135 | stop) 136 | stop 137 | ;; 138 | log) 139 | showlog 140 | ;; 141 | status) 142 | status 143 | ;; 144 | restart) 145 | stop 146 | start 147 | ;; 148 | esac 149 | -------------------------------------------------------------------------------- /document/images/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/document/images/1.PNG -------------------------------------------------------------------------------- /document/images/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/document/images/2.PNG -------------------------------------------------------------------------------- /document/images/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/document/images/3.PNG -------------------------------------------------------------------------------- /document/images/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/document/images/4.PNG -------------------------------------------------------------------------------- /document/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/document/images/logo.png -------------------------------------------------------------------------------- /xinguan-business/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | goods 7 | com.coderman 8 | 0.0.1-SNAPSHOT 9 | 10 | jar 11 | 4.0.0 12 | 13 | xinguan-business 14 | 15 | 16 | 17 | 18 | org.apache.shiro 19 | shiro-spring 20 | 21 | 22 | com.coderman 23 | xinguan-common 24 | 0.0.1-SNAPSHOT 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/converter/ConsumerConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.converter; 2 | 3 | 4 | import com.coderman.common.model.business.Consumer; 5 | import com.coderman.common.vo.business.ConsumerVO; 6 | import org.springframework.beans.BeanUtils; 7 | import org.springframework.util.CollectionUtils; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author zhangyukang 14 | * @Date 2020/3/16 20:27 15 | * @Version 1.0 16 | **/ 17 | public class ConsumerConverter { 18 | 19 | /** 20 | * 转voList 21 | * @param consumers 22 | * @return 23 | */ 24 | public static List converterToVOList(List consumers) { 25 | List supplierVOS=new ArrayList<>(); 26 | if(!CollectionUtils.isEmpty(consumers)){ 27 | for (Consumer supplier : consumers) { 28 | ConsumerVO supplierVO = converterToConsumerVO(supplier); 29 | supplierVOS.add(supplierVO); 30 | } 31 | } 32 | return supplierVOS; 33 | } 34 | 35 | 36 | /*** 37 | * 转VO 38 | * @param supplier 39 | * @return 40 | */ 41 | public static ConsumerVO converterToConsumerVO(Consumer supplier) { 42 | ConsumerVO supplierVO = new ConsumerVO(); 43 | BeanUtils.copyProperties(supplier,supplierVO); 44 | return supplierVO; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/converter/InStockConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.converter; 2 | 3 | import com.coderman.business.mapper.SupplierMapper; 4 | import com.coderman.common.model.business.InStock; 5 | import com.coderman.common.model.business.Supplier; 6 | import com.coderman.common.vo.business.InStockVO; 7 | import org.springframework.beans.BeanUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.CollectionUtils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author zhangyukang 17 | * @Date 2020/3/19 09:58 18 | * @Version 1.0 19 | **/ 20 | @Component 21 | public class InStockConverter { 22 | 23 | @Autowired 24 | private SupplierMapper supplierMapper; 25 | 26 | /** 27 | * 转voList 28 | * @param inStocks 29 | * @return 30 | */ 31 | public List converterToVOList(List inStocks) { 32 | List inStockVOS=new ArrayList<>(); 33 | if(!CollectionUtils.isEmpty(inStocks)){ 34 | for (InStock inStock : inStocks) { 35 | InStockVO inStockVO = new InStockVO(); 36 | BeanUtils.copyProperties(inStock,inStockVO); 37 | Supplier supplier = supplierMapper.selectByPrimaryKey(inStock.getSupplierId()); 38 | if(supplier!=null){ 39 | inStockVO.setSupplierName(supplier.getName()); 40 | inStockVO.setPhone(supplier.getPhone()); 41 | } 42 | inStockVOS.add(inStockVO); 43 | } 44 | } 45 | return inStockVOS; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/converter/OutStockConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.converter; 2 | 3 | import com.coderman.business.mapper.ConsumerMapper; 4 | import com.coderman.common.model.business.Consumer; 5 | import com.coderman.common.model.business.OutStock; 6 | import com.coderman.common.vo.business.OutStockVO; 7 | import org.springframework.beans.BeanUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.CollectionUtils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author zhangyukang 17 | * @Date 2020/5/10 14:32 18 | * @Version 1.0 19 | **/ 20 | @Component 21 | public class OutStockConverter { 22 | 23 | @Autowired 24 | private ConsumerMapper consumerMapper; 25 | 26 | /** 27 | * 转voList 28 | * @param outStocks 29 | * @return 30 | */ 31 | public List converterToVOList(List outStocks) { 32 | List outStockVOS=new ArrayList<>(); 33 | if(!CollectionUtils.isEmpty(outStocks)){ 34 | for (OutStock outStock : outStocks) { 35 | OutStockVO outStockVO = new OutStockVO(); 36 | BeanUtils.copyProperties(outStock,outStockVO); 37 | Consumer consumer = consumerMapper.selectByPrimaryKey(outStock.getConsumerId()); 38 | if(consumer!=null){ 39 | outStockVO.setName(consumer.getName()); 40 | outStockVO.setPhone(consumer.getPhone()); 41 | } 42 | outStockVOS.add(outStockVO); 43 | } 44 | } 45 | return outStockVOS; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/converter/ProductCategoryConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.converter; 2 | 3 | import com.coderman.common.model.business.ProductCategory; 4 | import com.coderman.common.vo.business.ProductCategoryTreeNodeVO; 5 | import com.coderman.common.vo.business.ProductCategoryVO; 6 | import org.springframework.beans.BeanUtils; 7 | import org.springframework.util.CollectionUtils; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author zhangyukang 14 | * @Date 2020/3/16 17:26 15 | * @Version 1.0 16 | **/ 17 | public class ProductCategoryConverter { 18 | 19 | /** 20 | * 转vo 21 | * @param productCategory 22 | * @return 23 | */ 24 | public static ProductCategoryVO converterToProductCategoryVO(ProductCategory productCategory) { 25 | ProductCategoryVO productCategoryVO = new ProductCategoryVO(); 26 | BeanUtils.copyProperties(productCategory,productCategoryVO); 27 | return productCategoryVO; 28 | } 29 | 30 | /** 31 | * 转voList 32 | * @param productCategories 33 | * @return 34 | */ 35 | public static List converterToVOList(List productCategories) { 36 | List productCategoryVOS=new ArrayList<>(); 37 | if(!CollectionUtils.isEmpty(productCategories)){ 38 | for (ProductCategory productCategory : productCategories) { 39 | ProductCategoryVO productCategoryVO = new ProductCategoryVO(); 40 | BeanUtils.copyProperties(productCategory,productCategoryVO); 41 | productCategoryVOS.add(productCategoryVO); 42 | } 43 | } 44 | return productCategoryVOS; 45 | } 46 | 47 | /** 48 | * 转树节点 49 | * @param productCategoryVOList 50 | * @return 51 | */ 52 | public static List converterToTreeNodeVO(List productCategoryVOList) { 53 | List nodes=new ArrayList<>(); 54 | if(!CollectionUtils.isEmpty(productCategoryVOList)){ 55 | for (ProductCategoryVO productCategoryVO : productCategoryVOList) { 56 | ProductCategoryTreeNodeVO productCategoryTreeNodeVO = new ProductCategoryTreeNodeVO(); 57 | BeanUtils.copyProperties(productCategoryVO,productCategoryTreeNodeVO); 58 | nodes.add(productCategoryTreeNodeVO); 59 | } 60 | } 61 | return nodes; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/converter/ProductConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.converter; 2 | 3 | import com.coderman.common.model.business.Product; 4 | import com.coderman.common.vo.business.ProductVO; 5 | import org.springframework.beans.BeanUtils; 6 | import org.springframework.util.CollectionUtils; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/17 09:22 14 | * @Version 1.0 15 | **/ 16 | public class ProductConverter { 17 | 18 | 19 | /** 20 | * 转VOList 21 | * @param products 22 | * @return 23 | */ 24 | public static List converterToVOList(List products) { 25 | List productVOS=new ArrayList<>(); 26 | if(!CollectionUtils.isEmpty(products)){ 27 | for (Product product : products) { 28 | ProductVO productVO = converterToProductVO(product); 29 | productVOS.add(productVO); 30 | } 31 | } 32 | return productVOS; 33 | } 34 | 35 | /** 36 | * 转VO 37 | * @param product 38 | * @return 39 | */ 40 | public static ProductVO converterToProductVO(Product product) { 41 | ProductVO productVO = new ProductVO(); 42 | BeanUtils.copyProperties(product,productVO); 43 | return productVO; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/converter/SupplierConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.converter; 2 | 3 | import com.coderman.common.model.business.Supplier; 4 | import com.coderman.common.vo.business.SupplierVO; 5 | import org.springframework.beans.BeanUtils; 6 | import org.springframework.util.CollectionUtils; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/16 20:27 14 | * @Version 1.0 15 | **/ 16 | public class SupplierConverter { 17 | 18 | /** 19 | * 转voList 20 | * @param suppliers 21 | * @return 22 | */ 23 | public static List converterToVOList(List suppliers) { 24 | List supplierVOS=new ArrayList<>(); 25 | if(!CollectionUtils.isEmpty(suppliers)){ 26 | for (Supplier supplier : suppliers) { 27 | SupplierVO supplierVO = converterToSupplierVO(supplier); 28 | supplierVOS.add(supplierVO); 29 | } 30 | } 31 | return supplierVOS; 32 | } 33 | 34 | 35 | /*** 36 | * 转VO 37 | * @param supplier 38 | * @return 39 | */ 40 | public static SupplierVO converterToSupplierVO(Supplier supplier) { 41 | SupplierVO supplierVO = new SupplierVO(); 42 | BeanUtils.copyProperties(supplier,supplierVO); 43 | return supplierVO; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/ConsumerMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.Consumer; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/4/5 09:55 10 | * @Version 1.0 11 | **/ 12 | public interface ConsumerMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/HealthMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | import com.coderman.common.model.business.Health; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.apache.ibatis.annotations.Select; 6 | import tk.mybatis.mapper.common.Mapper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/5/7 10:16 13 | * @Version 1.0 14 | **/ 15 | public interface HealthMapper extends Mapper { 16 | /** 17 | * 今日是否打卡 18 | * @param id 19 | * @return 20 | */ 21 | @Select("select * from biz_health where create_time < (CURDATE()+1) " + 22 | " and create_time>CURDATE() and user_id=#{id}") 23 | List isReport(@Param("id") Long id); 24 | } 25 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/InStockInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | import com.coderman.common.model.business.InStockInfo; 4 | import tk.mybatis.mapper.common.Mapper; 5 | 6 | /** 7 | * @Author zhangyukang 8 | * @Date 2020/3/20 15:46 9 | * @Version 1.0 10 | **/ 11 | public interface InStockInfoMapper extends Mapper { 12 | } 13 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/InStockMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.InStock; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/19 09:53 10 | * @Version 1.0 11 | **/ 12 | public interface InStockMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/OutStockInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.OutStockInfo; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/5/25 11:11 10 | * @Version 1.0 11 | **/ 12 | public interface OutStockInfoMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/OutStockMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.OutStock; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/19 09:53 10 | * @Version 1.0 11 | **/ 12 | public interface OutStockMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/ProductCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.ProductCategory; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/16 18:16 10 | * @Version 1.0 11 | **/ 12 | public interface ProductCategoryMapper extends Mapper { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.Product; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/17 09:18 10 | * @Version 1.0 11 | **/ 12 | public interface ProductMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/ProductStockMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.ProductStock; 5 | import com.coderman.common.vo.business.ProductStockVO; 6 | import com.coderman.common.vo.business.ProductVO; 7 | import tk.mybatis.mapper.common.Mapper; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/21 19:38 14 | * @Version 1.0 15 | **/ 16 | public interface ProductStockMapper extends Mapper { 17 | 18 | /** 19 | * 库存列表 20 | * @param productVO 21 | * @return 22 | */ 23 | List findProductStocks(ProductVO productVO); 24 | 25 | /** 26 | * 库存信息(饼图使用) 27 | * @return 28 | */ 29 | List findAllStocks(ProductVO productVO); 30 | } 31 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/mapper/SupplierMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.mapper; 2 | 3 | 4 | import com.coderman.common.model.business.Supplier; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/16 20:21 10 | * @Version 1.0 11 | **/ 12 | public interface SupplierMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/ConsumerService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.model.business.Consumer; 5 | import com.coderman.common.vo.business.ConsumerVO; 6 | import com.coderman.common.vo.system.PageVO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/4/5 09:53 13 | * @Version 1.0 14 | **/ 15 | public interface ConsumerService { 16 | 17 | /** 18 | * 添加物资去向 19 | * @param consumerVO 20 | */ 21 | Consumer add(ConsumerVO consumerVO); 22 | 23 | 24 | /** 25 | * 物资去向列表 26 | * @param pageNum 27 | * @param pageSize 28 | * @param consumerVO 29 | * @return 30 | */ 31 | PageVO findConsumerList(Integer pageNum, Integer pageSize, ConsumerVO consumerVO); 32 | 33 | 34 | /** 35 | * 编辑物资去向 36 | * @param id 37 | * @return 38 | */ 39 | ConsumerVO edit(Long id); 40 | 41 | /** 42 | * 更新物资去向 43 | * @param id 44 | * @param consumerVO 45 | */ 46 | void update(Long id, ConsumerVO consumerVO); 47 | 48 | /** 49 | * 删除物资去向 50 | * @param id 51 | */ 52 | void delete(Long id); 53 | 54 | /** 55 | * 查询所有物资去向 56 | * @return 57 | */ 58 | List findAll(); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/HealthService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.error.BusinessException; 5 | import com.coderman.common.model.business.Health; 6 | import com.coderman.common.vo.business.HealthVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/5/7 10:20 12 | * @Version 1.0 13 | **/ 14 | public interface HealthService { 15 | 16 | /** 17 | * 健康上报 18 | * @param healthVO 19 | */ 20 | void report(HealthVO healthVO) throws BusinessException; 21 | 22 | /** 23 | * 今日是否已经报备 24 | * @param id 25 | * @return 26 | */ 27 | Health isReport(Long id); 28 | 29 | /** 30 | * 签到记录 31 | * @return 32 | */ 33 | PageVO history(Long id, Integer pageNum, Integer pageSize); 34 | } 35 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/InStockService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.error.BusinessException; 5 | import com.coderman.common.vo.business.InStockDetailVO; 6 | import com.coderman.common.vo.business.InStockVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/3/19 09:54 12 | * @Version 1.0 13 | **/ 14 | public interface InStockService { 15 | 16 | /** 17 | * 入库单列表 18 | * @param pageNum 19 | * @param pageSize 20 | * @param inStockVO 21 | * @return 22 | */ 23 | PageVO findInStockList(Integer pageNum, Integer pageSize, InStockVO inStockVO); 24 | 25 | 26 | /** 27 | * 入库单明细 28 | * @param id 29 | * @return 30 | */ 31 | InStockDetailVO detail(Long id, int pageNo, int pageSize) throws BusinessException; 32 | 33 | /** 34 | * 删除入库单 35 | * @param id 36 | */ 37 | void delete(Long id) throws BusinessException; 38 | 39 | /** 40 | * 物资入库 41 | * @param inStockVO 42 | */ 43 | void addIntoStock(InStockVO inStockVO) throws BusinessException; 44 | 45 | /** 46 | * 移入回收站 47 | * @param id 48 | */ 49 | void remove(Long id) throws BusinessException; 50 | 51 | /** 52 | * 还原从回收站中 53 | * @param id 54 | */ 55 | void back(Long id) throws BusinessException; 56 | 57 | /** 58 | * 入库审核 59 | * @param id 60 | */ 61 | void publish(Long id) throws BusinessException; 62 | } 63 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/OutStockService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.error.BusinessException; 5 | import com.coderman.common.vo.business.OutStockDetailVO; 6 | import com.coderman.common.vo.business.OutStockVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/5/10 14:26 12 | * @Version 1.0 13 | **/ 14 | public interface OutStockService { 15 | 16 | /** 17 | * 出库单列表 18 | * @param pageNum 19 | * @param pageSize 20 | * @param outStockVO 21 | * @return 22 | */ 23 | PageVO findOutStockList(Integer pageNum, Integer pageSize, OutStockVO outStockVO); 24 | 25 | /** 26 | * 提交物资发放单 27 | * @param outStockVO 28 | */ 29 | void addOutStock(OutStockVO outStockVO) throws BusinessException; 30 | 31 | /** 32 | * 移入回收站 33 | * @param id 34 | */ 35 | void remove(Long id) throws BusinessException; 36 | 37 | /** 38 | * 恢复发放单 39 | * @param id 40 | */ 41 | void back(Long id) throws BusinessException; 42 | 43 | /** 44 | * 发放单详情 45 | * @param id 46 | * @param pageNum 47 | * @param pageSize 48 | * @return 49 | */ 50 | OutStockDetailVO detail(Long id, Integer pageNum, Integer pageSize) throws BusinessException; 51 | 52 | /** 53 | * 删除发放单 54 | * @param id 55 | */ 56 | void delete(Long id) throws BusinessException; 57 | 58 | /** 59 | * 发放单审核 60 | * @param id 61 | */ 62 | void publish(Long id) throws BusinessException; 63 | } 64 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/ProductCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.error.BusinessException; 5 | import com.coderman.common.vo.business.ProductCategoryTreeNodeVO; 6 | import com.coderman.common.vo.business.ProductCategoryVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/16 17:18 14 | * @Version 1.0 15 | **/ 16 | public interface ProductCategoryService { 17 | 18 | /** 19 | * 添加物资类别 20 | * @param ProductCategoryVO 21 | */ 22 | void add(ProductCategoryVO ProductCategoryVO); 23 | 24 | 25 | /** 26 | * 部门列表 27 | * @param pageNum 28 | * @param pageSize 29 | * @param ProductCategoryVO 30 | * @return 31 | */ 32 | PageVO findProductCategoryList(Integer pageNum, Integer pageSize, ProductCategoryVO ProductCategoryVO); 33 | 34 | 35 | /** 36 | * 编辑物资类别 37 | * @param id 38 | * @return 39 | */ 40 | ProductCategoryVO edit(Long id); 41 | 42 | /** 43 | * 更新物资类别 44 | * @param id 45 | * @param ProductCategoryVO 46 | */ 47 | void update(Long id, ProductCategoryVO ProductCategoryVO); 48 | 49 | /** 50 | * 删除物资类别 51 | * @param id 52 | */ 53 | void delete(Long id) throws BusinessException; 54 | 55 | /** 56 | * 查询所物资类别 57 | * @return 58 | */ 59 | List findAll(); 60 | 61 | /** 62 | * 分类树形 63 | * @return 64 | */ 65 | PageVO categoryTree(Integer pageNum, Integer pageSize); 66 | 67 | /** 68 | * 获取父级分类(2级树) 69 | * @return 70 | */ 71 | List getParentCategoryTree(); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.error.BusinessException; 5 | import com.coderman.common.vo.business.ProductStockVO; 6 | import com.coderman.common.vo.business.ProductVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/16 17:18 14 | * @Version 1.0 15 | **/ 16 | public interface ProductService { 17 | 18 | /** 19 | * 添加商品 20 | * @param productVO 21 | */ 22 | void add(ProductVO productVO); 23 | 24 | 25 | /** 26 | * 商品列表 27 | * @param pageNum 28 | * @param pageSize 29 | * @param productVO 30 | * @return 31 | */ 32 | PageVO findProductList(Integer pageNum, Integer pageSize, ProductVO productVO); 33 | 34 | 35 | /** 36 | * 编辑商品 37 | * @param id 38 | * @return 39 | */ 40 | ProductVO edit(Long id); 41 | 42 | /** 43 | * 更新商品 44 | * @param id 45 | * @param productVO 46 | */ 47 | void update(Long id, ProductVO productVO); 48 | 49 | /** 50 | * 删除商品 51 | * @param id 52 | */ 53 | void delete(Long id) throws BusinessException; 54 | 55 | /** 56 | * 库存列表 57 | * @param pageNum 58 | * @param pageSize 59 | * @param productVO 60 | * @return 61 | */ 62 | PageVO findProductStocks(Integer pageNum, Integer pageSize, ProductVO productVO); 63 | 64 | /** 65 | * 所有库存信息 66 | * @return 67 | */ 68 | List findAllStocks(Integer pageNum, Integer pageSize, ProductVO productVO); 69 | 70 | /** 71 | * 移入回收站 72 | * @param id 73 | */ 74 | void remove(Long id) throws BusinessException; 75 | 76 | /** 77 | * 从回收站恢复数据 78 | * @param id 79 | */ 80 | void back(Long id) throws BusinessException; 81 | 82 | /** 83 | * 物资添加审核 84 | * @param id 85 | */ 86 | void publish(Long id) throws BusinessException; 87 | 88 | 89 | } 90 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/SupplierService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service; 2 | 3 | 4 | import com.coderman.common.model.business.Supplier; 5 | import com.coderman.common.vo.business.SupplierVO; 6 | import com.coderman.common.vo.system.PageVO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/3/16 17:18 13 | * @Version 1.0 14 | **/ 15 | public interface SupplierService { 16 | 17 | /** 18 | * 添加供应商 19 | * @param supplierVO 20 | */ 21 | Supplier add(SupplierVO supplierVO); 22 | 23 | 24 | /** 25 | * 供应商列表 26 | * @param pageNum 27 | * @param pageSize 28 | * @param supplierVO 29 | * @return 30 | */ 31 | PageVO findSupplierList(Integer pageNum, Integer pageSize, SupplierVO supplierVO); 32 | 33 | 34 | /** 35 | * 编辑供应商 36 | * @param id 37 | * @return 38 | */ 39 | SupplierVO edit(Long id); 40 | 41 | /** 42 | * 更新供应商 43 | * @param id 44 | * @param supplierVO 45 | */ 46 | void update(Long id, SupplierVO supplierVO); 47 | 48 | /** 49 | * 删除供应商 50 | * @param id 51 | */ 52 | void delete(Long id); 53 | 54 | /** 55 | * 查询所有供应商 56 | * @return 57 | */ 58 | List findAll(); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/imp/ConsumerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service.imp; 2 | 3 | import com.coderman.business.converter.ConsumerConverter; 4 | import com.coderman.business.mapper.ConsumerMapper; 5 | import com.coderman.business.service.ConsumerService; 6 | import com.coderman.common.model.business.Consumer; 7 | import com.coderman.common.vo.business.ConsumerVO; 8 | import com.coderman.common.vo.system.PageVO; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import org.springframework.beans.BeanUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import tk.mybatis.mapper.entity.Example; 15 | 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | /** 20 | * @Author zhangyukang 21 | * @Date 2020/3/16 17:19 22 | * @Version 1.0 23 | **/ 24 | @Service 25 | public class ConsumerServiceImpl implements ConsumerService { 26 | 27 | 28 | @Autowired 29 | private ConsumerMapper consumerMapper; 30 | 31 | /** 32 | * 供应商列表 33 | * @param pageNum 34 | * @param pageSize 35 | * @param consumerVO 36 | * @return 37 | */ 38 | @Override 39 | public PageVO findConsumerList(Integer pageNum, Integer pageSize, ConsumerVO consumerVO) { 40 | PageHelper.startPage(pageNum, pageSize); 41 | Example o = new Example(Consumer.class); 42 | Example.Criteria criteria = o.createCriteria(); 43 | o.setOrderByClause("sort asc"); 44 | if (consumerVO.getName() != null && !"".equals(consumerVO.getName())) { 45 | criteria.andLike("name", "%" + consumerVO.getName() + "%"); 46 | } 47 | if (consumerVO.getAddress() != null && !"".equals(consumerVO.getAddress())) { 48 | criteria.andLike("address", "%" + consumerVO.getAddress() + "%"); 49 | } 50 | if (consumerVO.getContact() != null && !"".equals(consumerVO.getContact())) { 51 | criteria.andLike("contact", "%" + consumerVO.getContact() + "%"); 52 | } 53 | List consumers = consumerMapper.selectByExample(o); 54 | List categoryVOS= ConsumerConverter.converterToVOList(consumers); 55 | PageInfo info = new PageInfo<>(consumers); 56 | return new PageVO<>(info.getTotal(), categoryVOS); 57 | } 58 | 59 | 60 | 61 | /** 62 | * 添加供应商 63 | * @param ConsumerVO 64 | */ 65 | @Override 66 | public Consumer add(ConsumerVO ConsumerVO) { 67 | Consumer consumer = new Consumer(); 68 | BeanUtils.copyProperties(ConsumerVO,consumer); 69 | consumer.setCreateTime(new Date()); 70 | consumer.setModifiedTime(new Date()); 71 | consumerMapper.insert(consumer); 72 | return consumer; 73 | } 74 | 75 | /** 76 | * 编辑供应商 77 | * @param id 78 | * @return 79 | */ 80 | @Override 81 | public ConsumerVO edit(Long id) { 82 | Consumer consumer = consumerMapper.selectByPrimaryKey(id); 83 | return ConsumerConverter.converterToConsumerVO(consumer); 84 | } 85 | 86 | /** 87 | * 更新供应商 88 | * @param id 89 | * @param ConsumerVO 90 | */ 91 | @Override 92 | public void update(Long id, ConsumerVO ConsumerVO) { 93 | Consumer consumer = new Consumer(); 94 | BeanUtils.copyProperties(ConsumerVO,consumer); 95 | consumer.setModifiedTime(new Date()); 96 | consumerMapper.updateByPrimaryKeySelective(consumer); 97 | } 98 | 99 | /** 100 | * 删除供应商 101 | * @param id 102 | */ 103 | @Override 104 | public void delete(Long id) { 105 | consumerMapper.deleteByPrimaryKey(id); 106 | } 107 | 108 | /** 109 | * 查询所有 110 | * @return 111 | */ 112 | @Override 113 | public List findAll() { 114 | List consumers = consumerMapper.selectAll(); 115 | return ConsumerConverter.converterToVOList(consumers); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/imp/HealthServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service.imp; 2 | 3 | import com.coderman.business.mapper.HealthMapper; 4 | import com.coderman.business.service.HealthService; 5 | import com.coderman.common.error.BusinessCodeEnum; 6 | import com.coderman.common.error.BusinessException; 7 | import com.coderman.common.model.business.Health; 8 | import com.coderman.common.vo.business.HealthVO; 9 | import com.coderman.common.vo.system.PageVO; 10 | import com.github.pagehelper.PageHelper; 11 | import com.github.pagehelper.PageInfo; 12 | import org.springframework.beans.BeanUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Service; 15 | import tk.mybatis.mapper.entity.Example; 16 | 17 | import java.util.Date; 18 | import java.util.List; 19 | 20 | /** 21 | * @Author zhangyukang 22 | * @Date 2020/5/7 10:21 23 | * @Version 1.0 24 | **/ 25 | @Service 26 | public class HealthServiceImpl implements HealthService { 27 | 28 | @Autowired 29 | private HealthMapper healthMapper; 30 | 31 | /** 32 | * 健康上报 33 | * @param healthVO 34 | */ 35 | @Override 36 | public void report(HealthVO healthVO) throws BusinessException { 37 | Health report = isReport(healthVO.getUserId()); 38 | if(report!=null) { 39 | throw new BusinessException(BusinessCodeEnum.PARAMETER_ERROR, "今日已经打卡,无法重复打卡!"); 40 | } 41 | Health health = new Health(); 42 | BeanUtils.copyProperties(healthVO,health); 43 | health.setCreateTime(new Date()); 44 | healthMapper.insert(health); 45 | } 46 | 47 | /** 48 | * 今日是否已报备 49 | * @param id 50 | * @return 51 | */ 52 | @Override 53 | public Health isReport(Long id) { 54 | List health=healthMapper.isReport(id); 55 | if(health.size()>0){ 56 | return health.get(0); 57 | } 58 | return null; 59 | } 60 | 61 | /** 62 | * 签到历史记录 63 | * @return 64 | */ 65 | @Override 66 | public PageVO history(Long id,Integer pageNum,Integer pageSize) { 67 | Example o = new Example(Health.class); 68 | o.setOrderByClause("create_time desc"); 69 | PageHelper.startPage(pageNum,pageSize); 70 | o.createCriteria().andEqualTo("userId",id); 71 | List health = healthMapper.selectByExample(o); 72 | PageInfo pageInfo=new PageInfo<>(health); 73 | return new PageVO<>(pageInfo.getTotal(),pageInfo.getList()); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /xinguan-business/src/main/java/com/coderman/business/service/imp/SupplierServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.coderman.business.service.imp; 2 | 3 | import com.coderman.business.converter.SupplierConverter; 4 | import com.coderman.business.mapper.SupplierMapper; 5 | import com.coderman.business.service.SupplierService; 6 | import com.coderman.common.model.business.Supplier; 7 | import com.coderman.common.vo.business.SupplierVO; 8 | import com.coderman.common.vo.system.PageVO; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import org.springframework.beans.BeanUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import tk.mybatis.mapper.entity.Example; 15 | 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | /** 20 | * @Author zhangyukang 21 | * @Date 2020/3/16 17:19 22 | * @Version 1.0 23 | **/ 24 | @Service 25 | public class SupplierServiceImpl implements SupplierService { 26 | 27 | 28 | @Autowired 29 | private SupplierMapper supplierMapper; 30 | 31 | /** 32 | * 供应商列表 33 | * @param pageNum 34 | * @param pageSize 35 | * @param supplierVO 36 | * @return 37 | */ 38 | @Override 39 | public PageVO findSupplierList(Integer pageNum, Integer pageSize, SupplierVO supplierVO) { 40 | PageHelper.startPage(pageNum, pageSize); 41 | Example o = new Example(Supplier.class); 42 | Example.Criteria criteria = o.createCriteria(); 43 | o.setOrderByClause("sort asc"); 44 | if (supplierVO.getName() != null && !"".equals(supplierVO.getName())) { 45 | criteria.andLike("name", "%" + supplierVO.getName() + "%"); 46 | } 47 | if (supplierVO.getContact() != null && !"".equals(supplierVO.getContact())) { 48 | criteria.andLike("contact", "%" + supplierVO.getContact() + "%"); 49 | } 50 | if (supplierVO.getAddress() != null && !"".equals(supplierVO.getAddress())) { 51 | criteria.andLike("address", "%" + supplierVO.getAddress() + "%"); 52 | } 53 | List suppliers = supplierMapper.selectByExample(o); 54 | List categoryVOS= SupplierConverter.converterToVOList(suppliers); 55 | PageInfo info = new PageInfo<>(suppliers); 56 | return new PageVO<>(info.getTotal(), categoryVOS); 57 | } 58 | 59 | 60 | 61 | /** 62 | * 添加供应商 63 | * @param SupplierVO 64 | */ 65 | @Override 66 | public Supplier add(SupplierVO SupplierVO) { 67 | Supplier supplier = new Supplier(); 68 | BeanUtils.copyProperties(SupplierVO,supplier); 69 | supplier.setCreateTime(new Date()); 70 | supplier.setModifiedTime(new Date()); 71 | supplierMapper.insert(supplier); 72 | return supplier; 73 | } 74 | 75 | /** 76 | * 编辑供应商 77 | * @param id 78 | * @return 79 | */ 80 | @Override 81 | public SupplierVO edit(Long id) { 82 | Supplier supplier = supplierMapper.selectByPrimaryKey(id); 83 | return SupplierConverter.converterToSupplierVO(supplier); 84 | } 85 | 86 | /** 87 | * 更新供应商 88 | * @param id 89 | * @param SupplierVO 90 | */ 91 | @Override 92 | public void update(Long id, SupplierVO SupplierVO) { 93 | Supplier supplier = new Supplier(); 94 | BeanUtils.copyProperties(SupplierVO,supplier); 95 | supplier.setModifiedTime(new Date()); 96 | supplierMapper.updateByPrimaryKeySelective(supplier); 97 | } 98 | 99 | /** 100 | * 删除供应商 101 | * @param id 102 | */ 103 | @Override 104 | public void delete(Long id) { 105 | supplierMapper.deleteByPrimaryKey(id); 106 | } 107 | 108 | /** 109 | * 查询所有 110 | * @return 111 | */ 112 | @Override 113 | public List findAll() { 114 | List suppliers = supplierMapper.selectAll(); 115 | return SupplierConverter.converterToVOList(suppliers); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /xinguan-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | goods 7 | com.coderman 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | jar 13 | 14 | xinguan-common 15 | 16 | 17 | 18 | org.lionsoul 19 | ip2region 20 | 21 | 22 | com.alibaba 23 | druid-spring-boot-starter 24 | 25 | 26 | mysql 27 | mysql-connector-java 28 | 29 | 30 | com.google.code.gson 31 | gson 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-aop 36 | 2.3.3.RELEASE 37 | 38 | 39 | com.alibaba 40 | fastjson 41 | 42 | 43 | org.mybatis.spring.boot 44 | mybatis-spring-boot-starter 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-web 49 | 50 | 51 | org.projectlombok 52 | lombok 53 | 54 | 55 | com.wuwenze 56 | ExcelKit 57 | 58 | 59 | tk.mybatis 60 | mapper 61 | 62 | 63 | io.springfox 64 | springfox-swagger2 65 | 66 | 67 | io.springfox 68 | springfox-swagger-ui 69 | 70 | 71 | com.github.pagehelper 72 | pagehelper-spring-boot-starter 73 | 74 | 75 | eu.bitwalker 76 | UserAgentUtils 77 | 78 | 79 | com.github.tobato 80 | fastdfs-client 81 | 82 | 83 | com.auth0 84 | java-jwt 85 | 86 | 87 | 88 | 89 | 90 | 91 | src/main/java 92 | 93 | **/*.xml 94 | 95 | 96 | 97 | src/main/resources 98 | 99 | **.* 100 | **/*.* 101 | **/*/*.* 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/annotation/ControllerEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | 9 | /** 10 | * 自定义注解,用于标注在controller的方法上,异步记录日志 11 | * create by zhangyukang 12 | */ 13 | @Target(ElementType.METHOD) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface ControllerEndpoint { 16 | 17 | String operation() default ""; 18 | String exceptionMessage() default "系统内部异常"; 19 | } 20 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/dto/UserLoginDTO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/12/16 21:40 12 | * @Version 1.0 13 | **/ 14 | @Data 15 | @ApiModel(value = "用户登入表单") 16 | public class UserLoginDTO { 17 | @NotBlank(message = "用户名不能为空") 18 | @ApiModelProperty(value = "用户名") 19 | private String username; 20 | @NotBlank(message = "密码不能为空") 21 | @ApiModelProperty(value = "密码") 22 | private String password; 23 | } 24 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/enums/buisiness/BizUserTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.enums.buisiness; 2 | 3 | /** 4 | * 业务用户类型 5 | * @Author zhangyukang 6 | * @Date 2020/3/15 18:37 7 | * @Version 1.0 8 | **/ 9 | public enum BizUserTypeEnum { 10 | 11 | DEAN("部门主任"); 12 | private String val; 13 | 14 | BizUserTypeEnum(String val) { 15 | this.val = val; 16 | } 17 | 18 | public String getVal() { 19 | return val; 20 | } 21 | 22 | public void setVal(String val) { 23 | this.val = val; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/enums/system/RoleStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.enums.system; 2 | 3 | /** 4 | * @Author zhangyukang 5 | * @Date 2020/5/29 16:52 6 | * @Version 1.0 7 | **/ 8 | 9 | 10 | public enum RoleStatusEnum { 11 | DISABLE(0), 12 | AVAILABLE(1); 13 | 14 | private int statusCode; 15 | 16 | RoleStatusEnum(int statusCode) { 17 | this.statusCode = statusCode; 18 | } 19 | 20 | public int getStatusCode() { 21 | return statusCode; 22 | } 23 | 24 | public void setStatusCode(int statusCode) { 25 | this.statusCode = statusCode; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/enums/system/UserStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.enums.system; 2 | 3 | /** 4 | * 用户状态 5 | * @Author zhangyukang 6 | * @Date 2020/5/29 12:29 7 | * @Version 1.0 8 | **/ 9 | public enum UserStatusEnum { 10 | 11 | DISABLE(0), 12 | AVAILABLE(1); 13 | 14 | private int statusCode; 15 | 16 | UserStatusEnum(int statusCode) { 17 | this.statusCode = statusCode; 18 | } 19 | 20 | public int getStatusCode() { 21 | return statusCode; 22 | } 23 | 24 | public void setStatusCode(int statusCode) { 25 | this.statusCode = statusCode; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/enums/system/UserTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.enums.system; 2 | 3 | /** 4 | * 用户类型 5 | * @Author zhangyukang 6 | * @Date 2020/5/29 12:25 7 | * @Version 1.0 8 | **/ 9 | public enum UserTypeEnum { 10 | 11 | SYSTEM_ADMIN(0),//系统管理员admin 12 | 13 | SYSTEM_USER(1);//系统的普通用户 14 | 15 | private int typeCode; 16 | 17 | UserTypeEnum(int typeCode) { 18 | this.typeCode = typeCode; 19 | } 20 | 21 | public int getTypeCode() { 22 | return typeCode; 23 | } 24 | 25 | public void setTypeCode(int typeCode) { 26 | this.typeCode = typeCode; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/error/BaseError.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.error; 2 | 3 | /** 4 | * 自定义的错误描述枚举类需实现该接口 5 | * @Author zhangyukang 6 | * @Date 2020/3/1 14:49 7 | * @Version 1.0 8 | **/ 9 | public interface BaseError { 10 | 11 | /** 12 | * 获取错误码 13 | * @return 14 | */ 15 | int getErrorCode(); 16 | 17 | /** 18 | * 获取错误信息 19 | * @return 20 | */ 21 | String getErrorMsg(); 22 | 23 | 24 | /** 25 | * 设置错误信息 26 | * @param message 27 | * @return 28 | */ 29 | BaseError setErrorMsg(String message); 30 | } 31 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/error/BusinessCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.error; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * 7 | * 业务错误码:返回结果的状态码 8 | * 9 | * 如果想要代码更具维护性一点,可以定义不同种类的错误码,都实现 BaseCodeInterface 10 | * @Author zhangyukang 11 | * @Date 2020/3/1 14:51 12 | * @Version 1.0 13 | **/ 14 | @Getter 15 | public enum BusinessCodeEnum implements BaseError { 16 | 17 | //通用的异常以0000开头 18 | PARAMETER_ERROR(00001,"参数不合法"), 19 | 20 | // 数据操作错误定义 21 | BODY_NOT_MATCH(400,"请求的数据格式不符!"), 22 | SIGNATURE_NOT_MATCH(401,"请求的数字签名不匹配!"), 23 | NOT_FOUND(404, "未找到该资源!"), 24 | INTERNAL_SERVER_ERROR(500, "服务器内部错误!"), 25 | SERVER_BUSY(503,"服务器正忙,请稍后再试!"), 26 | //用户相关:10000** 27 | USER_ACCOUNT_NOT_FOUND(10001, "账号不存在!"), 28 | DoNotAllowToDisableTheCurrentUser(10002,"不允许禁用当前用户"), 29 | //业务异常 30 | PRODUCT_IS_REMOVE(30001,"物资已移入回收站"), 31 | PRODUCT_NOT_FOUND(30002,"物资找不到"), 32 | PRODUCT_WAIT_PASS(30003,"物资等待审核"), 33 | PRODUCT_STATUS_ERROR(30004,"物资状态错误"), 34 | PRODUCT_IN_STOCK_NUMBER_ERROR(30005,"物资入库数量非法"), 35 | PRODUCT_OUT_STOCK_NUMBER_ERROR(30008,"物资发放数量非法"), 36 | PRODUCT_IN_STOCK_EMPTY(30006,"物资入库不能为空"), 37 | PRODUCT_OUT_STOCK_EMPTY(30007,"物资发放不能为空"), 38 | PRODUCT_STOCK_ERROR(30009,"物资库存不足"); 39 | /** 错误码 */ 40 | private int errorCode; 41 | 42 | /** 错误描述 */ 43 | private String errorMsg; 44 | 45 | BusinessCodeEnum(int errorCode, String errorMsg) { 46 | this.errorCode = errorCode; 47 | this.errorMsg = errorMsg; 48 | } 49 | 50 | @Override 51 | public int getErrorCode() { 52 | return this.errorCode; 53 | } 54 | 55 | @Override 56 | public String getErrorMsg() { 57 | return this.errorMsg; 58 | } 59 | 60 | @Override 61 | public BaseError setErrorMsg(String errorMsg) { 62 | this.errorMsg=errorMsg; 63 | return this; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/error/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.error; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 业务异常 7 | * @Author zhangyukang 8 | * @Date 2020/3/1 14:47 9 | * @Version 1.0 10 | **/ 11 | @Data 12 | public class BusinessException extends Exception implements BaseError{ 13 | 14 | //所有实现了BaseError的ErrorEnum. 15 | private BaseError baseError; 16 | 17 | //直接构造错误消息的构造异常 18 | public BusinessException(BaseError baseError){ 19 | super(baseError.getErrorMsg()); 20 | this.baseError=baseError; 21 | } 22 | 23 | //自定义错误消息的构造异常 24 | public BusinessException(BaseError baseError,String customErrorMessage){ 25 | super(); 26 | this.baseError=baseError; 27 | this.baseError.setErrorMsg(customErrorMessage); 28 | } 29 | 30 | @Override 31 | public int getErrorCode() { 32 | return this.baseError.getErrorCode(); 33 | } 34 | 35 | @Override 36 | public String getErrorMsg() { 37 | return this.baseError.getErrorMsg(); 38 | } 39 | 40 | @Override 41 | public BaseError setErrorMsg(String message) { 42 | this.baseError.setErrorMsg(message); 43 | return this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/error/SystemCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.error; 2 | 3 | /** 4 | * @Author zhangyukang 5 | * @Date 2020/12/16 13:00 6 | * @Version 1.0 7 | **/ 8 | public enum SystemCodeEnum implements BaseError { 9 | PARAMETER_ERROR(50000,"参数不合法"), 10 | TOKEN_ERROR(50001,"用户未认证") 11 | ; 12 | 13 | /** 错误码 */ 14 | private int errorCode; 15 | 16 | /** 错误描述 */ 17 | private String errorMsg; 18 | 19 | SystemCodeEnum(int errorCode, String errorMsg) { 20 | this.errorCode = errorCode; 21 | this.errorMsg = errorMsg; 22 | } 23 | 24 | @Override 25 | public int getErrorCode() { 26 | return this.errorCode; 27 | } 28 | 29 | @Override 30 | public String getErrorMsg() { 31 | return this.errorMsg; 32 | } 33 | 34 | @Override 35 | public BaseError setErrorMsg(String errorMsg) { 36 | this.errorMsg=errorMsg; 37 | return this; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/error/SystemException.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.error; 2 | 3 | /** 4 | * @Author zhangyukang 5 | * @Date 2020/12/16 12:59 6 | * @Version 1.0 7 | **/ 8 | public class SystemException extends Exception implements BaseError{ 9 | //所有实现了BaseError的ErrorEnum. 10 | private BaseError baseError; 11 | 12 | //直接构造错误消息的构造异常 13 | public SystemException(BaseError baseError){ 14 | super(baseError.getErrorMsg()); 15 | this.baseError=baseError; 16 | } 17 | 18 | //自定义错误消息的构造异常 19 | public SystemException(BaseError baseError,String customErrorMessage){ 20 | super(customErrorMessage); 21 | this.baseError=baseError; 22 | this.baseError.setErrorMsg(customErrorMessage); 23 | } 24 | 25 | @Override 26 | public int getErrorCode() { 27 | return this.baseError.getErrorCode(); 28 | } 29 | 30 | @Override 31 | public String getErrorMsg() { 32 | return this.baseError.getErrorMsg(); 33 | } 34 | 35 | @Override 36 | public BaseError setErrorMsg(String message) { 37 | this.baseError.setErrorMsg(message); 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/Consumer.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | import java.util.Date; 9 | 10 | @Table(name = "biz_consumer") 11 | @Data 12 | public class Consumer { 13 | 14 | @Id 15 | @GeneratedValue(generator = "JDBC") 16 | private Long id; 17 | 18 | private String name; 19 | 20 | private String address; 21 | 22 | private Date createTime; 23 | 24 | private Date modifiedTime; 25 | 26 | private String phone; 27 | 28 | private Integer sort; 29 | 30 | private String contact; 31 | } 32 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/Health.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | import java.util.Date; 9 | 10 | @Data 11 | @Table(name = "biz_health") 12 | public class Health { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String address; 18 | 19 | private Long userId; 20 | 21 | private Integer situation; 22 | 23 | private Integer touch; 24 | 25 | private Integer passby; 26 | 27 | private Integer reception; 28 | 29 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 30 | private Date createTime; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/InStock.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "biz_in_stock") 11 | public class InStock { 12 | 13 | @Id 14 | private Long id; 15 | 16 | private String inNum; 17 | 18 | private Integer type; 19 | 20 | private String operator; 21 | 22 | private Long supplierId; 23 | 24 | private Date createTime; 25 | 26 | private Date modified; 27 | 28 | private Integer productNumber; 29 | 30 | private String remark; 31 | 32 | private Integer status; 33 | } 34 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/InStockInfo.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "biz_in_stock_info") 11 | public class InStockInfo { 12 | 13 | @Id 14 | private Long id; 15 | 16 | private String inNum; 17 | 18 | private String pNum; 19 | 20 | private Integer productNumber; 21 | 22 | private Date createTime; 23 | 24 | private Date modifiedTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/OutStock.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "biz_out_stock") 11 | public class OutStock { 12 | 13 | @Id 14 | private Long id; 15 | 16 | private String outNum; 17 | 18 | private Integer type; 19 | 20 | private String operator; 21 | 22 | private Date createTime; 23 | 24 | private Integer productNumber; 25 | 26 | private Long consumerId; 27 | 28 | private String remark; 29 | 30 | private Integer status; 31 | 32 | private Integer priority; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/OutStockInfo.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "biz_out_stock_info") 11 | public class OutStockInfo { 12 | 13 | @Id 14 | private Long id; 15 | 16 | private String outNum; 17 | 18 | private String pNum; 19 | 20 | private Integer productNumber; 21 | 22 | private Date createTime; 23 | 24 | private Date modifiedTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/Product.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "biz_product") 11 | public class Product { 12 | 13 | @Id 14 | private Long id; 15 | 16 | private String pNum; 17 | 18 | private String name; 19 | 20 | private String model; 21 | 22 | private String unit; 23 | 24 | private String remark; 25 | 26 | private Integer sort; 27 | 28 | private Date createTime; 29 | 30 | private Date modifiedTime; 31 | 32 | private Long oneCategoryId; 33 | 34 | private Long twoCategoryId; 35 | 36 | private Long threeCategoryId; 37 | 38 | private String imageUrl; 39 | 40 | private Integer status; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/ProductCategory.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "biz_product_category") 11 | public class ProductCategory { 12 | @Id 13 | private Long id; 14 | 15 | private String name; 16 | 17 | private String remark; 18 | 19 | private Integer sort; 20 | 21 | private Date createTime; 22 | 23 | private Date modifiedTime; 24 | 25 | private Long pid; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/ProductStock.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | 8 | /** 9 | * 商品库存 10 | */ 11 | @Data 12 | @Table(name = "biz_product_stock") 13 | public class ProductStock { 14 | @Id 15 | private Long id; 16 | 17 | private String pNum; 18 | 19 | private Long stock; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/business/Supplier.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | import java.util.Date; 9 | 10 | @Data 11 | @Table(name = "biz_supplier") 12 | public class Supplier { 13 | 14 | @Id 15 | @GeneratedValue(generator = "JDBC") 16 | private Long id; 17 | 18 | private String name; 19 | 20 | private String address; 21 | 22 | private String email; 23 | 24 | private String phone; 25 | 26 | private Date createTime; 27 | 28 | private Date modifiedTime; 29 | 30 | private Integer sort; 31 | 32 | private String contact; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/Department.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import com.wuwenze.poi.annotation.Excel; 4 | import com.wuwenze.poi.annotation.ExcelField; 5 | import lombok.Data; 6 | 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.util.Date; 10 | 11 | @Excel("department") 12 | @Data 13 | @Table(name = "tb_department") 14 | public class Department { 15 | @Id 16 | @ExcelField(value = "编号", width = 50) 17 | private Long id; 18 | 19 | @ExcelField(value = "部门名称", width = 100) 20 | private String name; 21 | 22 | @ExcelField(value = "联系电话", width = 120) 23 | private String phone; 24 | 25 | @ExcelField(value = "部门地址", width = 150) 26 | private String address; 27 | 28 | @ExcelField(value = "创建时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 29 | private Date createTime; 30 | 31 | @ExcelField(value = "修改时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 32 | private Date modifiedTime; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/ImageAttachment.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "tb_image") 11 | public class ImageAttachment { 12 | 13 | @Id 14 | private Long id; 15 | 16 | private String path; 17 | 18 | private Long size; 19 | 20 | private String mediaType; 21 | 22 | private String suffix; 23 | 24 | private Integer height; 25 | 26 | private Integer width; 27 | 28 | private Date createTime; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/Log.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.persistence.Id; 7 | import javax.persistence.Table; 8 | import java.util.Date; 9 | 10 | @Data 11 | @Table(name = "tb_log") 12 | public class Log { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String username; 18 | 19 | private Long time; 20 | 21 | private String ip; 22 | 23 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 24 | private Date createTime; 25 | 26 | private String location; 27 | 28 | private String operation; 29 | 30 | private String method; 31 | 32 | private String params; 33 | } 34 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/LoginLog.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import java.util.Date; 8 | 9 | @Data 10 | @Table(name = "tb_login_log") 11 | public class LoginLog { 12 | @Id 13 | private Long id; 14 | 15 | private String username; 16 | 17 | private Date loginTime; 18 | 19 | private String location; 20 | 21 | private String ip; 22 | 23 | private String userSystem; 24 | 25 | private String userBrowser; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/Menu.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import com.wuwenze.poi.annotation.Excel; 4 | import com.wuwenze.poi.annotation.ExcelField; 5 | import lombok.Data; 6 | 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | import java.util.Date; 11 | 12 | @Data 13 | @Excel(value = "菜单表格") 14 | @Table(name = "tb_menu") 15 | public class Menu { 16 | 17 | @Id 18 | @ExcelField(value = "编号", width = 50) 19 | @GeneratedValue(generator = "JDBC") 20 | private Long id; 21 | 22 | @ExcelField(value = "父级id", width = 50) 23 | private Long parentId; 24 | 25 | @ExcelField(value = "菜单名称", width = 100) 26 | private String menuName; 27 | 28 | @ExcelField(value = "菜单url", width = 100) 29 | private String url; 30 | 31 | @ExcelField(value = "菜单图标", width = 80) 32 | private String icon; 33 | 34 | @ExcelField(value = "是否展开", width = 50) 35 | private Integer open; 36 | 37 | @ExcelField(value = "菜单类型", width = 80) 38 | private Integer type; 39 | 40 | @ExcelField(value = "排序", width = 90) 41 | private Long orderNum; 42 | 43 | @ExcelField(value = "创建时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 44 | private Date createTime; 45 | 46 | @ExcelField(value = "修改时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 47 | private Date modifiedTime; 48 | 49 | @ExcelField(value = "是否可用",width = 80) 50 | private Integer available; 51 | 52 | @ExcelField(value = "权限编码", width = 180) 53 | private String perms; 54 | } 55 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/Role.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import com.wuwenze.poi.annotation.Excel; 4 | import com.wuwenze.poi.annotation.ExcelField; 5 | import lombok.Data; 6 | 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.util.Date; 10 | 11 | @Excel(value = "角色表格") 12 | @Data 13 | @Table(name = "tb_role") 14 | public class Role { 15 | @Id 16 | @ExcelField(value = "编号", width = 50) 17 | private Long id; 18 | 19 | @ExcelField(value = "角色名称", width = 100) 20 | private String roleName; 21 | 22 | @ExcelField(value = "备注信息", width = 180) 23 | private String remark; 24 | 25 | @ExcelField(value = "创建时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 26 | private Date createTime; 27 | 28 | @ExcelField(value = "修改时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 29 | private Date modifiedTime; 30 | 31 | @ExcelField(value = "禁用状态", width = 50) 32 | private Integer status; 33 | 34 | @Override 35 | public String toString() { 36 | return "Role{" + 37 | "id=" + id + 38 | ", roleName='" + roleName + '\'' + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/RoleMenu.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Table; 6 | 7 | @Data 8 | @Table(name = "tb_role_menu") 9 | public class RoleMenu { 10 | private Long roleId; 11 | 12 | private Long menuId; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/User.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import com.wuwenze.poi.annotation.Excel; 4 | import com.wuwenze.poi.annotation.ExcelField; 5 | import lombok.Data; 6 | 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.util.Date; 10 | 11 | @Data 12 | @Excel("user") 13 | @Table(name = "tb_user") 14 | public class User { 15 | @Id 16 | @ExcelField(value = "编号", width = 50) 17 | private Long id; 18 | 19 | @ExcelField(value = "用户名", width = 100) 20 | private String username; 21 | 22 | @ExcelField(value = "昵称", width = 100) 23 | private String nickname; 24 | 25 | @ExcelField(value = "邮箱", width = 150) 26 | private String email; 27 | 28 | @ExcelField(value = "电话号码", width = 100) 29 | private String phoneNumber; 30 | 31 | private Integer status; 32 | 33 | @ExcelField(value = "创建时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss", width = 180) 34 | private Date createTime; 35 | 36 | @ExcelField(value = "修改时间", dateFormat = "yyyy年MM月dd日 HH:mm:ss",width = 180) 37 | private Date modifiedTime; 38 | 39 | @ExcelField(// 40 | value = "性别", 41 | readConverterExp = "男=1,女=0", 42 | writeConverterExp = "1=男,0=女" 43 | ,width = 50 44 | ) 45 | private Integer sex; 46 | 47 | @ExcelField(value = "密码盐值", width = 100) 48 | private String salt; 49 | 50 | @ExcelField(// 51 | value = "用户类型", 52 | readConverterExp = "超级管理员=0,普通用户=1", 53 | writeConverterExp = "0=超级管理员,1=普通用户" 54 | ,width = 80 55 | ) 56 | private Integer type; 57 | 58 | @ExcelField(value = "用户密码", width = 100) 59 | private String password; 60 | 61 | @ExcelField(value = "出生日期", dateFormat = "yyyy/MM/dd",width = 100) 62 | private Date birth; 63 | 64 | private Long departmentId; 65 | 66 | @ExcelField(value = "头像url", width = 200) 67 | private String avatar; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/model/system/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.model.system; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | 8 | @Data 9 | @Table(name = "tb_user_role") 10 | public class UserRole { 11 | 12 | @Id 13 | private Long userId; 14 | 15 | private Long roleId; 16 | 17 | public Long getUserId() { 18 | return userId; 19 | } 20 | 21 | public void setUserId(Long userId) { 22 | this.userId = userId; 23 | } 24 | 25 | public Long getRoleId() { 26 | return roleId; 27 | } 28 | 29 | public void setRoleId(Long roleId) { 30 | this.roleId = roleId; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/response/ActiveUser.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.response; 2 | 3 | import com.coderman.common.model.system.Menu; 4 | import com.coderman.common.model.system.Role; 5 | import com.coderman.common.model.system.User; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class ActiveUser { 17 | 18 | /** 19 | * 当前用户对象 20 | */ 21 | private User user; 22 | /** 23 | * 当前用户具有的角色 24 | */ 25 | private List roles; 26 | /** 27 | * 当前用户具有的url 28 | */ 29 | private Set urls; 30 | 31 | /** 32 | * 包括url+permission 33 | */ 34 | private List menus; 35 | /** 36 | * 当前用户具有的权限API:例如[user:add],[user:delete]... 37 | */ 38 | private Set permissions; 39 | 40 | /** 41 | * session id 42 | */ 43 | private String id; 44 | /** 45 | * 用户 id 46 | */ 47 | private String userId; 48 | /** 49 | * 用户名称 50 | */ 51 | private String username; 52 | /** 53 | * 用户主机地址 54 | */ 55 | private String host; 56 | /** 57 | * 用户登录时系统 IP 58 | */ 59 | private String systemHost; 60 | /** 61 | * 状态 62 | */ 63 | private String status; 64 | /** 65 | * session 创建时间 66 | */ 67 | private String startTimestamp; 68 | /** 69 | * session 最后访问时间 70 | */ 71 | private String lastAccessTime; 72 | /** 73 | * 超时时间 74 | */ 75 | private Long timeout; 76 | /** 77 | * 所在地 78 | */ 79 | private String location; 80 | /** 81 | * 是否为当前登录用户 82 | */ 83 | private Boolean current; 84 | } 85 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/response/ResponseBean.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.response; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ResponseBean { 7 | 8 | /** 200:操作成功 -1:操作失败**/ 9 | 10 | // http 状态码 11 | private boolean success; 12 | 13 | // 返回的数据 14 | private T data; 15 | 16 | public static ResponseBean success(T data) { 17 | ResponseBean responseBean = new ResponseBean<>(); 18 | responseBean.setSuccess(true); 19 | responseBean.setData(data); 20 | return responseBean; 21 | } 22 | 23 | 24 | public static ResponseBean error(T errorData) { 25 | ResponseBean responseBean = new ResponseBean<>(); 26 | responseBean.setSuccess(false); 27 | responseBean.setData(errorData); 28 | return responseBean; 29 | } 30 | 31 | public static ResponseBean success() { 32 | ResponseBean responseBean = new ResponseBean<>(); 33 | responseBean.setSuccess(true); 34 | return responseBean; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/AddressUtil.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | import org.apache.commons.io.IOUtils; 4 | import org.lionsoul.ip2region.DataBlock; 5 | import org.lionsoul.ip2region.DbConfig; 6 | import org.lionsoul.ip2region.DbSearcher; 7 | import org.lionsoul.ip2region.Util; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.core.io.ClassPathResource; 11 | 12 | import java.io.File; 13 | import java.io.FileOutputStream; 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.lang.reflect.Method; 17 | 18 | /** 19 | * @author zhangyukang 20 | */ 21 | public class AddressUtil { 22 | 23 | private static Logger log = LoggerFactory.getLogger(AddressUtil.class); 24 | 25 | @SuppressWarnings("all") 26 | public static String getCityInfo(String ip) { 27 | //db 28 | String dbPath = AddressUtil.class.getResource("/ip2region/ip2region.db").getPath(); 29 | File file = new File(dbPath); 30 | 31 | if (!file.exists()) { 32 | log.info("地址库文件不存在,进行其他处理"); 33 | String tmpDir = System.getProperties().getProperty("java.io.tmpdir"); 34 | dbPath = tmpDir + File.separator + "ip2region.db"; 35 | log.info("临时文件路径:{}", dbPath); 36 | file = new File(dbPath); 37 | if (!file.exists() || (System.currentTimeMillis() - file.lastModified() > 86400000L)) { 38 | log.info("文件不存在或者文件存在时间超过1天进入..."); 39 | try { 40 | InputStream inputStream = new ClassPathResource("ip2region/ip2region.db").getInputStream(); 41 | IOUtils.copy(inputStream, new FileOutputStream(file)); 42 | } catch (IOException exception) { 43 | exception.printStackTrace(); 44 | } 45 | } 46 | } 47 | 48 | //查询算法 49 | int algorithm = DbSearcher.BTREE_ALGORITHM; //B-tree 50 | try { 51 | DbConfig config = new DbConfig(); 52 | DbSearcher searcher = new DbSearcher(config, dbPath); 53 | //define the method 54 | Method method = null; 55 | switch (algorithm) { 56 | case DbSearcher.BTREE_ALGORITHM: 57 | method = searcher.getClass().getMethod("btreeSearch", String.class); 58 | break; 59 | case DbSearcher.BINARY_ALGORITHM: 60 | method = searcher.getClass().getMethod("binarySearch", String.class); 61 | break; 62 | case DbSearcher.MEMORY_ALGORITYM: 63 | method = searcher.getClass().getMethod("memorySearch", String.class); 64 | break; 65 | } 66 | DataBlock dataBlock = null; 67 | if (Util.isIpAddress(ip) == false) { 68 | log.error("Error: Invalid ip address"); 69 | } 70 | dataBlock = (DataBlock) method.invoke(searcher, ip); 71 | return dataBlock.getRegion(); 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | } 75 | return null; 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/BrowserUtil.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * Created by zhangyukang on 2019/11/10 15:50 7 | */ 8 | public class BrowserUtil { 9 | /** 10 | * 获取来访者的浏览器版本 11 | * @param request 12 | * @return 13 | */ 14 | public static String getRequestBrowserInfo(HttpServletRequest request){ 15 | String browserVersion = null; 16 | String header = request.getHeader("user-agent"); 17 | if(header == null || header.equals("")){ 18 | return ""; 19 | } 20 | if(header.indexOf("MSIE")>0){ 21 | browserVersion = "IE"; 22 | }else if(header.indexOf("Firefox")>0){ 23 | browserVersion = "Firefox"; 24 | }else if(header.indexOf("Chrome")>0){ 25 | browserVersion = "Chrome"; 26 | }else if(header.indexOf("Safari")>0){ 27 | browserVersion = "Safari"; 28 | }else if(header.indexOf("Camino")>0){ 29 | browserVersion = "Camino"; 30 | }else if(header.indexOf("Konqueror")>0){ 31 | browserVersion = "Konqueror"; 32 | } 33 | return browserVersion; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/CategoryTreeBuilder.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | 4 | import com.coderman.common.vo.business.ProductCategoryTreeNodeVO; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by zhangyukang on 2020/2/6 15:34 12 | */ 13 | public class CategoryTreeBuilder { 14 | 15 | private static int count=1; 16 | 17 | /** 18 | * 构建多级 19 | * @param nodes 20 | * @return 21 | */ 22 | public static List build(List nodes){ 23 | //根节点 24 | List rootMenu = new ArrayList<>(); 25 | for (ProductCategoryTreeNodeVO nav : nodes) { 26 | if(nav.getPid()==0){ 27 | nav.setLev(1); 28 | rootMenu.add(nav); 29 | } 30 | } 31 | /* 根据Menu类的order排序 */ 32 | Collections.sort(rootMenu,ProductCategoryTreeNodeVO.order()); 33 | /*为根菜单设置子菜单,getChild是递归调用的*/ 34 | for (ProductCategoryTreeNodeVO nav : rootMenu) { 35 | /* 获取根节点下的所有子节点 使用getChild方法*/ 36 | List childList = getChild(nav, nodes); 37 | nav.setChildren(childList);//给根节点设置子节点 38 | } 39 | return rootMenu; 40 | } 41 | 42 | /** 43 | * 获取子菜单 44 | * @param pNode 45 | * @param nodes 46 | * @return 47 | */ 48 | private static List getChild(ProductCategoryTreeNodeVO pNode, List nodes) { 49 | //子菜单 50 | List childList = new ArrayList<>(); 51 | for (ProductCategoryTreeNodeVO nav : nodes) { 52 | // 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较 53 | //相等说明:为该根节点的子节点。 54 | if(nav.getPid().equals(pNode.getId())){ 55 | nav.setLev(pNode.getLev()+1); 56 | childList.add(nav); 57 | } 58 | } 59 | //递归 60 | for (ProductCategoryTreeNodeVO nav : childList) { 61 | nav.setChildren(getChild(nav, nodes)); 62 | } 63 | Collections.sort(childList,ProductCategoryTreeNodeVO.order());//排序 64 | //如果节点下没有子节点,返回一个空List(递归退出) 65 | if(childList.size() == 0){ 66 | return null; 67 | } 68 | return childList; 69 | } 70 | 71 | // 获取二级父级分类 72 | 73 | public static List buildParent(List nodes) { 74 | //根节点 75 | List rootMenu = new ArrayList<>(); 76 | for (ProductCategoryTreeNodeVO nav : nodes) { 77 | if(nav.getPid()==0){ 78 | nav.setLev(1); 79 | rootMenu.add(nav); 80 | } 81 | } 82 | /* 根据Menu类的order排序 */ 83 | Collections.sort(rootMenu,ProductCategoryTreeNodeVO.order()); 84 | /*为根菜单设置子菜单,getChild是递归调用的*/ 85 | for (ProductCategoryTreeNodeVO nav : rootMenu) { 86 | /* 获取根节点下的所有子节点 使用getChild方法*/ 87 | List childList = getParentChild(nav, nodes); 88 | nav.setChildren(childList);//给根节点设置子节点 89 | } 90 | return rootMenu; 91 | } 92 | 93 | private static List getParentChild(ProductCategoryTreeNodeVO pNode, List nodes) { 94 | //子菜单 95 | List childList = new ArrayList<>(); 96 | for (ProductCategoryTreeNodeVO nav : nodes) { 97 | // 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较 98 | //相等说明:为该根节点的子节点。 99 | if(nav.getPid().equals(pNode.getId())){ 100 | nav.setLev(2); 101 | childList.add(nav); 102 | } 103 | } 104 | return childList; 105 | } 106 | 107 | 108 | } 109 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/FdfsUtil.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | import com.github.tobato.fastdfs.domain.MateData; 4 | import com.github.tobato.fastdfs.domain.StorePath; 5 | import com.github.tobato.fastdfs.exception.FdfsException; 6 | import com.github.tobato.fastdfs.exception.FdfsUnsupportStorePathException; 7 | import com.github.tobato.fastdfs.service.FastFileStorageClient; 8 | import org.apache.commons.io.FilenameUtils; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.transaction.annotation.Propagation; 14 | import org.springframework.transaction.annotation.Transactional; 15 | import org.springframework.util.StringUtils; 16 | import org.springframework.web.multipart.MultipartFile; 17 | 18 | import java.io.*; 19 | import java.nio.charset.StandardCharsets; 20 | import java.util.Set; 21 | 22 | /** 23 | * @Author zhangyukang 24 | * @Date 2020/8/9 11:50 25 | * @Version 1.0 26 | **/ 27 | @Component 28 | public class FdfsUtil { 29 | private final Logger logger = LoggerFactory.getLogger(FdfsUtil.class); 30 | 31 | @Autowired 32 | private FastFileStorageClient storageClient; 33 | 34 | 35 | /** 36 | * MultipartFile类型的文件上传ַ 37 | * @param file 38 | * @return 39 | * @throws IOException 40 | */ 41 | public String uploadFile(MultipartFile file) throws IOException { 42 | StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), 43 | FilenameUtils.getExtension(file.getOriginalFilename()), null); 44 | return getResAccessUrl(storePath); 45 | } 46 | 47 | /** 48 | * 普通的文件上传 49 | * 50 | * @param file 51 | * @return 52 | * @throws IOException 53 | */ 54 | public String uploadFile(File file) throws IOException { 55 | FileInputStream inputStream = new FileInputStream(file); 56 | StorePath path = storageClient.uploadFile(inputStream, file.length(), 57 | FilenameUtils.getExtension(file.getName()), null); 58 | return getResAccessUrl(path); 59 | } 60 | 61 | /** 62 | * 带输入流形式的文件上传 63 | * 64 | * @param is 65 | * @param size 66 | * @param fileName 67 | * @return 68 | */ 69 | public String uploadFileStream(InputStream is, long size, String fileName) { 70 | StorePath path = storageClient.uploadFile(is, size, fileName, null); 71 | return getResAccessUrl(path); 72 | } 73 | 74 | /** 75 | * 将一段文本文件写到fastdfs的服务器上 76 | * 77 | * @param content 78 | * @param fileExtension 79 | * @return 80 | */ 81 | public String uploadFile(String content, String fileExtension) { 82 | byte[] buff = content.getBytes(StandardCharsets.UTF_8); 83 | ByteArrayInputStream stream = new ByteArrayInputStream(buff); 84 | StorePath path = storageClient.uploadFile(stream, buff.length, fileExtension, null); 85 | return getResAccessUrl(path); 86 | } 87 | 88 | /** 89 | * 返回文件上传成功后的地址名称ַ 90 | * @param storePath 91 | * @return 92 | */ 93 | private String getResAccessUrl(StorePath storePath) { 94 | return storePath.getFullPath(); 95 | } 96 | 97 | /** 98 | * 删除文件 99 | * @param fileUrl 100 | */ 101 | @Transactional(propagation = Propagation.REQUIRES_NEW) 102 | public void deleteFile(String fileUrl) throws FdfsException { 103 | if (StringUtils.isEmpty(fileUrl)) { 104 | return; 105 | } 106 | try { 107 | StorePath storePath = StorePath.praseFromUrl(fileUrl); 108 | storageClient.deleteFile(storePath.getGroup(), storePath.getPath()); 109 | } catch (FdfsUnsupportStorePathException e) { 110 | logger.warn("删除图片错误:"+e.getMessage()); 111 | } 112 | } 113 | 114 | public String upfileImage(InputStream is, long size, String fileExtName, Set metaData) { 115 | StorePath path = storageClient.uploadImageAndCrtThumbImage(is, size, fileExtName, metaData); 116 | return getResAccessUrl(path); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/IPUtil.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * @author MrBird 7 | */ 8 | public class IPUtil { 9 | 10 | private static final String UNKNOWN = "unknown"; 11 | 12 | /** 13 | * 获取 IP地址 14 | * 使用 Nginx等反向代理软件, 则不能通过 request.getRemoteAddr()获取 IP地址 15 | * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址, 16 | * X-Forwarded-For中第一个非 unknown的有效IP字符串,则为真实IP地址 17 | */ 18 | public static String getIpAddr(HttpServletRequest request) { 19 | String ip = request.getHeader("x-forwarded-for"); 20 | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { 21 | ip = request.getHeader("Proxy-Client-IP"); 22 | } 23 | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { 24 | ip = request.getHeader("WL-Proxy-Client-IP"); 25 | } 26 | if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { 27 | ip = request.getRemoteAddr(); 28 | } 29 | if(ip.contains(",")) { 30 | ip=ip.split(",")[0]; 31 | } 32 | return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/JWTUtils.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | /** 4 | * @Author zhangyukang 5 | * @Date 2020/3/1 09:18 6 | * @Version 1.0 7 | **/ 8 | import com.auth0.jwt.JWT; 9 | import com.auth0.jwt.JWTVerifier; 10 | import com.auth0.jwt.algorithms.Algorithm; 11 | import com.auth0.jwt.exceptions.JWTDecodeException; 12 | import com.auth0.jwt.interfaces.DecodedJWT; 13 | 14 | import java.io.UnsupportedEncodingException; 15 | import java.util.Date; 16 | 17 | public class JWTUtils { 18 | /** 19 | * 过期时间6小时 20 | */ 21 | private static final long EXPIRE_TIME = 6*60*60*1000; 22 | 23 | /** 24 | * 校验token是否正确 25 | * @param token 密钥 26 | * @param secret 用户的密码 27 | * @return 是否正确 28 | */ 29 | public static boolean verify(String token, String username, String secret) { 30 | try { 31 | Algorithm algorithm = Algorithm.HMAC256(secret); 32 | JWTVerifier verifier = JWT.require(algorithm) 33 | .withClaim("username", username) 34 | .build(); 35 | DecodedJWT jwt = verifier.verify(token); 36 | return true; 37 | } catch (Exception exception) { 38 | return false; 39 | } 40 | } 41 | 42 | /** 43 | * 获得token中的信息无需secret解密也能获得 44 | * @return token中包含的用户名 45 | */ 46 | public static String getUsername(String token) { 47 | try { 48 | DecodedJWT jwt = JWT.decode(token); 49 | return jwt.getClaim("username").asString(); 50 | } catch (JWTDecodeException e) { 51 | return null; 52 | } 53 | } 54 | 55 | /** 56 | * 生成签名,2min后过期 57 | * @param username 用户名 58 | * @param secret 用户的密码 59 | * @return 加密的token 60 | */ 61 | public static String sign(String username, String secret) { 62 | try { 63 | Date date = new Date(System.currentTimeMillis()+EXPIRE_TIME); 64 | Algorithm algorithm = Algorithm.HMAC256(secret); 65 | // 附带username信息 66 | return JWT.create() 67 | .withClaim("username", username) 68 | .withExpiresAt(date) 69 | .sign(algorithm); 70 | } catch (UnsupportedEncodingException e) { 71 | return null; 72 | } 73 | } 74 | 75 | /** 76 | * 判断过期 77 | * @param token 78 | * @return 79 | */ 80 | public static boolean isExpire(String token){ 81 | DecodedJWT jwt = JWT.decode(token); 82 | return System.currentTimeMillis()>jwt.getExpiresAt().getTime(); 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/ListPageUtils.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @Author zhangyukang 8 | * @Date 2020/3/17 13:05 9 | * @Version 1.0 10 | **/ 11 | public class ListPageUtils { 12 | /** 13 | * 手动分页类 14 | * @param datas 15 | * @param pageSize 16 | * @param pageNo 17 | * @param 18 | * @return 19 | */ 20 | public static List page(List datas,int pageSize,int pageNo){ 21 | int startNum = (pageNo-1)* pageSize+1 ; //起始截取数据位置 22 | if(startNum > datas.size()){ 23 | return null; 24 | } 25 | List res = new ArrayList<>(); 26 | int rum = datas.size() - startNum; 27 | if(rum < 0){ 28 | return null; 29 | } 30 | if(rum == 0){ //说明正好是最后一个了 31 | int index = datas.size() -1; 32 | res.add(datas.get(index)); 33 | return res; 34 | } 35 | if(rum / pageSize >= 1){ //剩下的数据还够1页,返回整页的数据 36 | for(int i=startNum;i 0){ //不够一页,直接返回剩下数据 41 | for(int j = startNum ;j<=datas.size();j++){ 42 | res.add(datas.get(j-1)); 43 | } 44 | return res; 45 | }else{ 46 | return null; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/utils/MenuTreeBuilder.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.utils; 2 | 3 | 4 | import com.coderman.common.vo.system.MenuNodeVO; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | /** 11 | * 该类用于递归构建树形菜单 12 | * Created by zhangyukang on 2020/2/6 15:34 13 | */ 14 | public class MenuTreeBuilder { 15 | 16 | 17 | /** 18 | * 构建多级菜单树 19 | * @param nodes 20 | * @return 21 | */ 22 | public static List build(List nodes){ 23 | //根节点 24 | List rootMenu = new ArrayList<>(); 25 | for (MenuNodeVO nav : nodes) { 26 | if(nav.getParentId()==0){ 27 | rootMenu.add(nav); 28 | } 29 | } 30 | /* 根据Menu类的order排序 */ 31 | Collections.sort(rootMenu,MenuNodeVO.order()); 32 | /*为根菜单设置子菜单,getChild是递归调用的*/ 33 | for (MenuNodeVO nav : rootMenu) { 34 | /* 获取根节点下的所有子节点 使用getChild方法*/ 35 | List childList = getChild(nav.getId(), nodes); 36 | nav.setChildren(childList);//给根节点设置子节点 37 | } 38 | return rootMenu; 39 | } 40 | 41 | /** 42 | * 获取子菜单 43 | * @param id 44 | * @param nodes 45 | * @return 46 | */ 47 | private static List getChild(Long id, List nodes) { 48 | //子菜单 49 | List childList = new ArrayList(); 50 | for (MenuNodeVO nav : nodes) { 51 | // 遍历所有节点,将所有菜单的父id与传过来的根节点的id比较 52 | //相等说明:为该根节点的子节点。 53 | if(nav.getParentId().equals(id)){ 54 | childList.add(nav); 55 | } 56 | } 57 | //递归 58 | for (MenuNodeVO nav : childList) { 59 | nav.setChildren(getChild(nav.getId(), nodes)); 60 | } 61 | Collections.sort(childList,MenuNodeVO.order());//排序 62 | //如果节点下没有子节点,返回一个空List(递归退出) 63 | if(childList.size() == 0){ 64 | return new ArrayList(); 65 | } 66 | return childList; 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/ConsumerVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/4/5 09:53 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | public class ConsumerVO { 17 | 18 | 19 | private Long id; 20 | 21 | @NotBlank(message = "物资发放地点不能为空") 22 | private String name; 23 | 24 | @NotBlank(message = "省市县不能为空") 25 | private String address; 26 | 27 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 28 | private Date createTime; 29 | 30 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 31 | private Date modifiedTime; 32 | 33 | @NotBlank(message = "联系人电话不能为空") 34 | private String phone; 35 | 36 | @NotNull(message = "排序号不能为空") 37 | private Integer sort; 38 | 39 | @NotBlank(message = "联系人姓名不能为空") 40 | private String contact; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/HealthVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotNull; 7 | import java.util.Date; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/5/7 10:19 12 | * @Version 1.0 13 | **/ 14 | @Data 15 | public class HealthVO { 16 | 17 | private Long id; 18 | 19 | @NotBlank(message="地址不能为空") 20 | private String address; 21 | 22 | private Long userId; 23 | 24 | @NotNull(message = "当前情况不能为空") 25 | private Integer situation; 26 | 27 | @NotNull(message = "是否接触不能为空") 28 | private Integer touch; 29 | 30 | @NotNull(message = "是否路过不能为空") 31 | private Integer passby; 32 | 33 | @NotNull(message = "是否招待不能为空") 34 | private Integer reception; 35 | 36 | private Date createTime; 37 | } 38 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/InStockDetailVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * @Author zhangyukang 10 | * @Date 2020/3/20 16:51 11 | * @Version 1.0 12 | **/ 13 | @Data 14 | public class InStockDetailVO { 15 | 16 | private String inNum; 17 | 18 | private Integer status; 19 | 20 | private Integer type; 21 | 22 | private String operator; 23 | 24 | private SupplierVO supplierVO; 25 | 26 | private long total;/** 总数**/ 27 | 28 | private List itemVOS=new ArrayList<>(); 29 | 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/InStockItemVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @Author zhangyukang 7 | * @Date 2020/3/20 16:53 8 | * @Version 1.0 9 | **/ 10 | @Data 11 | public class InStockItemVO { 12 | private Long id; 13 | 14 | private String pNum; 15 | 16 | private String name; 17 | 18 | private String model; 19 | 20 | private String unit; 21 | 22 | private String imageUrl; 23 | 24 | private int count; 25 | } 26 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/InStockVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | import org.springframework.format.annotation.DateTimeFormat; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.NotNull; 9 | import java.util.ArrayList; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * @Author zhangyukang 15 | * @Date 2020/3/19 09:52 16 | * @Version 1.0 17 | **/ 18 | @Data 19 | public class InStockVO { 20 | 21 | private Long id; 22 | 23 | private String inNum; 24 | 25 | @NotNull(message = "入库单类型不能为空") 26 | private Integer type; 27 | 28 | private String operator; 29 | 30 | private Long supplierId; 31 | 32 | private String supplierName; 33 | 34 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 35 | private Date createTime; 36 | 37 | private Date modified; 38 | 39 | /** 该入库单的总数**/ 40 | private Integer productNumber; 41 | 42 | 43 | @NotBlank(message = "入库备注不能为空") 44 | private String remark; 45 | 46 | private Listproducts=new ArrayList<>(); 47 | 48 | private Integer status; 49 | 50 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 51 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 52 | private Date startTime; 53 | 54 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 55 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 56 | private Date endTime; 57 | 58 | 59 | /** 如果supplierId不存在需要添加供应商信息**/ 60 | 61 | private String name; 62 | 63 | private String address; 64 | 65 | private String email; 66 | 67 | private String phone; 68 | 69 | private Integer sort; 70 | 71 | private String contact; 72 | } 73 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/MusicVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * @Author zhangyukang 8 | * @Date 2020/3/14 19:28 9 | * @Version 1.0 10 | **/ 11 | @Data 12 | public class MusicVO { 13 | @JsonProperty(value = "title") 14 | private String name; 15 | @JsonProperty(value = "src") 16 | private String url; 17 | private String artist; 18 | @JsonProperty(value = "pic") 19 | private String cover; 20 | private String lrc; 21 | } 22 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/OutStockDetailVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * @Author zhangyukang 10 | * @Date 2020/5/25 16:25 11 | * @Version 1.0 12 | **/ 13 | @Data 14 | public class OutStockDetailVO { 15 | 16 | private String outNum; 17 | 18 | private Integer status; 19 | 20 | private Integer type; 21 | 22 | private String operator; 23 | 24 | private ConsumerVO consumerVO; 25 | 26 | private long total;/** 总数**/ 27 | 28 | private List itemVOS=new ArrayList<>(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/OutStockItemVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @Author zhangyukang 7 | * @Date 2020/5/25 16:26 8 | * @Version 1.0 9 | **/ 10 | @Data 11 | public class OutStockItemVO { 12 | 13 | private Long id; 14 | 15 | private String pNum; 16 | 17 | private String name; 18 | 19 | private String model; 20 | 21 | private String unit; 22 | 23 | private String imageUrl; 24 | 25 | private int count; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/OutStockVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/5/10 14:24 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | public class OutStockVO { 17 | 18 | private Long id; 19 | 20 | private String outNum; 21 | 22 | private Integer type; 23 | 24 | private String operator; 25 | 26 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 27 | private Date createTime; 28 | 29 | private Integer productNumber; 30 | 31 | private Integer priority; 32 | 33 | 34 | //发放的物资列表 35 | private List products=new ArrayList<>(); 36 | 37 | private String remark; 38 | 39 | //发放单的状态 40 | private Integer status; 41 | 42 | 43 | /*** 如果consumerId不为空**/ 44 | 45 | private Long consumerId; 46 | 47 | //去向名 48 | private String name; 49 | 50 | //地址 51 | private String address; 52 | 53 | //联系电话 54 | private String phone; 55 | 56 | //联系人 57 | private String contact; 58 | 59 | //排序 60 | private Integer sort; 61 | 62 | 63 | 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/ProductCategoryTreeNodeVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Comparator; 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/3/17 12:18 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | public class ProductCategoryTreeNodeVO { 17 | private Long id; 18 | 19 | private String name; 20 | 21 | private String remark; 22 | 23 | private Integer sort; 24 | 25 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 26 | private Date createTime; 27 | 28 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 29 | private Date modifiedTime; 30 | 31 | private Long pid; 32 | 33 | private int lev; 34 | 35 | private List children; 36 | 37 | /* 38 | * 排序,根据order排序 39 | */ 40 | public static Comparator order(){ 41 | Comparator comparator = (o1, o2) -> { 42 | if(o1.getSort() != o2.getSort()){ 43 | return (int) (o1.getSort() - o2.getSort()); 44 | } 45 | return 0; 46 | }; 47 | return comparator; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/ProductCategoryVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/3/16 17:18 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | public class ProductCategoryVO { 17 | private Long id; 18 | 19 | @NotBlank(message = "类目名称不能为空") 20 | private String name; 21 | 22 | @NotBlank(message = "类目备注不能为空") 23 | private String remark; 24 | 25 | @NotNull(message = "排序号不能为空") 26 | private Integer sort; 27 | 28 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 29 | private Date createTime; 30 | 31 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 32 | private Date modifiedTime; 33 | 34 | /** 父级分类id*/ 35 | @NotNull(message = "父级菜单不能为空") 36 | private Long pid; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/ProductStockVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import lombok.Data; 4 | 5 | /** 商品库存 6 | * @Author zhangyukang 7 | * @Date 2020/4/16 09:27 8 | * @Version 1.0 9 | **/ 10 | @Data 11 | public class ProductStockVO { 12 | 13 | private Long id; 14 | 15 | private String name; 16 | 17 | private String pNum; 18 | 19 | private String model; 20 | 21 | private String unit; 22 | 23 | private String remark; 24 | 25 | private Long stock; 26 | 27 | private String imageUrl; 28 | } 29 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/ProductVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/3/17 09:16 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | public class ProductVO { 17 | 18 | private Long id; 19 | 20 | private String pNum; 21 | 22 | @NotBlank 23 | private String name; 24 | 25 | @NotBlank 26 | private String model; 27 | 28 | @NotBlank 29 | private String unit; 30 | 31 | @NotBlank 32 | private String remark; 33 | 34 | private Integer sort; 35 | 36 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 37 | private Date createTime; 38 | 39 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 40 | private Date modifiedTime; 41 | 42 | private String imageUrl; 43 | 44 | 45 | @NotNull(message = "分类不能为空") 46 | private Long[] categoryKeys; 47 | 48 | private Long oneCategoryId; 49 | 50 | private Long twoCategoryId; 51 | 52 | private Long threeCategoryId; 53 | 54 | private Integer status;//是否已经进入回收站:1:逻辑删除,0:正常数据,2:添加待审核 55 | 56 | } 57 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/business/SupplierVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.business; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/3/16 17:18 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | public class SupplierVO { 17 | private Long id; 18 | 19 | @NotBlank(message = "供应商名称不能为空") 20 | private String name; 21 | 22 | @NotBlank(message = "地址不能为空") 23 | private String address; 24 | 25 | @NotBlank(message = "邮箱不能为空") 26 | private String email; 27 | 28 | @NotBlank(message = "电话不能为空") 29 | private String phone; 30 | 31 | @NotNull(message = "排序号不能为空") 32 | private Integer sort; 33 | 34 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 35 | private Date createTime; 36 | 37 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 38 | private Date modifiedTime; 39 | 40 | private String contact; 41 | } 42 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/DeanVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 系主任 7 | * @Author zhangyukang 8 | * @Date 2020/3/15 18:40 9 | * @Version 1.0 10 | **/ 11 | @Data 12 | public class DeanVO { 13 | private Long id; 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/DepartmentVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import java.util.Date; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/3/15 14:13 12 | * @Version 1.0 13 | **/ 14 | @Data 15 | public class DepartmentVO { 16 | 17 | private Long id; 18 | 19 | @NotBlank(message = "院系名称不能为空") 20 | private String name; 21 | 22 | @NotBlank(message = "办公电话不能为空") 23 | private String phone; 24 | 25 | @NotBlank(message = "办公地址不能为空") 26 | private String address; 27 | 28 | 29 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 30 | private Date createTime; 31 | 32 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 33 | private Date modifiedTime; 34 | 35 | 36 | /** 部门内人数**/ 37 | private int total; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/ImageAttachmentVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @Author zhangyukang 7 | * @Date 2020/4/25 10:47 8 | * @Version 1.0 9 | **/ 10 | @Data 11 | public class ImageAttachmentVO { 12 | 13 | private String mediaType; 14 | 15 | private String suffix; 16 | 17 | private String path; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/LogVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.persistence.Id; 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by zhangyukang on 2019/11/15 17:29 11 | */ 12 | @Data 13 | public class LogVO { 14 | @Id 15 | private Long id; 16 | 17 | private String username; 18 | 19 | private Long time; 20 | 21 | private String ip; 22 | 23 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 24 | private Date createTime; 25 | 26 | private String location; 27 | 28 | private String operation; 29 | 30 | private String method; 31 | 32 | private String params; 33 | } 34 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/LoginLogVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @Author zhangyukang 10 | * @Date 2020/3/22 21:04 11 | * @Version 1.0 12 | **/ 13 | @Data 14 | public class LoginLogVO { 15 | private Long id; 16 | 17 | private String username; 18 | 19 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 20 | private Date loginTime; 21 | 22 | private String location; 23 | 24 | private String ip; 25 | 26 | private String userSystem; 27 | 28 | private String userBrowser; 29 | } 30 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/MenuNodeVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Comparator; 7 | import java.util.List; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/3/7 17:07 12 | * @Version 1.0 13 | **/ 14 | @Data 15 | public class MenuNodeVO { 16 | 17 | private Long id; 18 | 19 | private Long parentId; 20 | 21 | private String menuName; 22 | 23 | private String url=null; 24 | 25 | private String icon; 26 | 27 | private Long orderNum; 28 | 29 | private Integer open; 30 | 31 | private boolean disabled; 32 | 33 | private String perms; 34 | 35 | private Integer type; 36 | 37 | 38 | private List children=new ArrayList<>(); 39 | 40 | /* 41 | * 排序,根据order排序 42 | */ 43 | public static Comparator order(){ 44 | Comparator comparator = (o1, o2) -> { 45 | if(o1.getOrderNum() != o2.getOrderNum()){ 46 | return (int) (o1.getOrderNum() - o2.getOrderNum()); 47 | } 48 | return 0; 49 | }; 50 | return comparator; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/MenuVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotNull; 7 | import java.util.Date; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/3/10 11:52 12 | * @Version 1.0 13 | **/ 14 | @Data 15 | public class MenuVO { 16 | 17 | private Long id; 18 | 19 | @NotNull(message = "父级ID必须") 20 | private Long parentId; 21 | 22 | @NotBlank(message = "菜单名称不能为空") 23 | private String menuName; 24 | 25 | private String url; 26 | 27 | private String icon; 28 | 29 | @NotNull(message = "菜单类型不为空") 30 | private Integer type; 31 | 32 | @NotNull(message = "排序数不能为空") 33 | private Long orderNum; 34 | 35 | private Date createTime; 36 | 37 | private Date modifiedTime; 38 | 39 | @NotNull(message = "菜单状态不能为空") 40 | private boolean disabled; 41 | 42 | private Integer open; 43 | 44 | private String perms; 45 | } 46 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/PageVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * @Author zhangyukang 10 | * @Date 2020/3/7 19:41 11 | * @Version 1.0 12 | **/ 13 | @Data 14 | public class PageVO { 15 | private long total; 16 | 17 | private List rows=new ArrayList<>(); 18 | 19 | public PageVO(long total, List data) { 20 | this.total = total; 21 | this.rows = data; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/RoleTransferItemVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @Author zhangyukang 7 | * @Date 2020/3/9 20:48 8 | * @Version 1.0 9 | **/ 10 | @Data 11 | public class RoleTransferItemVO { 12 | private Long key; 13 | private String label; 14 | private boolean disabled; 15 | } 16 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/RoleVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.NotBlank; 7 | import java.util.Date; 8 | 9 | /** 10 | * @Author zhangyukang 11 | * @Date 2020/3/9 16:22 12 | * @Version 1.0 13 | **/ 14 | @Data 15 | public class RoleVO { 16 | 17 | private Long id; 18 | 19 | @NotBlank(message = "角色名必填") 20 | private String roleName; 21 | 22 | @NotBlank(message = "角色描述信息必填") 23 | private String remark; 24 | 25 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") 26 | private Date createTime; 27 | 28 | private Date modifiedTime; 29 | 30 | private Boolean status; 31 | } 32 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/UserEditVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.Email; 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.NotNull; 9 | import java.util.Date; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/9 11:06 14 | * @Version 1.0 15 | **/ 16 | @Data 17 | public class UserEditVO { 18 | private Long id; 19 | 20 | @NotBlank(message = "用户名不能为空") 21 | private String username; 22 | 23 | @NotBlank(message = "昵称不能为空") 24 | private String nickname; 25 | 26 | @Email(message = "请输入正确的邮箱格式") 27 | private String email; 28 | 29 | @NotBlank(message = "电话号码不能为空") 30 | private String phoneNumber; 31 | 32 | @NotNull(message = "性别不能为空") 33 | private Integer sex; 34 | 35 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy年MM月dd日") 36 | @NotNull(message = "生日不能为空") 37 | private Date birth; 38 | 39 | @NotNull(message = "部门不能为空") 40 | private Long departmentId; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/UserInfoVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | import java.util.Set; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/3/7 17:02 13 | * @Version 1.0 14 | **/ 15 | @Data 16 | @ApiModel(value = "用户登入信息") 17 | public class UserInfoVO { 18 | 19 | @ApiModelProperty(value = "用户名") 20 | private String username; 21 | 22 | @ApiModelProperty(value = "昵称") 23 | private String nickname; 24 | 25 | @ApiModelProperty(value = "头像") 26 | private String avatar; 27 | 28 | @ApiModelProperty(value = "菜单") 29 | private Set url; 30 | 31 | @ApiModelProperty(value = "权限") 32 | private Set perms; 33 | 34 | @ApiModelProperty(value = "角色集合") 35 | private List roles; 36 | 37 | @ApiModelProperty(value = "所在部门") 38 | private String department; 39 | 40 | @ApiModelProperty(value = "是否是超管") 41 | private Boolean isAdmin=false; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /xinguan-common/src/main/java/com/coderman/common/vo/system/UserVO.java: -------------------------------------------------------------------------------- 1 | package com.coderman.common.vo.system; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import javax.validation.constraints.Email; 7 | import javax.validation.constraints.NotBlank; 8 | import javax.validation.constraints.NotNull; 9 | import java.util.Date; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/7 19:16 14 | * @Version 1.0 15 | **/ 16 | @Data 17 | public class UserVO{ 18 | 19 | private Long id; 20 | 21 | @NotBlank(message = "用户名不能为空") 22 | private String username; 23 | 24 | @NotBlank(message = "昵称不能为空") 25 | private String nickname; 26 | 27 | @Email(message = "请输入正确的邮箱格式") 28 | private String email; 29 | 30 | @NotBlank(message = "电话号码不能为空") 31 | private String phoneNumber; 32 | 33 | private Boolean status; 34 | 35 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 36 | private Date createTime; 37 | 38 | @NotNull(message = "性别不能为空") 39 | private Integer sex; 40 | 41 | @JsonFormat(timezone = "GMT+8", pattern = "yyyy年MM月dd日") 42 | @NotNull(message = "生日不能为空") 43 | private Date birth; 44 | 45 | @NotBlank(message = "密码不能为空") 46 | private String password; 47 | 48 | private String departmentName; 49 | 50 | @NotNull(message = "部门id不能为空") 51 | private Long departmentId; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /xinguan-common/src/main/resources/ip2region/ip2region.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/xinguan-common/src/main/resources/ip2region/ip2region.db -------------------------------------------------------------------------------- /xinguan-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | goods 7 | com.coderman 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | xinguan-generator 13 | 14 | 15 | 16 | org.mybatis.generator 17 | mybatis-generator-core 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /xinguan-generator/src/main/java/com/coderman/generator/MybatisGenerator.java: -------------------------------------------------------------------------------- 1 | package com.coderman.generator; 2 | 3 | import org.mybatis.generator.api.MyBatisGenerator; 4 | import org.mybatis.generator.config.Configuration; 5 | import org.mybatis.generator.config.xml.ConfigurationParser; 6 | import org.mybatis.generator.internal.DefaultShellCallback; 7 | 8 | import java.io.InputStream; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author zhangyukang 14 | * @Date 2020/7/6 11:13 15 | * @Version 1.0 16 | **/ 17 | public class MybatisGenerator { 18 | 19 | public static void main(String[] args) throws Exception { 20 | List warnings = new ArrayList(); 21 | final boolean overwrite = true; 22 | InputStream resourceAsStream = MybatisGenerator.class.getResourceAsStream("/mybatis-generator.xml"); 23 | ConfigurationParser cp = new ConfigurationParser(warnings); 24 | Configuration config = cp.parseConfiguration(resourceAsStream); 25 | DefaultShellCallback callback = new DefaultShellCallback(overwrite); 26 | MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); 27 | myBatisGenerator.generate(null); 28 | System.out.println("代码生成成功"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xinguan-generator/src/main/resources/mybatis-generator.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /xinguan-system/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | goods 7 | com.coderman 8 | 0.0.1-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | jar 13 | 14 | xinguan-system 15 | 16 | 17 | 18 | org.apache.shiro 19 | shiro-spring 20 | 21 | 22 | com.coderman 23 | xinguan-common 24 | 0.0.1-SNAPSHOT 25 | 26 | 27 | 28 | 29 | 30 | src/main/java 31 | 32 | **/*.xml 33 | 34 | 35 | 36 | src/main/resources 37 | 38 | **.* 39 | **/*.* 40 | **/*/*.* 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/aspect/AspectSupport.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.aspect; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.reflect.MethodSignature; 5 | 6 | import java.lang.reflect.Method; 7 | 8 | /** 9 | * @author zhangyukang 10 | */ 11 | public abstract class AspectSupport { 12 | 13 | Method resolveMethod(ProceedingJoinPoint point) { 14 | MethodSignature signature = (MethodSignature)point.getSignature(); 15 | Class targetClass = point.getTarget().getClass(); 16 | 17 | Method method = getDeclaredMethod(targetClass, signature.getName(), 18 | signature.getMethod().getParameterTypes()); 19 | if (method == null) { 20 | throw new IllegalStateException("无法解析目标方法: " + signature.getMethod().getName()); 21 | } 22 | return method; 23 | } 24 | 25 | private Method getDeclaredMethod(Class clazz, String name, Class... parameterTypes) { 26 | try { 27 | return clazz.getDeclaredMethod(name, parameterTypes); 28 | } catch (NoSuchMethodException e) { 29 | Class superClass = clazz.getSuperclass(); 30 | if (superClass != null) { 31 | return getDeclaredMethod(superClass, name, parameterTypes); 32 | } 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/aspect/ControllerEndpointAspect.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.aspect; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.coderman.common.annotation.ControllerEndpoint; 5 | import com.coderman.common.model.system.Log; 6 | import com.coderman.common.response.ActiveUser; 7 | import com.coderman.common.utils.AddressUtil; 8 | import com.coderman.common.utils.IPUtil; 9 | import com.coderman.system.service.LogService; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.apache.shiro.SecurityUtils; 12 | import org.aspectj.lang.ProceedingJoinPoint; 13 | import org.aspectj.lang.annotation.Around; 14 | import org.aspectj.lang.annotation.Aspect; 15 | import org.aspectj.lang.annotation.Pointcut; 16 | import org.aspectj.lang.reflect.MethodSignature; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.core.LocalVariableTableParameterNameDiscoverer; 19 | import org.springframework.stereotype.Component; 20 | import org.springframework.web.context.request.RequestContextHolder; 21 | import org.springframework.web.context.request.ServletRequestAttributes; 22 | 23 | import javax.servlet.http.HttpServletRequest; 24 | import java.lang.reflect.Method; 25 | import java.util.Arrays; 26 | import java.util.Date; 27 | 28 | /** 29 | * 系统日志切面 30 | * @author zhangyukang 31 | */ 32 | @Slf4j 33 | @Aspect 34 | @Component 35 | public class ControllerEndpointAspect extends AspectSupport { 36 | 37 | private Log sysLog=new Log(); 38 | 39 | private long startTime; 40 | 41 | 42 | @Autowired 43 | private LogService logService; 44 | 45 | @Pointcut("@annotation(com.coderman.common.annotation.ControllerEndpoint)") 46 | public void pointcut() { 47 | } 48 | 49 | /** 50 | * 环绕通知 51 | * @param joinPoint 52 | */ 53 | @Around("pointcut()") 54 | public Object saveSysLog(ProceedingJoinPoint joinPoint) throws Throwable { 55 | Object result=null; 56 | //开始时间 57 | startTime=System.currentTimeMillis(); 58 | 59 | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); 60 | Method method = signature.getMethod(); 61 | //获取注解 62 | ControllerEndpoint controllerEndpoint = method.getAnnotation(ControllerEndpoint.class); 63 | if(controllerEndpoint!=null){ 64 | String operation = controllerEndpoint.operation(); 65 | //注解上的操作描述 66 | sysLog.setOperation(operation); 67 | } 68 | 69 | //请求的参数 70 | Object[] args = joinPoint.getArgs(); 71 | LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer(); 72 | String[] paramNames = u.getParameterNames(method); 73 | sysLog.setParams("paramName:"+ Arrays.toString(paramNames) +",args:"+ Arrays.toString(args)); 74 | 75 | //请求的IP 76 | HttpServletRequest request =((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); 77 | String ipAddr = IPUtil.getIpAddr(request); 78 | sysLog.setIp(ipAddr); 79 | //地理位置 80 | sysLog.setLocation(AddressUtil.getCityInfo(ipAddr)); 81 | //操作人 82 | ActiveUser activeUser= (ActiveUser) SecurityUtils.getSubject().getPrincipal(); 83 | sysLog.setUsername(activeUser.getUser().getUsername()); 84 | //添加时间 85 | sysLog.setCreateTime(new Date()); 86 | //执行目标方法 87 | result=joinPoint.proceed(); 88 | //请求的方法名 89 | String className = joinPoint.getTarget().getClass().getName(); 90 | String methodName = signature.getName(); 91 | sysLog.setMethod(className + "." + methodName + "()\n" 92 | +"\nresponse:"+postHandle(result)); 93 | //执行耗时 94 | sysLog.setTime(System.currentTimeMillis()-startTime); 95 | //保存系统日志 96 | logService.saveLog(sysLog); 97 | 98 | return result; 99 | } 100 | 101 | /** 102 | * 返回数据 103 | * @param retVal 104 | * @return 105 | */ 106 | private String postHandle(Object retVal) { 107 | if(null == retVal){ 108 | return ""; 109 | } 110 | return JSON.toJSONString(retVal); 111 | } 112 | } 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/converter/DepartmentConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.converter; 2 | 3 | import com.coderman.common.model.system.Department; 4 | import com.coderman.common.vo.system.DepartmentVO; 5 | import org.springframework.beans.BeanUtils; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/7 19:56 10 | * @Version 1.0 11 | **/ 12 | public class DepartmentConverter { 13 | 14 | 15 | /** 16 | * 转vo 17 | * @return 18 | */ 19 | public static DepartmentVO converterToDepartmentVO(Department department){ 20 | DepartmentVO departmentVO = new DepartmentVO(); 21 | BeanUtils.copyProperties(department,departmentVO); 22 | return departmentVO; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/converter/MenuConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.converter; 2 | 3 | import com.coderman.common.model.system.Menu; 4 | import com.coderman.common.vo.system.MenuNodeVO; 5 | import com.coderman.common.vo.system.MenuVO; 6 | import org.springframework.beans.BeanUtils; 7 | import org.springframework.util.CollectionUtils; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author zhangyukang 14 | * @Date 2020/3/7 17:22 15 | * @Version 1.0 16 | **/ 17 | public class MenuConverter { 18 | 19 | /** 20 | * 转成menuVO(只包含菜单)List 21 | * @param menus 22 | * @return 23 | */ 24 | public static List converterToMenuNodeVO(List menus){ 25 | //先过滤出用户的菜单 26 | List menuNodeVOS=new ArrayList<>(); 27 | if(!CollectionUtils.isEmpty(menus)){ 28 | for (Menu menu : menus) { 29 | if(menu.getType()==0){ 30 | MenuNodeVO menuNodeVO = new MenuNodeVO(); 31 | BeanUtils.copyProperties(menu,menuNodeVO); 32 | menuNodeVO.setDisabled(menu.getAvailable()==0); 33 | menuNodeVOS.add(menuNodeVO); 34 | } 35 | } 36 | } 37 | return menuNodeVOS; 38 | } 39 | 40 | 41 | /** 42 | * 转成menuVO(菜单和按钮) 43 | * @param menus 44 | * @return 45 | */ 46 | public static List converterToALLMenuNodeVO(List menus){ 47 | //先过滤出用户的菜单 48 | List menuNodeVOS=new ArrayList<>(); 49 | if(!CollectionUtils.isEmpty(menus)){ 50 | for (Menu menu : menus) { 51 | MenuNodeVO menuNodeVO = new MenuNodeVO(); 52 | BeanUtils.copyProperties(menu,menuNodeVO); 53 | menuNodeVO.setDisabled(menu.getAvailable()==0); 54 | menuNodeVOS.add(menuNodeVO); 55 | } 56 | } 57 | return menuNodeVOS; 58 | } 59 | /** 60 | * 转成menuVO(菜单和按钮) 61 | * @param menu 62 | * @return 63 | */ 64 | public static MenuVO converterToMenuVO(Menu menu){ 65 | MenuVO menuVO = new MenuVO(); 66 | if(menu!=null){ 67 | BeanUtils.copyProperties(menu,menuVO); 68 | menuVO.setDisabled(menu.getAvailable()==0); 69 | } 70 | return menuVO; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/converter/RoleConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.converter; 2 | 3 | import com.coderman.common.model.system.Role; 4 | import com.coderman.common.vo.system.RoleTransferItemVO; 5 | import com.coderman.common.vo.system.RoleVO; 6 | import org.springframework.beans.BeanUtils; 7 | import org.springframework.util.CollectionUtils; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @Author zhangyukang 14 | * @Date 2020/3/9 16:26 15 | * @Version 1.0 16 | **/ 17 | public class RoleConverter { 18 | 19 | /** 20 | * 转vo 21 | * @param roles 22 | * @return 23 | */ 24 | public static List converterToRoleVOList(List roles) { 25 | List roleVOS=new ArrayList<>(); 26 | if(!CollectionUtils.isEmpty(roles)){ 27 | for (Role role : roles) { 28 | RoleVO roleVO = new RoleVO(); 29 | BeanUtils.copyProperties(role,roleVO); 30 | roleVO.setStatus(role.getStatus() == 0); 31 | roleVOS.add(roleVO); 32 | } 33 | } 34 | return roleVOS; 35 | } 36 | 37 | /** 38 | * 转成前端需要的角色Item 39 | * @param list 40 | * @return 41 | */ 42 | public static List converterToRoleTransferItem(List list) { 43 | List itemVOList=new ArrayList<>(); 44 | if(!CollectionUtils.isEmpty(list)){ 45 | for (Role role : list) { 46 | RoleTransferItemVO item = new RoleTransferItemVO(); 47 | item.setLabel(role.getRoleName()); 48 | item.setDisabled(role.getStatus()==0); 49 | item.setKey(role.getId()); 50 | itemVOList.add(item); 51 | } 52 | } 53 | 54 | return itemVOList; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/converter/UserConverter.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.converter; 2 | 3 | import com.coderman.common.model.system.Department; 4 | import com.coderman.common.model.system.User; 5 | import com.coderman.common.vo.system.UserVO; 6 | import com.coderman.system.mapper.DepartmentMapper; 7 | import org.springframework.beans.BeanUtils; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.util.CollectionUtils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @Author zhangyukang 17 | * @Date 2020/3/7 19:56 18 | * @Version 1.0 19 | **/ 20 | @Component 21 | public class UserConverter { 22 | 23 | @Autowired 24 | private DepartmentMapper departmentMapper; 25 | 26 | /** 27 | * 转voList 28 | * @param users 29 | * @return 30 | */ 31 | public List converterToUserVOList(List users){ 32 | List userVOS=new ArrayList<>(); 33 | if(!CollectionUtils.isEmpty(users)){ 34 | for (User user : users) { 35 | UserVO userVO = converterToUserVO(user); 36 | userVOS.add(userVO); 37 | } 38 | } 39 | return userVOS; 40 | } 41 | 42 | /** 43 | * 转vo 44 | * @return 45 | */ 46 | public UserVO converterToUserVO(User user){ 47 | UserVO userVO = new UserVO(); 48 | BeanUtils.copyProperties(user,userVO); 49 | userVO.setStatus(user.getStatus() == 0); 50 | Department department = departmentMapper.selectByPrimaryKey(user.getDepartmentId()); 51 | if(department!=null&&department.getName()!=null){ 52 | userVO.setDepartmentName(department.getName()); 53 | userVO.setDepartmentId(department.getId()); 54 | } 55 | return userVO; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/DepartmentMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.Department; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/15 14:15 10 | * @Version 1.0 11 | **/ 12 | public interface DepartmentMapper extends Mapper { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/ImageAttachmentMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.ImageAttachment; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/4/25 10:17 10 | * @Version 1.0 11 | **/ 12 | public interface ImageAttachmentMapper extends Mapper { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/LogMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.Log; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/4/2 20:27 10 | * @Version 1.0 11 | **/ 12 | public interface LogMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/LoginLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.LoginLog; 5 | import com.coderman.common.vo.system.UserVO; 6 | import tk.mybatis.mapper.common.Mapper; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/20 19:09 14 | * @Version 1.0 15 | **/ 16 | public interface LoginLogMapper extends Mapper { 17 | 18 | /** 19 | * 用户登入报表 20 | * @param userVO 21 | * @return 22 | */ 23 | List> userLoginReport(UserVO userVO); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/MenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.Menu; 5 | import tk.mybatis.mapper.common.BaseMapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/7 16:11 10 | * @Version 1.0 11 | **/ 12 | public interface MenuMapper extends BaseMapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.Role; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/7 15:54 10 | * @Version 1.0 11 | **/ 12 | public interface RoleMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/RoleMenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.RoleMenu; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/7 16:06 10 | * @Version 1.0 11 | **/ 12 | public interface RoleMenuMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.User; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/7 15:03 10 | * @Version 1.0 11 | **/ 12 | public interface UserMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.mapper; 2 | 3 | 4 | import com.coderman.common.model.system.UserRole; 5 | import tk.mybatis.mapper.common.Mapper; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/3/7 15:56 10 | * @Version 1.0 11 | **/ 12 | public interface UserRoleMapper extends Mapper { 13 | } 14 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/DepartmentService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.Department; 6 | import com.coderman.common.vo.system.DeanVO; 7 | import com.coderman.common.vo.system.DepartmentVO; 8 | import com.coderman.common.vo.system.PageVO; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author zhangyukang 14 | * @Date 2020/3/15 14:12 15 | * @Version 1.0 16 | **/ 17 | public interface DepartmentService { 18 | /** 19 | * 部门列表 20 | * @param pageNum 21 | * @param pageSize 22 | * @param departmentVO 23 | * @return 24 | */ 25 | PageVO findDepartmentList(Integer pageNum, Integer pageSize, DepartmentVO departmentVO); 26 | 27 | /** 28 | * 查询所有部门主任 29 | * @return 30 | */ 31 | List findDeanList(); 32 | 33 | /** 34 | * 添加院部门 35 | * @param departmentVO 36 | */ 37 | void add(DepartmentVO departmentVO); 38 | 39 | /** 40 | * 编辑院部门 41 | * @param id 42 | * @return 43 | */ 44 | DepartmentVO edit(Long id) throws SystemException; 45 | 46 | /** 47 | * 更新院部门 48 | * @param id 49 | * @param departmentVO 50 | */ 51 | void update(Long id, DepartmentVO departmentVO) throws SystemException; 52 | 53 | /** 54 | * 删除院部门 55 | * @param id 56 | */ 57 | void delete(Long id) throws SystemException; 58 | 59 | /** 60 | * 所有部门 61 | * @return 62 | */ 63 | List findAllVO(); 64 | 65 | 66 | /** 67 | * 全部部门 68 | * @return 69 | */ 70 | List findAll(); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/LogService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | import com.coderman.common.error.SystemException; 4 | import com.coderman.common.model.system.Log; 5 | import com.coderman.common.vo.system.LogVO; 6 | import com.coderman.common.vo.system.PageVO; 7 | import org.springframework.scheduling.annotation.Async; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 系统日志 13 | * Created by zhangyukang on 2019/11/15 17:26 14 | */ 15 | public interface LogService { 16 | 17 | /** 18 | * 异步保存操作日志 19 | */ 20 | @Async("CodeAsyncThreadPool") 21 | void saveLog(Log log); 22 | 23 | 24 | /** 25 | * 删除登入日志 26 | * @param id 27 | */ 28 | void delete(Long id) throws SystemException; 29 | 30 | 31 | /** 32 | * 登入日志列表 33 | * @param pageNum 34 | * @param pageSize 35 | * @param logVO 36 | * @return 37 | */ 38 | PageVO findLogList(Integer pageNum, Integer pageSize, LogVO logVO); 39 | 40 | /** 41 | * 批量删除登入日志 42 | * @param list 43 | */ 44 | void batchDelete(List list) throws SystemException; 45 | } 46 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/LoginLogService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.vo.system.LoginLogVO; 6 | import com.coderman.common.vo.system.PageVO; 7 | import com.coderman.common.vo.system.UserVO; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | /** 14 | * @Author zhangyukang 15 | * @Date 2020/3/20 19:10 16 | * @Version 1.0 17 | **/ 18 | public interface LoginLogService { 19 | 20 | /** 21 | * 添加登入日志 22 | * @param request 23 | */ 24 | void add(HttpServletRequest request); 25 | 26 | 27 | /** 28 | * 删除登入日志 29 | * @param id 30 | */ 31 | void delete(Long id) throws SystemException; 32 | 33 | 34 | /** 35 | * 登入日志列表 36 | * @param pageNum 37 | * @param pageSize 38 | * @param loginLogVO 39 | * @return 40 | */ 41 | PageVO findLoginLogList(Integer pageNum, Integer pageSize, LoginLogVO loginLogVO); 42 | 43 | /** 44 | * 批量删除登入日志 45 | * @param list 46 | */ 47 | void batchDelete(List list) throws SystemException; 48 | 49 | /** 50 | * 用户登入报表 51 | * @param userVO 52 | * @return 53 | */ 54 | List> loginReport(UserVO userVO); 55 | } 56 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.Menu; 6 | import com.coderman.common.vo.system.MenuNodeVO; 7 | import com.coderman.common.vo.system.MenuVO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/10 11:55 14 | * @Version 1.0 15 | **/ 16 | public interface MenuService { 17 | /** 18 | * 获取菜单树 19 | * @return 20 | */ 21 | List findMenuTree(); 22 | 23 | /** 24 | * 添加菜单 25 | * @param menuVO 26 | */ 27 | Menu add(MenuVO menuVO); 28 | 29 | /** 30 | * 删除节点 31 | * @param id 32 | */ 33 | void delete(Long id) throws SystemException; 34 | 35 | /** 36 | * 编辑节点 37 | * @param id 38 | * @return 39 | */ 40 | MenuVO edit(Long id) throws SystemException; 41 | 42 | /** 43 | * 更新节点 44 | * @param id 45 | */ 46 | void update(Long id, MenuVO menuVO) throws SystemException; 47 | 48 | /** 49 | * 所有展开菜单的ID 50 | * @return 51 | */ 52 | List findOpenIds(); 53 | 54 | 55 | /** 56 | * 获取所有菜单 57 | * @return 58 | */ 59 | List findAll(); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.Role; 6 | import com.coderman.common.vo.system.PageVO; 7 | import com.coderman.common.vo.system.RoleVO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/7 15:52 14 | * @Version 1.0 15 | **/ 16 | public interface RoleService { 17 | 18 | /** 19 | * 角色列表 20 | * @param pageNum 21 | * @param pageSize 22 | * @param roleVO 23 | * @return 24 | */ 25 | PageVO findRoleList(Integer pageNum, Integer pageSize, RoleVO roleVO); 26 | 27 | /** 28 | * 添加角色 29 | * @param roleVO 30 | */ 31 | void add(RoleVO roleVO) throws SystemException; 32 | 33 | /** 34 | * 删除角色 35 | * @param id 36 | */ 37 | void deleteById(Long id) throws SystemException; 38 | 39 | /** 40 | * 编辑角色 41 | * @param id 42 | * @return 43 | */ 44 | RoleVO edit(Long id) throws SystemException; 45 | 46 | /** 47 | * 更新角色 48 | * @param id 49 | * @param roleVO 50 | */ 51 | void update(Long id, RoleVO roleVO) throws SystemException; 52 | 53 | /** 54 | * 根据角色状态 55 | * @param id 56 | * @param status 57 | */ 58 | void updateStatus(Long id, Boolean status) throws SystemException; 59 | 60 | /** 61 | * 查询所有的角色 62 | * @return 63 | */ 64 | List findAll(); 65 | 66 | /** 67 | * 查询角色拥有的菜单权限id 68 | * @param id 69 | * @return 70 | */ 71 | List findMenuIdsByRoleId(Long id) throws SystemException; 72 | 73 | /** 74 | * 角色授权 75 | * @param mids 76 | */ 77 | void authority(Long id,Long[] mids) throws SystemException; 78 | } 79 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/UploadService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | import com.coderman.common.error.SystemException; 4 | import com.coderman.common.model.system.ImageAttachment; 5 | import com.coderman.common.vo.system.ImageAttachmentVO; 6 | import org.springframework.web.multipart.MultipartFile; 7 | 8 | import java.io.IOException; 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/8/19 14:57 14 | * @Version 1.0 15 | **/ 16 | public interface UploadService { 17 | String uploadImage(MultipartFile file) throws IOException, SystemException; //图片上传 18 | List findImageList(ImageAttachmentVO imageAttachmentVO); //图片列表 19 | void delete(Long id) throws SystemException; //删除图片 20 | } 21 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service; 2 | 3 | import com.coderman.common.error.SystemException; 4 | import com.coderman.common.model.system.Menu; 5 | import com.coderman.common.model.system.Role; 6 | import com.coderman.common.model.system.User; 7 | import com.coderman.common.vo.system.*; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Author zhangyukang 13 | * @Date 2020/3/7 15:43 14 | * @Version 1.0 15 | **/ 16 | public interface UserService { 17 | 18 | /** 19 | * 根据用户名查询用户 20 | * 21 | * @param name 用户名 22 | * @return 23 | */ 24 | User findUserByName(String name); 25 | 26 | /** 27 | * 查询用户角色 28 | * 29 | * @param id 用户id 30 | * @return 31 | */ 32 | List findRolesById(Long id) throws SystemException; 33 | 34 | /** 35 | * 根据用户角色查询用户的菜单 36 | * 菜单: menu+button 37 | * 38 | * @param roles 用户的角色 39 | * @return 40 | */ 41 | List findMenuByRoles(List roles); 42 | 43 | /** 44 | * 加载菜单 45 | * 46 | * @return 47 | */ 48 | List findMenu(); 49 | 50 | /** 51 | * 用户列表 52 | * @param userVO 53 | * @return 54 | */ 55 | PageVO findUserList(Integer pageNum, Integer pageSize, UserVO userVO); 56 | 57 | /** 58 | * 删除用户 59 | * 60 | * @param id 61 | */ 62 | void deleteById(Long id) throws SystemException; 63 | 64 | /** 65 | * 更新状态 66 | * 67 | * @param id 68 | * @param status 69 | */ 70 | void updateStatus(Long id, Boolean status) throws SystemException; 71 | 72 | /** 73 | * 添加用户 74 | * @param userVO 75 | */ 76 | void add(UserVO userVO) throws SystemException; 77 | 78 | /** 79 | * 更新用户 80 | * 81 | * @param id 82 | * @param userVO 83 | */ 84 | void update(Long id, UserEditVO userVO) throws SystemException; 85 | 86 | /** 87 | * 编辑用户 88 | * 89 | * @param id 90 | * @return 91 | */ 92 | UserEditVO edit(Long id) throws SystemException; 93 | 94 | /** 95 | * 已拥有的角色ids 96 | * 97 | * @param id 用户id 98 | * @return 99 | */ 100 | List roles(Long id) throws SystemException; 101 | 102 | /** 103 | * 分配角色 104 | * 105 | * @param id 106 | * @param rids 107 | */ 108 | void assignRoles(Long id, Long[] rids) throws SystemException; 109 | 110 | /** 111 | * 所有用户 112 | * 113 | * @return 114 | */ 115 | List findAll(); 116 | 117 | /** 118 | * 用户登入 119 | * 120 | * @param username 121 | * @param password 122 | * @return 123 | */ 124 | String login(String username, String password) throws SystemException; 125 | 126 | 127 | /** 128 | * 用户详情 129 | * 130 | * @return 131 | */ 132 | UserInfoVO info() throws SystemException; 133 | 134 | } 135 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/impl/LogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service.impl; 2 | 3 | import com.coderman.common.error.SystemCodeEnum; 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.Log; 6 | import com.coderman.common.model.system.LoginLog; 7 | import com.coderman.common.vo.system.LogVO; 8 | import com.coderman.common.vo.system.PageVO; 9 | import com.coderman.system.mapper.LogMapper; 10 | import com.coderman.system.service.LogService; 11 | import com.github.pagehelper.PageHelper; 12 | import com.github.pagehelper.PageInfo; 13 | import org.springframework.beans.BeanUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | import org.springframework.util.CollectionUtils; 17 | import tk.mybatis.mapper.entity.Example; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * @Author zhangyukang 24 | * @Date 2020/4/2 20:24 25 | * @Version 1.0 26 | **/ 27 | @Service 28 | public class LogServiceImpl implements LogService { 29 | 30 | @Autowired 31 | private LogMapper logMapper; 32 | 33 | /** 34 | * 保存登入日志 35 | * @param log 36 | */ 37 | @Override 38 | public void saveLog(Log log) { 39 | logMapper.insert(log); 40 | } 41 | 42 | 43 | /** 44 | * 删除操作日志 45 | * @param id 46 | */ 47 | @Override 48 | public void delete(Long id) throws SystemException { 49 | Log log = logMapper.selectByPrimaryKey(id); 50 | if(log==null){ 51 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"要删除的操作日志不存在"); 52 | } 53 | logMapper.deleteByPrimaryKey(id); 54 | } 55 | 56 | 57 | @Override 58 | public PageVO findLogList(Integer pageNum, Integer pageSize, LogVO logVO) { 59 | PageHelper.startPage(pageNum,pageSize); 60 | Example o = new Example(LoginLog.class); 61 | Example.Criteria criteria = o.createCriteria(); 62 | o.setOrderByClause("create_time desc"); 63 | if(logVO.getLocation()!=null&&!"".equals(logVO.getLocation())){ 64 | criteria.andLike("location","%"+logVO.getLocation()+"%"); 65 | } 66 | if(logVO.getIp()!=null&&!"".equals(logVO.getIp())){ 67 | criteria.andLike("ip","%"+logVO.getIp()+"%"); 68 | } 69 | if(logVO.getUsername()!=null&&!"".equals(logVO.getUsername())){ 70 | criteria.andLike("username","%"+logVO.getUsername()+"%"); 71 | } 72 | List loginLogs = logMapper.selectByExample(o); 73 | List logVOS=new ArrayList<>(); 74 | if(!CollectionUtils.isEmpty(loginLogs)){ 75 | for (Log loginLog : loginLogs) { 76 | LogVO logVO1 = new LogVO(); 77 | BeanUtils.copyProperties(loginLog,logVO1); 78 | logVOS.add(logVO1); 79 | } 80 | } 81 | PageInfo info=new PageInfo<>(loginLogs); 82 | return new PageVO<>(info.getTotal(),logVOS); 83 | } 84 | 85 | /** 86 | * 批量删除 87 | * @param list 88 | */ 89 | @Override 90 | public void batchDelete(List list) throws SystemException { 91 | for (Long id : list) { 92 | Log log = logMapper.selectByPrimaryKey(id); 93 | if(log==null){ 94 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"id="+id+",操作日志不存在"); 95 | } 96 | delete(id); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/impl/MenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service.impl; 2 | 3 | import com.coderman.common.error.SystemCodeEnum; 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.Menu; 6 | import com.coderman.common.utils.MenuTreeBuilder; 7 | import com.coderman.common.vo.system.MenuNodeVO; 8 | import com.coderman.common.vo.system.MenuVO; 9 | import com.coderman.system.converter.MenuConverter; 10 | import com.coderman.system.mapper.MenuMapper; 11 | import com.coderman.system.mapper.RoleMapper; 12 | import com.coderman.system.mapper.RoleMenuMapper; 13 | import com.coderman.system.service.MenuService; 14 | import org.springframework.beans.BeanUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.util.CollectionUtils; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Date; 21 | import java.util.List; 22 | 23 | /** 24 | * @Author zhangyukang 25 | * @Date 2020/3/10 11:56 26 | * @Version 1.0 27 | **/ 28 | @Service 29 | public class MenuServiceImpl implements MenuService { 30 | 31 | @Autowired 32 | private MenuMapper menuMapper; 33 | 34 | 35 | /** 36 | * 加载菜单树(按钮和菜单) 37 | * 38 | * @return 39 | */ 40 | @Override 41 | public List findMenuTree() { 42 | List menus = menuMapper.selectAll(); 43 | List menuNodeVOS = MenuConverter.converterToALLMenuNodeVO(menus); 44 | return MenuTreeBuilder.build(menuNodeVOS); 45 | } 46 | 47 | /** 48 | * 添加菜单 49 | * 50 | * @param menuVO 51 | */ 52 | @Override 53 | public Menu add(MenuVO menuVO) { 54 | Menu menu = new Menu(); 55 | BeanUtils.copyProperties(menuVO,menu); 56 | menu.setCreateTime(new Date()); 57 | menu.setModifiedTime(new Date()); 58 | menu.setAvailable(menuVO.isDisabled()?0:1); 59 | menuMapper.insert(menu); 60 | return menu; 61 | } 62 | 63 | /** 64 | * 删除菜单 65 | * @param id 66 | */ 67 | @Override 68 | public void delete(Long id) throws SystemException { 69 | Menu menu = menuMapper.selectByPrimaryKey(id); 70 | if(menu==null){ 71 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"要删除的菜单不存在"); 72 | } 73 | menuMapper.deleteByPrimaryKey(id); 74 | } 75 | 76 | /** 77 | * 编辑菜单 78 | * @param id 79 | * @return 80 | */ 81 | @Override 82 | public MenuVO edit(Long id) throws SystemException { 83 | Menu menu = menuMapper.selectByPrimaryKey(id); 84 | if(menu==null){ 85 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"该编辑的菜单不存在"); 86 | } 87 | return MenuConverter.converterToMenuVO(menu); 88 | } 89 | 90 | /** 91 | * 更新菜单 92 | * @param id 93 | * @param menuVO 94 | */ 95 | @Override 96 | public void update(Long id, MenuVO menuVO) throws SystemException { 97 | Menu dbMenu = menuMapper.selectByPrimaryKey(id); 98 | if(dbMenu==null){ 99 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"要更新的菜单不存在"); 100 | } 101 | Menu menu = new Menu(); 102 | BeanUtils.copyProperties(menuVO,menu); 103 | menu.setId(id); 104 | menu.setAvailable(menuVO.isDisabled()?0:1); 105 | menu.setModifiedTime(new Date()); 106 | menuMapper.updateByPrimaryKeySelective(menu); 107 | } 108 | 109 | /** 110 | * 获取展开项 111 | * 112 | * @return 113 | */ 114 | @Override 115 | public List findOpenIds() { 116 | List ids=new ArrayList<>(); 117 | List menus = menuMapper.selectAll(); 118 | if(!CollectionUtils.isEmpty(menus)){ 119 | for (Menu menu : menus) { 120 | if(menu.getOpen()==1){ 121 | ids.add(menu.getId()); 122 | } 123 | } 124 | } 125 | return ids; 126 | } 127 | 128 | 129 | 130 | /** 131 | * 获取所有菜单 132 | * @return 133 | */ 134 | @Override 135 | public List findAll() { 136 | return menuMapper.selectAll(); 137 | } 138 | 139 | 140 | } 141 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/service/impl/UploadServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.service.impl; 2 | 3 | import com.coderman.common.error.SystemCodeEnum; 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.ImageAttachment; 6 | import com.coderman.common.utils.FdfsUtil; 7 | import com.coderman.common.vo.system.ImageAttachmentVO; 8 | import com.coderman.system.mapper.ImageAttachmentMapper; 9 | import com.coderman.system.service.UploadService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import org.springframework.web.multipart.MultipartFile; 14 | import tk.mybatis.mapper.entity.Example; 15 | 16 | import javax.imageio.ImageIO; 17 | import java.awt.image.BufferedImage; 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.util.Date; 21 | import java.util.List; 22 | 23 | /** 24 | * @Author zhangyukang 25 | * @Date 2020/8/19 14:59 26 | * @Version 1.0 27 | **/ 28 | @Service 29 | public class UploadServiceImpl implements UploadService { 30 | 31 | @Autowired 32 | private ImageAttachmentMapper attachmentMapper; 33 | 34 | // @Autowired 35 | // private FdfsConfig config; 36 | 37 | @Autowired 38 | private FdfsUtil fdfsUtil; 39 | 40 | @Override 41 | public String uploadImage(MultipartFile file) throws IOException, SystemException { 42 | if (file.isEmpty()) { 43 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"上传的文件不能为空"); 44 | } 45 | InputStream inputStream = file.getInputStream(); 46 | //文件的原名称 47 | long size = file.getSize(); 48 | String originalFilename = file.getOriginalFilename(); 49 | String fileExtName = originalFilename.substring(originalFilename.lastIndexOf(".") + 1); 50 | String path = fdfsUtil.upfileImage(inputStream, size, fileExtName.toUpperCase(), null); 51 | //保存图片信息到数据库 52 | BufferedImage image = ImageIO.read(file.getInputStream()); 53 | if (image != null) {//如果image=null 表示上传的不是图片格式 54 | ImageAttachment imageAttachment = new ImageAttachment(); 55 | imageAttachment.setCreateTime(new Date()); 56 | imageAttachment.setHeight(image.getHeight()); 57 | imageAttachment.setWidth(image.getWidth()); 58 | imageAttachment.setMediaType(fileExtName); 59 | imageAttachment.setMediaType(file.getContentType()); 60 | imageAttachment.setPath(path); 61 | attachmentMapper.insert(imageAttachment); 62 | } 63 | //TODO 64 | return path; 65 | } 66 | 67 | @Override 68 | public List findImageList(ImageAttachmentVO imageAttachmentVO) { 69 | Example o = new Example(ImageAttachment.class); 70 | Example.Criteria criteria = o.createCriteria(); 71 | o.setOrderByClause("create_time desc"); 72 | if (imageAttachmentVO.getMediaType() != null && !"".equals(imageAttachmentVO.getMediaType())) { 73 | criteria.andEqualTo("mediaType", imageAttachmentVO.getMediaType()); 74 | } 75 | if (imageAttachmentVO.getPath() != null && !"".equals(imageAttachmentVO.getPath())) { 76 | criteria.andLike("path", "%" + imageAttachmentVO.getPath() + "%"); 77 | } 78 | //拼装图片真实路径 79 | // for (ImageAttachment attachment : attachments) { 80 | // attachment.setPath(config.getResHost()+attachment.getPath()); 81 | // } 82 | return attachmentMapper.selectByExample(o); 83 | } 84 | 85 | @Override 86 | @Transactional 87 | public void delete(Long id) throws SystemException { 88 | ImageAttachment image = attachmentMapper.selectByPrimaryKey(id); 89 | if(image==null){ 90 | throw new SystemException(SystemCodeEnum.PARAMETER_ERROR,"图片不存在"); 91 | }else { 92 | attachmentMapper.deleteByPrimaryKey(id); 93 | // fdfsUtil.deleteFile(image.getPath()); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/shiro/JWTToken.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.shiro; 2 | 3 | import org.apache.shiro.authc.AuthenticationToken; 4 | 5 | public class JWTToken implements AuthenticationToken { 6 | 7 | // 密钥 8 | private String token; 9 | 10 | public JWTToken(String token) { 11 | this.token = token; 12 | } 13 | 14 | @Override 15 | public Object getPrincipal() { 16 | return token; 17 | } 18 | 19 | @Override 20 | public Object getCredentials() { 21 | return token; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/shiro/ShiroConfig.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.shiro; 2 | 3 | import org.apache.shiro.mgt.DefaultSessionStorageEvaluator; 4 | import org.apache.shiro.mgt.DefaultSubjectDAO; 5 | import org.apache.shiro.spring.LifecycleBeanPostProcessor; 6 | import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; 7 | import org.apache.shiro.spring.web.ShiroFilterFactoryBean; 8 | import org.apache.shiro.web.mgt.DefaultWebSecurityManager; 9 | import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.context.annotation.DependsOn; 13 | 14 | import javax.servlet.Filter; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | @Configuration 19 | public class ShiroConfig { 20 | 21 | @Bean("securityManager") 22 | public DefaultWebSecurityManager getManager(UserRealm realm) { 23 | DefaultWebSecurityManager manager = new DefaultWebSecurityManager(); 24 | // 使用自己的realm 25 | manager.setRealm(realm); 26 | /* 27 | * 关闭shiro自带的session,详情见文档 28 | * http://shiro.apache.org/session-management.html#SessionManagement-StatelessApplications%28Sessionless%29 29 | */ 30 | DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO(); 31 | DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator(); 32 | defaultSessionStorageEvaluator.setSessionStorageEnabled(false); 33 | subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator); 34 | manager.setSubjectDAO(subjectDAO); 35 | 36 | return manager; 37 | } 38 | 39 | @Bean("shiroFilter") 40 | public ShiroFilterFactoryBean factory(DefaultWebSecurityManager securityManager) { 41 | ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean(); 42 | 43 | // 添加自己的过滤器并且取名为jwt 44 | Map filterMap = new HashMap<>(); 45 | filterMap.put("jwt", new JWTFilter()); 46 | factoryBean.setFilters(filterMap); 47 | 48 | factoryBean.setSecurityManager(securityManager); 49 | /* 50 | * 自定义url规则 51 | * http://shiro.apache.org/web.html#urls- 52 | */ 53 | Map filterRuleMap = new HashMap<>(); 54 | // 所有请求通过我们自己的JWT Filter 55 | filterRuleMap.put("/**", "jwt"); 56 | // 访问401和404页面不通过我们的Filter 57 | filterRuleMap.put("/system/user/login", "anon"); 58 | filterRuleMap.put("/user/imgCode", "anon"); 59 | //开放API文档接口 60 | filterRuleMap.put("/swagger-ui.html", "anon"); 61 | filterRuleMap.put("/webjars/**","anon"); 62 | filterRuleMap.put("/swagger-resources/**","anon"); 63 | filterRuleMap.put("/v2/**","anon"); 64 | filterRuleMap.put("/static/**","anon"); 65 | //sql监控 66 | filterRuleMap.put("/druid/**","anon"); 67 | factoryBean.setFilterChainDefinitionMap(filterRuleMap); 68 | return factoryBean; 69 | } 70 | 71 | /** 72 | * 下面的代码是添加注解支持 73 | */ 74 | @Bean 75 | @DependsOn("lifecycleBeanPostProcessor") 76 | public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { 77 | DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator(); 78 | // 强制使用cglib,防止重复代理和可能引起代理出错的问题 79 | // https://zhuanlan.zhihu.com/p/29161098 80 | defaultAdvisorAutoProxyCreator.setProxyTargetClass(true); 81 | return defaultAdvisorAutoProxyCreator; 82 | } 83 | 84 | @Bean 85 | public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { 86 | return new LifecycleBeanPostProcessor(); 87 | } 88 | 89 | @Bean 90 | public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) { 91 | AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); 92 | advisor.setSecurityManager(securityManager); 93 | return advisor; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /xinguan-system/src/main/java/com/coderman/system/util/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.coderman.system.util; 2 | 3 | import org.apache.shiro.crypto.hash.SimpleHash; 4 | 5 | /** 6 | * @Author zhangyukang 7 | * @Date 2020/12/15 14:54 8 | * @Version 1.0 9 | **/ 10 | public class MD5Utils { 11 | /** 12 | * 密码加密 13 | * @return 14 | */ 15 | public static String md5Encryption(String source,String salt){ 16 | String algorithmName = "MD5";//加密算法 17 | int hashIterations = 1024;//加密次数 18 | SimpleHash simpleHash = new SimpleHash(algorithmName,source,salt,hashIterations); 19 | return simpleHash+""; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xinguan-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | goods 7 | com.coderman 8 | 0.0.1-SNAPSHOT 9 | 10 | jar 11 | 4.0.0 12 | 13 | xinguan-web 14 | 15 | 16 | 17 | com.coderman 18 | xinguan-system 19 | 0.0.1-SNAPSHOT 20 | 21 | 22 | com.coderman 23 | xinguan-business 24 | 0.0.1-SNAPSHOT 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-maven-plugin 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/XinguanApplication.java: -------------------------------------------------------------------------------- 1 | package com.coderman; 2 | 3 | import com.github.tobato.fastdfs.FdfsClientConfig; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Import; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | import tk.mybatis.spring.annotation.MapperScan; 9 | 10 | /** 11 | * @Author zhangyukang 12 | * @Date 2020/12/15 13:14 13 | * @Version 1.0 14 | **/ 15 | @SpringBootApplication 16 | @EnableTransactionManagement //开启事务管理 17 | @MapperScan("com.coderman.*.mapper") //扫描mapper 18 | @Import(FdfsClientConfig.class) 19 | public class XinguanApplication { 20 | public static void main(String[] args) { 21 | SpringApplication.run(XinguanApplication.class,args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/config/FdfsConfig.java: -------------------------------------------------------------------------------- 1 | package com.coderman.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Author zhangyukang 8 | * @Date 2020/8/9 11:48 9 | * @Version 1.0 10 | **/ 11 | @Component 12 | public class FdfsConfig { 13 | 14 | @Value("${fdfs.resHost}") 15 | private String resHost; 16 | 17 | @Value("${fdfs.storagePort}") 18 | private String storagePort; 19 | 20 | public String getResHost() { 21 | return resHost; 22 | } 23 | 24 | public void setResHost(String resHost) { 25 | this.resHost = resHost; 26 | } 27 | 28 | public String getStoragePort() { 29 | return storagePort; 30 | } 31 | 32 | public void setStoragePort(String storagePort) { 33 | this.storagePort = storagePort; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/config/FdfsConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.coderman.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.EnableMBeanExport; 5 | import org.springframework.jmx.support.RegistrationPolicy; 6 | 7 | /** 8 | * @Author zhangyukang 9 | * @Date 2020/8/9 11:49 10 | * @Version 1.0 11 | **/ 12 | @Configuration 13 | @EnableMBeanExport(registration= RegistrationPolicy.IGNORE_EXISTING) 14 | public class FdfsConfiguration { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.coderman.config; 2 | 3 | import com.google.common.collect.Lists; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiKey; 10 | import springfox.documentation.service.AuthorizationScope; 11 | import springfox.documentation.service.SecurityReference; 12 | import springfox.documentation.spi.DocumentationType; 13 | import springfox.documentation.spi.service.contexts.SecurityContext; 14 | import springfox.documentation.spring.web.plugins.Docket; 15 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * @Author zhangyukang 22 | * @Date 2020/11/11 20:22 23 | * @Version 1.0 24 | **/ 25 | @Configuration 26 | @EnableSwagger2 27 | public class SwaggerConfig { 28 | 29 | 30 | @Bean 31 | public Docket createRestApi() { 32 | return new Docket(DocumentationType.SWAGGER_2) 33 | .pathMapping("/") 34 | .select() 35 | .apis(RequestHandlerSelectors.basePackage("com.coderman")) 36 | .paths(PathSelectors.any()) 37 | .build().apiInfo(new ApiInfoBuilder() 38 | .build()) 39 | .securitySchemes(securitySchemes()) 40 | .securityContexts(securityContexts()); 41 | } 42 | 43 | 44 | private List securitySchemes() { 45 | ArrayList apiKeyList = Lists.newArrayList(); 46 | apiKeyList.add(new ApiKey("JSON WEB TOKEN(秘钥)", "Authorization", "header")); 47 | return apiKeyList; 48 | } 49 | 50 | private List securityContexts() { 51 | List securityContexts=new ArrayList<>(); 52 | securityContexts.add( 53 | SecurityContext.builder() 54 | .securityReferences(defaultAuth()) 55 | .forPaths(PathSelectors.regex("^(?!auth).*$")) 56 | .build()); 57 | return securityContexts; 58 | } 59 | 60 | List defaultAuth() { 61 | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); 62 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 63 | authorizationScopes[0] = authorizationScope; 64 | List securityReferences=new ArrayList<>(); 65 | securityReferences.add(new SecurityReference("Authorization", authorizationScopes)); 66 | return securityReferences; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/business/ConsumerController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.business; 2 | 3 | import com.coderman.business.service.ConsumerService; 4 | import com.coderman.common.annotation.ControllerEndpoint; 5 | import com.coderman.common.response.ResponseBean; 6 | import com.coderman.common.vo.business.ConsumerVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.shiro.authz.annotation.RequiresPermissions; 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 | 17 | /** 18 | * 去向管理 19 | * 20 | * @Author zhangyukang 21 | * @Date 2020/3/16 20:18 22 | * @Version 1.0 23 | **/ 24 | @Api(tags = "业务模块-物资去向相关接口") 25 | @RestController 26 | @RequestMapping("/business/consumer") 27 | public class ConsumerController { 28 | 29 | 30 | @Autowired 31 | private ConsumerService consumerService; 32 | 33 | /** 34 | * 去向列表 35 | * 36 | * @return 37 | */ 38 | @ApiOperation(value = "去向列表", notes = "去向列表,根据去向名模糊查询") 39 | @GetMapping("/findConsumerList") 40 | public ResponseBean findConsumerList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, 41 | @RequestParam(value = "pageSize") Integer pageSize, 42 | ConsumerVO consumerVO) { 43 | PageVO consumerVOPageVO = consumerService.findConsumerList(pageNum, pageSize, consumerVO); 44 | return ResponseBean.success(consumerVOPageVO); 45 | } 46 | 47 | /** 48 | * 添加去向 49 | * 50 | * @return 51 | */ 52 | @ControllerEndpoint(exceptionMessage = "物资去向添加失败", operation = "物资去向添加") 53 | @RequiresPermissions({"consumer:add"}) 54 | @ApiOperation(value = "添加去向") 55 | @PostMapping("/add") 56 | public ResponseBean add(@RequestBody @Validated ConsumerVO consumerVO) { 57 | consumerService.add(consumerVO); 58 | return ResponseBean.success(); 59 | } 60 | 61 | /** 62 | * 编辑去向 63 | * 64 | * @param id 65 | * @return 66 | */ 67 | @ApiOperation(value = "编辑去向", notes = "编辑去向信息") 68 | @RequiresPermissions({"consumer:edit"}) 69 | @GetMapping("/edit/{id}") 70 | public ResponseBean edit(@PathVariable Long id) { 71 | ConsumerVO consumerVO = consumerService.edit(id); 72 | return ResponseBean.success(consumerVO); 73 | } 74 | 75 | /** 76 | * 更新去向 77 | * 78 | * @return 79 | */ 80 | @ControllerEndpoint(exceptionMessage = "物资去向更新失败", operation = "物资去向更新") 81 | @ApiOperation(value = "更新去向", notes = "更新去向信息") 82 | @RequiresPermissions({"consumer:update"}) 83 | @PutMapping("/update/{id}") 84 | public ResponseBean update(@PathVariable Long id, @RequestBody @Validated ConsumerVO consumerVO) { 85 | consumerService.update(id, consumerVO); 86 | return ResponseBean.success(); 87 | } 88 | 89 | /** 90 | * 删除去向 91 | * 92 | * @param id 93 | * @return 94 | */ 95 | @ControllerEndpoint(exceptionMessage = "物资去向删除失败", operation = "物资去向删除") 96 | @ApiOperation(value = "删除去向", notes = "删除去向信息") 97 | @RequiresPermissions({"consumer:delete"}) 98 | @DeleteMapping("/delete/{id}") 99 | public ResponseBean delete(@PathVariable Long id) { 100 | consumerService.delete(id); 101 | return ResponseBean.success(); 102 | } 103 | 104 | /** 105 | * 所有去向 106 | * 107 | * @return 108 | */ 109 | @ApiOperation(value = "所有去向", notes = "所有去向列表") 110 | @GetMapping("/findAll") 111 | public ResponseBean findAll() { 112 | List consumerVOS = consumerService.findAll(); 113 | return ResponseBean.success(consumerVOS); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/business/HealthController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.business; 2 | 3 | import com.coderman.business.service.HealthService; 4 | import com.coderman.common.annotation.ControllerEndpoint; 5 | import com.coderman.common.error.BusinessException; 6 | import com.coderman.common.model.business.Health; 7 | import com.coderman.common.response.ActiveUser; 8 | import com.coderman.common.response.ResponseBean; 9 | import com.coderman.common.vo.business.HealthVO; 10 | import com.coderman.common.vo.system.PageVO; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiOperation; 13 | import org.apache.shiro.SecurityUtils; 14 | import org.apache.shiro.authz.annotation.RequiresPermissions; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.validation.annotation.Validated; 17 | import org.springframework.web.bind.annotation.*; 18 | 19 | /** 20 | * @Author zhangyukang 21 | * @Date 2020/5/7 10:14 22 | * @Version 1.0 23 | **/ 24 | @Api(tags = "业务模块-健康上报相关接口") 25 | @RestController 26 | @RequestMapping("/business/health") 27 | public class HealthController { 28 | 29 | @Autowired 30 | private HealthService healthService; 31 | 32 | /** 33 | * 健康上报 34 | * @param healthVO 35 | * @return 36 | */ 37 | @ControllerEndpoint(exceptionMessage = "健康上报失败", operation = "健康上报") 38 | @ApiOperation(value = "健康上报",notes = "用户健康上报") 39 | @RequiresPermissions({"health:report"}) 40 | @PostMapping("/report") 41 | public ResponseBean report(@Validated @RequestBody HealthVO healthVO) throws BusinessException { 42 | ActiveUser activeUser = (ActiveUser) SecurityUtils.getSubject().getPrincipal(); 43 | healthVO.setUserId(activeUser.getUser().getId()); 44 | healthService.report(healthVO); 45 | return ResponseBean.success(); 46 | } 47 | 48 | /** 49 | * 签到记录 50 | * @return 51 | */ 52 | @ApiOperation(value = "健康记录",notes = "用户健康上报历史记录") 53 | @GetMapping("/history") 54 | public ResponseBean history(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, 55 | @RequestParam(value = "pageSize") Integer pageSize){ 56 | ActiveUser activeUser= (ActiveUser) SecurityUtils.getSubject().getPrincipal(); 57 | Long id = activeUser.getUser().getId(); 58 | PageVO Health=healthService.history(id,pageNum,pageSize); 59 | return ResponseBean.success(Health); 60 | } 61 | 62 | /** 63 | * 今日是否已报备 64 | * @return 65 | */ 66 | @ApiOperation(value = "是否报备",notes = "今日是否已报备") 67 | @GetMapping("/isReport") 68 | public ResponseBean isReport(){ 69 | ActiveUser activeUser = (ActiveUser) SecurityUtils.getSubject().getPrincipal(); 70 | Health report = healthService.isReport(activeUser.getUser().getId()); 71 | return ResponseBean.success(report); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/business/SupplierController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.business; 2 | 3 | import com.coderman.business.service.SupplierService; 4 | import com.coderman.common.annotation.ControllerEndpoint; 5 | import com.coderman.common.response.ResponseBean; 6 | import com.coderman.common.vo.business.SupplierVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.shiro.authz.annotation.RequiresPermissions; 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 | 17 | /** 18 | * 来源管理 19 | * 20 | * @Author zhangyukang 21 | * @Date 2020/3/16 20:18 22 | * @Version 1.0 23 | **/ 24 | @Api(tags = "业务模块-物资来源相关接口") 25 | @RestController 26 | @RequestMapping("/business/supplier") 27 | public class SupplierController { 28 | 29 | 30 | @Autowired 31 | private SupplierService supplierService; 32 | 33 | /** 34 | * 来源列表 35 | * 36 | * @return 37 | */ 38 | @ApiOperation(value = "来源列表", notes = "来源列表,根据来源名模糊查询") 39 | @GetMapping("/findSupplierList") 40 | public ResponseBean findSupplierList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, 41 | @RequestParam(value = "pageSize") Integer pageSize, 42 | SupplierVO supplierVO) { 43 | PageVO supplierVOPageVO = supplierService.findSupplierList(pageNum, pageSize, supplierVO); 44 | return ResponseBean.success(supplierVOPageVO); 45 | } 46 | 47 | 48 | /** 49 | * 添加来源 50 | * 51 | * @return 52 | */ 53 | @ControllerEndpoint(exceptionMessage = "物资来源添加失败", operation = "物资来源添加") 54 | @RequiresPermissions({"supplier:add"}) 55 | @ApiOperation(value = "添加来源") 56 | @PostMapping("/add") 57 | public ResponseBean add(@RequestBody @Validated SupplierVO supplierVO) { 58 | supplierService.add(supplierVO); 59 | return ResponseBean.success(); 60 | } 61 | 62 | /** 63 | * 编辑来源 64 | * 65 | * @param id 66 | * @return 67 | */ 68 | @ApiOperation(value = "编辑来源", notes = "编辑来源信息") 69 | @RequiresPermissions({"supplier:edit"}) 70 | @GetMapping("/edit/{id}") 71 | public ResponseBean edit(@PathVariable Long id) { 72 | SupplierVO supplierVO = supplierService.edit(id); 73 | return ResponseBean.success(supplierVO); 74 | } 75 | 76 | /** 77 | * 更新来源 78 | * 79 | * @return 80 | */ 81 | @ControllerEndpoint(exceptionMessage = "物资来源更新失败", operation = "物资来源更新") 82 | @ApiOperation(value = "更新来源", notes = "更新来源信息") 83 | @RequiresPermissions({"supplier:update"}) 84 | @PutMapping("/update/{id}") 85 | public ResponseBean update(@PathVariable Long id, @RequestBody @Validated SupplierVO supplierVO) { 86 | supplierService.update(id, supplierVO); 87 | return ResponseBean.success(); 88 | } 89 | 90 | /** 91 | * 删除来源 92 | * 93 | * @param id 94 | * @return 95 | */ 96 | @ControllerEndpoint(exceptionMessage = "物资来源删除失败", operation = "物资来源删除") 97 | @ApiOperation(value = "删除来源", notes = "删除来源信息") 98 | @RequiresPermissions({"supplier:delete"}) 99 | @DeleteMapping("/delete/{id}") 100 | public ResponseBean delete(@PathVariable Long id) { 101 | supplierService.delete(id); 102 | return ResponseBean.success(); 103 | } 104 | 105 | /** 106 | * 所有来源 107 | * 108 | * @return 109 | */ 110 | @ApiOperation(value = "所有来源", notes = "所有来源列表") 111 | @GetMapping("/findAll") 112 | public ResponseBean> findAll() { 113 | List supplierVOS = supplierService.findAll(); 114 | return ResponseBean.success(supplierVOS); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/system/LogController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.system; 2 | 3 | import com.coderman.common.error.SystemException; 4 | import com.coderman.common.response.ResponseBean; 5 | import com.coderman.common.vo.system.LogVO; 6 | import com.coderman.common.vo.system.PageVO; 7 | import com.coderman.system.service.LogService; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.shiro.authz.annotation.RequiresPermissions; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * 系统日志 19 | * 20 | * @Author zhangyukang 21 | * @Date 2020/3/22 21:03 22 | * @Version 1.0 23 | **/ 24 | @Api(tags = "系统模块-操作日志相关接口") 25 | @RestController 26 | @RequestMapping("/system/log") 27 | public class LogController { 28 | 29 | 30 | @Autowired 31 | private LogService logService; 32 | 33 | /** 34 | * 日志列表 35 | * 36 | * @return 37 | */ 38 | @ApiOperation(value = "日志列表", notes = "系统日志列表,模糊查询") 39 | @GetMapping("/findLogList") 40 | public ResponseBean> findLogList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, 41 | @RequestParam(value = "pageSize") Integer pageSize, 42 | LogVO logVO) { 43 | PageVO logList = logService.findLogList(pageNum, pageSize, logVO); 44 | return ResponseBean.success(logList); 45 | } 46 | 47 | /** 48 | * 删除日志 49 | * 50 | * @param id 51 | * @return 52 | */ 53 | @ApiOperation(value = "删除日志") 54 | @RequiresPermissions({"log:delete"}) 55 | @DeleteMapping("/delete/{id}") 56 | public ResponseBean delete(@PathVariable Long id) throws SystemException { 57 | logService.delete(id); 58 | return ResponseBean.success("删除系统日志成功"); 59 | } 60 | 61 | /** 62 | * 批量删除 63 | * 64 | * @param ids 65 | * @return 66 | */ 67 | @ApiOperation(value = "批量删除") 68 | @RequiresPermissions({"log:batchDelete"}) 69 | @DeleteMapping("/batchDelete/{ids}") 70 | public ResponseBean batchDelete(@PathVariable String ids) throws SystemException { 71 | String[] idList = ids.split(","); 72 | List list = new ArrayList<>(); 73 | if (idList.length > 0) { 74 | for (String s : idList) { 75 | list.add(Long.parseLong(s)); 76 | } 77 | } 78 | logService.batchDelete(list); 79 | return ResponseBean.success("批量删除成功"); 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/system/LoginLogController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.system; 2 | 3 | import com.coderman.common.annotation.ControllerEndpoint; 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.response.ResponseBean; 6 | import com.coderman.common.vo.system.LoginLogVO; 7 | import com.coderman.common.vo.system.PageVO; 8 | import com.coderman.common.vo.system.UserVO; 9 | import com.coderman.system.service.LoginLogService; 10 | import io.swagger.annotations.Api; 11 | import io.swagger.annotations.ApiOperation; 12 | import org.apache.shiro.authz.annotation.RequiresPermissions; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import java.util.ArrayList; 17 | import java.util.HashMap; 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | /** 22 | * 登入日志 23 | * 24 | * @Author zhangyukang 25 | * @Date 2020/3/22 21:03 26 | * @Version 1.0 27 | **/ 28 | @Api(tags = "系统模块-登入日志相关接口") 29 | @RestController 30 | @RequestMapping("/system/loginLog") 31 | public class LoginLogController { 32 | 33 | 34 | @Autowired 35 | private LoginLogService loginLogService; 36 | 37 | /** 38 | * 日志列表 39 | * 40 | * @return 41 | */ 42 | @ApiOperation(value = "日志列表", notes = "登入日志列表,模糊查询") 43 | @GetMapping("/findLoginLogList") 44 | public ResponseBean findLoginLogList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, 45 | @RequestParam(value = "pageSize") Integer pageSize, 46 | LoginLogVO loginLogVO) { 47 | PageVO loginLogList = loginLogService.findLoginLogList(pageNum, pageSize, loginLogVO); 48 | return ResponseBean.success(loginLogList); 49 | } 50 | 51 | /** 52 | * 删除日志 53 | * 54 | * @param id 55 | * @return 56 | */ 57 | @ControllerEndpoint(exceptionMessage = "删除登入日志失败", operation = "删除登入日志") 58 | @ApiOperation(value = "删除日志") 59 | @RequiresPermissions({"loginLog:delete"}) 60 | @DeleteMapping("/delete/{id}") 61 | public ResponseBean delete(@PathVariable Long id) throws SystemException { 62 | loginLogService.delete(id); 63 | return ResponseBean.success(); 64 | } 65 | 66 | /** 67 | * 批量删除 68 | * 69 | * @param ids 70 | * @return 71 | */ 72 | @ControllerEndpoint(exceptionMessage = "批量删除登入日志失败", operation = "批量删除登入日志") 73 | @ApiOperation(value = "批量删除") 74 | @RequiresPermissions({"loginLog:batchDelete"}) 75 | @DeleteMapping("/batchDelete/{ids}") 76 | public ResponseBean batchDelete(@PathVariable String ids) throws SystemException { 77 | String[] idList = ids.split(","); 78 | List list = new ArrayList<>(); 79 | if (idList.length > 0) { 80 | for (String s : idList) { 81 | list.add(Long.parseLong(s)); 82 | } 83 | } 84 | loginLogService.batchDelete(list); 85 | return ResponseBean.success(); 86 | } 87 | 88 | /** 89 | * 登入报表 90 | * @return 91 | */ 92 | @PostMapping("/loginReport") 93 | @ApiOperation(value = "登入报表",notes = "用户登入报表") 94 | public ResponseBean loginReport(@RequestBody UserVO userVO){ 95 | List> mapList= loginLogService.loginReport(userVO); 96 | Map map=new HashMap<>(); 97 | userVO.setUsername(null); 98 | List> meList= loginLogService.loginReport(userVO); 99 | map.put("me",mapList); 100 | map.put("all",meList); 101 | return ResponseBean.success(map); 102 | } 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/system/MenuController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.system; 2 | 3 | import com.coderman.common.annotation.ControllerEndpoint; 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.Menu; 6 | import com.coderman.common.response.ResponseBean; 7 | import com.coderman.common.vo.system.MenuNodeVO; 8 | import com.coderman.common.vo.system.MenuVO; 9 | import com.coderman.system.service.MenuService; 10 | import com.wuwenze.poi.ExcelKit; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiOperation; 13 | import org.apache.shiro.authz.annotation.RequiresPermissions; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.util.ArrayList; 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * @Author zhangyukang 26 | * @Date 2020/3/10 11:51 27 | * @Version 1.0 28 | **/ 29 | @Api(tags = "系统模块-菜单权限相关接口") 30 | @RequestMapping("/system/menu") 31 | @RestController 32 | public class MenuController { 33 | 34 | @Autowired 35 | private MenuService menuService; 36 | 37 | /** 38 | * 加载菜单树 39 | * 40 | * @return 41 | */ 42 | @ApiOperation(value = "加载菜单树", notes = "获取所有菜单树,以及展开项") 43 | @GetMapping("/tree") 44 | public ResponseBean> tree() { 45 | List menuTree = menuService.findMenuTree(); 46 | List ids = menuService.findOpenIds(); 47 | Map map = new HashMap<>(); 48 | map.put("tree", menuTree); 49 | map.put("open", ids); 50 | return ResponseBean.success(map); 51 | } 52 | 53 | /** 54 | * 新增菜单/按钮 55 | * 56 | * @return 57 | */ 58 | @ControllerEndpoint(exceptionMessage = "新增菜单/按钮失败", operation = "新增菜单/按钮") 59 | @ApiOperation(value = "新增菜单") 60 | @RequiresPermissions({"menu:add"}) 61 | @PostMapping("/add") 62 | public ResponseBean> add(@RequestBody @Validated MenuVO menuVO) { 63 | Menu node = menuService.add(menuVO); 64 | Map map = new HashMap<>(); 65 | map.put("id", node.getId()); 66 | map.put("menuName", node.getMenuName()); 67 | map.put("children", new ArrayList<>()); 68 | map.put("icon", node.getIcon()); 69 | return ResponseBean.success(map); 70 | } 71 | 72 | /** 73 | * 删除菜单/按钮 74 | * 75 | * @param id 76 | * @return 77 | */ 78 | @ControllerEndpoint(exceptionMessage = "删除菜单/按钮失败", operation = "删除菜单/按钮") 79 | @ApiOperation(value = "删除菜单", notes = "根据id删除菜单节点") 80 | @RequiresPermissions({"menu:delete"}) 81 | @DeleteMapping("/delete/{id}") 82 | public ResponseBean delete(@PathVariable Long id) throws SystemException { 83 | menuService.delete(id); 84 | return ResponseBean.success(); 85 | } 86 | 87 | /** 88 | * 菜单详情 89 | * 90 | * @param id 91 | * @return 92 | */ 93 | @ApiOperation(value = "菜单详情", notes = "根据id编辑菜单,获取菜单详情") 94 | @RequiresPermissions({"menu:edit"}) 95 | @GetMapping("/edit/{id}") 96 | public ResponseBean edit(@PathVariable Long id) throws SystemException { 97 | MenuVO menuVO = menuService.edit(id); 98 | return ResponseBean.success(menuVO); 99 | } 100 | 101 | /** 102 | * 更新菜单 103 | * 104 | * @param id 105 | * @param menuVO 106 | * @return 107 | */ 108 | @ControllerEndpoint(exceptionMessage = "更新菜单失败", operation = "更新菜单") 109 | @ApiOperation(value = "更新菜单", notes = "根据id更新菜单节点") 110 | @RequiresPermissions({"menu:update"}) 111 | @PutMapping("/update/{id}") 112 | public ResponseBean update(@PathVariable Long id, @RequestBody @Validated MenuVO menuVO) throws SystemException { 113 | menuService.update(id, menuVO); 114 | return ResponseBean.success(); 115 | } 116 | 117 | /** 118 | * 导出excel 119 | * @param response 120 | */ 121 | @ApiOperation(value = "导出excel", notes = "导出所有菜单的excel表格") 122 | @PostMapping("excel") 123 | @RequiresPermissions("menu:export") 124 | @ControllerEndpoint(exceptionMessage = "导出Excel失败",operation = "导出菜单excel") 125 | public void export(HttpServletResponse response) { 126 | List menus = this.menuService.findAll(); 127 | ExcelKit.$Export(Menu.class, response).downXlsx(menus, false); 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /xinguan-web/src/main/java/com/coderman/controller/system/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.coderman.controller.system; 2 | 3 | 4 | import com.coderman.common.error.SystemException; 5 | import com.coderman.common.model.system.ImageAttachment; 6 | import com.coderman.common.response.ResponseBean; 7 | import com.coderman.common.vo.system.ImageAttachmentVO; 8 | import com.coderman.system.service.UploadService; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiOperation; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.apache.shiro.authz.annotation.RequiresPermissions; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.web.bind.annotation.*; 17 | import org.springframework.web.multipart.MultipartFile; 18 | 19 | import java.io.IOException; 20 | import java.util.List; 21 | 22 | /** 23 | * 文件上传 24 | * @Author zhangyukang 25 | * @Date 2020/3/18 10:29 26 | * @Version 1.0 27 | **/ 28 | @Slf4j 29 | @Api(tags = "系统模块-文件上传相关接口") 30 | @RestController 31 | @RequestMapping("/system/upload") 32 | public class UploadController { 33 | 34 | 35 | 36 | @Autowired 37 | private UploadService uploadService; 38 | 39 | /** 40 | * 上传图片文件 41 | * @param file 42 | * @return 43 | */ 44 | @ApiOperation(value = "上传文件") 45 | @RequiresPermissions({"upload:image"}) 46 | @PostMapping("/image") 47 | public ResponseBean uploadImage(MultipartFile file) throws IOException, SystemException { 48 | String realPath=uploadService.uploadImage(file); 49 | return ResponseBean.success(realPath); 50 | } 51 | 52 | 53 | /** 54 | * 附件列表(图片) 55 | * 56 | * @return 57 | */ 58 | @ApiOperation(value = "附件列表", notes = "模糊查询附件列表") 59 | @GetMapping("/findImageList") 60 | public ResponseBean> findImageList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, 61 | @RequestParam(value = "pageSize", defaultValue = "8") Integer pageSize, 62 | ImageAttachmentVO imageAttachmentVO) { 63 | PageHelper.startPage(pageNum,pageSize); 64 | List imageAttachmentVOList=uploadService.findImageList(imageAttachmentVO); 65 | PageInfo pageInfo = new PageInfo<>(imageAttachmentVOList); 66 | return ResponseBean.success(pageInfo); 67 | } 68 | 69 | /** 70 | * 删除图片 71 | * @param id 72 | * @return 73 | */ 74 | @ApiOperation(value = "删除图片", notes = "删除数据库记录,删除图片服务器上的图片") 75 | @RequiresPermissions("attachment:delete") 76 | @DeleteMapping("/delete/{id}") 77 | public ResponseBean delete(@PathVariable Long id) throws SystemException { 78 | uploadService.delete(id); 79 | return ResponseBean.success(); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/3828034_www.zykhome.club.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zykzhangyukang/Xinguan/4801196cf569f09ed93bb4b6d344351f2225b38e/xinguan-web/src/main/resources/3828034_www.zykhome.club.pfx -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8989 3 | spring: 4 | datasource: 5 | username: root 6 | password: zhangyukang 7 | url: jdbc:mysql://127.0.0.1:3306/xinguan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=CTT 8 | driver-class-name: com.mysql.cj.jdbc.Driver 9 | type: com.alibaba.druid.pool.DruidDataSource 10 | druid: 11 | # 下面为连接池的补充设置,应用到上面所有数据源中 12 | # 初始化大小,最小,最大 13 | initial-size: 5 14 | min-idle: 5 15 | max-active: 20 16 | # 配置获取连接等待超时的时间 17 | max-wait: 60000 18 | stat-view-servlet: 19 | enabled: true 20 | login-username: root 21 | login-password: 123456 22 | allow: 23 | deny: 24 | url-pattern: /druid/* 25 | servlet: 26 | multipart: 27 | enabled: true #是否启用http上传处理 28 | max-request-size: 100MB #最大请求文件的大小 29 | max-file-size: 20MB #设置单个文件最大长度 30 | file-size-threshold: 20MB #当文件达到多少时进行磁盘写入 31 | mybatis: 32 | mapper-locations: classpath:mapper/*/*Mapper.xml 33 | type-aliases-package: com.coderman.common.model 34 | configuration: 35 | map-underscore-to-camel-case: true 36 | fdfs: 37 | resHost: https://www.zykhome.club/ 38 | storagePort: 80 39 | connect-timeout: 1000 40 | so-timeout: 1500 41 | trackerList: 39.99.182.103:22122 42 | thumbImage: 43 | width: 100 44 | height: 100 45 | pool: 46 | max-total: 500 47 | max-wait-millis: 2000 48 | -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8989 3 | ssl: 4 | key-store: classpath:3828034_www.zykhome.club.pfx 5 | key-store-type: PKCS12 6 | key-store-password: stpnsPTW 7 | spring: 8 | datasource: 9 | username: root 10 | password: zhangyukang 11 | url: jdbc:mysql://127.0.0.1:3306/xinguan?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=CTT 12 | driver-class-name: com.mysql.cj.jdbc.Driver 13 | type: com.alibaba.druid.pool.DruidDataSource 14 | druid: 15 | # 下面为连接池的补充设置,应用到上面所有数据源中 16 | # 初始化大小,最小,最大 17 | initial-size: 5 18 | min-idle: 5 19 | max-active: 20 20 | # 配置获取连接等待超时的时间 21 | max-wait: 60000 22 | stat-view-servlet: 23 | enabled: true 24 | login-username: root 25 | login-password: 123456 26 | allow: 27 | deny: 28 | url-pattern: /druid/* 29 | servlet: 30 | multipart: 31 | enabled: true #是否启用http上传处理 32 | max-request-size: 100MB #最大请求文件的大小 33 | max-file-size: 20MB #设置单个文件最大长度 34 | file-size-threshold: 20MB #当文件达到多少时进行磁盘写入 35 | mybatis: 36 | mapper-locations: classpath:mapper/*/*Mapper.xml 37 | type-aliases-package: com.coderman.common.model 38 | configuration: 39 | map-underscore-to-camel-case: true 40 | fdfs: 41 | resHost: https://www.zykhome.club/ 42 | storagePort: 80 43 | connect-timeout: 1000 44 | so-timeout: 1500 45 | trackerList: 39.99.182.103:22122 46 | thumbImage: 47 | width: 100 48 | height: 100 49 | pool: 50 | max-total: 500 51 | max-wait-millis: 2000 52 | -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/mapper/biz/ProductStockMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 26 | 27 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/mapper/system/LoginLogExtMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /xinguan-web/src/main/resources/pfx-password.txt: -------------------------------------------------------------------------------- 1 | stpnsPTW --------------------------------------------------------------------------------