first commit
This commit is contained in:
commit
55d728f09b
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/target/
|
||||
.classpath
|
||||
.project
|
||||
.factorypath
|
||||
.settings
|
||||
*.class
|
||||
.apt_generated
|
||||
.apt_generated_tests
|
||||
.idea
|
||||
*.iml
|
||||
2719
docs/database/All-Bak/xgl_oa_20200915_结构.sql
Normal file
2719
docs/database/All-Bak/xgl_oa_20200915_结构.sql
Normal file
File diff suppressed because it is too large
Load Diff
45
docs/database/oa_update.sql
Normal file
45
docs/database/oa_update.sql
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
-- 0. 注意修改所有关联的表编码统一,不统一的话查询不会走索引
|
||||
|
||||
-- 1. 任务用户关联表添加项目id作为key,提高查询效率
|
||||
alter table project_task_user add key `key_projectid` (`_project_id`);
|
||||
|
||||
-- 2. 查询函数
|
||||
|
||||
-- ----------------------------
|
||||
-- Function structure for `queryUserIdsByDeptId`
|
||||
-- 根据部门ID,递归查询所有子部门ID,返回结果包含当前查询的部门id
|
||||
-- ----------------------------
|
||||
DROP FUNCTION IF EXISTS queryDeptIdsByDeptId;
|
||||
DELIMITER ;;
|
||||
CREATE FUNCTION queryDeptIdsByDeptId(deptId VARCHAR(50))
|
||||
RETURNS VARCHAR(500)
|
||||
BEGIN
|
||||
DECLARE sTemp VARCHAR(500);
|
||||
DECLARE sTempChd VARCHAR(200);
|
||||
|
||||
SET sTemp='';
|
||||
SET sTempChd = deptId;
|
||||
|
||||
WHILE sTempChd IS NOT NULL DO
|
||||
IF sTemp='' THEN SET sTemp = sTempChd;
|
||||
ELSE SET sTemp = CONCAT(sTemp,',',sTempChd);
|
||||
END IF;
|
||||
|
||||
SELECT GROUP_CONCAT(Id) INTO sTempChd FROM qywx_party WHERE FIND_IN_SET(ParentId, sTempChd)>0;
|
||||
END WHILE;
|
||||
RETURN sTemp;
|
||||
END
|
||||
;;
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
194
docs/database/shiro.sql
Normal file
194
docs/database/shiro.sql
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : local
|
||||
Source Server Version : 50624
|
||||
Source Host : localhost:3306
|
||||
Source Database : zb-shiro
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50624
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2018-09-18 11:40:47
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `permission`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `permission`;
|
||||
CREATE TABLE `permission` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`permission_id` varchar(20) NOT NULL COMMENT '权限id',
|
||||
`name` varchar(100) NOT NULL COMMENT '权限名称',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '权限描述',
|
||||
`url` varchar(255) DEFAULT NULL COMMENT '权限访问路径',
|
||||
`perms` varchar(255) DEFAULT NULL COMMENT '权限标识',
|
||||
`parent_id` int(11) DEFAULT NULL COMMENT '父级权限id',
|
||||
`type` int(1) DEFAULT NULL COMMENT '类型 0:目录 1:菜单 2:按钮',
|
||||
`order_num` int(3) DEFAULT '0' COMMENT '排序',
|
||||
`icon` varchar(50) DEFAULT NULL COMMENT '图标',
|
||||
`status` int(1) NOT NULL COMMENT '状态:1有效;2删除',
|
||||
`create_time` datetime DEFAULT NULL,
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of permission
|
||||
-- ----------------------------
|
||||
INSERT INTO `permission` VALUES ('1', '1', '工作台', '工作台', '/workdest', 'workdest', '0', '1', '1', 'fa fa-home', '1', '2017-09-27 21:22:02', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('2', '2', '权限管理', '权限管理', '', null, '0', '0', '2', 'fa fa-th-list', '1', '2017-07-13 15:04:42', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('3', '201', '用户管理', '用户管理', '/users', 'users', '2', '1', '1', 'fa fa-circle-o', '1', '2017-07-13 15:05:47', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('4', '20101', '列表查询', '用户列表查询', '/user/list', 'user:list', '3', '2', '0', null, '1', '2017-07-13 15:09:24', '2017-10-09 05:38:29');
|
||||
INSERT INTO `permission` VALUES ('5', '20102', '新增', '新增用户', '/user/add', 'user:add', '3', '2', '0', null, '1', '2017-07-13 15:06:50', '2018-02-28 17:58:46');
|
||||
INSERT INTO `permission` VALUES ('6', '20103', '编辑', '编辑用户', '/user/edit', 'user:edit', '3', '2', '0', null, '1', '2017-07-13 15:08:03', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('7', '20104', '删除', '删除用户', '/user/delete', 'user:delete', '3', '2', '0', null, '1', '2017-07-13 15:08:42', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('8', '20105', '批量删除', '批量删除用户', '/user/batch/delete', 'user:batchDelete', '3', '2', '0', '', '1', '2018-07-11 01:53:09', '2018-07-11 01:53:09');
|
||||
INSERT INTO `permission` VALUES ('9', '20106', '分配角色', '分配角色', '/user/assign/role', 'user:assignRole', '3', '2', '0', null, '1', '2017-07-13 15:09:24', '2017-10-09 05:38:29');
|
||||
INSERT INTO `permission` VALUES ('10', '202', '角色管理', '角色管理', '/roles', 'roles', '2', '1', '2', 'fa fa-circle-o', '1', '2017-07-17 14:39:09', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('11', '20201', '列表查询', '角色列表查询', '/role/list', 'role:list', '10', '2', '0', null, '1', '2017-10-10 15:31:36', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('12', '20202', '新增', '新增角色', '/role/add', 'role:add', '10', '2', '0', null, '1', '2017-07-17 14:39:46', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('13', '20203', '编辑', '编辑角色', '/role/edit', 'role:edit', '10', '2', '0', null, '1', '2017-07-17 14:40:15', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('14', '20204', '删除', '删除角色', '/role/delete', 'role:delete', '10', '2', '0', null, '1', '2017-07-17 14:40:57', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('15', '20205', '批量删除', '批量删除角色', '/role/batch/delete', 'role:batchDelete', '10', '2', '0', '', '1', '2018-07-10 22:20:43', '2018-07-10 22:20:43');
|
||||
INSERT INTO `permission` VALUES ('16', '20206', '分配权限', '分配权限', '/role/assign/permission', 'role:assignPerms', '10', '2', '0', null, '1', '2017-09-26 07:33:05', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('17', '203', '资源管理', '资源管理', '/permissions', 'permissions', '2', '1', '3', 'fa fa-circle-o', '1', '2017-09-26 07:33:51', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('18', '20301', '列表查询', '资源列表', '/permission/list', 'permission:list', '17', '2', '0', null, '1', '2018-07-12 16:25:28', '2018-07-12 16:25:33');
|
||||
INSERT INTO `permission` VALUES ('19', '20302', '新增', '新增资源', '/permission/add', 'permission:add', '17', '2', '0', null, '1', '2017-09-26 08:06:58', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('20', '20303', '编辑', '编辑资源', '/permission/edit', 'permission:edit', '17', '2', '0', null, '1', '2017-09-27 21:29:04', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('21', '20304', '删除', '删除资源', '/permission/delete', 'permission:delete', '17', '2', '0', null, '1', '2017-09-27 21:29:50', '2018-02-27 10:53:14');
|
||||
INSERT INTO `permission` VALUES ('22', '3', '运维管理', '运维管理', '', null, '0', '0', '3', 'fa fa-th-list', '1', '2018-07-06 15:19:26', '2018-07-06 15:19:26');
|
||||
INSERT INTO `permission` VALUES ('23', '301', '数据监控', '数据监控', '/database/monitoring', 'database', '22', '1', '1', 'fa fa-circle-o', '1', '2018-07-06 15:19:55', '2018-09-12 13:14:48');
|
||||
INSERT INTO `permission` VALUES ('24', '4', '系统工具', '系统工具', '', null, '0', '0', '4', 'fa fa-th-list', '1', '2018-07-06 15:20:38', '2018-07-06 15:20:38');
|
||||
INSERT INTO `permission` VALUES ('25', '401', '图标工具', '图标工具', '/icons', 'icons', '24', '1', '1', 'fa fa-circle-o', '1', '2018-07-06 15:21:00', '2018-07-06 15:21:00');
|
||||
INSERT INTO `permission` VALUES ('28', '1000000884924014', '在线用户', '在线用户', '/online/users', 'onlineUsers', '2', '1', '4', 'fa fa-circle-o', '1', '2018-07-18 21:00:38', '2018-07-19 12:47:42');
|
||||
INSERT INTO `permission` VALUES ('29', '1000000433323073', '在线用户查询', '在线用户查询', '/online/user/list', 'onlineUser:list', '28', '2', '0', null, '1', '2018-07-18 21:01:25', '2018-07-19 12:48:04');
|
||||
INSERT INTO `permission` VALUES ('30', '1000000903407910', '踢出用户', '踢出用户', '/online/user/kickout', 'onlineUser:kickout', '28', '2', '0', null, '1', '2018-07-18 21:41:54', '2018-07-19 12:48:25');
|
||||
INSERT INTO `permission` VALUES ('31', '1000000851815490', '批量踢出', '批量踢出', '/online/user/batch/kickout', 'onlineUser:batchKickout', '28', '2', '0', '', '1', '2018-07-19 12:49:30', '2018-07-19 12:49:30');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `role`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `role`;
|
||||
CREATE TABLE `role` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`role_id` varchar(20) NOT NULL COMMENT '角色id',
|
||||
`name` varchar(50) NOT NULL COMMENT '角色名称',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '角色描述',
|
||||
`status` int(1) NOT NULL COMMENT '状态:1有效;2删除',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of role
|
||||
-- ----------------------------
|
||||
INSERT INTO `role` VALUES ('1', '1', '超级管理员', '超级管理员', '1', '2017-06-28 20:30:05', '2017-06-28 20:30:10');
|
||||
INSERT INTO `role` VALUES ('2', '2', '管理员', '管理员', '1', '2017-06-30 23:35:19', '2017-10-11 09:32:33');
|
||||
INSERT INTO `role` VALUES ('3', '3', '普通用户', '普通用户', '1', '2017-06-30 23:35:44', '2018-07-13 11:44:06');
|
||||
INSERT INTO `role` VALUES ('4', '4', '数据库管理员', '数据库管理员', '1', '2017-07-12 11:50:22', '2017-10-09 17:38:02');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `role_permission`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `role_permission`;
|
||||
CREATE TABLE `role_permission` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`role_id` varchar(20) NOT NULL COMMENT '角色id',
|
||||
`permission_id` varchar(20) NOT NULL COMMENT '权限id',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=892 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of role_permission
|
||||
-- ----------------------------
|
||||
INSERT INTO `role_permission` VALUES ('840', '1', '1');
|
||||
INSERT INTO `role_permission` VALUES ('841', '1', '2');
|
||||
INSERT INTO `role_permission` VALUES ('842', '1', '201');
|
||||
INSERT INTO `role_permission` VALUES ('843', '1', '20101');
|
||||
INSERT INTO `role_permission` VALUES ('844', '1', '20102');
|
||||
INSERT INTO `role_permission` VALUES ('845', '1', '20103');
|
||||
INSERT INTO `role_permission` VALUES ('846', '1', '20104');
|
||||
INSERT INTO `role_permission` VALUES ('847', '1', '20105');
|
||||
INSERT INTO `role_permission` VALUES ('848', '1', '20106');
|
||||
INSERT INTO `role_permission` VALUES ('849', '1', '202');
|
||||
INSERT INTO `role_permission` VALUES ('850', '1', '20201');
|
||||
INSERT INTO `role_permission` VALUES ('851', '1', '20202');
|
||||
INSERT INTO `role_permission` VALUES ('852', '1', '20203');
|
||||
INSERT INTO `role_permission` VALUES ('853', '1', '20204');
|
||||
INSERT INTO `role_permission` VALUES ('854', '1', '20205');
|
||||
INSERT INTO `role_permission` VALUES ('855', '1', '20206');
|
||||
INSERT INTO `role_permission` VALUES ('856', '1', '203');
|
||||
INSERT INTO `role_permission` VALUES ('857', '1', '20301');
|
||||
INSERT INTO `role_permission` VALUES ('858', '1', '20302');
|
||||
INSERT INTO `role_permission` VALUES ('859', '1', '20303');
|
||||
INSERT INTO `role_permission` VALUES ('860', '1', '20304');
|
||||
INSERT INTO `role_permission` VALUES ('861', '1', '1000000884924014');
|
||||
INSERT INTO `role_permission` VALUES ('862', '1', '1000000433323073');
|
||||
INSERT INTO `role_permission` VALUES ('863', '1', '1000000903407910');
|
||||
INSERT INTO `role_permission` VALUES ('864', '1', '1000000851815490');
|
||||
INSERT INTO `role_permission` VALUES ('865', '1', '3');
|
||||
INSERT INTO `role_permission` VALUES ('866', '1', '301');
|
||||
INSERT INTO `role_permission` VALUES ('867', '1', '4');
|
||||
INSERT INTO `role_permission` VALUES ('868', '1', '401');
|
||||
INSERT INTO `role_permission` VALUES ('877', '3', '2');
|
||||
INSERT INTO `role_permission` VALUES ('878', '3', '201');
|
||||
INSERT INTO `role_permission` VALUES ('879', '3', '20101');
|
||||
INSERT INTO `role_permission` VALUES ('880', '3', '20102');
|
||||
INSERT INTO `role_permission` VALUES ('881', '3', '20103');
|
||||
INSERT INTO `role_permission` VALUES ('882', '3', '20104');
|
||||
INSERT INTO `role_permission` VALUES ('883', '3', '20105');
|
||||
INSERT INTO `role_permission` VALUES ('884', '3', '20106');
|
||||
INSERT INTO `role_permission` VALUES ('885', '3', '202');
|
||||
INSERT INTO `role_permission` VALUES ('886', '3', '20201');
|
||||
INSERT INTO `role_permission` VALUES ('887', '3', '20202');
|
||||
INSERT INTO `role_permission` VALUES ('888', '3', '20203');
|
||||
INSERT INTO `role_permission` VALUES ('889', '3', '20204');
|
||||
INSERT INTO `role_permission` VALUES ('890', '3', '20205');
|
||||
INSERT INTO `role_permission` VALUES ('891', '3', '20206');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `user`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user`;
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` varchar(20) NOT NULL COMMENT '用户id',
|
||||
`username` varchar(50) NOT NULL COMMENT '用户名',
|
||||
`password` varchar(50) NOT NULL,
|
||||
`salt` varchar(128) DEFAULT NULL COMMENT '加密盐值',
|
||||
`email` varchar(50) DEFAULT NULL COMMENT '邮箱',
|
||||
`phone` varchar(50) DEFAULT NULL COMMENT '联系方式',
|
||||
`sex` int(255) DEFAULT NULL COMMENT '年龄:1男2女',
|
||||
`age` int(3) DEFAULT NULL COMMENT '年龄',
|
||||
`status` int(1) NOT NULL COMMENT '用户状态:1有效; 2删除',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
|
||||
PRIMARY KEY (`id`,`user_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user
|
||||
-- ----------------------------
|
||||
INSERT INTO `user` VALUES ('1', '1', 'admin', '872359cc44c637cc73b7cd55c06d95e4', '8cd50474d2a3c1e88298e91df8bf6f1c', '523179414@qq.com', '187888899991', '1', '22', '1', '2018-05-23 21:22:06', '2018-07-17 23:04:46', '2018-09-12 13:13:31');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `user_role`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user_role`;
|
||||
CREATE TABLE `user_role` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` varchar(20) NOT NULL COMMENT '用户id',
|
||||
`role_id` varchar(20) NOT NULL COMMENT '角色id',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user_role
|
||||
-- ----------------------------
|
||||
INSERT INTO `user_role` VALUES ('1', '1', '1');
|
||||
264
pom.xml
Normal file
264
pom.xml
Normal file
@ -0,0 +1,264 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.nbclass</groupId>
|
||||
<artifactId>worktile</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>worktile</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.9.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<mapper.starter.version>2.1.5</mapper.starter.version>
|
||||
<pagehelper.starter.version>1.3.0</pagehelper.starter.version>
|
||||
<poi.version>3.12</poi.version>
|
||||
<mysql.version>8.0.23</mysql.version>
|
||||
<druid.springboot.version>1.2.5</druid.springboot.version>
|
||||
<fastjson.version>1.2.75</fastjson.version>
|
||||
<ognl.version>3.2.19</ognl.version>
|
||||
<commons-fileupload.version>1.4</commons-fileupload.version>
|
||||
<shiro-redis.version>3.3.1</shiro-redis.version>
|
||||
<shiro-spring.version>1.7.1</shiro-spring.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- jsp解析依赖,不加这个访问jsp直接变成下载 -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jsp-api</artifactId>
|
||||
</dependency>
|
||||
<!-- jsp解析依赖 end -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion><!-- 去掉springboot默认的logback, 使用log4j2 -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 引入log4j2依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Druid Spring Boot Starter -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.springboot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--mapper-->
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||
<version>${mapper.starter.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- 这个persistence-api-1.0.jar与Spring Data JPA引入的javax.persistence-api-2.2.jar有冲突 -->
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--pagehelper-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>${pagehelper.starter.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>${shiro-spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.theborakompanioni</groupId>
|
||||
<artifactId>thymeleaf-extras-shiro</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.crazycake</groupId>
|
||||
<artifactId>shiro-redis</artifactId>
|
||||
<version>${shiro-redis.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ognl</groupId>
|
||||
<artifactId>ognl</artifactId>
|
||||
<version>${ognl.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 测试用, 配置devtools实现热部署 -->
|
||||
<!--
|
||||
会导致ClassCastException异常
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
<scope>true</scope>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>worktile</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
<version>1.3.7</version>
|
||||
<configuration>
|
||||
<configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile>
|
||||
<overwrite>true</overwrite>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-generator</artifactId>
|
||||
<version>1.1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
39
src/main/java/com/nbclass/SpringbootApplication.java
Normal file
39
src/main/java/com/nbclass/SpringbootApplication.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.nbclass;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
import com.nbclass.config.MyLocaleResolver;
|
||||
|
||||
import tk.mybatis.spring.annotation.MapperScan;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午7:21:36
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@MapperScan(basePackages = "com.nbclass.**.mapper")
|
||||
public class SpringbootApplication extends SpringBootServletInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringbootApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(SpringbootApplication.class);
|
||||
}
|
||||
|
||||
//注册国际化组件
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
return new MyLocaleResolver();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
26
src/main/java/com/nbclass/component/MyErrorAttributes.java
Normal file
26
src/main/java/com/nbclass/component/MyErrorAttributes.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.nbclass.component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Component
|
||||
public class MyErrorAttributes extends DefaultErrorAttributes{
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
|
||||
Map<String,Object> map = super.getErrorAttributes(webRequest, includeStackTrace);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,Object> ext = (Map<String,Object>)webRequest.getAttribute("ext", 0);
|
||||
map.put("ext",ext);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/com/nbclass/config/CorsConfig.java
Normal file
32
src/main/java/com/nbclass/config/CorsConfig.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.nbclass.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 跨域请求配置
|
||||
* @author Leon
|
||||
* @datetime 2019年4月3日 下午4:45:49
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry
|
||||
// .addMapping("/api/**") // 允许跨域请求的地址
|
||||
.addMapping("/mobile/api/**") // 允许跨域请求的地址
|
||||
.allowedOrigins("*") // 允许任何域请求
|
||||
.allowedMethods("*") // 允许任何方法(post、get等)
|
||||
.allowedHeaders("*") // 允许任何头
|
||||
.allowCredentials(true)
|
||||
;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
23
src/main/java/com/nbclass/config/DefaultViewConfig.java
Normal file
23
src/main/java/com/nbclass/config/DefaultViewConfig.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.nbclass.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 默认首页
|
||||
* @author Leon
|
||||
* @datetime 2019年4月11日 下午5:14:24
|
||||
*/
|
||||
@Configuration
|
||||
public class DefaultViewConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/").setViewName("forward:/index.html");
|
||||
registry.setOrder(Ordered.HIGHEST_PRECEDENCE); // 设置为最高级,哪怕其他controller里有映射(也就是 /)那么根据优先级,也会先加载这个配置
|
||||
WebMvcConfigurer.super.addViewControllers(registry);
|
||||
}
|
||||
|
||||
}
|
||||
37
src/main/java/com/nbclass/config/DruidConfig.java
Normal file
37
src/main/java/com/nbclass/config/DruidConfig.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.nbclass.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年3月30日 下午9:57:31
|
||||
*/
|
||||
@Configuration
|
||||
public class DruidConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public DataSource druid(){
|
||||
return new DruidDataSource();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Bean
|
||||
public ServletRegistrationBean druidServlet() {
|
||||
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
|
||||
//登录查看信息的账号密码.
|
||||
servletRegistrationBean.addInitParameter("loginUsername","admin");
|
||||
servletRegistrationBean.addInitParameter("loginPassword","123456");
|
||||
return servletRegistrationBean;
|
||||
}
|
||||
|
||||
}
|
||||
35
src/main/java/com/nbclass/config/KaptchaConfig.java
Normal file
35
src/main/java/com/nbclass/config/KaptchaConfig.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.nbclass.config;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
|
||||
/**
|
||||
* kaptcha验证码参数配置
|
||||
* @author Leon
|
||||
* @datetime 2019年4月17日 上午10:23:09
|
||||
*/
|
||||
@Component
|
||||
public class KaptchaConfig {
|
||||
@Bean
|
||||
public DefaultKaptcha getDefaultKaptcha(){
|
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("kaptcha.border", "no"); // 图片边框,合法值:yes , no
|
||||
properties.setProperty("kaptcha.border.color", "105,179,90"); // 边框颜色,合法值: r,g,b (and optional alpha) 或者 white,black,blue.
|
||||
properties.setProperty("kaptcha.textproducer.font.color", "black"); // 字体颜色,合法值: r,g,b 或者 white,black,blue.
|
||||
properties.setProperty("kaptcha.image.width", "125"); // 图片宽
|
||||
properties.setProperty("kaptcha.image.height", "45"); // 图片高
|
||||
properties.setProperty("kaptcha.textproducer.font.size", "35"); // 字体大小
|
||||
properties.setProperty("kaptcha.textproducer.char.length", "4"); // 验证码长度
|
||||
properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑"); // 字体
|
||||
properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise"); // 去除干扰线
|
||||
Config config = new Config(properties);
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
}
|
||||
44
src/main/java/com/nbclass/config/MyLocaleResolver.java
Normal file
44
src/main/java/com/nbclass/config/MyLocaleResolver.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.nbclass.config;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
import com.nbclass.szxgl.constant.ActivityConstants;
|
||||
import com.nbclass.util.WebUtils;
|
||||
|
||||
/**
|
||||
* 语言国际化
|
||||
* @author Leon
|
||||
* @datetime 2019年4月1日 下午4:00:51
|
||||
*/
|
||||
public class MyLocaleResolver implements LocaleResolver {
|
||||
|
||||
@Override
|
||||
public Locale resolveLocale(HttpServletRequest request) {
|
||||
// String lang = request.getParameter("lang");
|
||||
String lang = StringUtils.trimToEmpty(WebUtils.getValueFromCookie(request, ActivityConstants.cookie_key_customer_lang)).toLowerCase();
|
||||
if("en".equals(lang)){ //前端存值: zh/en
|
||||
lang = "en_US";
|
||||
}else{
|
||||
lang = "zh_CN";
|
||||
}
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
if(StringUtils.isNotBlank(lang)){
|
||||
String[] split = lang.split("_");
|
||||
locale = new Locale(split[0], split[1]);
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
48
src/main/java/com/nbclass/config/RedisConfig.java
Normal file
48
src/main/java/com/nbclass/config/RedisConfig.java
Normal file
@ -0,0 +1,48 @@
|
||||
package com.nbclass.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Value("${spring.redis.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.redis.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.redis.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${spring.redis.timeout}")
|
||||
private int timeout;
|
||||
|
||||
@Value("${spring.redis.lettuce.pool.max-idle}")
|
||||
private int maxIdle;
|
||||
|
||||
@Value("${spring.redis.lettuce.pool.max-wait}")
|
||||
private long maxWaitMillis;
|
||||
|
||||
@Bean
|
||||
public JedisPool redisPoolFactory() {
|
||||
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||
jedisPoolConfig.setMaxIdle(maxIdle);
|
||||
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
|
||||
JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout,password);
|
||||
return jedisPool;
|
||||
}
|
||||
|
||||
}
|
||||
33
src/main/java/com/nbclass/enums/ResponseStatus.java
Normal file
33
src/main/java/com/nbclass/enums/ResponseStatus.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.nbclass.enums;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月13日
|
||||
* @author superzheng
|
||||
*/
|
||||
public enum ResponseStatus {
|
||||
|
||||
/**
|
||||
* 返回状态
|
||||
*/
|
||||
SUCCESS(200, "操作成功!"),
|
||||
FORBIDDEN(403, "您没有权限访问!"),
|
||||
NOT_FOUND(404, "资源不存在!"),
|
||||
ERROR(500, "服务器内部错误!");
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
|
||||
ResponseStatus(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.nbclass.exception;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nbclass.util.CoreConst;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* 实现spring注解进行异常统一处理
|
||||
* @author Leon
|
||||
* @datetime 2019年3月5日 下午6:08:54
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class CommonExceptionAdvice {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CommonExceptionAdvice.class);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ExceptionHandler(Exception.class)
|
||||
//@ResponseBody
|
||||
public void defaultErrorHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) {
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
try {
|
||||
logger.info("RequestURL = "+request.getRequestURL());
|
||||
String error = exception.getMessage();
|
||||
if(exception instanceof ParameterException || exception instanceof ServiceException || exception instanceof LogicalException){
|
||||
logger.info(exception.toString());
|
||||
}else if(exception instanceof NullPointerException){
|
||||
error = "网络异常,请稍候再试~";
|
||||
}else{
|
||||
if(StringUtils.isBlank(error))error="网络异常,请稍候再试!";
|
||||
logger.error("系统异常: ", exception);
|
||||
}
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put(CoreConst.STATUS, CoreConst.STATUS_ERROR);
|
||||
json.put(CoreConst.MSG, error);
|
||||
out.print(json.toString());
|
||||
|
||||
/*
|
||||
if(StringUtils.isBlank(error)){
|
||||
response.setHeader("Content-Type", "text/html;charset=UTF-8");
|
||||
out.print("<div style=\"width:100%;margin-top:20px;text-align:center;\">Sorry, System error !</div>");
|
||||
}else{
|
||||
JSONObject json = new JSONObject();
|
||||
json.put(CoreConst.STATUS, CoreConst.STATUS_ERROR);
|
||||
json.put(CoreConst.MSG, error);
|
||||
out.print(json.toString());
|
||||
}
|
||||
*/
|
||||
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("统一处理异常错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public String handleAuth(HttpServletRequest request) {
|
||||
request.setAttribute("javax.servlet.error.status_code",com.nbclass.enums.ResponseStatus.FORBIDDEN.getCode());
|
||||
return "forward:/error";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
26
src/main/java/com/nbclass/exception/DataBaseException.java
Normal file
26
src/main/java/com/nbclass/exception/DataBaseException.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.nbclass.exception;
|
||||
|
||||
/**
|
||||
* 数据库异常类
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午11:17:35
|
||||
*/
|
||||
public class DataBaseException extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = -7912461660403185962L;
|
||||
|
||||
public DataBaseException(){
|
||||
}
|
||||
|
||||
public DataBaseException(String message, Throwable cause){
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DataBaseException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DataBaseException(Throwable cause){
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
26
src/main/java/com/nbclass/exception/LogicalException.java
Normal file
26
src/main/java/com/nbclass/exception/LogicalException.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.nbclass.exception;
|
||||
|
||||
/**
|
||||
* 业务逻辑异常类
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午11:16:56
|
||||
*/
|
||||
public class LogicalException extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = 2494732724125452953L;
|
||||
|
||||
public LogicalException(){
|
||||
}
|
||||
|
||||
public LogicalException(String message, Throwable cause){
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public LogicalException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public LogicalException(Throwable cause){
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
38
src/main/java/com/nbclass/exception/MyRuntimeException.java
Normal file
38
src/main/java/com/nbclass/exception/MyRuntimeException.java
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @Project: jxoa
|
||||
* @Title: MyException.java
|
||||
* @Package com.oa.commons.exception
|
||||
* @date 2013-6-30 下午5:43:15
|
||||
* @Copyright: 2013
|
||||
*/
|
||||
package com.nbclass.exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* 类名:MyException
|
||||
* 功能:自定义异常
|
||||
* 详细:
|
||||
* 作者:LiuJincheng
|
||||
* 版本:1.0
|
||||
* 日期:2013-6-30 下午5:43:15
|
||||
*
|
||||
*/
|
||||
public class MyRuntimeException extends RuntimeException{
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID :
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
*
|
||||
* 创建一个新的实例 MyException.
|
||||
*
|
||||
* @param message 异常信息
|
||||
*/
|
||||
public MyRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
26
src/main/java/com/nbclass/exception/ParameterException.java
Normal file
26
src/main/java/com/nbclass/exception/ParameterException.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.nbclass.exception;
|
||||
|
||||
/**
|
||||
* 参数错误异常类
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午11:01:35
|
||||
*/
|
||||
public class ParameterException extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = 7936887727544416780L;
|
||||
|
||||
public ParameterException(){
|
||||
}
|
||||
|
||||
public ParameterException(String message, Throwable cause){
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ParameterException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ParameterException(Throwable cause){
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
26
src/main/java/com/nbclass/exception/ServiceException.java
Normal file
26
src/main/java/com/nbclass/exception/ServiceException.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.nbclass.exception;
|
||||
|
||||
/**
|
||||
* 服务异常类
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午11:16:09
|
||||
*/
|
||||
public class ServiceException extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = 3794850430751334041L;
|
||||
|
||||
public ServiceException(){
|
||||
}
|
||||
|
||||
public ServiceException(String message, Throwable cause){
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ServiceException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ServiceException(Throwable cause){
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
68
src/main/java/com/nbclass/holder/SpringContextHolder.java
Normal file
68
src/main/java/com/nbclass/holder/SpringContextHolder.java
Normal file
@ -0,0 +1,68 @@
|
||||
package com.nbclass.holder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SpringContextHolder implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext appContext = null;
|
||||
|
||||
/**
|
||||
* 通过name获取 Bean.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static Object getBean(String name) {
|
||||
return appContext.getBean(name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过class获取Bean.
|
||||
*
|
||||
* @param clazz
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return appContext.getBean(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name,以及Clazz返回指定的Bean
|
||||
*
|
||||
* @param name
|
||||
* @param clazz
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T getBean(String name, Class<T> clazz) {
|
||||
return appContext.getBean(name, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (appContext == null) {
|
||||
appContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取spring.profiles.active
|
||||
public static String getActiveProfile() {
|
||||
return appContext.getEnvironment().getActiveProfiles()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是生产环境
|
||||
* @return true 或 false
|
||||
*/
|
||||
public static boolean isProd() {
|
||||
return "prod".equalsIgnoreCase(StringUtils.trimToEmpty(getActiveProfile()));
|
||||
}
|
||||
|
||||
}
|
||||
179
src/main/java/com/nbclass/shiro/MyShiroRealm.java
Normal file
179
src/main/java/com/nbclass/shiro/MyShiroRealm.java
Normal file
@ -0,0 +1,179 @@
|
||||
package com.nbclass.shiro;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
||||
import org.apache.shiro.authc.UnknownAccountException;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
import org.apache.shiro.mgt.RealmSecurityManager;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||
import org.apache.shiro.util.ByteSource;
|
||||
import org.crazycake.shiro.RedisSessionDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.system.service.PermissionService;
|
||||
import com.nbclass.system.service.RoleService;
|
||||
import com.nbclass.szxgl.model.SyUsers;
|
||||
import com.nbclass.szxgl.service.SyUsersService;
|
||||
import com.nbclass.util.CommonUtils;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public class MyShiroRealm extends AuthorizingRealm {
|
||||
|
||||
@Autowired
|
||||
private SyUsersService userService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
@Autowired
|
||||
private RedisSessionDAO redisSessionDAO;
|
||||
|
||||
//授权
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
|
||||
if(principals == null){
|
||||
throw new AuthorizationException("principals should not be null");
|
||||
}
|
||||
User user = (User) principals.getPrimaryPrincipal();
|
||||
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
|
||||
info.setRoles(roleService.findRoleByUserId(user.getUserId()));
|
||||
info.setStringPermissions(permissionService.findPermsByUserId(user.getUserId()));
|
||||
return info;
|
||||
}
|
||||
|
||||
/*
|
||||
//认证
|
||||
@Override
|
||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
|
||||
//获取用户的输入的账号.
|
||||
String username = (String)token.getPrincipal();
|
||||
User user = userService.selectByUsername(username);
|
||||
if(user==null) {
|
||||
throw new UnknownAccountException();
|
||||
}
|
||||
if (CoreConst.STATUS_INVALID.equals(user.getStatus())) {
|
||||
// 帐号锁定
|
||||
throw new LockedAccountException();
|
||||
}
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
// 把ip放入user存入redis缓存里
|
||||
user.setLoginIpAddress(CommonUtils.getIpAddr(request));
|
||||
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
|
||||
user,
|
||||
user.getPassword(),
|
||||
ByteSource.Util.bytes(user.getCredentialsSalt()),
|
||||
getName()
|
||||
);
|
||||
return authenticationInfo;
|
||||
}
|
||||
*/
|
||||
|
||||
//认证
|
||||
@Override
|
||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
|
||||
//获取用户的输入的账号.
|
||||
String username = (String)token.getPrincipal();
|
||||
SyUsers syUsers = userService.selectByUsername(username);
|
||||
if(syUsers==null) {
|
||||
throw new UnknownAccountException();
|
||||
}
|
||||
User user = new User();
|
||||
user.setUserId(syUsers.getUserName());
|
||||
user.setUsername(syUsers.getUserName());
|
||||
user.setPassword(syUsers.getUserPassword());
|
||||
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
// 把ip放入user存入redis缓存里
|
||||
user.setLoginIpAddress(CommonUtils.getIpAddr(request));
|
||||
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
|
||||
user,
|
||||
user.getPassword(),
|
||||
ByteSource.Util.bytes(user.getCredentialsSalt()),
|
||||
getName()
|
||||
);
|
||||
return authenticationInfo;
|
||||
}
|
||||
|
||||
/**清除认证信息*/
|
||||
public void removeCachedAuthenticationInfo(List<String> userIds) {
|
||||
if(null == userIds || userIds.size() == 0) {
|
||||
return ;
|
||||
}
|
||||
List<SimplePrincipalCollection> list = getSpcListByUserIds(userIds);
|
||||
RealmSecurityManager securityManager =
|
||||
(RealmSecurityManager) SecurityUtils.getSecurityManager();
|
||||
MyShiroRealm realm = (MyShiroRealm)securityManager.getRealms().iterator().next();
|
||||
for (SimplePrincipalCollection simplePrincipalCollection : list) {
|
||||
realm.clearCachedAuthenticationInfo(simplePrincipalCollection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据userId 清除当前session存在的用户的权限缓存
|
||||
* @param userIds 已经修改了权限的userId
|
||||
*/
|
||||
public void clearAuthorizationByUserId(List<String> userIds){
|
||||
if(null == userIds || userIds.size() == 0) {
|
||||
return ;
|
||||
}
|
||||
List<SimplePrincipalCollection> list = getSpcListByUserIds(userIds);
|
||||
RealmSecurityManager securityManager =
|
||||
(RealmSecurityManager) SecurityUtils.getSecurityManager();
|
||||
MyShiroRealm realm = (MyShiroRealm)securityManager.getRealms().iterator().next();
|
||||
for (SimplePrincipalCollection simplePrincipalCollection : list) {
|
||||
realm.clearCachedAuthorizationInfo(simplePrincipalCollection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取所有spc
|
||||
* @param userIds 已经修改了权限的userId
|
||||
*/
|
||||
private List<SimplePrincipalCollection> getSpcListByUserIds(List<String> userIds){
|
||||
//获取所有session
|
||||
Collection<Session> sessions = redisSessionDAO.getActiveSessions();
|
||||
//定义返回
|
||||
List<SimplePrincipalCollection> list = new ArrayList<SimplePrincipalCollection>();
|
||||
for (Session session:sessions){
|
||||
//获取session登录信息。
|
||||
Object obj = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
if(null != obj && obj instanceof SimplePrincipalCollection){
|
||||
//强转
|
||||
SimplePrincipalCollection spc = (SimplePrincipalCollection)obj;
|
||||
//判断用户,匹配用户ID。
|
||||
obj = spc.getPrimaryPrincipal();
|
||||
if(null != obj && obj instanceof User){
|
||||
User user = (User) obj;
|
||||
System.out.println("user:"+user);
|
||||
//比较用户ID,符合即加入集合
|
||||
if(null != user && userIds.contains(user.getUserId())){
|
||||
list.add(spc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/nbclass/shiro/PermsService.java
Normal file
19
src/main/java/com/nbclass/shiro/PermsService.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.nbclass.shiro;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* js调用 thymeleaf 实现按钮权限
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Component("perms")
|
||||
public class PermsService
|
||||
{
|
||||
public boolean hasPerm(String permission)
|
||||
{
|
||||
return SecurityUtils.getSubject().isPermitted(permission);
|
||||
}
|
||||
}
|
||||
119
src/main/java/com/nbclass/shiro/ShiroService.java
Normal file
119
src/main/java/com/nbclass/shiro/ShiroService.java
Normal file
@ -0,0 +1,119 @@
|
||||
package com.nbclass.shiro;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager;
|
||||
import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;
|
||||
import org.apache.shiro.web.servlet.AbstractShiroFilter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nbclass.holder.SpringContextHolder;
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.service.PermissionService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年4月1日 下午2:47:53
|
||||
*/
|
||||
@Service
|
||||
public class ShiroService {
|
||||
|
||||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 初始化加载权限
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> loadFilterChainDefinitions() {
|
||||
// 权限控制map.从数据库获取
|
||||
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
|
||||
|
||||
filterChainDefinitionMap.put("/register", "anon");
|
||||
filterChainDefinitionMap.put("/login", "anon");
|
||||
filterChainDefinitionMap.put("/error/**", "anon");
|
||||
filterChainDefinitionMap.put("/kickout", "anon");
|
||||
/*filterChainDefinitionMap.put("/logout", "logout");*/
|
||||
filterChainDefinitionMap.put("/css/**","anon");
|
||||
filterChainDefinitionMap.put("/js/**","anon");
|
||||
filterChainDefinitionMap.put("/img/**","anon");
|
||||
filterChainDefinitionMap.put("/libs/**","anon");
|
||||
filterChainDefinitionMap.put("/favicon.ico", "anon");
|
||||
filterChainDefinitionMap.put("/verificationCode", "anon");
|
||||
|
||||
filterChainDefinitionMap.put("/api/**" ,"anon"); // 前端接口
|
||||
filterChainDefinitionMap.put("/", "anon"); // 网站首页
|
||||
// 静态资源按后缀排除
|
||||
filterChainDefinitionMap.put("/**/*.css", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.js", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.jpg", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.png", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.gif", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.webp", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.ttf", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.mp3", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.mp4", "anon");
|
||||
|
||||
// filterChainDefinitionMap.put("/**/*.html", "authc,wxOAuthFilter");
|
||||
// filterChainDefinitionMap.put("/**/*.jsp", "authc,wxOAuthFilter");
|
||||
filterChainDefinitionMap.put("/**/*.html", "wxOAuthFilter");
|
||||
filterChainDefinitionMap.put("/mobile/page/**", "wxOAuthFilter");
|
||||
// 测试放开权限
|
||||
filterChainDefinitionMap.put("/mobile/api/**", "anon");
|
||||
|
||||
//List<Permission> permissionList = permissionService.selectAll(CoreConst.STATUS_VALID); // 迁移此数据库结构不一致,不从数据库查权限配置
|
||||
List<Permission> permissionList = new ArrayList<Permission>();
|
||||
for(Permission permission : permissionList){
|
||||
if (StringUtils.isNotBlank(permission.getUrl())&& StringUtils.isNotBlank(permission.getPerms())) {
|
||||
String perm = "perms[" + permission.getPerms()+ "]";
|
||||
filterChainDefinitionMap.put(permission.getUrl(),perm+",kickout");
|
||||
}
|
||||
}
|
||||
|
||||
filterChainDefinitionMap.put("/**", "user,kickout");
|
||||
|
||||
return filterChainDefinitionMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/修改/删除 后 重新加载权限
|
||||
*/
|
||||
public void updatePermission() {
|
||||
ShiroFilterFactoryBean shiroFilterFactoryBean = SpringContextHolder.getBean(ShiroFilterFactoryBean.class);
|
||||
synchronized (shiroFilterFactoryBean) {
|
||||
AbstractShiroFilter shiroFilter = null;
|
||||
try {
|
||||
shiroFilter = (AbstractShiroFilter) shiroFilterFactoryBean.getObject();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("get ShiroFilter from shiroFilterFactoryBean error!");
|
||||
}
|
||||
|
||||
PathMatchingFilterChainResolver filterChainResolver = (PathMatchingFilterChainResolver) shiroFilter
|
||||
.getFilterChainResolver();
|
||||
DefaultFilterChainManager manager = (DefaultFilterChainManager) filterChainResolver
|
||||
.getFilterChainManager();
|
||||
|
||||
// 清空老的权限控制
|
||||
manager.getFilterChains().clear();
|
||||
|
||||
shiroFilterFactoryBean.getFilterChainDefinitionMap().clear();
|
||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(loadFilterChainDefinitions());
|
||||
// 重新构建生成
|
||||
Map<String, String> chains = shiroFilterFactoryBean.getFilterChainDefinitionMap();
|
||||
for (Map.Entry<String, String> entry : chains.entrySet()) {
|
||||
String url = entry.getKey();
|
||||
String chainDefinition = entry.getValue().trim().replace(" ", "");
|
||||
manager.createChain(url, chainDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/main/java/com/nbclass/shiro/config/LoginType.java
Normal file
22
src/main/java/com/nbclass/shiro/config/LoginType.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.nbclass.shiro.config;
|
||||
|
||||
/**
|
||||
* 登录类型
|
||||
* @author Leon
|
||||
* @datetime 2019年4月22日 下午8:48:14
|
||||
*/
|
||||
public enum LoginType {
|
||||
|
||||
PASSWORD("password"), // 密码登录
|
||||
NOPASSWD("nopassword"); // 免密登录
|
||||
|
||||
private String code;// 状态值
|
||||
|
||||
private LoginType(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
public String getCode () {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.nbclass.shiro.config;
|
||||
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
|
||||
|
||||
public class MyHashedCredentialsMatcher extends HashedCredentialsMatcher {
|
||||
|
||||
@Override
|
||||
public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
|
||||
MyUsernamePasswordToken tk = (MyUsernamePasswordToken) authcToken;
|
||||
// 如果是免密登录直接返回true
|
||||
if(tk.getType().equals(LoginType.NOPASSWD)){
|
||||
return true;
|
||||
}
|
||||
// 不是免密登录,调用父类的方法
|
||||
return super.doCredentialsMatch(tk, info);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.nbclass.shiro.config;
|
||||
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年4月22日 下午8:59:23
|
||||
*/
|
||||
public class MyUsernamePasswordToken extends UsernamePasswordToken {
|
||||
|
||||
private static final long serialVersionUID = 1744966815127132051L;
|
||||
|
||||
private LoginType type;
|
||||
|
||||
public MyUsernamePasswordToken() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MyUsernamePasswordToken(String username, String password, LoginType type, boolean rememberMe, String host) {
|
||||
super(username, password, rememberMe, host);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**免密登录*/
|
||||
public MyUsernamePasswordToken(String username) {
|
||||
super(username, "", false, null);
|
||||
this.type = LoginType.NOPASSWD;
|
||||
}
|
||||
|
||||
/**账号密码登录*/
|
||||
public MyUsernamePasswordToken(String username, String password) {
|
||||
super(username, password, false, null);
|
||||
this.type = LoginType.PASSWORD;
|
||||
}
|
||||
|
||||
public LoginType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(LoginType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
265
src/main/java/com/nbclass/shiro/config/ShiroConfig.java
Normal file
265
src/main/java/com/nbclass/shiro/config/ShiroConfig.java
Normal file
@ -0,0 +1,265 @@
|
||||
package com.nbclass.shiro.config;
|
||||
|
||||
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
|
||||
import com.nbclass.shiro.MyShiroRealm;
|
||||
import com.nbclass.shiro.ShiroService;
|
||||
import com.nbclass.shiro.filter.KickoutSessionControlFilter;
|
||||
import com.nbclass.szxgl.filter.WxWorkFilter;
|
||||
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
|
||||
import org.apache.shiro.codec.Base64;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.CookieRememberMeManager;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
import org.apache.shiro.web.servlet.SimpleCookie;
|
||||
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
|
||||
import org.crazycake.shiro.RedisCacheManager;
|
||||
import org.crazycake.shiro.RedisManager;
|
||||
import org.crazycake.shiro.RedisSessionDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.servlet.Filter;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
@Autowired
|
||||
private ShiroService shiroService;
|
||||
|
||||
@Value("${spring.redis.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.redis.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${spring.redis.timeout}")
|
||||
private int timeout;
|
||||
|
||||
@Value("${spring.redis.password}")
|
||||
private String password;
|
||||
|
||||
@Bean
|
||||
public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
|
||||
return new LifecycleBeanPostProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* ShiroDialect,为了在thymeleaf里使用shiro的标签的bean
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ShiroDialect shiroDialect() {
|
||||
return new ShiroDialect();
|
||||
}
|
||||
/**
|
||||
* ShiroFilterFactoryBean 处理拦截资源文件问题。
|
||||
* 注意:单独一个ShiroFilterFactoryBean配置是或报错的,因为在
|
||||
* 初始化ShiroFilterFactoryBean的时候需要注入:SecurityManager
|
||||
*
|
||||
Filter Chain定义说明
|
||||
1、一个URL可以配置多个Filter,使用逗号分隔
|
||||
2、当设置多个过滤器时,全部验证通过,才视为通过
|
||||
3、部分过滤器可指定参数,如perms,roles
|
||||
*
|
||||
*/
|
||||
@Bean
|
||||
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager){
|
||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
||||
// 必须设置 SecurityManager
|
||||
shiroFilterFactoryBean.setSecurityManager(securityManager);
|
||||
// 登录url
|
||||
shiroFilterFactoryBean.setLoginUrl("/login");
|
||||
// 登录成功后要跳转的链接
|
||||
shiroFilterFactoryBean.setSuccessUrl("/index");
|
||||
//未授权界面;
|
||||
shiroFilterFactoryBean.setUnauthorizedUrl("/error/403");
|
||||
//自定义拦截器
|
||||
Map<String, Filter> filtersMap = new LinkedHashMap<String, Filter>();
|
||||
//限制同一帐号同时在线的个数。
|
||||
filtersMap.put("kickout", kickoutSessionControlFilter());
|
||||
// 企业微信登录拦截器
|
||||
filtersMap.put("wxOAuthFilter", new WxWorkFilter());
|
||||
|
||||
shiroFilterFactoryBean.setFilters(filtersMap);
|
||||
//拦截器.
|
||||
Map<String,String> filterChainDefinitionMap = shiroService.loadFilterChainDefinitions();
|
||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
|
||||
return shiroFilterFactoryBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* cookie对象;
|
||||
* @return
|
||||
*/
|
||||
public SimpleCookie rememberMeCookie(){
|
||||
//这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
|
||||
SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
|
||||
//<!-- 记住我cookie生效时间30天 ,单位秒;-->
|
||||
simpleCookie.setMaxAge(2592000);
|
||||
return simpleCookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* cookie管理对象;记住我功能
|
||||
* @return
|
||||
*/
|
||||
public CookieRememberMeManager rememberMeManager(){
|
||||
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
|
||||
cookieRememberMeManager.setCookie(rememberMeCookie());
|
||||
// rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)
|
||||
// 参考getCipherKey()
|
||||
cookieRememberMeManager.setCipherKey(Base64.decode("PQnhURJTzZyhW+5fV8b49g=="));
|
||||
return cookieRememberMeManager;
|
||||
}
|
||||
|
||||
@Bean(name = "securityManager")
|
||||
public SecurityManager securityManager(){
|
||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
||||
//设置realm.
|
||||
securityManager.setRealm(myShiroRealm());
|
||||
/*记住我*/
|
||||
securityManager.setRememberMeManager(rememberMeManager());
|
||||
// 自定义缓存实现 使用redis
|
||||
securityManager.setCacheManager(redisCacheManager());
|
||||
// 自定义session管理 使用redis
|
||||
securityManager.setSessionManager(sessionManager());
|
||||
return securityManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MyShiroRealm myShiroRealm(){
|
||||
MyShiroRealm myShiroRealm = new MyShiroRealm();
|
||||
myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher());
|
||||
return myShiroRealm;
|
||||
}
|
||||
|
||||
/**
|
||||
* 凭证匹配器
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public HashedCredentialsMatcher hashedCredentialsMatcher(){
|
||||
// HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();
|
||||
MyHashedCredentialsMatcher hashedCredentialsMatcher = new MyHashedCredentialsMatcher();
|
||||
hashedCredentialsMatcher.setHashAlgorithmName("md5");
|
||||
hashedCredentialsMatcher.setHashIterations(2);
|
||||
return hashedCredentialsMatcher;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开启shiro aop注解支持.
|
||||
* 使用代理方式;所以需要开启代码支持;
|
||||
* @param securityManager
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager){
|
||||
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
|
||||
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
|
||||
return authorizationAttributeSourceAdvisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置shiro redisManager
|
||||
* 使用的是shiro-redis开源插件
|
||||
* @return
|
||||
*/
|
||||
public RedisManager redisManager() {
|
||||
RedisManager redisManager = new RedisManager();
|
||||
redisManager.setHost(host+":"+port);
|
||||
//redisManager.setPort(port);
|
||||
// 配置缓存过期时间
|
||||
//redisManager.setExpire(1800);
|
||||
redisManager.setTimeout(timeout);
|
||||
redisManager.setPassword(password);
|
||||
return redisManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* cacheManager 缓存 redis实现
|
||||
* 使用的是shiro-redis开源插件
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisCacheManager redisCacheManager() {
|
||||
RedisCacheManager redisCacheManager = new RedisCacheManager();
|
||||
redisCacheManager.setRedisManager(redisManager());
|
||||
return redisCacheManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RedisSessionDAO shiro sessionDao层的实现 通过redis
|
||||
* 使用的是shiro-redis开源插件
|
||||
*/
|
||||
@Bean
|
||||
public RedisSessionDAO redisSessionDAO() {
|
||||
RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
|
||||
redisSessionDAO.setRedisManager(redisManager());
|
||||
return redisSessionDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* shiro session的管理
|
||||
*/
|
||||
@Bean
|
||||
public DefaultWebSessionManager sessionManager() {
|
||||
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
|
||||
sessionManager.setSessionDAO(redisSessionDAO());
|
||||
return sessionManager;
|
||||
}
|
||||
/**
|
||||
* 限制同一账号登录同时登录人数控制
|
||||
* @return
|
||||
*/
|
||||
public KickoutSessionControlFilter kickoutSessionControlFilter(){
|
||||
KickoutSessionControlFilter kickoutSessionControlFilter = new KickoutSessionControlFilter();
|
||||
//使用cacheManager获取相应的cache来缓存用户登录的会话;用于保存用户—会话之间的关系的;
|
||||
//这里我们还是用之前shiro使用的redisManager()实现的cacheManager()缓存管理
|
||||
//也可以重新另写一个,重新配置缓存时间之类的自定义缓存属性
|
||||
kickoutSessionControlFilter.setCacheManager(redisCacheManager());
|
||||
//用于根据会话ID,获取会话进行踢出操作的;
|
||||
kickoutSessionControlFilter.setSessionManager(sessionManager());
|
||||
//是否踢出后来登录的,默认是false;即后者登录的用户踢出前者登录的用户;踢出顺序。
|
||||
kickoutSessionControlFilter.setKickoutAfter(false);
|
||||
//同一个用户最大的会话数,默认5;比如5的意思是同一个用户允许最多同时五个人登录;
|
||||
kickoutSessionControlFilter.setMaxSession(5);
|
||||
//被踢出后重定向到的地址;
|
||||
kickoutSessionControlFilter.setKickoutUrl("/kickout");
|
||||
return kickoutSessionControlFilter;
|
||||
}
|
||||
|
||||
|
||||
private static byte[] getCipherKey(){
|
||||
byte[] cipherKey = null;
|
||||
KeyGenerator keygen = null;
|
||||
try {
|
||||
keygen = KeyGenerator.getInstance("AES");
|
||||
SecretKey deskey = keygen.generateKey();
|
||||
cipherKey = deskey.getEncoded();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cipherKey;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("cipherKey="+Base64.encodeToString(getCipherKey()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,175 @@
|
||||
package com.nbclass.shiro.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.cache.Cache;
|
||||
import org.apache.shiro.cache.CacheManager;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.mgt.DefaultSessionKey;
|
||||
import org.apache.shiro.session.mgt.SessionManager;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.filter.AccessControlFilter;
|
||||
import org.apache.shiro.web.util.WebUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.nbclass.system.model.User;
|
||||
|
||||
/**
|
||||
* @author superzheng
|
||||
* @date 2018-07-18
|
||||
*/
|
||||
public class KickoutSessionControlFilter extends AccessControlFilter {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(KickoutSessionControlFilter.class);
|
||||
|
||||
/**
|
||||
* 踢出后到的地址
|
||||
*/
|
||||
private String kickoutUrl;
|
||||
/**
|
||||
* 踢出之前登录的/之后登录的用户 默认踢出之前登录的用户
|
||||
*/
|
||||
private boolean kickoutAfter = false;
|
||||
/**
|
||||
* 同一个帐号最大会话数 默认5
|
||||
*/
|
||||
private int maxSession = 5;
|
||||
|
||||
private SessionManager sessionManager;
|
||||
private Cache<String, Deque<Serializable>> cache;
|
||||
|
||||
public void setKickoutUrl(String kickoutUrl) {
|
||||
this.kickoutUrl = kickoutUrl;
|
||||
}
|
||||
|
||||
public void setKickoutAfter(boolean kickoutAfter) {
|
||||
this.kickoutAfter = kickoutAfter;
|
||||
}
|
||||
|
||||
public void setMaxSession(int maxSession) {
|
||||
this.maxSession = maxSession;
|
||||
}
|
||||
|
||||
public void setSessionManager(SessionManager sessionManager) {
|
||||
this.sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
public void setCacheManager(CacheManager cacheManager) {
|
||||
this.cache = cacheManager.getCache("shiro_redis_cache");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
|
||||
// HttpServletRequest req = (HttpServletRequest) request;
|
||||
|
||||
Subject subject = getSubject(request, response);
|
||||
if(!subject.isAuthenticated() && !subject.isRemembered()) {
|
||||
//如果没有登录,直接进行之后的流程
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Session session = subject.getSession();
|
||||
User user = (User) subject.getPrincipal();
|
||||
String username = user.getUsername();
|
||||
Serializable sessionId = session.getId();
|
||||
|
||||
//读取缓存 没有就存入
|
||||
Deque<Serializable> deque = cache.get(username);
|
||||
|
||||
//如果此用户没有session队列,也就是还没有登录过,缓存中没有
|
||||
//就new一个空队列,不然deque对象为空,会报空指针
|
||||
if(deque==null){
|
||||
deque = new LinkedList<Serializable>();
|
||||
}
|
||||
|
||||
//如果队列里没有此sessionId,且用户没有被踢出;放入队列
|
||||
if(!deque.contains(sessionId) && session.getAttribute("kickout") == null) {
|
||||
//将sessionId存入队列
|
||||
deque.push(sessionId);
|
||||
//将用户的sessionId队列缓存
|
||||
cache.put(username, deque);
|
||||
}
|
||||
|
||||
//如果队列里的sessionId数超出最大会话数,开始踢人
|
||||
while(deque.size() > maxSession) {
|
||||
Serializable kickoutSessionId = null;
|
||||
//如果踢出后者
|
||||
if(kickoutAfter) {
|
||||
kickoutSessionId = deque.removeFirst();
|
||||
//踢出后再更新下缓存队列
|
||||
cache.put(username, deque);
|
||||
} else { //否则踢出前者
|
||||
kickoutSessionId = deque.removeLast();
|
||||
//踢出后再更新下缓存队列
|
||||
cache.put(username, deque);
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
//获取被踢出的sessionId的session对象
|
||||
Session kickoutSession = sessionManager.getSession(new DefaultSessionKey(kickoutSessionId));
|
||||
if(kickoutSession != null) {
|
||||
//设置会话的kickout属性表示踢出了
|
||||
kickoutSession.setAttribute("kickout", true);
|
||||
}
|
||||
} catch (Exception e) {//ignore exception
|
||||
}
|
||||
}
|
||||
|
||||
//如果被踢出了,直接退出,重定向到踢出后的地址
|
||||
if ((Boolean)session.getAttribute("kickout")!=null&&(Boolean)session.getAttribute("kickout") == true) {
|
||||
//会话被踢出了
|
||||
try {
|
||||
//退出登录
|
||||
subject.logout();
|
||||
} catch (Exception e) { //ignore
|
||||
}
|
||||
saveRequest(request);
|
||||
|
||||
Map<String, String> resultMap = new HashMap<String, String>(2);
|
||||
//判断是不是Ajax请求
|
||||
if ("XMLHttpRequest".equalsIgnoreCase(((HttpServletRequest) request).getHeader("X-Requested-With"))) {
|
||||
resultMap.put("user_status", "300");
|
||||
resultMap.put("message", "您已经在其他地方登录,请重新登录!");
|
||||
//输出json串
|
||||
out(response, resultMap);
|
||||
}else{
|
||||
//重定向
|
||||
WebUtils.issueRedirect(request, response, kickoutUrl);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void out(ServletResponse hresponse, Map<String, String> resultMap)
|
||||
throws IOException {
|
||||
try {
|
||||
hresponse.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = hresponse.getWriter();
|
||||
out.println(JSON.toJSONString(resultMap));
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
System.err.println("KickoutSessionFilter.class 输出JSON异常,可以忽略。");
|
||||
}
|
||||
}
|
||||
}
|
||||
208
src/main/java/com/nbclass/system/controller/BaseController.java
Normal file
208
src/main/java/com/nbclass/system/controller/BaseController.java
Normal file
@ -0,0 +1,208 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.util.CoreConst;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年4月1日 下午3:22:58
|
||||
*/
|
||||
public abstract class BaseController {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private static ThreadLocal<Map<String,Object>> outPutMsg = new ThreadLocal<Map<String,Object>>();
|
||||
|
||||
/**
|
||||
* 获取request
|
||||
* @return HttpServletRequest
|
||||
*/
|
||||
protected HttpServletRequest getRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Response
|
||||
* @return HttpServletResponse
|
||||
*/
|
||||
protected HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取session
|
||||
* @return HttpSession
|
||||
*/
|
||||
protected HttpSession getSession() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession();
|
||||
}
|
||||
|
||||
protected ServletContext getServletContext() {
|
||||
return ContextLoader.getCurrentWebApplicationContext().getServletContext();
|
||||
}
|
||||
|
||||
public void outPrint1() {
|
||||
outPrint1(null);
|
||||
}
|
||||
|
||||
public void outPrint1(Object result) {
|
||||
outPrint1(result, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出,同时清空outPutMsg
|
||||
* @param result
|
||||
* @param respCode -- 是否返回响应状态吗,false:将直接输出result
|
||||
*/
|
||||
public void outPrint1(Object result, boolean respCode) {
|
||||
try {
|
||||
HttpServletResponse response = getResponse();
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/json");
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
if(respCode){
|
||||
JSONObject obj = new JSONObject();
|
||||
if(result == null){
|
||||
// no msg
|
||||
}else if(result instanceof String){
|
||||
obj.put(CoreConst.MSG, result);
|
||||
}else{
|
||||
obj = (JSONObject) JSONObject.toJSON(result);
|
||||
}
|
||||
obj.put(CoreConst.STATUS, CoreConst.STATUS_SUCCESS);
|
||||
out.print(obj.toString());
|
||||
}else{
|
||||
out.print(result.toString());
|
||||
}
|
||||
getOutputMsg().clear();
|
||||
} catch (IOException e) {
|
||||
logger.error("输出异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出失败信息,同时清空outPutMsg
|
||||
* @param result void
|
||||
*/
|
||||
public void outPrintFail1(Object result) {
|
||||
try {
|
||||
HttpServletResponse response = getResponse();
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/json");
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
if(result == null){
|
||||
// no msg
|
||||
}else if(result instanceof String){
|
||||
obj.put(CoreConst.MSG, result);
|
||||
}else{
|
||||
obj = (JSONObject) JSONObject.toJSON(result);
|
||||
}
|
||||
obj.put(CoreConst.STATUS, CoreConst.STATUS_ERROR);
|
||||
PrintWriter out = response.getWriter();
|
||||
out.print(obj.toString());
|
||||
getOutputMsg().clear();
|
||||
} catch (IOException e) {
|
||||
logger.error("输出异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 线程绑定,其内容会在outPrint方法调用后清空
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
public Map<String,Object> getOutputMsg() {
|
||||
Map<String,Object> output = outPutMsg.get();
|
||||
if(output==null){
|
||||
output = new HashMap<String, Object>();
|
||||
outPutMsg.set(output);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public User getLoginUser(){
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getLoginUserId(){
|
||||
int userid = -1;
|
||||
User user = getLoginUser();
|
||||
if(user!=null && user.getId()!=null)userid=user.getId();
|
||||
return userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应企业微信的userId
|
||||
* @return
|
||||
*/
|
||||
public String getLoginUserIdStr(){
|
||||
String userid = null;
|
||||
User user = getLoginUser();
|
||||
if(user!=null)userid=user.getUserId();
|
||||
return userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是管理员角色
|
||||
* @return
|
||||
*/
|
||||
public boolean isAdminRole(){
|
||||
boolean isAdmin = SecurityUtils.getSubject().hasRole("1"); //是否是管理员,admin的roleid为1
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实体类转JSON
|
||||
* 为什么这么转?
|
||||
* 因为fastjson直接转会把_name转成name
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public JSONObject toJSON(Object value){
|
||||
if(value == null)return null;
|
||||
JSONObject returnObj = new JSONObject();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
String json = mapper.writeValueAsString(value);
|
||||
returnObj = JSONObject.parseObject(json);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return returnObj;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Object result = null;
|
||||
result = "";
|
||||
JSONObject obj = (JSONObject) JSONObject.toJSON(result);
|
||||
obj.put(CoreConst.STATUS, CoreConst.STATUS_SUCCESS);
|
||||
System.out.println(obj);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/database")
|
||||
public class DatabaseController{
|
||||
@GetMapping(value = "/monitoring")
|
||||
public ModelAndView databaseMonitoring(){
|
||||
return new ModelAndView("database/monitoring");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/error")
|
||||
public class ErrorController {
|
||||
/*shiro无权限时进入*/
|
||||
@RequestMapping("/403")
|
||||
public String noPermission(HttpServletRequest request, HttpServletResponse response){
|
||||
response.setStatus(HttpStatus.FORBIDDEN.value());
|
||||
return "error/403";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
/**
|
||||
* 异常处理请参考 CommonExceptionAdvice
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午11:07:57
|
||||
*/
|
||||
/*@ControllerAdvice*/
|
||||
public class ExceptionHandleController {
|
||||
|
||||
/*
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExceptionHandleController.class);
|
||||
|
||||
@ExceptionHandler(ZbException.class)
|
||||
public String handleZb(Exception e, HttpServletRequest request) {
|
||||
request.setAttribute("javax.servlet.error.status_code",ResponseStatus.ERROR.getCode());
|
||||
Map<String,Object> map = new HashMap<>(2);
|
||||
map.put("status", ResponseStatus.ERROR.getCode());
|
||||
map.put("msg", StringUtils.isNotBlank(e.getMessage())? e.getMessage() : ResponseStatus.ERROR.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
request.setAttribute("ext",map);
|
||||
return "forward:/error";
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public String handleAuth(HttpServletRequest request) {
|
||||
request.setAttribute("javax.servlet.error.status_code",ResponseStatus.FORBIDDEN.getCode());
|
||||
return "forward:/error";
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import com.google.code.kaptcha.Constants;
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
public class KaptchaController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(KaptchaController.class);
|
||||
|
||||
private Producer captchaProducer = null;
|
||||
|
||||
@Autowired
|
||||
public void setCaptchaProducer(Producer captchaProducer) {
|
||||
this.captchaProducer = captchaProducer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取验证码图片
|
||||
* Gets captcha code.
|
||||
*
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
* @return the captcha code
|
||||
* @throws IOException the io exception
|
||||
*/
|
||||
@RequestMapping("/verificationCode")
|
||||
public ModelAndView getCaptchaCode(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
HttpSession session = request.getSession();
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
||||
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setContentType("image/jpeg");
|
||||
//生成验证码文本
|
||||
String capText = captchaProducer.createText();
|
||||
session.setAttribute(Constants.KAPTCHA_SESSION_KEY, capText);
|
||||
logger.info("生成验证码文本====" + capText);
|
||||
//利用生成的字符串构建图片
|
||||
BufferedImage bi = captchaProducer.createImage(capText);
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
ImageIO.write(bi, "jpg", out);
|
||||
try {
|
||||
out.flush();
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import com.nbclass.system.service.UserService;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.vo.UserOnlineVo;
|
||||
import com.nbclass.vo.UserSessionVo;
|
||||
import com.nbclass.vo.base.PageResultVo;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/online/user")
|
||||
public class OnlineUserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
// 在线用户列表
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public PageResultVo onlineUsers(UserOnlineVo user, Integer limit, Integer offset){
|
||||
List<UserOnlineVo> userList = userService.selectOnlineUsers(user);
|
||||
int endIndex = (offset+limit) > userList.size() ? userList.size() : (offset+limit);
|
||||
return ResultUtil.table(userList.subList(offset,endIndex),(long)userList.size());
|
||||
}
|
||||
|
||||
// 强制踢出用户
|
||||
@PostMapping("/kickout")
|
||||
@ResponseBody
|
||||
public ResponseVo kickout(String sessionId,String username) {
|
||||
try {
|
||||
if(SecurityUtils.getSubject().getSession().getId().equals(sessionId)){
|
||||
return ResultUtil.error("不能踢出自己");
|
||||
}
|
||||
userService.kickout(sessionId,username);
|
||||
return ResultUtil.success("踢出用户成功");
|
||||
} catch (Exception e) {
|
||||
return ResultUtil.error("踢出用户失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 批量强制踢出用户
|
||||
@PostMapping("/batch/kickout")
|
||||
@ResponseBody
|
||||
public ResponseVo kickout(@RequestBody List<UserSessionVo> sessions) {
|
||||
try {
|
||||
//要踢出的用户中是否有自己
|
||||
boolean hasOwn=false;
|
||||
Serializable sessionId = SecurityUtils.getSubject().getSession().getId();
|
||||
for (UserSessionVo sessionVo : sessions) {
|
||||
if(sessionVo.getSessionId().equals(sessionId)){
|
||||
hasOwn=true;
|
||||
}else{
|
||||
userService.kickout(sessionVo.getSessionId(),sessionVo.getUsername());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(hasOwn){
|
||||
return ResultUtil.success("不能踢出自己");
|
||||
}
|
||||
return ResultUtil.success("踢出用户成功");
|
||||
} catch (Exception e) {
|
||||
return ResultUtil.error("踢出用户失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.nbclass.shiro.ShiroService;
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.service.PermissionService;
|
||||
import com.nbclass.util.CoreConst;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/permission")
|
||||
public class PermissionController{
|
||||
private static final Logger logger = LoggerFactory.getLogger(PermissionController.class);
|
||||
/**1:全部资源,2:菜单资源*/
|
||||
private static final String[] MENU_FLAG ={"1","2"};
|
||||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
@Autowired
|
||||
private ShiroService shiroService;
|
||||
|
||||
|
||||
|
||||
/*权限列表数据*/
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public List<Permission> loadPermissions(String flag){
|
||||
List<Permission> permissionListList = new ArrayList<Permission>();
|
||||
if(StringUtils.isBlank(flag) || MENU_FLAG[0].equals(flag)){
|
||||
permissionListList = permissionService.selectAll(CoreConst.STATUS_VALID);
|
||||
}else if(MENU_FLAG[1].equals(flag)){
|
||||
permissionListList = permissionService.selectAllMenuName(CoreConst.STATUS_VALID);
|
||||
}
|
||||
return permissionListList;
|
||||
}
|
||||
|
||||
/*添加权限*/
|
||||
@ResponseBody
|
||||
@PostMapping("/add")
|
||||
public ResponseVo addPermission(Permission permission){
|
||||
try {
|
||||
int a = permissionService.insert(permission);
|
||||
if (a > 0) {
|
||||
shiroService.updatePermission();
|
||||
return ResultUtil.success("添加权限成功");
|
||||
} else {
|
||||
return ResultUtil.error("添加权限失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(String.format("PermissionController.addPermission%s", e));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*删除权限*/
|
||||
@ResponseBody
|
||||
@PostMapping("/delete")
|
||||
public ResponseVo deletePermission(String permissionId){
|
||||
try {
|
||||
int subPermsByPermissionIdCount = permissionService.selectSubPermsByPermissionId(permissionId);
|
||||
if(subPermsByPermissionIdCount>0){
|
||||
return ResultUtil.error("改资源存在下级资源,无法删除!");
|
||||
}
|
||||
int a = permissionService.updateStatus(permissionId,CoreConst.STATUS_INVALID);
|
||||
if (a > 0) {
|
||||
shiroService.updatePermission();
|
||||
return ResultUtil.success("删除权限成功");
|
||||
} else {
|
||||
return ResultUtil.error("删除权限失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(String.format("PermissionController.deletePermission%s", e));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*权限详情*/
|
||||
@GetMapping("/edit")
|
||||
public String detail(Model model, String permissionId) {
|
||||
Permission permission = permissionService.findByPermissionId(permissionId);
|
||||
if(null!=permission){
|
||||
if(permission.getParentId().equals(CoreConst.TOP_MENU_ID)){
|
||||
model.addAttribute("parentName", CoreConst.TOP_MENU_NAME);
|
||||
}else{
|
||||
Permission parent = permissionService.findById(permission.getParentId());
|
||||
model.addAttribute("parentName", parent.getName());
|
||||
}
|
||||
}
|
||||
model.addAttribute("permission", permission);
|
||||
return "permission/detail";
|
||||
}
|
||||
|
||||
/*编辑权限*/
|
||||
@ResponseBody
|
||||
@PostMapping("/edit")
|
||||
public ResponseVo editPermission(@ModelAttribute("permission")Permission permission){
|
||||
int a = permissionService.updateByPermissionId(permission);
|
||||
if (a > 0) {
|
||||
shiroService.updatePermission();
|
||||
return ResultUtil.success("编辑权限成功");
|
||||
} else {
|
||||
return ResultUtil.error("编辑权限失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月13日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
public class RenderController {
|
||||
|
||||
/*工作台*/
|
||||
@GetMapping("/workdest")
|
||||
public String workdest(){
|
||||
return "index/workdest";
|
||||
}
|
||||
|
||||
/**用户列表入口*/
|
||||
@GetMapping("/users")
|
||||
public String userList(){
|
||||
return "user/list";
|
||||
}
|
||||
|
||||
/*角色列表入口*/
|
||||
@GetMapping("/roles")
|
||||
public String roleList() {
|
||||
return "role/list";
|
||||
}
|
||||
|
||||
/*权限列表入口*/
|
||||
@GetMapping("/permissions")
|
||||
public String permissionList(){
|
||||
return "permission/list";
|
||||
}
|
||||
|
||||
/*在线用户入口*/
|
||||
@GetMapping("/online/users")
|
||||
public String onlineUsers(){return "onlineUsers/list";}
|
||||
}
|
||||
184
src/main/java/com/nbclass/system/controller/RoleController.java
Normal file
184
src/main/java/com/nbclass/system/controller/RoleController.java
Normal file
@ -0,0 +1,184 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.nbclass.shiro.MyShiroRealm;
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.model.Role;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.system.service.PermissionService;
|
||||
import com.nbclass.system.service.RoleService;
|
||||
import com.nbclass.util.CoreConst;
|
||||
import com.nbclass.util.PageUtil;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.vo.PermissionTreeListVo;
|
||||
import com.nbclass.vo.base.PageResultVo;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/role")
|
||||
public class RoleController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RoleController.class);
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
@Autowired
|
||||
private MyShiroRealm myShiroRealm;
|
||||
|
||||
/*角色列表数据*/
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public PageResultVo pageRoles(Role role, Integer limit, Integer offset) {
|
||||
try {
|
||||
PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit);
|
||||
List<Role> roleList = roleService.selectRoles(role);
|
||||
PageInfo<Role> pages = new PageInfo<>(roleList);
|
||||
return ResultUtil.table(roleList,pages.getTotal());
|
||||
} catch (Exception e) {
|
||||
logger.error(String.format("RoleController.loadRoles%s", e));
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*新增角色*/
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public ResponseVo addRole(Role role) {
|
||||
try {
|
||||
int a = roleService.insert(role);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("添加角色成功");
|
||||
} else {
|
||||
return ResultUtil.error("添加角色失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(String.format("RoleController.addRole%s", e));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/*删除角色*/
|
||||
@GetMapping("/delete")
|
||||
@ResponseBody
|
||||
public ResponseVo deleteRole(String roleId) {
|
||||
if(roleService.findByRoleId(roleId).size()>0){
|
||||
return ResultUtil.error("删除失败,该角色下存在用户");
|
||||
}
|
||||
List<String> roleIdsList = Arrays.asList(roleId);
|
||||
int a = roleService.updateStatusBatch(roleIdsList, CoreConst.STATUS_INVALID);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("删除角色成功");
|
||||
} else {
|
||||
return ResultUtil.error("删除角色失败");
|
||||
}
|
||||
}
|
||||
|
||||
/*批量删除角色*/
|
||||
@GetMapping("/batch/delete")
|
||||
@ResponseBody
|
||||
public ResponseVo batchDeleteRole(String roleIdStr) {
|
||||
String[] roleIds = roleIdStr.split(",");
|
||||
List<String> roleIdsList = Arrays.asList(roleIds);
|
||||
if(roleService.findByRoleIds(roleIdsList).size()>0){
|
||||
return ResultUtil.error("删除失败,选择的角色下存在用户");
|
||||
}
|
||||
int a = roleService.updateStatusBatch(roleIdsList, CoreConst.STATUS_INVALID);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("删除角色成功");
|
||||
} else {
|
||||
return ResultUtil.error("删除角色失败");
|
||||
}
|
||||
}
|
||||
|
||||
/*编辑角色详情*/
|
||||
@GetMapping("/edit")
|
||||
public String detail(Model model, Integer id) {
|
||||
Role role = roleService.findById(id);
|
||||
model.addAttribute("role", role);
|
||||
return "role/detail";
|
||||
}
|
||||
|
||||
/*编辑角色*/
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public ResponseVo editRole(@ModelAttribute("role") Role role) {
|
||||
int a = roleService.updateByRoleId(role);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("编辑角色成功");
|
||||
} else {
|
||||
return ResultUtil.error("编辑角色失败");
|
||||
}
|
||||
}
|
||||
|
||||
/*分配权限列表查询*/
|
||||
@PostMapping("/assign/permission/list")
|
||||
@ResponseBody
|
||||
public List<PermissionTreeListVo> assignRole(String roleId){
|
||||
List<PermissionTreeListVo> listVos = new ArrayList<>();
|
||||
List<Permission> allPermissions = permissionService.selectAll(CoreConst.STATUS_VALID);
|
||||
List<Permission> hasPermissions = roleService.findPermissionsByRoleId(roleId);
|
||||
for(Permission permission : allPermissions){
|
||||
PermissionTreeListVo vo = new PermissionTreeListVo();
|
||||
vo.setId(permission.getId());
|
||||
vo.setPermissionId(permission.getPermissionId());
|
||||
vo.setName(permission.getName());
|
||||
vo.setParentId(permission.getParentId());
|
||||
for(Permission hasPermission:hasPermissions){
|
||||
//有权限则选中
|
||||
if(hasPermission.getPermissionId().equals(permission.getPermissionId())){
|
||||
vo.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
listVos.add(vo);
|
||||
}
|
||||
return listVos;
|
||||
}
|
||||
|
||||
|
||||
/*分配权限*/
|
||||
@PostMapping("/assign/permission")
|
||||
@ResponseBody
|
||||
public ResponseVo assignRole(String roleId, String permissionIdStr){
|
||||
List<String> permissionIdsList = new ArrayList<>();
|
||||
if(StringUtils.isNotBlank(permissionIdStr)){
|
||||
String[] permissionIds = permissionIdStr.split(",");
|
||||
permissionIdsList = Arrays.asList(permissionIds);
|
||||
}
|
||||
ResponseVo responseVo = roleService.addAssignPermission(roleId,permissionIdsList);
|
||||
/*重新加载角色下所有用户权限*/
|
||||
List<User> userList = roleService.findByRoleId(roleId);
|
||||
if(userList.size()>0){
|
||||
List<String> userIds = new ArrayList<>();
|
||||
for(User user : userList){
|
||||
userIds.add(user.getUserId());
|
||||
}
|
||||
myShiroRealm.clearAuthorizationByUserId(userIds);
|
||||
}
|
||||
return responseVo;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,192 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.LockedAccountException;
|
||||
import org.apache.shiro.cache.Cache;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.crazycake.shiro.RedisCacheManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.google.code.kaptcha.Constants;
|
||||
import com.nbclass.shiro.config.MyUsernamePasswordToken;
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.system.service.PermissionService;
|
||||
import com.nbclass.system.service.UserService;
|
||||
import com.nbclass.util.CoreConst;
|
||||
import com.nbclass.util.PasswordHelper;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.util.UUIDUtil;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
public class SystemController{
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
@Autowired
|
||||
private RedisCacheManager redisCacheManager;
|
||||
|
||||
/*首页*/
|
||||
/*@RequestMapping(value={"/","/index"})*/
|
||||
@RequestMapping(value={"/admin"})
|
||||
public String admin(){
|
||||
return "index/index";
|
||||
}
|
||||
|
||||
/*注册*/
|
||||
@GetMapping(value = "/register")
|
||||
public String register(){
|
||||
return "system/register";
|
||||
}
|
||||
|
||||
/*提交注册*/
|
||||
@PostMapping("/register")
|
||||
@ResponseBody
|
||||
public ResponseVo register(HttpServletRequest request, User registerUser, String confirmPassword, String verification){
|
||||
//判断验证码
|
||||
String rightCode = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
|
||||
if (StringUtils.isNotBlank(verification) && StringUtils.isNotBlank(rightCode) && verification.equals(rightCode)) {
|
||||
//验证码通过
|
||||
} else {
|
||||
return ResultUtil.error("验证码错误!");
|
||||
}
|
||||
String username = registerUser.getUsername();
|
||||
User user = userService.selectByUsername(username);
|
||||
if (null != user) {
|
||||
return ResultUtil.error("用户名已存在!");
|
||||
}
|
||||
String password = registerUser.getPassword();
|
||||
//判断两次输入密码是否相等
|
||||
if (confirmPassword != null && password != null) {
|
||||
if (!confirmPassword.equals(password)) {
|
||||
return ResultUtil.error("两次密码不一致!");
|
||||
}
|
||||
}
|
||||
registerUser.setUserId(UUIDUtil.getUniqueIdByUUId());
|
||||
registerUser.setStatus(CoreConst.STATUS_VALID);
|
||||
Date date = new Date();
|
||||
registerUser.setCreateTime(date);
|
||||
registerUser.setUpdateTime(date);
|
||||
registerUser.setLastLoginTime(date);
|
||||
PasswordHelper.encryptPassword(registerUser);
|
||||
//注册
|
||||
int registerResult = userService.register(registerUser);
|
||||
if(registerResult > 0){
|
||||
return ResultUtil.success("注册成功!");
|
||||
}else {
|
||||
return ResultUtil.error("注册失败,请稍后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
/*登陆*/
|
||||
@GetMapping("/login")
|
||||
public String login(Map map){
|
||||
return "system/login";
|
||||
}
|
||||
|
||||
/*提交登录*/
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
public ResponseVo login(HttpServletRequest request, String username, String password, String verification,
|
||||
@RequestParam(value = "rememberMe", defaultValue = "0") Integer rememberMe){
|
||||
//判断验证码
|
||||
String rightCode = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
|
||||
if (StringUtils.isNotBlank(verification) && StringUtils.isNotBlank(rightCode) && verification.equalsIgnoreCase(rightCode)) {
|
||||
//验证码通过
|
||||
} else {
|
||||
return ResultUtil.error("验证码错误!");
|
||||
}
|
||||
MyUsernamePasswordToken token = new MyUsernamePasswordToken(username, password);
|
||||
// MyUsernamePasswordToken token = new MyUsernamePasswordToken(username); // 免密登录
|
||||
try{
|
||||
token.setRememberMe(1 == rememberMe);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
subject.login(token);
|
||||
} catch (LockedAccountException e) {
|
||||
token.clear();
|
||||
return ResultUtil.error("用户已经被锁定不能登录,请联系管理员!");
|
||||
} catch (AuthenticationException e) {
|
||||
token.clear();
|
||||
return ResultUtil.error("用户名或者密码错误!");
|
||||
}
|
||||
//更新最后登录时间
|
||||
userService.updateLastLoginTime((User) SecurityUtils.getSubject().getPrincipal());
|
||||
return ResultUtil.success("登录成功!");
|
||||
}
|
||||
|
||||
/*踢出*/
|
||||
@GetMapping("/kickout")
|
||||
public String kickout(Map map){
|
||||
return "system/kickout";
|
||||
}
|
||||
|
||||
/*登出*/
|
||||
@RequestMapping(value = "/logout")
|
||||
@ResponseBody
|
||||
public ResponseVo logout() {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
if(null!=subject){
|
||||
String username = ((User) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
||||
Serializable sessionId = SecurityUtils.getSubject().getSession().getId();
|
||||
Cache<String, Deque<Serializable>> cache = redisCacheManager.getCache(redisCacheManager.getKeyPrefix()+username);
|
||||
Deque<Serializable> deques = cache.get(username);
|
||||
for(Serializable deque : deques){
|
||||
if(sessionId.equals(deque)){
|
||||
deques.remove(deque);
|
||||
break;
|
||||
}
|
||||
}
|
||||
cache.put(username,deques);
|
||||
}
|
||||
subject.logout();
|
||||
return ResultUtil.success("退出成功");
|
||||
}
|
||||
|
||||
/*获取当前登录用户的菜单*/
|
||||
@PostMapping("/menu")
|
||||
@ResponseBody
|
||||
public List<Permission> getMenus(){
|
||||
List<Permission> permissionListList = permissionService.selectMenuByUserId(((User) SecurityUtils.getSubject().getPrincipal()).getUserId());
|
||||
return permissionListList;
|
||||
}
|
||||
|
||||
/*图标*/
|
||||
@GetMapping(value = "/icons")
|
||||
public String getIcons(){
|
||||
return "ui/icons";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/test")
|
||||
public String test(){
|
||||
return "ui/icons";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/test1")
|
||||
public String test1(){
|
||||
return "ui/icons";
|
||||
}
|
||||
|
||||
}
|
||||
179
src/main/java/com/nbclass/system/controller/UserController.java
Normal file
179
src/main/java/com/nbclass/system/controller/UserController.java
Normal file
@ -0,0 +1,179 @@
|
||||
package com.nbclass.system.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.nbclass.shiro.MyShiroRealm;
|
||||
import com.nbclass.system.model.Role;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.system.service.RoleService;
|
||||
import com.nbclass.system.service.UserService;
|
||||
import com.nbclass.util.*;
|
||||
import com.nbclass.vo.ChangePasswordVo;
|
||||
import com.nbclass.vo.base.PageResultVo;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private MyShiroRealm myShiroRealm;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private MyShiroRealm shiroRealm;
|
||||
|
||||
/**用户列表数据*/
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public PageResultVo loadUsers(User user, Integer limit, Integer offset){
|
||||
PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit);
|
||||
List<User> userList = userService.selectUsers(user);
|
||||
PageInfo<User> pages = new PageInfo<>(userList);
|
||||
return ResultUtil.table(userList,pages.getTotal());
|
||||
}
|
||||
|
||||
/**新增用户*/
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public ResponseVo add(User userForm, String confirmPassword){
|
||||
String username = userForm.getUsername();
|
||||
User user = userService.selectByUsername(username);
|
||||
if (null != user) {
|
||||
return ResultUtil.error("用户名已存在");
|
||||
}
|
||||
String password = userForm.getPassword();
|
||||
//判断两次输入密码是否相等
|
||||
if (confirmPassword != null && password != null) {
|
||||
if (!confirmPassword.equals(password)) {
|
||||
return ResultUtil.error("两次密码不一致");
|
||||
}
|
||||
}
|
||||
userForm.setUserId(UUIDUtil.getUniqueIdByUUId());
|
||||
userForm.setStatus(CoreConst.STATUS_VALID);
|
||||
Date date = new Date();
|
||||
userForm.setCreateTime(date);
|
||||
userForm.setUpdateTime(date);
|
||||
userForm.setLastLoginTime(date);
|
||||
PasswordHelper.encryptPassword(userForm);
|
||||
int num = userService.register(userForm);
|
||||
if(num > 0){
|
||||
return ResultUtil.success("添加用户成功");
|
||||
}else {
|
||||
return ResultUtil.error("添加用户失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**编辑用户详情*/
|
||||
@GetMapping("/edit")
|
||||
public String userDetail(Model model, String userId){
|
||||
User user = userService.selectByUserId(userId);
|
||||
model.addAttribute("user", user);
|
||||
return "user/userDetail";
|
||||
}
|
||||
|
||||
/**编辑用户*/
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public ResponseVo editUser(User userForm){
|
||||
int a = userService.updateByUserId(userForm);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("编辑用户成功!");
|
||||
} else {
|
||||
return ResultUtil.error("编辑用户失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**删除用户*/
|
||||
@GetMapping("/delete")
|
||||
@ResponseBody
|
||||
public ResponseVo deleteUser(String userId) {
|
||||
List<String> userIdsList = Arrays.asList(userId);
|
||||
int a = userService.updateStatusBatch(userIdsList,CoreConst.STATUS_INVALID);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("删除用户成功");
|
||||
} else {
|
||||
return ResultUtil.error("删除用户失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**批量删除用户*/
|
||||
@GetMapping("/batch/delete")
|
||||
@ResponseBody
|
||||
public ResponseVo batchDeleteUser(String userIdStr) {
|
||||
String[] userIds = userIdStr.split(",");
|
||||
List<String> userIdsList = Arrays.asList(userIds);
|
||||
int a = userService.updateStatusBatch(userIdsList,CoreConst.STATUS_INVALID);
|
||||
if (a > 0) {
|
||||
return ResultUtil.success("删除用户成功");
|
||||
} else {
|
||||
return ResultUtil.error("删除用户失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**分配角色列表查询*/
|
||||
@PostMapping("/assign/role/list")
|
||||
@ResponseBody
|
||||
public Map<String,Object> assignRoleList(String userId){
|
||||
List<Role> roleList = roleService.selectRoles(new Role());
|
||||
Set<String> hasRoles = roleService.findRoleByUserId(userId);
|
||||
Map<String, Object> jsonMap = new HashMap<>(2);
|
||||
jsonMap.put("rows", roleList);
|
||||
jsonMap.put("hasRoles",hasRoles);
|
||||
return jsonMap;
|
||||
}
|
||||
|
||||
/**保存分配角色*/
|
||||
@PostMapping("/assign/role")
|
||||
@ResponseBody
|
||||
public ResponseVo assignRole(String userId, String roleIdStr){
|
||||
String[] roleIds = roleIdStr.split(",");
|
||||
List<String> roleIdsList = Arrays.asList(roleIds);
|
||||
ResponseVo responseVo = userService.addAssignRole(userId,roleIdsList);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(userId);
|
||||
myShiroRealm.clearAuthorizationByUserId(userIds);
|
||||
return responseVo;
|
||||
}
|
||||
|
||||
/*修改密码*/
|
||||
@RequestMapping(value = "/changePassword",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseVo changePassword(ChangePasswordVo changePasswordVo) {
|
||||
if(!changePasswordVo.getNewPassword().equals(changePasswordVo.getConfirmNewPassword())){
|
||||
return ResultUtil.error("两次密码输入不一致");
|
||||
}
|
||||
User loginUser = userService.selectByUserId(((User) SecurityUtils.getSubject().getPrincipal()).getUserId());
|
||||
User newUser = CopyUtil.getCopy(loginUser,User.class);
|
||||
String sysOldPassword = loginUser.getPassword();
|
||||
newUser.setPassword(changePasswordVo.getOldPassword());
|
||||
String entryOldPassword = PasswordHelper.getPassword(newUser);
|
||||
if(sysOldPassword.equals(entryOldPassword)){
|
||||
newUser.setPassword(changePasswordVo.getNewPassword());
|
||||
PasswordHelper.encryptPassword(newUser);
|
||||
userService.updateUserByPrimaryKey(newUser);
|
||||
//*清除登录缓存*//
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(loginUser.getUserId());
|
||||
shiroRealm.removeCachedAuthenticationInfo(userIds);
|
||||
/*SecurityUtils.getSubject().logout();*/
|
||||
}else{
|
||||
return ResultUtil.error("您输入的旧密码有误");
|
||||
}
|
||||
return ResultUtil.success("修改密码成功");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.nbclass.system.mapper;
|
||||
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.util.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface PermissionMapper extends MyMapper<Permission> {
|
||||
|
||||
/**
|
||||
* 根据状态查询全部资源
|
||||
* @param status 状态
|
||||
* @return the list
|
||||
*/
|
||||
List<Permission> selectAllPerms(Integer status);
|
||||
|
||||
/**
|
||||
* 根据状态查询全部菜单
|
||||
* @param status 状态
|
||||
* @return the list
|
||||
*/
|
||||
List<Permission> selectAllMenuName(Integer status);
|
||||
|
||||
/**
|
||||
* 根据用户id查询权限集合
|
||||
* @param userId 状态
|
||||
* @return set
|
||||
*/
|
||||
Set<String> findPermsByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据角色id查询权限
|
||||
* @param id 角色id
|
||||
* @return the list
|
||||
*/
|
||||
List<Permission> findByRoleId(String id);
|
||||
|
||||
/**
|
||||
* 根据用户id查询权限
|
||||
* @param userId 用户id
|
||||
* @return the list
|
||||
*/
|
||||
List<Permission> selectByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户id查询菜单
|
||||
* @param userId 用户id
|
||||
* @return the list
|
||||
*/
|
||||
List<Permission> selectMenuByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据权限id修改状态
|
||||
* @param permissionId 权限id
|
||||
* @param status 状态
|
||||
* @return int
|
||||
*/
|
||||
int updateStatusByPermissionId(@Param("permissionId") String permissionId, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 根据权限id查询权限
|
||||
* @param permissionId 权限id
|
||||
* @return permission
|
||||
*/
|
||||
Permission selectByPermissionId(String permissionId);
|
||||
|
||||
/**
|
||||
* 根据权限bean修改权限
|
||||
* @param permission 权限
|
||||
* @return int
|
||||
*/
|
||||
int updateByPermissionId(Permission permission);
|
||||
|
||||
/**
|
||||
* 根据权限id查询有几个子资源
|
||||
* @param permissionId 权限id
|
||||
* @return int
|
||||
*/
|
||||
int selectSubPermsByPermissionId(String permissionId);
|
||||
}
|
||||
45
src/main/java/com/nbclass/system/mapper/RoleMapper.java
Normal file
45
src/main/java/com/nbclass/system/mapper/RoleMapper.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.nbclass.system.mapper;
|
||||
|
||||
import com.nbclass.system.model.Role;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface RoleMapper extends MyMapper<Role> {
|
||||
/**
|
||||
* 根据用户id查询角色集合
|
||||
* @param userId 用户id
|
||||
* @return set
|
||||
*/
|
||||
Set<String> findRoleByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据role参数查询角色列表
|
||||
* @param role role
|
||||
* @return list
|
||||
*/
|
||||
List<Role> selectRoles(Role role);
|
||||
|
||||
/**
|
||||
* 根据参数批量更新状态
|
||||
* @param params
|
||||
* @return int
|
||||
*/
|
||||
int updateStatusBatch(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据roleId更新角色信息
|
||||
* @param params
|
||||
* @return int
|
||||
*/
|
||||
int updateByRoleId(Map<String, Object> params);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.nbclass.system.mapper;
|
||||
|
||||
import com.nbclass.system.model.RolePermission;
|
||||
import com.nbclass.util.MyMapper;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface RolePermissionMapper extends MyMapper<RolePermission> {
|
||||
}
|
||||
68
src/main/java/com/nbclass/system/mapper/UserMapper.java
Normal file
68
src/main/java/com/nbclass/system/mapper/UserMapper.java
Normal file
@ -0,0 +1,68 @@
|
||||
package com.nbclass.system.mapper;
|
||||
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface UserMapper extends MyMapper<User> {
|
||||
/**
|
||||
* 根据user参数查询用户列表
|
||||
* @param user
|
||||
* @return list
|
||||
*/
|
||||
List<User> selectUsers(User user);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
* @param username
|
||||
* @return user
|
||||
*/
|
||||
User selectByUsername(String username);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户
|
||||
* @param userId
|
||||
* @return user
|
||||
*/
|
||||
User selectByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 更新最后登录时间
|
||||
* @param user
|
||||
*/
|
||||
void updateLastLoginTime(User user);
|
||||
|
||||
/**
|
||||
* 根据用户id更新用户信息
|
||||
* @param user
|
||||
* @return int
|
||||
*/
|
||||
int updateByUserId(User user);
|
||||
|
||||
/**
|
||||
* 根据参数批量修改用户状态
|
||||
* @param params
|
||||
* @return int
|
||||
*/
|
||||
int updateStatusBatch(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据角色id查询用户list
|
||||
* @param roleId
|
||||
* @return list
|
||||
*/
|
||||
List<User> findByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 根据角色id查询用户list
|
||||
* @param roleIds
|
||||
* @return list
|
||||
*/
|
||||
List<User> findByRoleIds(List<String> roleIds);
|
||||
}
|
||||
13
src/main/java/com/nbclass/system/mapper/UserRoleMapper.java
Normal file
13
src/main/java/com/nbclass/system/mapper/UserRoleMapper.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.nbclass.system.mapper;
|
||||
|
||||
import com.nbclass.system.model.UserRole;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface UserRoleMapper extends MyMapper<UserRole> {
|
||||
}
|
||||
246
src/main/java/com/nbclass/system/model/Permission.java
Normal file
246
src/main/java/com/nbclass/system/model/Permission.java
Normal file
@ -0,0 +1,246 @@
|
||||
package com.nbclass.system.model;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public class Permission implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 权限id
|
||||
*/
|
||||
private String permissionId;
|
||||
|
||||
/**
|
||||
* 权限名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 权限描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 权限访问路径
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
private String perms;
|
||||
|
||||
/**
|
||||
* 父级权限id
|
||||
*/
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* 类型 0:目录 1:菜单 2:按钮
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 状态:1有效; 0无效
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限id
|
||||
*
|
||||
* @return permission_id - 权限id
|
||||
*/
|
||||
public String getPermissionId() {
|
||||
return permissionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置权限id
|
||||
*
|
||||
* @param permissionId 权限id
|
||||
*/
|
||||
public void setPermissionId(String permissionId) {
|
||||
this.permissionId = permissionId == null ? null : permissionId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限名称
|
||||
*
|
||||
* @return name - 权限名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置权限名称
|
||||
*
|
||||
* @param name 权限名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限描述
|
||||
*
|
||||
* @return description - 权限描述
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置权限描述
|
||||
*
|
||||
* @param description 权限描述
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description == null ? null : description.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限访问路径
|
||||
*
|
||||
* @return url - 权限访问路径
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置权限访问路径
|
||||
*
|
||||
* @param url 权限访问路径
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url == null ? null : url.trim();
|
||||
}
|
||||
|
||||
public String getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(String perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父级权限id
|
||||
*
|
||||
* @return parent_id - 父级权限id
|
||||
*/
|
||||
public Integer getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置父级权限id
|
||||
*
|
||||
* @param parentId 父级权限id
|
||||
*/
|
||||
public void setParentId(Integer parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态:1有效;2删除
|
||||
*
|
||||
* @return status - 状态:1有效;2删除
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态:1有效;2删除
|
||||
*
|
||||
* @param status 状态:1有效;2删除
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return create_time
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createTime
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
169
src/main/java/com/nbclass/system/model/Role.java
Normal file
169
src/main/java/com/nbclass/system/model/Role.java
Normal file
@ -0,0 +1,169 @@
|
||||
package com.nbclass.system.model;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public class Role implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态:1有效; 0无效
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色id
|
||||
*
|
||||
* @return role_id - 角色id
|
||||
*/
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色id
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId == null ? null : roleId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色名称
|
||||
*
|
||||
* @return name - 角色名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色名称
|
||||
*
|
||||
* @param name 角色名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色描述
|
||||
*
|
||||
* @return description - 角色描述
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色描述
|
||||
*
|
||||
* @param description 角色描述
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description == null ? null : description.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态:1有效;2删除
|
||||
*
|
||||
* @return status - 状态:1有效;2删除
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态:1有效;2删除
|
||||
*
|
||||
* @param status 状态:1有效;2删除
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取更新时间
|
||||
*
|
||||
* @return update_time - 更新时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置更新时间
|
||||
*
|
||||
* @param updateTime 更新时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
76
src/main/java/com/nbclass/system/model/RolePermission.java
Normal file
76
src/main/java/com/nbclass/system/model/RolePermission.java
Normal file
@ -0,0 +1,76 @@
|
||||
package com.nbclass.system.model;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public class RolePermission implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 权限id
|
||||
*/
|
||||
private String permissionId;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色id
|
||||
*
|
||||
* @return role_id - 角色id
|
||||
*/
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色id
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId == null ? null : roleId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限id
|
||||
*
|
||||
* @return permission_id - 权限id
|
||||
*/
|
||||
public String getPermissionId() {
|
||||
return permissionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置权限id
|
||||
*
|
||||
* @param permissionId 权限id
|
||||
*/
|
||||
public void setPermissionId(String permissionId) {
|
||||
this.permissionId = permissionId == null ? null : permissionId.trim();
|
||||
}
|
||||
}
|
||||
359
src/main/java/com/nbclass/system/model/User.java
Normal file
359
src/main/java/com/nbclass/system/model/User.java
Normal file
@ -0,0 +1,359 @@
|
||||
package com.nbclass.system.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public class User implements Serializable{
|
||||
private static final long serialVersionUID = -8736616045315083846L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 加密盐值
|
||||
*/
|
||||
private String salt;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 联系方式
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 年龄:1男2女
|
||||
*/
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 用户状态:1有效; 0无效
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
* 登录ip
|
||||
*/
|
||||
@Transient
|
||||
private String loginIpAddress;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@Transient
|
||||
private List<Role> roles;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Transient
|
||||
private String rolename;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @return user_id - 用户id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId == null ? null : userId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户名
|
||||
*
|
||||
* @return username - 用户名
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户名
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username == null ? null : username.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password == null ? null : password.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 重写获取盐值方法,自定义realm使用
|
||||
* Gets credentials salt.
|
||||
*
|
||||
* @return the credentials salt
|
||||
*/
|
||||
public String getCredentialsSalt() {
|
||||
return username + "com.github.cnjd" + salt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取加密盐值
|
||||
*
|
||||
* @return salt - 加密盐值
|
||||
*/
|
||||
public String getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置加密盐值
|
||||
*
|
||||
* @param salt 加密盐值
|
||||
*/
|
||||
public void setSalt(String salt) {
|
||||
this.salt = salt == null ? null : salt.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮箱
|
||||
*
|
||||
* @return email - 邮箱
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置邮箱
|
||||
*
|
||||
* @param email 邮箱
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email == null ? null : email.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取联系方式
|
||||
*
|
||||
* @return phone - 联系方式
|
||||
*/
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置联系方式
|
||||
*
|
||||
* @param phone 联系方式
|
||||
*/
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone == null ? null : phone.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年龄:1男2女
|
||||
*
|
||||
* @return sex - 年龄:1男2女
|
||||
*/
|
||||
public Integer getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置年龄:1男2女
|
||||
*
|
||||
* @param sex 年龄:1男2女
|
||||
*/
|
||||
public void setSex(Integer sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年龄
|
||||
*
|
||||
* @return age - 年龄
|
||||
*/
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置年龄
|
||||
*
|
||||
* @param age 年龄
|
||||
*/
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户状态:1有效; 2删除
|
||||
*
|
||||
* @return status - 用户状态:1有效; 2删除
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户状态:1有效; 2删除
|
||||
*
|
||||
* @param status 用户状态:1有效; 2删除
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取更新时间
|
||||
*
|
||||
* @return update_time - 更新时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置更新时间
|
||||
*
|
||||
* @param updateTime 更新时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最后登录时间
|
||||
*
|
||||
* @return last_login_time - 最后登录时间
|
||||
*/
|
||||
public Date getLastLoginTime() {
|
||||
return lastLoginTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最后登录时间
|
||||
*
|
||||
* @param lastLoginTime 最后登录时间
|
||||
*/
|
||||
public void setLastLoginTime(Date lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
|
||||
public String getLoginIpAddress() {
|
||||
return loginIpAddress;
|
||||
}
|
||||
|
||||
public void setLoginIpAddress(String loginIpAddress) {
|
||||
this.loginIpAddress = loginIpAddress;
|
||||
}
|
||||
|
||||
public List<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String getRolename() {
|
||||
return rolename;
|
||||
}
|
||||
|
||||
public void setRolename(String rolename) {
|
||||
this.rolename = rolename;
|
||||
}
|
||||
}
|
||||
76
src/main/java/com/nbclass/system/model/UserRole.java
Normal file
76
src/main/java/com/nbclass/system/model/UserRole.java
Normal file
@ -0,0 +1,76 @@
|
||||
package com.nbclass.system.model;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public class UserRole implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户id
|
||||
*
|
||||
* @return user_id - 用户id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId == null ? null : userId.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色id
|
||||
*
|
||||
* @return role_id - 角色id
|
||||
*/
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色id
|
||||
*
|
||||
* @param roleId 角色id
|
||||
*/
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId == null ? null : roleId.trim();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.nbclass.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.nbclass.system.model.Permission;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface PermissionService {
|
||||
|
||||
/**
|
||||
* 根据用户id查询权限集合
|
||||
* @param userId
|
||||
* @return set
|
||||
*/
|
||||
Set<String> findPermsByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询全部权限
|
||||
* @param status
|
||||
* @return list
|
||||
*/
|
||||
List<Permission> selectAll(Integer status);
|
||||
|
||||
/**
|
||||
* 查询全部菜单
|
||||
* @param status
|
||||
* @return list
|
||||
*/
|
||||
List<Permission> selectAllMenuName(Integer status);
|
||||
|
||||
/**
|
||||
* 根据用户id查询权限集合
|
||||
* @param userId
|
||||
* @return list
|
||||
*/
|
||||
List<Permission> selectMenuByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 插入权限
|
||||
* @param permission
|
||||
* @return int
|
||||
*/
|
||||
int insert(Permission permission);
|
||||
|
||||
/**
|
||||
* 根据权限id更新状态
|
||||
* @param permissionId
|
||||
* @param status
|
||||
* @return int
|
||||
*/
|
||||
int updateStatus(String permissionId, Integer status);
|
||||
|
||||
/**
|
||||
* 根据权限id查询权限
|
||||
* @param permissionId
|
||||
* @return permission
|
||||
*/
|
||||
Permission findByPermissionId(String permissionId);
|
||||
|
||||
/**
|
||||
* 根据id查询权限
|
||||
* @param id
|
||||
* @return permission
|
||||
*/
|
||||
Permission findById(Integer id);
|
||||
|
||||
/**
|
||||
* 更新权限
|
||||
* @param permission
|
||||
* @return int
|
||||
*/
|
||||
int updateByPermissionId(Permission permission);
|
||||
|
||||
/**
|
||||
* 查询子权限条数
|
||||
* @param permissionId
|
||||
* @return int
|
||||
*/
|
||||
int selectSubPermsByPermissionId(String permissionId);
|
||||
}
|
||||
91
src/main/java/com/nbclass/system/service/RoleService.java
Normal file
91
src/main/java/com/nbclass/system/service/RoleService.java
Normal file
@ -0,0 +1,91 @@
|
||||
package com.nbclass.system.service;
|
||||
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.model.Role;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface RoleService {
|
||||
|
||||
/**
|
||||
* 根据用户id查询角色集合
|
||||
* @param userId
|
||||
* @return set
|
||||
*/
|
||||
Set<String> findRoleByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据条件查询角色列表
|
||||
* @param role
|
||||
* @return list
|
||||
*/
|
||||
List<Role> selectRoles(Role role);
|
||||
|
||||
/**
|
||||
* 插入角色
|
||||
* @param role
|
||||
* @return int
|
||||
*/
|
||||
int insert(Role role);
|
||||
|
||||
/**
|
||||
* 批量更新状态
|
||||
* @param roleIds
|
||||
* @param status
|
||||
* @return int
|
||||
*/
|
||||
int updateStatusBatch(List<String> roleIds, Integer status);
|
||||
|
||||
/**
|
||||
* 根据id查询角色
|
||||
* @param id
|
||||
* @return role
|
||||
*/
|
||||
Role findById(Integer id);
|
||||
|
||||
/**
|
||||
* 根据角色id更新角色信息
|
||||
* @param role
|
||||
* @return int
|
||||
*/
|
||||
int updateByRoleId(Role role);
|
||||
|
||||
/**
|
||||
* 根据角色id查询权限集合
|
||||
* @param roleId
|
||||
* @return list
|
||||
*/
|
||||
List<Permission> findPermissionsByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 根据角色id保存分配权限
|
||||
* @param roleId
|
||||
* @param permissionIdsList
|
||||
* @return list
|
||||
*/
|
||||
ResponseVo addAssignPermission(String roleId, List<String> permissionIdsList);
|
||||
|
||||
/**
|
||||
* 根据角色id下的所有用户
|
||||
* @param roleId
|
||||
* @return list
|
||||
*/
|
||||
List<User> findByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 根据角色id下的所有用户
|
||||
* @param roleIds
|
||||
* @return list
|
||||
*/
|
||||
List<User> findByRoleIds(List<String> roleIds);
|
||||
|
||||
|
||||
}
|
||||
95
src/main/java/com/nbclass/system/service/UserService.java
Normal file
95
src/main/java/com/nbclass/system/service/UserService.java
Normal file
@ -0,0 +1,95 @@
|
||||
package com.nbclass.system.service;
|
||||
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.vo.UserOnlineVo;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
public interface UserService {
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
* @param username
|
||||
* @return user
|
||||
*/
|
||||
User selectByUsername(String username);
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
* @param user
|
||||
* @return int
|
||||
*/
|
||||
int register(User user);
|
||||
|
||||
/**
|
||||
* 更新最后登录时间
|
||||
* @param user
|
||||
*/
|
||||
void updateLastLoginTime(User user);
|
||||
|
||||
/**
|
||||
* 根据条件查询用户列表
|
||||
* @param user
|
||||
* @return list
|
||||
*/
|
||||
List<User> selectUsers(User user);
|
||||
|
||||
/**
|
||||
* 根据用户id查询用户
|
||||
* @param userId
|
||||
* @return user
|
||||
*/
|
||||
User selectByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户id更新用户信息
|
||||
* @param user
|
||||
* @return int
|
||||
*/
|
||||
int updateByUserId(User user);
|
||||
|
||||
/**
|
||||
* 根据用户id集合批量更新用户状态
|
||||
* @param userIds
|
||||
* @param status
|
||||
* @return int
|
||||
*/
|
||||
int updateStatusBatch(List<String> userIds, Integer status);
|
||||
|
||||
/**
|
||||
* 根据用户id分配角色集合
|
||||
* @param userId
|
||||
* @param roleIds
|
||||
* @return int
|
||||
*/
|
||||
ResponseVo addAssignRole(String userId, List<String> roleIds);
|
||||
|
||||
/**
|
||||
* 根据主键更新用户信息
|
||||
* @param user
|
||||
* @return int
|
||||
*/
|
||||
int updateUserByPrimaryKey(User user);
|
||||
|
||||
/**
|
||||
* 查询在线用户
|
||||
* @param userOnlineVo
|
||||
* @return list
|
||||
*/
|
||||
List<UserOnlineVo> selectOnlineUsers(UserOnlineVo userOnlineVo);
|
||||
|
||||
/**
|
||||
* 踢出用户
|
||||
* @param sessionId 会话id
|
||||
* @param username 用户名
|
||||
*/
|
||||
void kickout(Serializable sessionId, String username);
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.nbclass.system.service.impl;
|
||||
|
||||
import com.nbclass.system.mapper.PermissionMapper;
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.service.PermissionService;
|
||||
import com.nbclass.util.CoreConst;
|
||||
import com.nbclass.util.UUIDUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Service
|
||||
public class PermissionServiceImpl implements PermissionService {
|
||||
@Autowired
|
||||
private PermissionMapper permissionMapper;
|
||||
|
||||
@Override
|
||||
public Set<String> findPermsByUserId(String userId) {
|
||||
return permissionMapper.findPermsByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> selectAll(Integer status) {
|
||||
return permissionMapper.selectAllPerms(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> selectAllMenuName(Integer status) {
|
||||
return permissionMapper.selectAllMenuName(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> selectMenuByUserId(String userId) {
|
||||
return permissionMapper.selectMenuByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(Permission permission) {
|
||||
Date date = new Date();
|
||||
permission.setPermissionId(UUIDUtil.getUniqueIdByUUId());
|
||||
permission.setStatus(CoreConst.STATUS_VALID);
|
||||
permission.setCreateTime(date);
|
||||
permission.setUpdateTime(date);
|
||||
return permissionMapper.insert(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateStatus(String permissionId,Integer status) {
|
||||
return permissionMapper.updateStatusByPermissionId(permissionId,status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission findByPermissionId(String permissionId) {
|
||||
return permissionMapper.selectByPermissionId(permissionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission findById(Integer id) {
|
||||
Permission permission = new Permission();
|
||||
permission.setId(id);
|
||||
return permissionMapper.selectByPrimaryKey(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByPermissionId(Permission permission) {
|
||||
return permissionMapper.updateByPermissionId(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectSubPermsByPermissionId(String permissionId) {
|
||||
return permissionMapper.selectSubPermsByPermissionId(permissionId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package com.nbclass.system.service.impl;
|
||||
|
||||
import com.nbclass.system.mapper.PermissionMapper;
|
||||
import com.nbclass.system.mapper.RoleMapper;
|
||||
import com.nbclass.system.mapper.RolePermissionMapper;
|
||||
import com.nbclass.system.mapper.UserMapper;
|
||||
import com.nbclass.system.model.Permission;
|
||||
import com.nbclass.system.model.Role;
|
||||
import com.nbclass.system.model.RolePermission;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.system.service.RoleService;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.util.UUIDUtil;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Autowired
|
||||
private RoleMapper roleMapper;
|
||||
@Autowired
|
||||
private PermissionMapper permissionMapper;
|
||||
@Autowired
|
||||
private RolePermissionMapper rolePermissionMapper;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public Set<String> findRoleByUserId(String userId) {
|
||||
return roleMapper.findRoleByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> selectRoles(Role role) {
|
||||
return roleMapper.selectRoles(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(Role role) {
|
||||
role.setRoleId(UUIDUtil.getUniqueIdByUUId());
|
||||
role.setStatus(1);
|
||||
role.setCreateTime(new Date());
|
||||
return roleMapper.insert(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateStatusBatch(List<String> roleIds, Integer status) {
|
||||
Map<String,Object> params = new HashMap<String,Object>(2);
|
||||
params.put("roleIds",roleIds);
|
||||
params.put("status",status);
|
||||
return roleMapper.updateStatusBatch(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role findById(Integer id) {
|
||||
Role role = new Role();
|
||||
role.setId(id);
|
||||
return roleMapper.selectByPrimaryKey(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByRoleId(Role role) {
|
||||
Map<String,Object> params = new HashMap<>(3);
|
||||
params.put("name",role.getName());
|
||||
params.put("description",role.getDescription());
|
||||
params.put("role_id",role.getRoleId());
|
||||
return roleMapper.updateByRoleId(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permission> findPermissionsByRoleId(String roleId) {
|
||||
return permissionMapper.findByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseVo addAssignPermission(String roleId, List<String> permissionIds) {
|
||||
try{
|
||||
RolePermission rolePermission = new RolePermission();
|
||||
rolePermission.setRoleId(roleId);
|
||||
rolePermissionMapper.delete(rolePermission);
|
||||
for(String permissionId : permissionIds){
|
||||
rolePermission.setId(null);
|
||||
rolePermission.setPermissionId(permissionId);
|
||||
rolePermissionMapper.insert(rolePermission);
|
||||
}
|
||||
return ResultUtil.success("分配权限成功");
|
||||
}catch(Exception e){
|
||||
return ResultUtil.error("分配权限失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByRoleId(String roleId) {
|
||||
return userMapper.findByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByRoleIds(List<String> roleIds) {
|
||||
return userMapper.findByRoleIds(roleIds);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,207 @@
|
||||
package com.nbclass.system.service.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.cache.Cache;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.mgt.DefaultSessionKey;
|
||||
import org.apache.shiro.session.mgt.SessionManager;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||
import org.crazycake.shiro.RedisCacheManager;
|
||||
import org.crazycake.shiro.RedisSessionDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nbclass.system.mapper.UserMapper;
|
||||
import com.nbclass.system.mapper.UserRoleMapper;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.system.model.UserRole;
|
||||
import com.nbclass.system.service.UserService;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.vo.UserOnlineVo;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
|
||||
/**
|
||||
* @version V1.0
|
||||
* @date 2018年7月11日
|
||||
* @author superzheng
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisSessionDAO redisSessionDAO;
|
||||
|
||||
@Autowired
|
||||
private SessionManager sessionManager;
|
||||
|
||||
@Autowired
|
||||
private RedisCacheManager redisCacheManager;
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Autowired
|
||||
private UserRoleMapper userRoleMapper;
|
||||
|
||||
@Override
|
||||
public User selectByUsername(String username) {
|
||||
return userMapper.selectByUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int register(User user) {
|
||||
int a = userMapper.insert(user);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLastLoginTime(User user) {
|
||||
userMapper.updateLastLoginTime(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> selectUsers(User user) {
|
||||
return userMapper.selectUsers(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User selectByUserId(String userId) {
|
||||
return userMapper.selectByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByUserId(User user) {
|
||||
return userMapper.updateByUserId(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateStatusBatch(List<String> userIds,Integer status) {
|
||||
Map<String,Object> params = new HashMap<String,Object>(2);
|
||||
params.put("userIds",userIds);
|
||||
params.put("status",status);
|
||||
return userMapper.updateStatusBatch(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseVo addAssignRole(String userId, List<String> roleIds) {
|
||||
try{
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(userId);
|
||||
userRoleMapper.delete(userRole);
|
||||
for(String roleId :roleIds){
|
||||
userRole.setId(null);
|
||||
userRole.setRoleId(roleId);
|
||||
userRoleMapper.insert(userRole);
|
||||
}
|
||||
return ResultUtil.success("分配角色成功");
|
||||
}catch(Exception e){
|
||||
return ResultUtil.error("分配角色失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUserByPrimaryKey(User user) {
|
||||
return userMapper.updateByPrimaryKey(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOnlineVo> selectOnlineUsers(UserOnlineVo userVo) {
|
||||
// 因为我们是用redis实现了shiro的session的Dao,而且是采用了shiro+redis这个插件
|
||||
// 所以从spring容器中获取redisSessionDAO
|
||||
// 来获取session列表.
|
||||
Collection<Session> sessions = redisSessionDAO.getActiveSessions();
|
||||
Iterator<Session> it = sessions.iterator();
|
||||
List<UserOnlineVo> onlineUserList = new ArrayList<UserOnlineVo>();
|
||||
// 遍历session
|
||||
while (it.hasNext()) {
|
||||
// 这是shiro已经存入session的
|
||||
// 现在直接取就是了
|
||||
Session session = it.next();
|
||||
//标记为已提出的不加入在线列表
|
||||
if(session.getAttribute("kickout") != null) {
|
||||
continue;
|
||||
}
|
||||
UserOnlineVo onlineUser = getSessionBo(session);
|
||||
if(onlineUser!=null){
|
||||
/*用户名搜索*/
|
||||
if(StringUtils.isNotBlank(userVo.getUsername())){
|
||||
if(onlineUser.getUsername().contains(userVo.getUsername()) ){
|
||||
onlineUserList.add(onlineUser);
|
||||
}
|
||||
}else{
|
||||
onlineUserList.add(onlineUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlineUserList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickout(Serializable sessionId, String username) {
|
||||
getSessionBysessionId(sessionId).setAttribute("kickout", true);
|
||||
//读取缓存,找到并从队列中移除
|
||||
Cache<String, Deque<Serializable>> cache = redisCacheManager.getCache(redisCacheManager.getKeyPrefix()+username);
|
||||
Deque<Serializable> deques = cache.get(username);
|
||||
for(Serializable deque : deques){
|
||||
if(sessionId.equals(deque)){
|
||||
deques.remove(deque);
|
||||
break;
|
||||
}
|
||||
}
|
||||
cache.put(username,deques);
|
||||
}
|
||||
|
||||
|
||||
private Session getSessionBysessionId(Serializable sessionId){
|
||||
Session kickoutSession = sessionManager.getSession(new DefaultSessionKey(sessionId));
|
||||
return kickoutSession;
|
||||
}
|
||||
|
||||
private UserOnlineVo getSessionBo(Session session){
|
||||
//获取session登录信息。
|
||||
Object obj = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
if(null == obj){
|
||||
return null;
|
||||
}
|
||||
//确保是 SimplePrincipalCollection对象。
|
||||
if(obj instanceof SimplePrincipalCollection){
|
||||
SimplePrincipalCollection spc = (SimplePrincipalCollection)obj;
|
||||
obj = spc.getPrimaryPrincipal();
|
||||
if(null != obj && obj instanceof User){
|
||||
User user = (User) obj;
|
||||
//存储session + user 综合信息
|
||||
UserOnlineVo userBo = new UserOnlineVo();
|
||||
//最后一次和系统交互的时间
|
||||
userBo.setLastAccess(session.getLastAccessTime());
|
||||
//主机的ip地址
|
||||
userBo.setHost(user.getLoginIpAddress());
|
||||
//session ID
|
||||
userBo.setSessionId(session.getId().toString());
|
||||
//最后登录时间
|
||||
userBo.setLastLoginTime(user.getLastLoginTime());
|
||||
//回话到期 ttl(ms)
|
||||
userBo.setTimeout(session.getTimeout());
|
||||
//session创建时间
|
||||
userBo.setStartTime(session.getStartTimestamp());
|
||||
//是否踢出
|
||||
userBo.setSessionStatus(false);
|
||||
/*用户名*/
|
||||
userBo.setUsername(user.getUsername());
|
||||
return userBo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.nbclass.szxgl.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 项目常量
|
||||
* @author Leon
|
||||
* @datetime 2019年4月11日 上午11:22:59
|
||||
*/
|
||||
public class ActivityConstants {
|
||||
|
||||
/**
|
||||
* Cookie Key - Customer用户选择语言
|
||||
*/
|
||||
public static final String cookie_key_customer_lang = "userLanguage";
|
||||
|
||||
/**
|
||||
* Cookie Key - Customer用户ID
|
||||
*/
|
||||
public static final String cookie_key_customer_id = "ck_seedaward_uid";
|
||||
|
||||
|
||||
/**
|
||||
* Session Key - 企业微信授权用户ID
|
||||
*/
|
||||
public static final String session_key_user_id = "sid_qywx_userid";
|
||||
|
||||
/**
|
||||
* 企业微信接口域名
|
||||
*/
|
||||
public static final String qywx_api_domain = "http://wx.szxgl.cn/qywx";
|
||||
|
||||
/**
|
||||
* 企业微信登录应用ID
|
||||
*/
|
||||
public static final int qywx_agentid = 1000019;
|
||||
|
||||
|
||||
private static final List<String> adminUserIds = Arrays.asList(new String[]{"admin", "pangtao"});
|
||||
|
||||
/**
|
||||
* 判断是否是超级管理员
|
||||
* @param loginUserId
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAdmin(String loginUserId){
|
||||
boolean result = false;
|
||||
result = StringUtils.isNotBlank(loginUserId)&&adminUserIds.contains(loginUserId);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.nbclass.szxgl.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import com.nbclass.system.controller.BaseController;
|
||||
|
||||
/**
|
||||
* 入口页面
|
||||
* @author Leon
|
||||
* @datetime 2019年3月31日 下午10:45:57
|
||||
*/
|
||||
@Controller
|
||||
public class PageEntryController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 动态路径,方便测试用
|
||||
* @param filename
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/project/{filename}")
|
||||
public String newspage(@PathVariable("filename") String filename){
|
||||
return "xgl-pages/project/"+filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目列表页面
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/project/list")
|
||||
public String page_projectList(){
|
||||
return "xgl-pages/project/list";
|
||||
}
|
||||
|
||||
/**
|
||||
* 未完成的项目列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/project/unfinished/list")
|
||||
public String page_project_unfinished_list(){
|
||||
return "xgl-pages/project/unfinished/list";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目文档页面
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/project/file/list")
|
||||
public String page_projectFileList(){
|
||||
return "xgl-pages/project/file/list";
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目任务进度页面
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/project/task/list")
|
||||
public String page_projectTaskList(){
|
||||
return "xgl-pages/project/task/list";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 图表页面
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/graphic/index")
|
||||
public String page_graphicIndex(){
|
||||
return "xgl-pages/graphic/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交任务
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/project/add")
|
||||
public String page_projectAdd(ModelMap map){
|
||||
return "xgl-pages/project/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人排名
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/graphic/person")
|
||||
public String person(){
|
||||
return "xgl-pages/graphic/person";
|
||||
}
|
||||
/**
|
||||
* 部门月报表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/mobile/page/graphic/department")
|
||||
public String department(){
|
||||
return "xgl-pages/graphic/department";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
package com.nbclass.szxgl.controller.mobile;
|
||||
|
||||
import com.nbclass.exception.ParameterException;
|
||||
import com.nbclass.system.controller.BaseController;
|
||||
import com.nbclass.szxgl.model.ProjectFiles;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.util.Utility;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.tomcat.util.http.fileupload.FileUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公共文件上传接口
|
||||
* @Author leiyun
|
||||
* @Date 2021/3/11 17:10
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/mobile/api/file")
|
||||
public class FileUploadController extends BaseController {
|
||||
|
||||
// CDN保存目录
|
||||
private static final String upload_dir = "/mnt/cdn/worktile";
|
||||
|
||||
// CDN域名
|
||||
private static final String cdn_domain = "https://cdn.szxgl.cn";
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件接口,支持批量上传
|
||||
* @param files
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public ResponseVo fileUploadTest(@RequestParam(required=false, value="files") MultipartFile[] files, String category){
|
||||
if (null == files || files.length < 1) {
|
||||
throw new ParameterException("请选择文件");
|
||||
}
|
||||
if(StringUtils.isBlank(category)){
|
||||
throw new ParameterException("文件类别不能为空");
|
||||
}
|
||||
category = category.toLowerCase().trim();
|
||||
// 后台限制根目录名,防止前端随意提交
|
||||
if(!Arrays.asList("project_files,attachment".split(",")).contains(category)) {
|
||||
throw new ParameterException("文件类别参数有误");
|
||||
}
|
||||
|
||||
List<ProjectFiles> list = new ArrayList<>();
|
||||
try {
|
||||
for (MultipartFile file : files) {
|
||||
if(file==null || file.isEmpty())continue;
|
||||
String suffix = "", original_name = file.getOriginalFilename();
|
||||
if(StringUtils.isNotBlank(original_name)){
|
||||
suffix = original_name.substring(original_name.lastIndexOf(".")+1);
|
||||
suffix = suffix.toLowerCase();
|
||||
}
|
||||
|
||||
String filePath = upload_dir+"/"+category+"/"+ Utility.getDateFormat(new Date(), "yyyyMM")+"/";
|
||||
String fileName = System.currentTimeMillis()+ "_"+Utility.getRandomCode(5).toLowerCase()+"."+suffix;
|
||||
File dest = new File(filePath + fileName);
|
||||
//if(!dest.getParentFile().exists())dest.getParentFile().mkdirs();
|
||||
FileUtils.forceMkdirParent(dest); // 强制创建父目录
|
||||
dest.createNewFile();
|
||||
file.transferTo(dest);
|
||||
|
||||
filePath = filePath.replace("/mnt/cdn/","");
|
||||
String fileUrl = cdn_domain+"/"+filePath+fileName;
|
||||
ProjectFiles pf = new ProjectFiles();
|
||||
pf.setFileExt(suffix);
|
||||
pf.setFileSize(file.getSize());
|
||||
pf.setOriginalName(original_name);
|
||||
pf.setFilePath(fileUrl);
|
||||
list.add(pf);
|
||||
}
|
||||
|
||||
return ResultUtil.success("上传成功",list);
|
||||
} catch (IOException e) {
|
||||
logger.error("上传文件异常", e);
|
||||
return ResultUtil.error(e.getMessage()!=null ? e.getMessage() :"上传文件失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.nbclass.szxgl.controller.mobile;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nbclass.system.controller.BaseController;
|
||||
import com.nbclass.szxgl.service.GraphicStatisticsService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 图表统计数据
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年5月21日 下午2:07:17
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/mobile/api/graphic")
|
||||
public class GraphicStatisticsController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private GraphicStatisticsService service;
|
||||
|
||||
/**
|
||||
* 获取区域项目数量统计数据 - 饼图
|
||||
*
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
*/
|
||||
@RequestMapping("/getProjectNumDataByPie")
|
||||
@ResponseBody
|
||||
public JSONObject getProjectNumDataByPie(String starttime, String endtime) {
|
||||
if (StringUtils.isNotBlank(starttime) && starttime.length() < 11)
|
||||
starttime = starttime.trim() + " 00:00:00";
|
||||
if (StringUtils.isNotBlank(endtime) && endtime.length() < 11)
|
||||
endtime = endtime.trim() + " 23:59:59";
|
||||
JSONObject obj = service.getProjectNumDataByPie(starttime, endtime);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域项目数量统计数据 - 折线图
|
||||
*
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
*/
|
||||
@RequestMapping("/getProjectNumDataByLine")
|
||||
@ResponseBody
|
||||
public JSONObject getProjectNumDataByLine(String starttime, String endtime) {
|
||||
if (StringUtils.isNotBlank(starttime) && starttime.length() < 11)
|
||||
starttime = starttime.trim() + " 00:00:00";
|
||||
if (StringUtils.isNotBlank(endtime) && endtime.length() < 11)
|
||||
endtime = endtime.trim() + " 23:59:59";
|
||||
JSONObject obj = service.getProjectNumDataByLine(starttime, endtime);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得个人项目数量统计
|
||||
*
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
*/
|
||||
@RequestMapping("/queryPersonProject")
|
||||
@ResponseBody
|
||||
public JSONObject queryPersonProject(String starttime, String endtime,String deptId,String userId) {
|
||||
if (StringUtils.isNotBlank(starttime) && starttime.length() < 11)
|
||||
starttime = starttime.trim() + " 00:00:00";
|
||||
if (StringUtils.isNotBlank(endtime) && endtime.length() < 11)
|
||||
endtime = endtime.trim() + " 23:59:59";
|
||||
JSONObject obj = service.queryPersonProject(starttime, endtime,deptId,userId);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得月报表--折线图
|
||||
*
|
||||
* @param year
|
||||
* @param deptId
|
||||
*/
|
||||
@RequestMapping("/queryMonthProjectLine")
|
||||
@ResponseBody
|
||||
public JSONObject queryMonthProjectLine(String year, String deptId) {
|
||||
JSONObject obj = service.queryMonthProjectLine(year, deptId);
|
||||
return obj;
|
||||
}
|
||||
/**
|
||||
* 获得公司部门列表
|
||||
*/
|
||||
@RequestMapping("/queryDepartmentLable")
|
||||
@ResponseBody
|
||||
public JSONObject queryDepartmentLable() {
|
||||
JSONObject obj = service.queryDepartmentLable();
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,281 @@
|
||||
package com.nbclass.szxgl.controller.mobile;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.nbclass.system.controller.BaseController;
|
||||
import com.nbclass.szxgl.model.ListType;
|
||||
import com.nbclass.szxgl.model.Project;
|
||||
import com.nbclass.szxgl.model.ProjectFiles;
|
||||
import com.nbclass.szxgl.service.ProjectClientService;
|
||||
import com.nbclass.szxgl.service.ProjectService;
|
||||
import com.nbclass.util.MemoryCacheUtil;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.vo.base.PageResultVo;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年4月24日 下午4:27:39
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/mobile/api/project")
|
||||
public class ProjectController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ProjectService service;
|
||||
|
||||
@Resource
|
||||
private ProjectClientService projectClientService;
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目列表
|
||||
*
|
||||
* @param entity
|
||||
* @param limit 每页数量
|
||||
* @param offset 页码
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getList")
|
||||
@ResponseBody
|
||||
public PageResultVo getList(Project entity, String userIds, @RequestParam(defaultValue = "10") Integer limit,
|
||||
@RequestParam(defaultValue = "1") Integer offset) {
|
||||
if (StringUtils.isNotBlank(entity.getDeptId())) { // 根据部门id查询,查询出所有部门/子部门成员id
|
||||
// 注意,分页查询中,子查询不能在PageHelper.startPage内,否则分页会失效,service.getList会返回所有数据
|
||||
entity.setDeptUserIds(service.selectUserIdsByDeptId(entity.getDeptId()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(userIds)) { // 根据成员id查询,把id全部到到DeptUserIds内
|
||||
List<String> deptUserIds = null;
|
||||
if(entity.getDeptUserIds()!=null) {
|
||||
//AbstractList中的add方法系统并没有给我们默认实现,而是直接抛出java.lang.UnsupportedOperationException,需要强行转化
|
||||
//使用ArrayList( java.util.ArrayList)的构造方法去创建
|
||||
deptUserIds = new ArrayList<>(entity.getDeptUserIds());
|
||||
}
|
||||
// logger.info("从数据库查询部门用户信息:"+ JSON.toJSONString(deptUserIds));
|
||||
if(deptUserIds==null)deptUserIds=new ArrayList<>();
|
||||
deptUserIds.addAll(Arrays.asList(userIds.split(",")));
|
||||
// logger.info("最终保存用户信息:"+JSON.toJSONString(deptUserIds));
|
||||
entity.setDeptUserIds(deptUserIds);
|
||||
}
|
||||
|
||||
PageHelper.startPage(offset, limit);
|
||||
List<Project> list = service.getList(entity);
|
||||
if(list!=null && !list.isEmpty()){
|
||||
String loginId = StringUtils.trimToEmpty(getLoginUserIdStr());
|
||||
for (Project p : list) {
|
||||
boolean allowModify = (p!=null && p.getStatus()!=null && p.getStatus()!=0); // 0为作废状态,不给修改
|
||||
if(allowModify && p!=null && StringUtils.isNotBlank(p.getFzrIds())){
|
||||
List<String> fzrIds = Arrays.asList(p.getFzrIds().split(","));
|
||||
allowModify = StringUtils.equals(loginId, p.getCreateUserId()) || fzrIds.contains(loginId);
|
||||
}
|
||||
p.setAllowModify(allowModify);
|
||||
}
|
||||
}
|
||||
PageInfo<Project> pages = new PageInfo<>(list, limit);
|
||||
return ResultUtil.table(list, pages.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询项目详情记录
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@RequestMapping("/findById")
|
||||
@ResponseBody
|
||||
public ResponseVo findById(String id) {
|
||||
JSONObject obj = service.findById(id);
|
||||
return ResultUtil.success(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目任务列表
|
||||
*
|
||||
* @param pid
|
||||
* @param limit
|
||||
* @param offset
|
||||
*/
|
||||
/*
|
||||
@RequestMapping("/task/getList")
|
||||
@ResponseBody
|
||||
public void selectProjectTaskList(String pid, @RequestParam(defaultValue = "100") Integer limit,
|
||||
@RequestParam(defaultValue = "1") Integer offset) {
|
||||
PageHelper.startPage(PageUtil.getPageNo(limit, offset), limit);
|
||||
List<ProjectTask> list = service.getTaskList(pid);
|
||||
PageInfo<ProjectTask> pages = new PageInfo<>(list);
|
||||
JSONObject obj = new JSONObject();
|
||||
JSONObject pageObj = toJSON(ResultUtil.table(list, pages.getTotal()));
|
||||
obj.putAll(pageObj);
|
||||
boolean allowModify = service.hasPowerForTask(pid);
|
||||
obj.put("allowModify", allowModify);
|
||||
outPrint(obj);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取项目任务进度日志列表
|
||||
*
|
||||
* @param taskId
|
||||
*/
|
||||
/*
|
||||
@RequestMapping("/task/journal/getList")
|
||||
@ResponseBody
|
||||
public void selectProjectTaskJournalList(String taskId) {
|
||||
List<ProjectTaskJournal> list = service.getTaskJournalList(taskId);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("rows", list);
|
||||
outPrint(obj);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取select枚举列表 -- 用于移动端查询地区列表
|
||||
* @param listType 地域列表:333
|
||||
*/
|
||||
@RequestMapping("/getListValues")
|
||||
@ResponseBody
|
||||
public JSONObject selectListValues(String listType) {
|
||||
List<ListType> list = service.getListValues(listType);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("ret", 0);
|
||||
obj.put("rows", list);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加项目
|
||||
*
|
||||
* @param p
|
||||
* @param errors
|
||||
* @param isSendMsg
|
||||
* @param deptIds
|
||||
* @return
|
||||
*/
|
||||
|
||||
@RequestMapping("add")
|
||||
@ResponseBody
|
||||
public ResponseVo add(@Valid Project p, Errors errors, Integer isSendMsg, String[] deptIds, String filesList) {
|
||||
if (errors.hasErrors()) {
|
||||
return ResultUtil.error ("参数验证失败");
|
||||
}
|
||||
List<ProjectFiles> projectFiles = null;
|
||||
if(StringUtils.isNotBlank(filesList)) {
|
||||
filesList = filesList.replaceAll(" ", "");
|
||||
projectFiles = JSONArray.parseArray(filesList, ProjectFiles.class);
|
||||
}
|
||||
String projectId = service.addProject(p, isSendMsg, deptIds, projectFiles);
|
||||
return ResultUtil.success("success", projectId);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*
|
||||
* @param p
|
||||
* @param errors
|
||||
* @param isSendMsg
|
||||
* @param deptIds
|
||||
*/
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public ResponseVo update(@Valid Project p, Errors errors, Integer isSendMsg, String[] deptIds, String filesList) {
|
||||
if (errors.hasErrors()) {
|
||||
return ResultUtil.error ("参数验证失败");
|
||||
}
|
||||
List<ProjectFiles> projectFiles = null;
|
||||
if(StringUtils.isNotBlank(filesList)) {
|
||||
filesList = filesList.replaceAll(" ", "");
|
||||
projectFiles = JSONArray.parseArray(filesList, ProjectFiles.class);
|
||||
}
|
||||
service.updateProject(p, isSendMsg, deptIds, projectFiles);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
* @param ids
|
||||
*/
|
||||
@RequestMapping("del")
|
||||
@ResponseBody
|
||||
public ResponseVo delete(String[] ids) {
|
||||
service.deleteProject(ids);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过userid查询上级用户,包括负责人和抄送人
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("selectLeaderUsers")
|
||||
@ResponseBody
|
||||
public ResponseVo selectLeaderUsers(String userIds, String isZxrIds) {
|
||||
JSONObject obj = new JSONObject();
|
||||
if("true".equals(StringUtils.trimToEmpty(isZxrIds))) {
|
||||
List<Map<String, Object>> zxrMap = service.selectZxrUserObj(userIds);
|
||||
obj.put("zxrData",zxrMap);
|
||||
} else {
|
||||
JSONArray csrMap = service.selectLeaderUserObj(userIds, true); // 抄送人查询出所有上级
|
||||
// JSONArray fzrMap = service.selectLeaderUserObj(userIds, false); // 负责人只查询选择用户的上级
|
||||
// obj.put("fzrData", fzrMap); // 负责人数据。 后面改成负责人不自动添加上级,选择谁就是谁
|
||||
obj.put("csrData", csrMap); // 抄送人数据
|
||||
}
|
||||
return ResultUtil.success(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户单位列表
|
||||
*/
|
||||
@RequestMapping("getCustomerList")
|
||||
@ResponseBody
|
||||
public ResponseVo getCustomerList() {
|
||||
JSONArray array = MemoryCacheUtil.getT("api_customer_list");
|
||||
if(array == null || array.isEmpty()){
|
||||
array = projectClientService.getTreeList();
|
||||
MemoryCacheUtil.set("api_customer_list", array, 1000*60*3); // 缓存三分钟
|
||||
}
|
||||
return ResultUtil.success("success",array);
|
||||
}
|
||||
|
||||
/**findProductById
|
||||
* 获取负责人区域列表
|
||||
*/
|
||||
@RequestMapping("queryArea")
|
||||
@ResponseBody
|
||||
public ResponseVo queryArea(String userIds) {
|
||||
Map<String, Set<String>> stringSetMap = service.selectCityByUserIds(userIds);
|
||||
return ResultUtil.success("success", stringSetMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新项目状态
|
||||
*/
|
||||
@RequestMapping("updateStatus")
|
||||
@ResponseBody
|
||||
public ResponseVo updateProjectStatus(String id, String contractno, String status) {
|
||||
service.updateProjectStatus(id, contractno, status);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,198 @@
|
||||
package com.nbclass.szxgl.controller.mobile;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.nbclass.exception.ParameterException;
|
||||
import com.nbclass.holder.SpringContextHolder;
|
||||
import com.nbclass.system.controller.BaseController;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.szxgl.model.ProjectTask;
|
||||
import com.nbclass.szxgl.model.ProjectTaskJournal;
|
||||
import com.nbclass.szxgl.service.ProjectService;
|
||||
import com.nbclass.szxgl.service.ProjectTaskService;
|
||||
import com.nbclass.util.PageUtil;
|
||||
import com.nbclass.util.ResultUtil;
|
||||
import com.nbclass.vo.base.ResponseVo;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author wangweifeng
|
||||
* @version 1.0 2021/3/15
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/mobile/api/projectTask")
|
||||
public class ProjectTaskController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ProjectService service;
|
||||
|
||||
@Resource
|
||||
private ProjectTaskService projectTaskService;
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目任务列表
|
||||
*
|
||||
* @param pid
|
||||
* @param limit
|
||||
* @param offset
|
||||
*/
|
||||
@RequestMapping("/getList")
|
||||
@ResponseBody
|
||||
public ResponseVo selectProjectTaskList(String pid, String userId,
|
||||
@RequestParam(defaultValue = "100") Integer limit, @RequestParam(defaultValue = "1") Integer offset) {
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
if(user==null && SpringContextHolder.isProd()) {
|
||||
throw new ParameterException("登录失效,请重新登录!");
|
||||
}
|
||||
|
||||
PageHelper.startPage(PageUtil.getPageNo(limit, offset), limit);
|
||||
List<ProjectTask> list = service.getTaskList(pid);
|
||||
PageInfo<ProjectTask> pages = new PageInfo<>(list);
|
||||
JSONObject obj = new JSONObject();
|
||||
JSONObject pageObj = toJSON(ResultUtil.table(list, pages.getTotal()));
|
||||
obj.putAll(pageObj);
|
||||
boolean allowModify = service.hasPowerForTask(pid);
|
||||
obj.put("allowModify", allowModify);
|
||||
|
||||
obj.put("userId", user == null ? userId : user.getUserId());
|
||||
return ResultUtil.success("success", obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目任务进度日志列表
|
||||
*
|
||||
* @param taskId
|
||||
*/
|
||||
@RequestMapping("/journal/getList")
|
||||
@ResponseBody
|
||||
public ResponseVo selectProjectTaskJournalList(String taskId) {
|
||||
List<ProjectTaskJournal> list = service.getTaskJournalList(taskId);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("rows", list);
|
||||
return ResultUtil.success("success", obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
@RequestMapping("del")
|
||||
@ResponseBody
|
||||
public ResponseVo delete(String projectId, String[] ids) {
|
||||
projectTaskService.deleteProjectTask(projectId, ids);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加项目任务
|
||||
*
|
||||
* @param t
|
||||
* @param errors
|
||||
* @param isSendMsg
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
|
||||
@RequestMapping("add")
|
||||
@ResponseBody
|
||||
public ResponseVo add(@Valid ProjectTask t, Errors errors, Integer isSendMsg, String[] userIds) {
|
||||
if (errors.hasErrors()) {
|
||||
return ResultUtil.error("参数验证失败");
|
||||
}
|
||||
projectTaskService.addProjectTask(t, isSendMsg, userIds);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目任务
|
||||
*
|
||||
* @param t
|
||||
* @param errors
|
||||
* @param isSendMsg
|
||||
* @param userIds
|
||||
*/
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public ResponseVo update(@Valid ProjectTask t, Errors errors, Integer isSendMsg, String[] userIds) {
|
||||
|
||||
if (errors.hasErrors()) {
|
||||
return ResultUtil.error("参数验证失败");
|
||||
}
|
||||
projectTaskService.updateProjectTask(t, isSendMsg, userIds);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询我的任务列表
|
||||
*
|
||||
* @param limit
|
||||
* @param offset
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myTask/query")
|
||||
@ResponseBody
|
||||
public ResponseVo selectMyTaskList(@RequestParam(defaultValue = "10") Integer limit,
|
||||
@RequestParam(defaultValue = "1") Integer offset, String userid) {
|
||||
PageHelper.startPage(offset, limit);
|
||||
//正式环境不用传用户id
|
||||
if (userid == null) {
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
if (user != null) {
|
||||
List<Map> list = projectTaskService.selectMyTaskList(user.getUserId());
|
||||
PageInfo<Map> pages = new PageInfo<>(list, limit);
|
||||
return ResultUtil.success("success", pages);
|
||||
|
||||
} else {
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
} else {
|
||||
List<Map> list = projectTaskService.selectMyTaskList(userid);
|
||||
PageInfo<Map> pages = new PageInfo<>(list, limit);
|
||||
return ResultUtil.success("success", pages);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加任务进度日志
|
||||
*
|
||||
* @param j
|
||||
* @param errors
|
||||
* @param speed
|
||||
*/
|
||||
@RequestMapping("/myTask/addJournal")
|
||||
@ResponseBody
|
||||
public ResponseVo addJournal(@Valid ProjectTaskJournal j,Errors errors,short speed) {
|
||||
|
||||
if (errors.hasErrors()) {
|
||||
return ResultUtil.error("参数验证失败");
|
||||
}
|
||||
projectTaskService.addProjectTaskJournal(j, speed);
|
||||
return ResultUtil.success("success");
|
||||
}
|
||||
}
|
||||
155
src/main/java/com/nbclass/szxgl/filter/WxWorkFilter.java
Normal file
155
src/main/java/com/nbclass/szxgl/filter/WxWorkFilter.java
Normal file
@ -0,0 +1,155 @@
|
||||
package com.nbclass.szxgl.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nbclass.shiro.config.MyUsernamePasswordToken;
|
||||
import com.nbclass.szxgl.constant.ActivityConstants;
|
||||
import com.nbclass.util.CommonUtils;
|
||||
import com.nbclass.util.HttpUtils;
|
||||
|
||||
/**
|
||||
* 企业微信OA页面授权
|
||||
* @author Leon
|
||||
* @datetime 2019年4月23日 下午3:01:57
|
||||
*/
|
||||
/*@WebFilter("*.html")*/
|
||||
public class WxWorkFilter implements Filter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(WxWorkFilter.class);
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setHeader("Cache-Control", "no-store");
|
||||
|
||||
String httpRequestFullURL = getHttpRequestFullURL(request);
|
||||
String redirect_uri = ActivityConstants.qywx_api_domain + "/api/oauth?agentid="+ActivityConstants.qywx_agentid+"&redirect_uri="+httpRequestFullURL;
|
||||
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
|
||||
// String userkey = (String) request.getSession().getAttribute(ActivityConstants.session_key_user_id);
|
||||
// logger.info("[企业微信授权拦截器] userkey="+userkey+", requrl: "+httpRequestFullURL);
|
||||
|
||||
if(subject.isAuthenticated()){ // 已登录状态
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
String key = StringUtils.trimToEmpty(request.getParameter("key"));
|
||||
if("xglgg".equals(key)){ // 测试时传key绕过登录
|
||||
MyUsernamePasswordToken token = new MyUsernamePasswordToken("liixi"); // 免密登录
|
||||
token.setRememberMe(true);
|
||||
try {
|
||||
subject.login(token);
|
||||
} catch (AuthenticationException e) {
|
||||
outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
|
||||
return;
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String code = request.getParameter("code");
|
||||
if(StringUtils.isBlank(code)){
|
||||
response.sendRedirect(redirect_uri);
|
||||
return;
|
||||
}
|
||||
|
||||
String url = ActivityConstants.qywx_api_domain + "/api/oauthInfo?agentid="+ActivityConstants.qywx_agentid+"&code=" + code;
|
||||
JSONObject result = HttpUtils.httpGet(url);
|
||||
if(result != null && result.getIntValue("ret") == 0 && StringUtils.isNotBlank(result.getString("userid"))
|
||||
&& !"null".equalsIgnoreCase(result.getString("userid"))){
|
||||
logger.info("企业微信授权获取到用户信息: "+result.toString());
|
||||
String userid = result.getString("userid");
|
||||
request.getSession().setAttribute(ActivityConstants.session_key_user_id, userid);
|
||||
|
||||
// OA系统shiro登录
|
||||
MyUsernamePasswordToken token = new MyUsernamePasswordToken(userid); // 免密登录
|
||||
token.setRememberMe(true);
|
||||
try {
|
||||
subject.login(token);
|
||||
} catch (AuthenticationException e) {
|
||||
outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
if(result!=null && (result.getIntValue("errcode") == 40029 || result.getIntValue("errcode") == 40163)){
|
||||
logger.info("授权失败, 将重新跳转到微信授权, RedirectURL : " + redirect_uri);
|
||||
redirect_uri = CommonUtils.removeParamValue(redirect_uri, "code");
|
||||
response.sendRedirect(redirect_uri);
|
||||
return;
|
||||
}
|
||||
outPrintError(response, "微信授权失败,你可能未关注该企业号,请关注后重试!");
|
||||
return;
|
||||
}
|
||||
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
public static String getHttpRequestFullURL(HttpServletRequest request) {
|
||||
StringBuffer requestURL = request.getRequestURL();
|
||||
String queryString = request.getQueryString();
|
||||
if (queryString == null) {
|
||||
return requestURL.toString();
|
||||
} else {
|
||||
return requestURL.append('?').append(queryString).toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出错误信息到页面
|
||||
* @param response
|
||||
* @param result
|
||||
*/
|
||||
public void outPrintError(HttpServletResponse response, String result) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
String html = "<!DOCTYPE html><html><head>";
|
||||
html += "<title>授权失败</title>";
|
||||
html += "<meta charset=\"utf-8\">";
|
||||
html += "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1\">";
|
||||
html += "</head><body>";
|
||||
html+="<center><div style=\"width:85%; text-align:center; font-size: 18px; line-height:35px; color: red;\">";
|
||||
html += result;
|
||||
html+="</div></center></body></html>";
|
||||
out = response.getWriter();
|
||||
out.print(html);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("IO工作流出现异常!");
|
||||
} finally {
|
||||
if(out!=null){
|
||||
out.close();
|
||||
out = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface GraphicStatisticsMapper {
|
||||
|
||||
/**
|
||||
* 获取区域项目数量统计数据 - 饼图
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getProjectNumDataByPie(@Param("starttime")String starttime, @Param("endtime")String endtime, @Param("username")String username);
|
||||
|
||||
/**
|
||||
* 获取区域项目数量统计数据 - 折线图
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getProjectNumDataByLine(@Param("starttime")String starttime, @Param("endtime")String endtime, @Param("username")String username);
|
||||
/**
|
||||
* 获得个人项目数量统计
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> queryPersonProject(@Param("starttime")String starttime, @Param("endtime")String endtime, @Param("deptId")String deptId, @Param("userId")String userId);
|
||||
/**
|
||||
* 获得项目月度统计
|
||||
* @param year
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public List<Map> queryMonthProjectLine(@Param("year")String year, @Param("deptId")String deptId);
|
||||
/**
|
||||
* 获得公司部门列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map> queryDepartmentLable();
|
||||
}
|
||||
18
src/main/java/com/nbclass/szxgl/mapper/ListTypeMapper.java
Normal file
18
src/main/java/com/nbclass/szxgl/mapper/ListTypeMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nbclass.szxgl.model.ListType;
|
||||
import com.nbclass.szxgl.model.ProjectFiles;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface ListTypeMapper extends MyMapper<ListType> {
|
||||
|
||||
public List<ListType> getList(@Param("listType")String listType);
|
||||
|
||||
public String getListValue(@Param("listType")String listType,@Param("id")String id);
|
||||
|
||||
public String getAreaIdByName(@Param("areaName")String areaName);
|
||||
}
|
||||
10
src/main/java/com/nbclass/szxgl/mapper/PerMsgMapper.java
Normal file
10
src/main/java/com/nbclass/szxgl/mapper/PerMsgMapper.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.PerMsg;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface PerMsgMapper extends MyMapper<PerMsg> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectCity;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
/**
|
||||
* @author wangweifeng
|
||||
* @version 1.0 2021/3/13
|
||||
*/
|
||||
public interface ProjectCityMapper extends MyMapper<ProjectCity> {
|
||||
|
||||
void deleteByProjectId(String projectId);
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectClient;
|
||||
import com.nbclass.util.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectClientMapper extends MyMapper<ProjectClient> {
|
||||
|
||||
/**
|
||||
* 查询树形结构数据列表
|
||||
* @return
|
||||
*/
|
||||
List<ProjectClient> getTreeList(@Param("ParentId")String ParentId);
|
||||
|
||||
/**
|
||||
* 通过ID查询名称
|
||||
* @param Id
|
||||
* @return
|
||||
*/
|
||||
ProjectClient getNameById(@Param("Id")String Id);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectFiles;
|
||||
import com.nbclass.util.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectFilesMapper extends MyMapper<ProjectFiles> {
|
||||
|
||||
List<ProjectFiles> getList(@Param("pid")String pid);
|
||||
|
||||
void deleteByProjectId(String projectId);
|
||||
}
|
||||
41
src/main/java/com/nbclass/szxgl/mapper/ProjectMapper.java
Normal file
41
src/main/java/com/nbclass/szxgl/mapper/ProjectMapper.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nbclass.szxgl.model.Project;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface ProjectMapper extends MyMapper<Project> {
|
||||
|
||||
public List<Project> getList(Project project);
|
||||
|
||||
public Project findById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门ID,递归查询所有子部门ID
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public String queryDeptIdsByDeptId(String deptId);
|
||||
|
||||
/**
|
||||
* 根据部门IDs查询所有用户ID
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public String queryUserIdsByDeptIds(List<Integer> list);
|
||||
|
||||
public List<Map> findProductById(String id);
|
||||
|
||||
/**
|
||||
* 根据项目id,更新状态
|
||||
* @param id
|
||||
* @param contractno
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
public void updateProjectStatus(String id, String contractno, int status);
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectTaskJournalComment;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface ProjectTaskJournalCommentMapper extends MyMapper<ProjectTaskJournalComment> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectTaskJournal;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface ProjectTaskJournalMapper extends MyMapper<ProjectTaskJournal> {
|
||||
|
||||
/**
|
||||
* 根据任务id获取任务日志进度列表
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectTaskJournal> getList(String taskId);
|
||||
|
||||
public void deleteByTaskId(String projectTaskId);
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectTask;
|
||||
import com.nbclass.util.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ProjectTaskMapper extends MyMapper<ProjectTask> {
|
||||
|
||||
/**
|
||||
* 查询项目任务列表
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectTask> getList(@Param("pid")String pid);
|
||||
|
||||
public ProjectTask findById(String id);
|
||||
|
||||
public ProjectTask findByProjectId(String projectId);
|
||||
|
||||
public void deleteByProjectId(String projectId);
|
||||
|
||||
public List<String> getProjectTaskIds(String projectId);
|
||||
|
||||
public List<Map> getMyTaskList(String userid);
|
||||
|
||||
public void updateTaskSpeed(String id, int speed);
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectTaskUser;
|
||||
import com.nbclass.util.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectTaskUserMapper extends MyMapper<ProjectTaskUser> {
|
||||
|
||||
/**
|
||||
* 查询用户是否是项目任务执行人
|
||||
* @param taskId
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public Integer selectProjectTaskUser(@Param("taskId")String taskId, @Param("userid")String userid);
|
||||
|
||||
public void deleteByTaskId(String projectTaskId);
|
||||
|
||||
public void deleteByProjectId(String projectId);
|
||||
|
||||
/**
|
||||
* 通过项目任务id去查询项目任务关联人的列表
|
||||
* @param projectTaskId
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectTaskUser> selectProjectTaskUserList(@Param("projectTaskId")String projectTaskId);
|
||||
|
||||
/**
|
||||
* 插入或者新增项目任务关联人
|
||||
* @param id
|
||||
* @param projectId
|
||||
* @param projectTaskId
|
||||
* @param userId
|
||||
* @param updateTime
|
||||
* @param createTime
|
||||
*/
|
||||
public void insertOrUpdate(@Param("id")String id, @Param("projectId")String projectId, @Param("projectTaskId")String projectTaskId, @Param("userId")String userId, @Param("updateTime") Date updateTime, @Param("createTime")Date createTime);
|
||||
|
||||
public List<String> selectUserIds(@Param("projectTaskId") String projectTaskId);
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectUser;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface ProjectUserMapper extends MyMapper<ProjectUser> {
|
||||
|
||||
/**
|
||||
* 查询用户是否是项目负责人
|
||||
* @param pid
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public Integer selectProjectUser(@Param("pid")String pid, @Param("username")String username);
|
||||
/**
|
||||
* 通过项目id去查询项目关联人的列表
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectUser> selectProjectUserList(@Param("projectId")String projectId);
|
||||
|
||||
/**
|
||||
* 插入或者新增项目关联人
|
||||
* @param projectId
|
||||
* @param type
|
||||
* @param tableId
|
||||
* @param updateTime
|
||||
*/
|
||||
public void insertOrUpdate(@Param("id")String id,@Param("projectId")String projectId,@Param("type")Byte type, @Param("tableId")String tableId, @Param("updateTime")Date updateTime, @Param("createTime")Date createTime);
|
||||
|
||||
public void deleteByProjectId(String projectId);
|
||||
}
|
||||
13
src/main/java/com/nbclass/szxgl/mapper/QywxPartyMapper.java
Normal file
13
src/main/java/com/nbclass/szxgl/mapper/QywxPartyMapper.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nbclass.szxgl.model.QywxParty;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface QywxPartyMapper extends MyMapper<QywxParty> {
|
||||
|
||||
public List<Map<String,Object>> findAll();
|
||||
|
||||
}
|
||||
28
src/main/java/com/nbclass/szxgl/mapper/QywxUserMapper.java
Normal file
28
src/main/java/com/nbclass/szxgl/mapper/QywxUserMapper.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nbclass.szxgl.model.QywxUser;
|
||||
import com.nbclass.util.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface QywxUserMapper extends MyMapper<QywxUser> {
|
||||
|
||||
|
||||
List<Map<String, Object>> findByUserId(String userId);
|
||||
|
||||
List<Map<String, Object>> findAllByDepartment(String depId);
|
||||
|
||||
List<Map<String, Object>> findByDepartment(String depId);
|
||||
|
||||
List<Map<String, Object>> findSuperiorLeadersByDepartment(String depId);
|
||||
|
||||
/**
|
||||
* 通过用户id查出用户姓名和头像
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getUserInfoByUserIds(@Param("userIds") List<String> userIds);
|
||||
|
||||
}
|
||||
14
src/main/java/com/nbclass/szxgl/mapper/SyUsersMapper.java
Normal file
14
src/main/java/com/nbclass/szxgl/mapper/SyUsersMapper.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.nbclass.szxgl.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nbclass.szxgl.model.SyUsers;
|
||||
import com.nbclass.util.MyMapper;
|
||||
|
||||
public interface SyUsersMapper extends MyMapper<SyUsers> {
|
||||
|
||||
public SyUsers findByUserName(String userName);
|
||||
|
||||
public List<String> findIdByDeptId(String deptId);
|
||||
}
|
||||
42
src/main/java/com/nbclass/szxgl/model/FileList.java
Normal file
42
src/main/java/com/nbclass/szxgl/model/FileList.java
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @Project: jxoa
|
||||
* @Title: FileList.java
|
||||
* @Package com.oa.commons.model
|
||||
* @date 2013-5-31 下午4:05:37
|
||||
* @Copyright: 2013
|
||||
*/
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
*
|
||||
* 类名:FileList
|
||||
* 功能:多文件上传模型
|
||||
* 详细:单文件接收:@RequestParam MultipartFile file
|
||||
* 多文件接收:FileList files
|
||||
* 作者:LiuJincheng
|
||||
* 版本:1.0
|
||||
* 日期:2013-5-31 下午4:05:37
|
||||
*
|
||||
*/
|
||||
public class FileList {
|
||||
/**
|
||||
* 上传文件集合
|
||||
*/
|
||||
List<MultipartFile> file;
|
||||
|
||||
|
||||
public List<MultipartFile> getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(List<MultipartFile> file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
56
src/main/java/com/nbclass/szxgl/model/ListType.java
Normal file
56
src/main/java/com/nbclass/szxgl/model/ListType.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Table(name = "list_values")
|
||||
public class ListType {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Column(name = "list_type")
|
||||
private String listType;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Column(name = "list_value")
|
||||
private String listValue;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getListType() {
|
||||
return listType;
|
||||
}
|
||||
|
||||
public void setListType(String listType) {
|
||||
this.listType = listType;
|
||||
}
|
||||
|
||||
public String getListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public void setListValue(String listValue) {
|
||||
this.listValue = listValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
90
src/main/java/com/nbclass/szxgl/model/PerMsg.java
Normal file
90
src/main/java/com/nbclass/szxgl/model/PerMsg.java
Normal file
@ -0,0 +1,90 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "per_msg")
|
||||
public class PerMsg {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@Column(name = "msg_type")
|
||||
private Byte msgType;
|
||||
|
||||
/**
|
||||
* 关联表id
|
||||
*/
|
||||
@Column(name = "table_id")
|
||||
private String tableId;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@Column(name = "msg_time")
|
||||
private Date msgTime;
|
||||
|
||||
/**
|
||||
* 消息读取状态,1:已读,0:未读
|
||||
*/
|
||||
@Column(name = "read_state")
|
||||
private int readState;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Byte getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(Byte msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
public void setTableId(String tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
public Date getMsgTime() {
|
||||
return msgTime;
|
||||
}
|
||||
|
||||
public void setMsgTime(Date msgTime) {
|
||||
this.msgTime = msgTime;
|
||||
}
|
||||
|
||||
public int getReadState() {
|
||||
return readState;
|
||||
}
|
||||
|
||||
public void setReadState(int readState) {
|
||||
this.readState = readState;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
463
src/main/java/com/nbclass/szxgl/model/Project.java
Normal file
463
src/main/java/com/nbclass/szxgl/model/Project.java
Normal file
@ -0,0 +1,463 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Transient;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Project {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message="项目名称不能为空")
|
||||
@Length(min=1, max=100, message="项目名称长度限制在1-100")
|
||||
@Column(name = "_name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 项目类型
|
||||
*/
|
||||
// @NotEmpty(message="项目类型不能为空")
|
||||
@Column(name = "_type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 重要程度
|
||||
*/
|
||||
// @NotEmpty(message="项目重要程度不能为空")
|
||||
@Column(name = "_importance")
|
||||
private String importance;
|
||||
|
||||
/**
|
||||
* 项目地区
|
||||
*/
|
||||
@NotEmpty(message="项目地区不能为空")
|
||||
@Column(name = "_area")
|
||||
private String area;
|
||||
|
||||
/**
|
||||
* 状态,0:未开始,1:运行中,2:暂停,3:结束
|
||||
*/
|
||||
@Column(name = "_status")
|
||||
private Byte status;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@NotNull(message="开始时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Column(name = "_start_time")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@NotNull(message="结束时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Column(name = "_end_time")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column(name = "_create_user_id")
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Column(name = "_create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(name = "_update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否发送微信通知,0:未通知
|
||||
*/
|
||||
@Column(name = "_notify")
|
||||
private Short notify;
|
||||
|
||||
/**
|
||||
* 客户接口人姓名+联系方式
|
||||
*/
|
||||
@Column(name = "_customer")
|
||||
private String customer;
|
||||
|
||||
/**
|
||||
* 合同编号
|
||||
*/
|
||||
// @NotEmpty(message="合同编号不能为空")
|
||||
// @Length(min=1, max=30, message="合同编号长度限制在1-30")
|
||||
@Column(name = "_contractno")
|
||||
private String contractno;
|
||||
|
||||
/**
|
||||
* 项目内容
|
||||
*/
|
||||
@Column(name = "_content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 客户单位表id
|
||||
*/
|
||||
@Column(name = "_project_client_id")
|
||||
private String projectClientId;
|
||||
|
||||
/**
|
||||
* 客户单位数组
|
||||
*/
|
||||
@Column(name = "_project_clien_array")
|
||||
private String projectClienArray;
|
||||
|
||||
// 以下是查询字段
|
||||
|
||||
/**
|
||||
* 是否是管理员, 值为Y或N
|
||||
*/
|
||||
@Transient
|
||||
private String isAdmin;
|
||||
|
||||
/**
|
||||
* 登录用户ID
|
||||
*/
|
||||
@Transient
|
||||
private String loginName;
|
||||
/**
|
||||
* 客户单位名称
|
||||
*/
|
||||
@Transient
|
||||
private String typeName;
|
||||
/**
|
||||
* 重要程度名称
|
||||
*/
|
||||
@Transient
|
||||
private String importanceName;
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
@Transient
|
||||
private String createUserName;
|
||||
/**
|
||||
* 查询的部门id
|
||||
*/
|
||||
@Transient
|
||||
private String deptId;
|
||||
/**
|
||||
* 部门下所有成员userid
|
||||
*/
|
||||
@Transient
|
||||
private List<String> deptUserIds;
|
||||
|
||||
// 按时间范围查询,注意这个类不要用lombok插件,不然这个取不到值,应该是与上面的startTime、endTime冲突了
|
||||
@Transient
|
||||
private String starttime;
|
||||
@Transient
|
||||
private String endtime;
|
||||
|
||||
/**
|
||||
* 项目负责人userid(多个逗号分隔)
|
||||
*/
|
||||
@Transient
|
||||
private String fzrIds;
|
||||
|
||||
/**
|
||||
* 项目负责人名字(多个逗号分隔)
|
||||
*/
|
||||
@Transient
|
||||
private String fzrNames;
|
||||
|
||||
/**
|
||||
* 项目抄送人userid(多个逗号分隔)
|
||||
*/
|
||||
@Transient
|
||||
private String csrIds;
|
||||
|
||||
/**
|
||||
* 项目抄送人名字(多个逗号分隔)
|
||||
*/
|
||||
@Transient
|
||||
private String csrNames;
|
||||
|
||||
/**
|
||||
* 返回给前端的字段,表示是否可修改删除项目的权限操作
|
||||
*/
|
||||
@Transient
|
||||
private Boolean allowModify;
|
||||
|
||||
@Transient
|
||||
private String areaShow;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getImportance() {
|
||||
return importance;
|
||||
}
|
||||
|
||||
public void setImportance(String importance) {
|
||||
this.importance = importance;
|
||||
}
|
||||
|
||||
public String getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(String area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public Byte getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Byte status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(String createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Short getNotify() {
|
||||
return notify;
|
||||
}
|
||||
|
||||
public void setNotify(Short notify) {
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(String customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getContractno() {
|
||||
return contractno;
|
||||
}
|
||||
|
||||
public void setContractno(String contractno) {
|
||||
this.contractno = contractno;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getProjectClientId() {
|
||||
return projectClientId;
|
||||
}
|
||||
|
||||
public void setProjectClientId(String projectClientId) {
|
||||
this.projectClientId = projectClientId;
|
||||
}
|
||||
|
||||
public String getProjectClienArray() {
|
||||
return projectClienArray;
|
||||
}
|
||||
|
||||
public void setProjectClienArray(String projectClienArray) {
|
||||
this.projectClienArray = projectClienArray;
|
||||
}
|
||||
|
||||
public String getIsAdmin() {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public void setIsAdmin(String isAdmin) {
|
||||
this.isAdmin = isAdmin;
|
||||
}
|
||||
|
||||
public String getLoginName() {
|
||||
return loginName;
|
||||
}
|
||||
|
||||
public void setLoginName(String loginName) {
|
||||
this.loginName = loginName;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public String getImportanceName() {
|
||||
return importanceName;
|
||||
}
|
||||
|
||||
public void setImportanceName(String importanceName) {
|
||||
this.importanceName = importanceName;
|
||||
}
|
||||
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
|
||||
public String getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(String deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public List<String> getDeptUserIds() {
|
||||
return deptUserIds;
|
||||
}
|
||||
|
||||
public void setDeptUserIds(List<String> deptUserIds) {
|
||||
this.deptUserIds = deptUserIds;
|
||||
}
|
||||
|
||||
public String getStarttime() {
|
||||
return starttime;
|
||||
}
|
||||
|
||||
public void setStarttime(String starttime) {
|
||||
this.starttime = starttime;
|
||||
}
|
||||
|
||||
public String getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
|
||||
public void setEndtime(String endtime) {
|
||||
this.endtime = endtime;
|
||||
}
|
||||
|
||||
public String getFzrIds() {
|
||||
return fzrIds;
|
||||
}
|
||||
|
||||
public void setFzrIds(String fzrIds) {
|
||||
this.fzrIds = fzrIds;
|
||||
}
|
||||
|
||||
public String getFzrNames() {
|
||||
return fzrNames;
|
||||
}
|
||||
|
||||
public void setFzrNames(String fzrNames) {
|
||||
this.fzrNames = fzrNames;
|
||||
}
|
||||
|
||||
public String getCsrIds() {
|
||||
return csrIds;
|
||||
}
|
||||
|
||||
public void setCsrIds(String csrIds) {
|
||||
this.csrIds = csrIds;
|
||||
}
|
||||
|
||||
public String getCsrNames() {
|
||||
return csrNames;
|
||||
}
|
||||
|
||||
public void setCsrNames(String csrNames) {
|
||||
this.csrNames = csrNames;
|
||||
}
|
||||
|
||||
public Boolean getAllowModify() {
|
||||
return allowModify;
|
||||
}
|
||||
|
||||
public void setAllowModify(Boolean allowModify) {
|
||||
this.allowModify = allowModify;
|
||||
}
|
||||
|
||||
public String getAreaShow() {
|
||||
return areaShow;
|
||||
}
|
||||
|
||||
public void setAreaShow(String areaShow) {
|
||||
this.areaShow = areaShow;
|
||||
}
|
||||
}
|
||||
34
src/main/java/com/nbclass/szxgl/model/ProjectCity.java
Normal file
34
src/main/java/com/nbclass/szxgl/model/ProjectCity.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author wangweifeng
|
||||
* @version 1.0 2021/3/13
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "project_city")
|
||||
public class ProjectCity {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@NotEmpty(message="城市类型不能为空")
|
||||
@Column(name = "_type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotEmpty(message="项目id不能为空")
|
||||
@Column(name = "_project_id")
|
||||
private String projectId;
|
||||
|
||||
}
|
||||
36
src/main/java/com/nbclass/szxgl/model/ProjectClient.java
Normal file
36
src/main/java/com/nbclass/szxgl/model/ProjectClient.java
Normal file
@ -0,0 +1,36 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author leiyun
|
||||
* @Date 2021/3/11 18:57
|
||||
**/
|
||||
@Data
|
||||
@Table(name = "project_client")
|
||||
public class ProjectClient {
|
||||
|
||||
@Id
|
||||
@Column(name = "Id")
|
||||
private String id;
|
||||
|
||||
private Date createtime;
|
||||
|
||||
private Date updatetime;
|
||||
|
||||
@Column(name = "Name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "ParentId")
|
||||
private String parentId;
|
||||
|
||||
@Column(name = "Sort")
|
||||
private Integer sort;
|
||||
|
||||
|
||||
}
|
||||
39
src/main/java/com/nbclass/szxgl/model/ProjectFiles.java
Normal file
39
src/main/java/com/nbclass/szxgl/model/ProjectFiles.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author leiyun
|
||||
* @Date 2021/3/11 16:58
|
||||
**/
|
||||
@Data
|
||||
@Table(name = "project_files")
|
||||
public class ProjectFiles {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
//@Column(name = "project_id")
|
||||
@NotEmpty(message="项目Id不能为空")
|
||||
private String projectId;
|
||||
|
||||
private String fileExt;
|
||||
|
||||
private Long fileSize;
|
||||
|
||||
@NotEmpty(message="原始文件名不能为空")
|
||||
private String originalName;
|
||||
|
||||
@NotEmpty(message="文件路径不能为空")
|
||||
private String filePath;
|
||||
|
||||
}
|
||||
323
src/main/java/com/nbclass/szxgl/model/ProjectTask.java
Normal file
323
src/main/java/com/nbclass/szxgl/model/ProjectTask.java
Normal file
@ -0,0 +1,323 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
@Table(name = "project_task")
|
||||
public class ProjectTask {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 关联项目id
|
||||
*/
|
||||
@Column(name = "_project_id")
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
@Column(name = "_name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Column(name = "_start_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@Column(name = "_end_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@Column(name = "_content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column(name = "_create_user_id")
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "_create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(name = "_update_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 进度%数 范围:1-100
|
||||
*/
|
||||
@Column(name = "_speed")
|
||||
private Byte speed;
|
||||
|
||||
/**
|
||||
* 是否发送微信通知,0:未通知
|
||||
*/
|
||||
@Column(name = "_notify")
|
||||
private Short notify;
|
||||
|
||||
|
||||
// 以下为查询字段
|
||||
|
||||
// 任务执行人名字
|
||||
@Transient
|
||||
private String zxrNames;
|
||||
// 项目名称
|
||||
@Transient
|
||||
private String projectName;
|
||||
// 任务创建者姓名
|
||||
@Transient
|
||||
private String createUserName;
|
||||
//任务执行人id
|
||||
@Transient
|
||||
private String zxrIds;
|
||||
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联项目id
|
||||
*
|
||||
* @return _project_id - 关联项目id
|
||||
*/
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联项目id
|
||||
*
|
||||
* @param projectId 关联项目id
|
||||
*/
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务名称
|
||||
*
|
||||
* @return _name - 任务名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务名称
|
||||
*
|
||||
* @param name 任务名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开始时间
|
||||
*
|
||||
* @return _start_time - 开始时间
|
||||
*/
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开始时间
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
*/
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结束时间
|
||||
*
|
||||
* @return _end_time - 结束时间
|
||||
*/
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置结束时间
|
||||
*
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容
|
||||
*
|
||||
* @return _content - 内容
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置内容
|
||||
*
|
||||
* @param content 内容
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建人
|
||||
*
|
||||
* @return _create_user_id - 创建人
|
||||
*/
|
||||
public String getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建人
|
||||
*
|
||||
* @param createUserId 创建人
|
||||
*/
|
||||
public void setCreateUserId(String createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return _create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return _update_time - 修改时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updateTime 修改时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度%数 范围:1-100
|
||||
*
|
||||
* @return _speed - 进度%数 范围:1-100
|
||||
*/
|
||||
public Byte getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度%数 范围:1-100
|
||||
*
|
||||
* @param speed 进度%数 范围:1-100
|
||||
*/
|
||||
public void setSpeed(Byte speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否发送微信通知,0:未通知
|
||||
*
|
||||
* @return _notify - 是否发送微信通知,0:未通知
|
||||
*/
|
||||
public Short getNotify() {
|
||||
return notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否发送微信通知,0:未通知
|
||||
*
|
||||
* @param notify 是否发送微信通知,0:未通知
|
||||
*/
|
||||
public void setNotify(Short notify) {
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
public String getZxrNames() {
|
||||
return zxrNames;
|
||||
}
|
||||
|
||||
public void setZxrNames(String zxrNames) {
|
||||
this.zxrNames = zxrNames;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
|
||||
public String getZxrIds() {
|
||||
return zxrIds;
|
||||
}
|
||||
|
||||
public void setZxrIds(String zxrIds) {
|
||||
this.zxrIds = zxrIds;
|
||||
}
|
||||
}
|
||||
240
src/main/java/com/nbclass/szxgl/model/ProjectTaskJournal.java
Normal file
240
src/main/java/com/nbclass/szxgl/model/ProjectTaskJournal.java
Normal file
@ -0,0 +1,240 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
@Table(name = "project_task_journal")
|
||||
public class ProjectTaskJournal {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 关联的任务id
|
||||
*/
|
||||
@Column(name = "_project_task_id")
|
||||
private String projectTaskId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Column(name = "_start_time")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@Column(name = "_end_time")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 进度说明 内容
|
||||
*/
|
||||
@Column(name = "_content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 进度日志,由系统自动生成
|
||||
*/
|
||||
@Column(name = "_journal")
|
||||
private String journal;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column(name = "_create_user_id")
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "_create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(name = "_update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
// 以下是查询字段
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
@Transient
|
||||
private String createUserName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联的任务id
|
||||
*
|
||||
* @return _project_task_id - 关联的任务id
|
||||
*/
|
||||
public String getProjectTaskId() {
|
||||
return projectTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联的任务id
|
||||
*
|
||||
* @param projectTaskId 关联的任务id
|
||||
*/
|
||||
public void setProjectTaskId(String projectTaskId) {
|
||||
this.projectTaskId = projectTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开始时间
|
||||
*
|
||||
* @return _start_time - 开始时间
|
||||
*/
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开始时间
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
*/
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取结束时间
|
||||
*
|
||||
* @return _end_time - 结束时间
|
||||
*/
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置结束时间
|
||||
*
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度说明 内容
|
||||
*
|
||||
* @return _content - 进度说明 内容
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度说明 内容
|
||||
*
|
||||
* @param content 进度说明 内容
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度日志,由系统自动生成
|
||||
*
|
||||
* @return _journal - 进度日志,由系统自动生成
|
||||
*/
|
||||
public String getJournal() {
|
||||
return journal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度日志,由系统自动生成
|
||||
*
|
||||
* @param journal 进度日志,由系统自动生成
|
||||
*/
|
||||
public void setJournal(String journal) {
|
||||
this.journal = journal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建人
|
||||
*
|
||||
* @return _create_user_id - 创建人
|
||||
*/
|
||||
public String getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建人
|
||||
*
|
||||
* @param createUserId 创建人
|
||||
*/
|
||||
public void setCreateUserId(String createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return _create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return _update_time - 修改时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updateTime 修改时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,127 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "project_task_journal_comment")
|
||||
public class ProjectTaskJournalComment {
|
||||
/**
|
||||
* ID, 主键,自增
|
||||
*/
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "_create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 关联的任务日志id
|
||||
*/
|
||||
@Column(name = "_project_task_journal_id")
|
||||
private String projectTaskJournalId;
|
||||
|
||||
/**
|
||||
* 评论人id
|
||||
*/
|
||||
@Column(name = "_user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
@Column(name = "_content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 获取ID, 主键,自增
|
||||
*
|
||||
* @return id - ID, 主键,自增
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ID, 主键,自增
|
||||
*
|
||||
* @param id ID, 主键,自增
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return _create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联的任务日志id
|
||||
*
|
||||
* @return _project_task_journal_id - 关联的任务日志id
|
||||
*/
|
||||
public String getProjectTaskJournalId() {
|
||||
return projectTaskJournalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联的任务日志id
|
||||
*
|
||||
* @param projectTaskJournalId 关联的任务日志id
|
||||
*/
|
||||
public void setProjectTaskJournalId(String projectTaskJournalId) {
|
||||
this.projectTaskJournalId = projectTaskJournalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评论人id
|
||||
*
|
||||
* @return _user_id - 评论人id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置评论人id
|
||||
*
|
||||
* @param userId 评论人id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评论内容
|
||||
*
|
||||
* @return _content - 评论内容
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置评论内容
|
||||
*
|
||||
* @param content 评论内容
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
144
src/main/java/com/nbclass/szxgl/model/ProjectTaskUser.java
Normal file
144
src/main/java/com/nbclass/szxgl/model/ProjectTaskUser.java
Normal file
@ -0,0 +1,144 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "project_task_user")
|
||||
public class ProjectTaskUser {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 关联项目id
|
||||
*/
|
||||
@Column(name = "_project_id")
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* 关联的任务表id
|
||||
*/
|
||||
@Column(name = "_project_task_id")
|
||||
private String projectTaskId;
|
||||
|
||||
/**
|
||||
* 任务负责人id
|
||||
*/
|
||||
@Column(name = "_user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "_create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(name = "_update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联项目id
|
||||
*
|
||||
* @return _project_id - 关联项目id
|
||||
*/
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联项目id
|
||||
*
|
||||
* @param projectId 关联项目id
|
||||
*/
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联的任务表id
|
||||
*
|
||||
* @return _project_task_id - 关联的任务表id
|
||||
*/
|
||||
public String getProjectTaskId() {
|
||||
return projectTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联的任务表id
|
||||
*
|
||||
* @param projectTaskId 关联的任务表id
|
||||
*/
|
||||
public void setProjectTaskId(String projectTaskId) {
|
||||
this.projectTaskId = projectTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务负责人id
|
||||
*
|
||||
* @return _user_id - 任务负责人id
|
||||
*/
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务负责人id
|
||||
*
|
||||
* @param userId 任务负责人id
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return _create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return _update_time - 修改时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updateTime 修改时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
144
src/main/java/com/nbclass/szxgl/model/ProjectUser.java
Normal file
144
src/main/java/com/nbclass/szxgl/model/ProjectUser.java
Normal file
@ -0,0 +1,144 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "project_user")
|
||||
public class ProjectUser {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 关联的项目id
|
||||
*/
|
||||
@Column(name = "_project_id")
|
||||
private String projectId;
|
||||
|
||||
/**
|
||||
* 关联人类型,1:负责人,2:授权部门,3:授权人员
|
||||
*/
|
||||
@Column(name = "_type")
|
||||
private Byte type;
|
||||
|
||||
/**
|
||||
* 关联表id
|
||||
*/
|
||||
@Column(name = "_table_id")
|
||||
private String tableId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "_create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(name = "_update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联的项目id
|
||||
*
|
||||
* @return _project_id - 关联的项目id
|
||||
*/
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联的项目id
|
||||
*
|
||||
* @param projectId 关联的项目id
|
||||
*/
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联人类型,1:负责人,2:授权部门,3:授权人员
|
||||
*
|
||||
* @return _type - 关联人类型,1:负责人,2:授权部门,3:授权人员
|
||||
*/
|
||||
public Byte getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联人类型,1:负责人,2:授权部门,3:授权人员
|
||||
*
|
||||
* @param type 关联人类型,1:负责人,2:授权部门,3:授权人员
|
||||
*/
|
||||
public void setType(Byte type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联表id
|
||||
*
|
||||
* @return _table_id - 关联表id
|
||||
*/
|
||||
public String getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关联表id
|
||||
*
|
||||
* @param tableId 关联表id
|
||||
*/
|
||||
public void setTableId(String tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return _create_time - 创建时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return _update_time - 修改时间
|
||||
*/
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updateTime 修改时间
|
||||
*/
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
150
src/main/java/com/nbclass/szxgl/model/QywxParty.java
Normal file
150
src/main/java/com/nbclass/szxgl/model/QywxParty.java
Normal file
@ -0,0 +1,150 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "qywx_party")
|
||||
public class QywxParty {
|
||||
/**
|
||||
* ID, 主键,部门Id
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "Id")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createtime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updatetime;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Column(name = "Name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父部门id
|
||||
*/
|
||||
@Column(name = "ParentId")
|
||||
private Integer parentid;
|
||||
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
@Column(name = "Order")
|
||||
private Integer order;
|
||||
|
||||
/**
|
||||
* 获取ID, 主键,部门Id
|
||||
*
|
||||
* @return Id - ID, 主键,部门Id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ID, 主键,部门Id
|
||||
*
|
||||
* @param id ID, 主键,部门Id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return createtime - 创建时间
|
||||
*/
|
||||
public Date getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createtime 创建时间
|
||||
*/
|
||||
public void setCreatetime(Date createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return updatetime - 修改时间
|
||||
*/
|
||||
public Date getUpdatetime() {
|
||||
return updatetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updatetime 修改时间
|
||||
*/
|
||||
public void setUpdatetime(Date updatetime) {
|
||||
this.updatetime = updatetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门名称
|
||||
*
|
||||
* @return Name - 部门名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置部门名称
|
||||
*
|
||||
* @param name 部门名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父部门id
|
||||
*
|
||||
* @return ParentId - 父部门id
|
||||
*/
|
||||
public Integer getParentid() {
|
||||
return parentid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置父部门id
|
||||
*
|
||||
* @param parentid 父部门id
|
||||
*/
|
||||
public void setParentid(Integer parentid) {
|
||||
this.parentid = parentid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门排序
|
||||
*
|
||||
* @return Order - 部门排序
|
||||
*/
|
||||
public Integer getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置部门排序
|
||||
*
|
||||
* @param order 部门排序
|
||||
*/
|
||||
public void setOrder(Integer order) {
|
||||
this.order = order;
|
||||
}
|
||||
}
|
||||
389
src/main/java/com/nbclass/szxgl/model/QywxUser.java
Normal file
389
src/main/java/com/nbclass/szxgl/model/QywxUser.java
Normal file
@ -0,0 +1,389 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "qywx_user")
|
||||
public class QywxUser {
|
||||
/**
|
||||
* ID, 主键,自增
|
||||
*/
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createtime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updatetime;
|
||||
|
||||
/**
|
||||
* 成员UserID
|
||||
*/
|
||||
@Column(name = "UserID")
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
* 成员名称
|
||||
*/
|
||||
@Column(name = "Name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 成员部门列表
|
||||
*/
|
||||
@Column(name = "Department")
|
||||
private String department;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@Column(name = "Mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 职位信息
|
||||
*/
|
||||
@Column(name = "Position")
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 性别,1表示男性,2表示女性
|
||||
*/
|
||||
@Column(name = "Gender")
|
||||
private Short gender;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Column(name = "Email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)
|
||||
*/
|
||||
@Column(name = "Status")
|
||||
private Short status;
|
||||
|
||||
/**
|
||||
* 头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可
|
||||
*/
|
||||
@Column(name = "Avatar")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 英文名
|
||||
*/
|
||||
@Column(name = "EnglishName")
|
||||
private String englishname;
|
||||
|
||||
/**
|
||||
* 上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*/
|
||||
@Column(name = "IsLeader")
|
||||
private Short isleader;
|
||||
|
||||
/**
|
||||
* 座机
|
||||
*/
|
||||
@Column(name = "Telephone")
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 扩展属性
|
||||
*/
|
||||
@Column(name = "ExtAttr")
|
||||
private String extattr;
|
||||
|
||||
/**
|
||||
* 获取ID, 主键,自增
|
||||
*
|
||||
* @return id - ID, 主键,自增
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ID, 主键,自增
|
||||
*
|
||||
* @param id ID, 主键,自增
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建时间
|
||||
*
|
||||
* @return createtime - 创建时间
|
||||
*/
|
||||
public Date getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置创建时间
|
||||
*
|
||||
* @param createtime 创建时间
|
||||
*/
|
||||
public void setCreatetime(Date createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取修改时间
|
||||
*
|
||||
* @return updatetime - 修改时间
|
||||
*/
|
||||
public Date getUpdatetime() {
|
||||
return updatetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置修改时间
|
||||
*
|
||||
* @param updatetime 修改时间
|
||||
*/
|
||||
public void setUpdatetime(Date updatetime) {
|
||||
this.updatetime = updatetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员UserID
|
||||
*
|
||||
* @return UserID - 成员UserID
|
||||
*/
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置成员UserID
|
||||
*
|
||||
* @param userid 成员UserID
|
||||
*/
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员名称
|
||||
*
|
||||
* @return Name - 成员名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置成员名称
|
||||
*
|
||||
* @param name 成员名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员部门列表
|
||||
*
|
||||
* @return Department - 成员部门列表
|
||||
*/
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置成员部门列表
|
||||
*
|
||||
* @param department 成员部门列表
|
||||
*/
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机号码
|
||||
*
|
||||
* @return Mobile - 手机号码
|
||||
*/
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置手机号码
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
*/
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取职位信息
|
||||
*
|
||||
* @return Position - 职位信息
|
||||
*/
|
||||
public String getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置职位信息
|
||||
*
|
||||
* @param position 职位信息
|
||||
*/
|
||||
public void setPosition(String position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取性别,1表示男性,2表示女性
|
||||
*
|
||||
* @return Gender - 性别,1表示男性,2表示女性
|
||||
*/
|
||||
public Short getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置性别,1表示男性,2表示女性
|
||||
*
|
||||
* @param gender 性别,1表示男性,2表示女性
|
||||
*/
|
||||
public void setGender(Short gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取邮箱
|
||||
*
|
||||
* @return Email - 邮箱
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置邮箱
|
||||
*
|
||||
* @param email 邮箱
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)
|
||||
*
|
||||
* @return Status - 激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)
|
||||
*/
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)
|
||||
*
|
||||
* @param status 激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)
|
||||
*/
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可
|
||||
*
|
||||
* @return Avatar - 头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可
|
||||
*/
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可
|
||||
*
|
||||
* @param avatar 头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可
|
||||
*/
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取英文名
|
||||
*
|
||||
* @return EnglishName - 英文名
|
||||
*/
|
||||
public String getEnglishname() {
|
||||
return englishname;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置英文名
|
||||
*
|
||||
* @param englishname 英文名
|
||||
*/
|
||||
public void setEnglishname(String englishname) {
|
||||
this.englishname = englishname;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*
|
||||
* @return IsLeader - 上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*/
|
||||
public Short getIsleader() {
|
||||
return isleader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*
|
||||
* @param isleader 上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*/
|
||||
public void setIsleader(Short isleader) {
|
||||
this.isleader = isleader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取座机
|
||||
*
|
||||
* @return Telephone - 座机
|
||||
*/
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置座机
|
||||
*
|
||||
* @param telephone 座机
|
||||
*/
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展属性
|
||||
*
|
||||
* @return ExtAttr - 扩展属性
|
||||
*/
|
||||
public String getExtattr() {
|
||||
return extattr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扩展属性
|
||||
*
|
||||
* @param extattr 扩展属性
|
||||
*/
|
||||
public void setExtattr(String extattr) {
|
||||
this.extattr = extattr;
|
||||
}
|
||||
}
|
||||
383
src/main/java/com/nbclass/szxgl/model/SyUsers.java
Normal file
383
src/main/java/com/nbclass/szxgl/model/SyUsers.java
Normal file
@ -0,0 +1,383 @@
|
||||
package com.nbclass.szxgl.model;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Table(name = "sy_users")
|
||||
public class SyUsers {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 登陆账号
|
||||
*/
|
||||
@Column(name = "user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@Column(name = "true_name")
|
||||
private String trueName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Column(name = "user_password")
|
||||
private String userPassword;
|
||||
|
||||
/**
|
||||
* 注册时间
|
||||
*/
|
||||
@Column(name = "register_time")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 最后登陆时间
|
||||
*/
|
||||
@Column(name = "last_login_time")
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
@Column(name = "last_login_ip")
|
||||
private String lastLoginIp;
|
||||
|
||||
/**
|
||||
* 登录错误时间
|
||||
*/
|
||||
@Column(name = "error_time")
|
||||
private Date errorTime;
|
||||
|
||||
/**
|
||||
* 登录错误次数
|
||||
*/
|
||||
@Column(name = "error_count")
|
||||
private Integer errorCount;
|
||||
|
||||
/**
|
||||
* 账号状态 1:正常 0 禁止登陆
|
||||
*/
|
||||
@Column(name = "user_status")
|
||||
private Boolean userStatus;
|
||||
|
||||
/**
|
||||
* 所属部门id
|
||||
*/
|
||||
@Column(name = "dept_id")
|
||||
private String deptId;
|
||||
|
||||
/**
|
||||
* 用户说明
|
||||
*/
|
||||
@Column(name = "user_desc")
|
||||
private String userDesc;
|
||||
|
||||
/**
|
||||
* 性别,1表示男性,2表示女性
|
||||
*/
|
||||
@Column(name = "user_sex")
|
||||
private Boolean userSex;
|
||||
|
||||
/**
|
||||
* 注册人
|
||||
*/
|
||||
@Column(name = "register_uid")
|
||||
private String registerUid;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(name = "mobile_phone_number")
|
||||
private String mobilePhoneNumber;
|
||||
|
||||
/**
|
||||
* 上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*/
|
||||
private Boolean isleader;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登陆账号
|
||||
*
|
||||
* @return user_name - 登陆账号
|
||||
*/
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置登陆账号
|
||||
*
|
||||
* @param userName 登陆账号
|
||||
*/
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取真实姓名
|
||||
*
|
||||
* @return true_name - 真实姓名
|
||||
*/
|
||||
public String getTrueName() {
|
||||
return trueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置真实姓名
|
||||
*
|
||||
* @param trueName 真实姓名
|
||||
*/
|
||||
public void setTrueName(String trueName) {
|
||||
this.trueName = trueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取密码
|
||||
*
|
||||
* @return user_password - 密码
|
||||
*/
|
||||
public String getUserPassword() {
|
||||
return userPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置密码
|
||||
*
|
||||
* @param userPassword 密码
|
||||
*/
|
||||
public void setUserPassword(String userPassword) {
|
||||
this.userPassword = userPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注册时间
|
||||
*
|
||||
* @return register_time - 注册时间
|
||||
*/
|
||||
public Date getRegisterTime() {
|
||||
return registerTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置注册时间
|
||||
*
|
||||
* @param registerTime 注册时间
|
||||
*/
|
||||
public void setRegisterTime(Date registerTime) {
|
||||
this.registerTime = registerTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最后登陆时间
|
||||
*
|
||||
* @return last_login_time - 最后登陆时间
|
||||
*/
|
||||
public Date getLastLoginTime() {
|
||||
return lastLoginTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最后登陆时间
|
||||
*
|
||||
* @param lastLoginTime 最后登陆时间
|
||||
*/
|
||||
public void setLastLoginTime(Date lastLoginTime) {
|
||||
this.lastLoginTime = lastLoginTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最后登录IP
|
||||
*
|
||||
* @return last_login_ip - 最后登录IP
|
||||
*/
|
||||
public String getLastLoginIp() {
|
||||
return lastLoginIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最后登录IP
|
||||
*
|
||||
* @param lastLoginIp 最后登录IP
|
||||
*/
|
||||
public void setLastLoginIp(String lastLoginIp) {
|
||||
this.lastLoginIp = lastLoginIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录错误时间
|
||||
*
|
||||
* @return error_time - 登录错误时间
|
||||
*/
|
||||
public Date getErrorTime() {
|
||||
return errorTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置登录错误时间
|
||||
*
|
||||
* @param errorTime 登录错误时间
|
||||
*/
|
||||
public void setErrorTime(Date errorTime) {
|
||||
this.errorTime = errorTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录错误次数
|
||||
*
|
||||
* @return error_count - 登录错误次数
|
||||
*/
|
||||
public Integer getErrorCount() {
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置登录错误次数
|
||||
*
|
||||
* @param errorCount 登录错误次数
|
||||
*/
|
||||
public void setErrorCount(Integer errorCount) {
|
||||
this.errorCount = errorCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号状态 1:正常 0 禁止登陆
|
||||
*
|
||||
* @return user_status - 账号状态 1:正常 0 禁止登陆
|
||||
*/
|
||||
public Boolean getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置账号状态 1:正常 0 禁止登陆
|
||||
*
|
||||
* @param userStatus 账号状态 1:正常 0 禁止登陆
|
||||
*/
|
||||
public void setUserStatus(Boolean userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所属部门id
|
||||
*
|
||||
* @return dept_id - 所属部门id
|
||||
*/
|
||||
public String getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置所属部门id
|
||||
*
|
||||
* @param deptId 所属部门id
|
||||
*/
|
||||
public void setDeptId(String deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户说明
|
||||
*
|
||||
* @return user_desc - 用户说明
|
||||
*/
|
||||
public String getUserDesc() {
|
||||
return userDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户说明
|
||||
*
|
||||
* @param userDesc 用户说明
|
||||
*/
|
||||
public void setUserDesc(String userDesc) {
|
||||
this.userDesc = userDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取性别,1表示男性,2表示女性
|
||||
*
|
||||
* @return user_sex - 性别,1表示男性,2表示女性
|
||||
*/
|
||||
public Boolean getUserSex() {
|
||||
return userSex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置性别,1表示男性,2表示女性
|
||||
*
|
||||
* @param userSex 性别,1表示男性,2表示女性
|
||||
*/
|
||||
public void setUserSex(Boolean userSex) {
|
||||
this.userSex = userSex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注册人
|
||||
*
|
||||
* @return register_uid - 注册人
|
||||
*/
|
||||
public String getRegisterUid() {
|
||||
return registerUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置注册人
|
||||
*
|
||||
* @param registerUid 注册人
|
||||
*/
|
||||
public void setRegisterUid(String registerUid) {
|
||||
this.registerUid = registerUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机号
|
||||
*
|
||||
* @return mobile_phone_number - 手机号
|
||||
*/
|
||||
public String getMobilePhoneNumber() {
|
||||
return mobilePhoneNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置手机号
|
||||
*
|
||||
* @param mobilePhoneNumber 手机号
|
||||
*/
|
||||
public void setMobilePhoneNumber(String mobilePhoneNumber) {
|
||||
this.mobilePhoneNumber = mobilePhoneNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*
|
||||
* @return isleader - 上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*/
|
||||
public Boolean getIsleader() {
|
||||
return isleader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*
|
||||
* @param isleader 上级字段,标识是否为上级。0表示普通成员,1表示上级
|
||||
*/
|
||||
public void setIsleader(Boolean isleader) {
|
||||
this.isleader = isleader;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.nbclass.szxgl.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年5月21日 下午2:08:59
|
||||
*/
|
||||
public interface GraphicStatisticsService {
|
||||
|
||||
/**
|
||||
* 获取区域项目数量统计数据 - 饼图
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getProjectNumDataByPie(String starttime, String endtime);
|
||||
|
||||
|
||||
/**
|
||||
* 获取区域项目数量统计数据 - 折线图
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getProjectNumDataByLine(String starttime, String endtime);
|
||||
/**
|
||||
* 查看个人项目统计-表格
|
||||
* @param starttime
|
||||
* @param endtime
|
||||
* @return
|
||||
*/
|
||||
public JSONObject queryPersonProject(String starttime, String endtime,String deptId,String userId);
|
||||
/**
|
||||
* 部门月报表统计-折线图
|
||||
* @param year
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public JSONObject queryMonthProjectLine(String year,String deptId);
|
||||
/**
|
||||
* 获得公司部门列表 key-value
|
||||
* @return
|
||||
*/
|
||||
public JSONObject queryDepartmentLable();
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.nbclass.szxgl.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
/**
|
||||
* @Author leiyun
|
||||
* @Date 2021/3/11 19:03
|
||||
**/
|
||||
public interface ProjectClientService {
|
||||
|
||||
/**
|
||||
* 查询树形结构数据列表
|
||||
* @return
|
||||
*/
|
||||
JSONArray getTreeList();
|
||||
|
||||
|
||||
/**
|
||||
* 通过ID查询名称, 包括所有上级,用中横线连接 eg. 平安集团 - 人力资源部
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String getNamesById(String id);
|
||||
|
||||
}
|
||||
156
src/main/java/com/nbclass/szxgl/service/ProjectService.java
Normal file
156
src/main/java/com/nbclass/szxgl/service/ProjectService.java
Normal file
@ -0,0 +1,156 @@
|
||||
package com.nbclass.szxgl.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nbclass.szxgl.model.ListType;
|
||||
import com.nbclass.szxgl.model.Project;
|
||||
import com.nbclass.szxgl.model.ProjectFiles;
|
||||
import com.nbclass.szxgl.model.ProjectTask;
|
||||
import com.nbclass.szxgl.model.ProjectTaskJournal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leon
|
||||
* @datetime 2019年4月24日 下午4:24:11
|
||||
*/
|
||||
public interface ProjectService {
|
||||
|
||||
/**
|
||||
* 是否有项目修改权限
|
||||
* 管理员、项目创建者、项目负责人才有修改权限
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public boolean hasUpdateProject(String pid);
|
||||
|
||||
/**
|
||||
* 拥有对项目文档的权限
|
||||
* 管理员、项目创建者、项目负责人、项目任务执行人 才有修改权限
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public boolean hasPowerForFile(String pid);
|
||||
|
||||
/**
|
||||
* 是否有 添加 修改 删除 项目任务的权限
|
||||
* 只有项目创建者或项目负责人才有此权限
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public boolean hasPowerForTask(String pid);
|
||||
|
||||
/**
|
||||
* 根据条件查询项目列表
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
public List<Project> getList(Project project);
|
||||
|
||||
/**
|
||||
* 递归查询部门下的所以成员(包括本部门和子部门)
|
||||
* @param deptId 部门id
|
||||
* @return 用户id列表
|
||||
*/
|
||||
public List<String> selectUserIdsByDeptId(String deptId);
|
||||
|
||||
/**
|
||||
* 根据主键id查询
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public JSONObject findById(String pid);
|
||||
|
||||
/**
|
||||
* 项目的文档管理 查询文件列表
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectFiles> getFileList(String pid);
|
||||
|
||||
/**
|
||||
* 项目任务列表
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectTask> getTaskList(String pid);
|
||||
|
||||
/**
|
||||
* 项目任务进度日志列表
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
public List<ProjectTaskJournal> getTaskJournalList(String taskId);
|
||||
/**
|
||||
* 根据类型获得枚举列表
|
||||
* @param listType
|
||||
* @return
|
||||
*/
|
||||
public List<ListType> getListValues(String listType);
|
||||
|
||||
/**
|
||||
* 添加项目
|
||||
* @param p
|
||||
* @param isSendMsg
|
||||
* @param deptIds
|
||||
* @param filesList
|
||||
* @return
|
||||
*/
|
||||
public String addProject(Project p,Integer isSendMsg, String[] deptIds, List<ProjectFiles> filesList);
|
||||
/**
|
||||
* 修改项目
|
||||
* @param p
|
||||
* @param isSendMsg
|
||||
* @param deptIds
|
||||
* @param filesList
|
||||
* @return
|
||||
*/
|
||||
public void updateProject(Project p,Integer isSendMsg, String[] deptIds, List<ProjectFiles> filesList);
|
||||
/**
|
||||
* 通过userid查询上级用户
|
||||
* @param userIds 用户的id
|
||||
* @param toTop 是否遍历查询所有上级,如果为false只查询当前上级
|
||||
* @return
|
||||
*/
|
||||
public Map<String,List<String>> selectLeaderUsers(String userIds, boolean toTop);
|
||||
|
||||
/**
|
||||
* 通过userid查询上级用户 - 返回对象,包含用户头像
|
||||
* @param userIds
|
||||
* @param toTop 是否遍历查询所有上级,如果为false只查询当前上级
|
||||
* @return
|
||||
*/
|
||||
JSONArray selectLeaderUserObj(String userIds, boolean toTop);
|
||||
|
||||
/**
|
||||
* 通过执行人userid查询用户信息 - 返回对象,包含用户头像
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectZxrUserObj(String userIds);
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
* @param ids
|
||||
*/
|
||||
public void deleteProject(String[] ids);
|
||||
|
||||
/**
|
||||
* 查询负责人所属区域
|
||||
* @param userIds
|
||||
*/
|
||||
public Map<String,Set<String>> selectCityByUserIds(String userIds);
|
||||
|
||||
/**
|
||||
* 修改项目状态
|
||||
* @param id
|
||||
* @param contractno
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
public void updateProjectStatus(String id, String contractno, String status);
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.nbclass.szxgl.service;
|
||||
|
||||
import com.nbclass.szxgl.model.ProjectTask;
|
||||
import com.nbclass.szxgl.model.ProjectTaskJournal;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author wangweifeng
|
||||
* @version 1.0 2021/3/10
|
||||
*/
|
||||
public interface ProjectTaskService {
|
||||
|
||||
/**
|
||||
* 删除项目任务
|
||||
* @param projectId
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteProjectTask(String projectId,String[] ids);
|
||||
|
||||
/**
|
||||
* 添加项目任务
|
||||
* @param t
|
||||
* @param isSendMsg
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds);
|
||||
|
||||
/**
|
||||
* 修改项目任务
|
||||
* @param t
|
||||
* @param isSendMsg
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public void updateProjectTask(ProjectTask t,Integer isSendMsg,String[] userIds);
|
||||
|
||||
/**
|
||||
* 查询用户所有的任务
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
public List<Map> selectMyTaskList(String userid);
|
||||
|
||||
/**
|
||||
* 添加进度日志
|
||||
* @param j
|
||||
* @return
|
||||
*/
|
||||
public void addProjectTaskJournal(ProjectTaskJournal j, short speed);
|
||||
|
||||
/**
|
||||
* //判断当前用户是否是任务的执行人
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
public boolean myIsExecutorByTaskId(String taskId);
|
||||
}
|
||||
18
src/main/java/com/nbclass/szxgl/service/SyUsersService.java
Normal file
18
src/main/java/com/nbclass/szxgl/service/SyUsersService.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.nbclass.szxgl.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nbclass.szxgl.model.SyUsers;
|
||||
|
||||
public interface SyUsersService {
|
||||
|
||||
/**
|
||||
* 根据用户id查询
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public SyUsers selectByUsername(String username);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,150 @@
|
||||
package com.nbclass.szxgl.service.impl;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nbclass.exception.ParameterException;
|
||||
import com.nbclass.system.model.User;
|
||||
import com.nbclass.szxgl.constant.ActivityConstants;
|
||||
import com.nbclass.szxgl.mapper.GraphicStatisticsMapper;
|
||||
import com.nbclass.szxgl.service.GraphicStatisticsService;
|
||||
|
||||
import tk.mybatis.mapper.util.StringUtil;
|
||||
|
||||
@Service
|
||||
public class GraphicStatisticsServiceImpl implements GraphicStatisticsService {
|
||||
|
||||
@Resource
|
||||
private GraphicStatisticsMapper mapper;
|
||||
|
||||
@Override
|
||||
public JSONObject getProjectNumDataByPie(String starttime, String endtime) {
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
if (user == null) {
|
||||
throw new ParameterException("登录失效,请重新登录!");
|
||||
}
|
||||
String username = user.getUsername();
|
||||
if (ActivityConstants.isAdmin(user.getUsername()))
|
||||
username = "admin";
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
List<Map<String, Object>> list = mapper.getProjectNumDataByPie(starttime, endtime, username);
|
||||
result.put("list", list);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getProjectNumDataByLine(String starttime, String endtime) {
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
if (user == null) {
|
||||
throw new ParameterException("登录失效,请重新登录!");
|
||||
}
|
||||
String username = user.getUsername();
|
||||
if (ActivityConstants.isAdmin(user.getUsername()))
|
||||
username = "admin";
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
ArrayList<String> legendData = new ArrayList<String>();
|
||||
ArrayList<String> xAxisData = new ArrayList<String>();
|
||||
JSONArray seriesData = new JSONArray();
|
||||
|
||||
Map<String, ArrayList<Long>> areaNums = new LinkedHashMap<String, ArrayList<Long>>(); // 使用LinkedHashMap按插入顺序排序
|
||||
List<Map<String, Object>> list = mapper.getProjectNumDataByLine(starttime, endtime, username);
|
||||
if (!list.isEmpty()) {
|
||||
for (Map<String, Object> map : list) {
|
||||
String weeks = (String) map.get("weeks");
|
||||
String area = (String) map.get("area");
|
||||
long num = (long) map.get("num");
|
||||
if (!xAxisData.contains(weeks))
|
||||
xAxisData.add(weeks);
|
||||
|
||||
if (areaNums.containsKey(area)) {
|
||||
|
||||
areaNums.get(area).add(num);
|
||||
} else {
|
||||
ArrayList<Long> tmpList = new ArrayList<Long>();
|
||||
tmpList.add(num);
|
||||
areaNums.put(area, tmpList);
|
||||
}
|
||||
}
|
||||
Iterator<Entry<String, ArrayList<Long>>> it = areaNums.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, ArrayList<Long>> entry = it.next();
|
||||
legendData.add(entry.getKey());
|
||||
JSONObject seriesObj = new JSONObject();
|
||||
seriesObj.put("name", entry.getKey());
|
||||
seriesObj.put("type", "line");
|
||||
seriesObj.put("data", entry.getValue());
|
||||
seriesData.add(seriesObj);
|
||||
}
|
||||
}
|
||||
result.put("legendData", legendData);
|
||||
result.put("xAxisData", xAxisData);
|
||||
result.put("seriesData", seriesData);
|
||||
return result;
|
||||
}
|
||||
|
||||
public JSONObject queryPersonProject(String starttime, String endtime,String deptId,String userId) {
|
||||
// User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
// if(user == null){
|
||||
// throw new ParameterException("登录失效,请重新登录!");
|
||||
// }
|
||||
// String username = user.getUsername();
|
||||
// if(ActivityConstants.isAdmin(user.getUsername()))username="admin";
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
List<Map<String, Object>> list = mapper.queryPersonProject(starttime, endtime,deptId,userId);
|
||||
result.put("list", list);
|
||||
return result;
|
||||
}
|
||||
|
||||
public JSONObject queryMonthProjectLine(String year, String deptId) {
|
||||
JSONObject result = new JSONObject();
|
||||
List<Map> monthList = mapper.queryMonthProjectLine(year, StringUtils.isBlank(deptId) ? null : deptId);
|
||||
List<Integer> list = new ArrayList();
|
||||
Calendar now = Calendar.getInstance();
|
||||
String yearStr = now.get(Calendar.YEAR) + "";
|
||||
int month = now.get(Calendar.MONTH) + 1;
|
||||
if (yearStr.equals(year)) {
|
||||
for (int i = 1; i <= month && i <= 12; i++) {
|
||||
list.add(0);
|
||||
}
|
||||
} else {
|
||||
for (int i = 1;i <= 12; i++) {
|
||||
list.add(0);
|
||||
}
|
||||
}
|
||||
for (Map map : monthList) {
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
if (map.get("month") != null && Integer.parseInt(map.get("month").toString()) == i)
|
||||
list.set(i - 1, Integer.parseInt(map.get("num").toString()));
|
||||
}
|
||||
}
|
||||
result.put("list", list);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryDepartmentLable() {
|
||||
JSONObject result = new JSONObject();
|
||||
List<Map> list = mapper.queryDepartmentLable();
|
||||
result.put("list", list);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.nbclass.szxgl.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nbclass.szxgl.mapper.ProjectClientMapper;
|
||||
import com.nbclass.szxgl.model.ProjectClient;
|
||||
import com.nbclass.szxgl.service.ProjectClientService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author leiyun
|
||||
* @Date 2021/3/11 19:03
|
||||
*/
|
||||
@Service
|
||||
public class ProjectClientServiceImpl implements ProjectClientService {
|
||||
|
||||
@Resource
|
||||
private ProjectClientMapper mapper;
|
||||
|
||||
@Override
|
||||
public JSONArray getTreeList() {
|
||||
return getTreeList("0"); // 顶级ID为0
|
||||
}
|
||||
|
||||
|
||||
private JSONArray getTreeList(String ParentId) {
|
||||
JSONArray retArray = new JSONArray();
|
||||
List<ProjectClient> list = mapper.getTreeList(ParentId);
|
||||
if(list == null || list.isEmpty())return retArray;
|
||||
for(ProjectClient client : list){
|
||||
JSONObject obj = (JSONObject) JSONObject.toJSON(client);
|
||||
JSONArray arrayChild = new JSONArray();
|
||||
if(StringUtils.isNotBlank(client.getId()) && "0".equals(ParentId)){ // 为了性能,暂时只查二级,不查二级以下的子集,后台录入数据也只添加二级机构
|
||||
arrayChild = getTreeList(client.getId());
|
||||
//if(array2!=null && !array2.isEmpty())obj.put("children", array2); // 给前端空的arrayChild
|
||||
}
|
||||
obj.put("children", arrayChild);
|
||||
retArray.add(obj);
|
||||
}
|
||||
return retArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamesById(String id){
|
||||
String names = "";
|
||||
ProjectClient entity = mapper.getNameById(id);
|
||||
if(entity != null){
|
||||
names = entity.getName();
|
||||
if(StringUtils.isNotBlank(entity.getParentId()) && !"0".equals(entity.getParentId())){
|
||||
entity = mapper.getNameById(entity.getParentId());
|
||||
if(entity != null)names = entity.getName() + " - " + names ;
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user