init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
java -jar mybatis-generator-core-1.3.7.jar -configfile generatorConfig.xml
|
||||
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
<generatorConfiguration>
|
||||
<!--数据库驱动 -->
|
||||
<classPathEntry location="mysql-connector-java-5.1.38.jar"/>
|
||||
<context id="DB2Tables" targetRuntime="MyBatis3">
|
||||
<!-- 生成的Java文件的编码 -->
|
||||
<property name="javaFileEncoding" value="UTF-8"/>
|
||||
<!-- 格式化java代码 -->
|
||||
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
|
||||
<!-- 格式化XML代码 -->
|
||||
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
|
||||
<!-- JavaBean 实现 序列化 接口 -->
|
||||
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
|
||||
<!-- 以上为插件配置信息 -->
|
||||
<!-- 是否去除自动生成的注释 true:是;false:否 -->
|
||||
<commentGenerator>
|
||||
<!--生成的注释包含时间戳-->
|
||||
<property name="suppressDate" value="true"/>
|
||||
<property name="suppressAllComments" value="true"/>
|
||||
</commentGenerator>
|
||||
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
|
||||
<jdbcConnection
|
||||
driverClass="com.mysql.jdbc.Driver"
|
||||
connectionURL="jdbc:Mysql://47.103.14.6:3306/zilean-bms?characterEncoding=utf8"
|
||||
userId="root"
|
||||
password="$oDboy*#sDa22#11">
|
||||
<property name="useInformationSchema" value="true"/>
|
||||
</jdbcConnection>
|
||||
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal -->
|
||||
<javaTypeResolver>
|
||||
<property name="forceBigDecimals" value="false"/>
|
||||
</javaTypeResolver>
|
||||
<!--生成Model类存放位置 -->
|
||||
<!-- targetProject:生成PO类的位置 -->
|
||||
<javaModelGenerator targetPackage="cn.odboy.zilean.core.entity" targetProject="src/main/java">
|
||||
<!-- enableSubPackages:是否让schema作为包的后缀 -->
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
<!-- 从数据库返回的值被清理前后的空格 -->
|
||||
<property name="trimStrings" value="true"/>
|
||||
</javaModelGenerator>
|
||||
<!--生成映射文件存放位置 -->
|
||||
<sqlMapGenerator targetPackage="cn.odboy.zilean.dao" targetProject="src/main/java">
|
||||
<!-- enableSubPackages:是否让schema作为包的后缀 -->
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</sqlMapGenerator>
|
||||
<!--生成Dao类存放位置 -->
|
||||
<!--
|
||||
ANNOTATEDMAPPER: 生成java类文件,基于注解的Mapper接口,不会有对应的XML映射文件
|
||||
MIXEDMAPPER:XML和注解的混合形式
|
||||
XMLMAPPER:所有的方法都在XML中,接口调用依赖XML文件
|
||||
-->
|
||||
<javaClientGenerator type="XMLMAPPER" targetPackage="cn.odboy.zilean.dao" targetProject="src/main/java">
|
||||
<property name="enableSubPackages" value="true"/>
|
||||
</javaClientGenerator>
|
||||
<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_dict_data"
|
||||
domainObjectName="DictData"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_dict_Type"
|
||||
domainObjectName="DictType"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_operation_log"
|
||||
domainObjectName="OperationLog"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_permission"
|
||||
domainObjectName="Permission"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_role"
|
||||
domainObjectName="Role"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_role_permission"
|
||||
domainObjectName="RolePermission"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
<table
|
||||
schema=""
|
||||
tableName="t_user"
|
||||
domainObjectName="User"
|
||||
enableCountByExample="false"
|
||||
enableUpdateByExample="false"
|
||||
enableDeleteByExample="false"
|
||||
enableSelectByExample="false"
|
||||
selectByExampleQueryId="false">
|
||||
</table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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>
|
||||
|
||||
<!-- maven可以继承父项目中的参数,所以可以删除子模块中相同定义 -->
|
||||
<artifactId>zilean-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>zilean-base</name>
|
||||
<description>基础模块</description>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.odboy</groupId>
|
||||
<artifactId>zilean</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<!-- 向上查看父节点依赖 -->
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- maven可以继承父项目中的依赖,所以可以删除子模块中相同定义 -->
|
||||
<!--lombok 依赖-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--jpa 依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
</dependency>
|
||||
<!-- 优雅的将DO转换成VO -->
|
||||
<!-- https://mvnrepository.com/artifact/org.mapstruct/mapstruct-jdk8 -->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
<version>1.0.0.Final</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.mapstruct/mapstruct-processor -->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.0.0.Final</version>
|
||||
</dependency>
|
||||
<!--zilean-mybatis 依赖-->
|
||||
<dependency>
|
||||
<groupId>cn.odboy</groupId>
|
||||
<artifactId>zilean-mybatis</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- 如果其他包需要依赖这个模块那么就不要加这个 -->
|
||||
<!--<build>-->
|
||||
<!--<plugins>-->
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.springframework.boot</groupId>-->
|
||||
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
|
||||
<!--</plugin>-->
|
||||
<!--</plugins>-->
|
||||
<!--</build>-->
|
||||
</project>
|
||||
@@ -0,0 +1,77 @@
|
||||
package cn.odboy.zilean.biz;
|
||||
|
||||
import cn.odboy.zilean.bo.UserBo;
|
||||
import cn.odboy.zilean.common.HttpResult;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 用户相关业务
|
||||
* @time: 2019/8/8 10:56
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
public interface IUserBiz {
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* @param username 账号
|
||||
* @param password 密码
|
||||
* @return HttpResult
|
||||
*/
|
||||
HttpResult login(String username, String password);
|
||||
|
||||
/**
|
||||
* 用户退登
|
||||
*
|
||||
* @param username 账号
|
||||
* @param token 登录成功后返回的token值
|
||||
* @return HttpResult
|
||||
*/
|
||||
HttpResult logout(String username, String token);
|
||||
|
||||
/**
|
||||
* 获取用户菜单权限
|
||||
*
|
||||
* @param userId 用户UD
|
||||
* @return HttpResult
|
||||
*/
|
||||
HttpResult getUserPermission(Long userId);
|
||||
|
||||
/**
|
||||
* 保存user登录信息,返回token
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
String generateJwtToken(String username);
|
||||
|
||||
/**
|
||||
* 获取上次token生成时的salt值和登录用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return UserBo
|
||||
*/
|
||||
UserBo getJwtTokenInfo(String username);
|
||||
|
||||
/**
|
||||
* 清除token信息
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
void cleanLoginInfo(String username);
|
||||
|
||||
/**
|
||||
* 获取数据库中保存的用户信息,主要是加密后的密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return UserBo
|
||||
*/
|
||||
UserBo getUserInfo(String userName);
|
||||
|
||||
/**
|
||||
* 获取用户角色列表,强烈建议从缓存中获取
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return List<String>
|
||||
*/
|
||||
String getUserRole(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package cn.odboy.zilean.biz.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.zilean.biz.IUserBiz;
|
||||
import cn.odboy.zilean.bo.UserBo;
|
||||
import cn.odboy.zilean.common.HttpResult;
|
||||
import cn.odboy.zilean.common.constant.RedisKeyConsts;
|
||||
import cn.odboy.zilean.dao.IRoleDao;
|
||||
import cn.odboy.zilean.dao.IUserDao;
|
||||
import cn.odboy.zilean.entity.Role;
|
||||
import cn.odboy.zilean.entity.User;
|
||||
import cn.odboy.zilean.map.UserBoMapper;
|
||||
import cn.odboy.zilean.mybatis.core.EntityPropNav;
|
||||
import cn.odboy.zilean.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 用户相关业务实现类
|
||||
* @time: 2019/8/8 11:05
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Service("userBiz")
|
||||
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
|
||||
public class UserBizImpl implements IUserBiz {
|
||||
/**
|
||||
* 自动注入: 用户DAO
|
||||
*/
|
||||
@Autowired
|
||||
private IUserDao userDao;
|
||||
/**
|
||||
* 自动注入: 权限DAO
|
||||
*/
|
||||
@Autowired
|
||||
private IRoleDao roleDao;
|
||||
/**
|
||||
* 自动注入: 用户Service
|
||||
*/
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
/**
|
||||
* 自动注入: Redis缓存
|
||||
*/
|
||||
@Resource
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
/**
|
||||
* 自动注入: UserDto转换器
|
||||
*/
|
||||
@Resource
|
||||
private UserBoMapper userBoMapper;
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* @param username 账号
|
||||
* @param password 密码
|
||||
* @return HttpResult
|
||||
*/
|
||||
@Override
|
||||
public HttpResult login(String username, String password) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户退登
|
||||
*
|
||||
* @param username 账号
|
||||
* @param token 登录成功后返回的token值
|
||||
* @return HttpResult
|
||||
*/
|
||||
@Override
|
||||
public HttpResult logout(String username, String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户菜单权限
|
||||
*
|
||||
* @param userId 用户UD
|
||||
* @return HttpResult
|
||||
*/
|
||||
@Override
|
||||
public HttpResult getUserPermission(Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存user登录信息,返回token
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
@Override
|
||||
public String generateJwtToken(String username) {
|
||||
String salt = "123456";
|
||||
// 将salt保存到缓存中
|
||||
redisTemplate.opsForValue().set(StrUtil.format(RedisKeyConsts.TOKEN, username), salt, 3600, TimeUnit.SECONDS);
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上次token生成时的salt值和登录用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return UserBo
|
||||
*/
|
||||
@Override
|
||||
public UserBo getJwtTokenInfo(String username) {
|
||||
// 从缓存中取出token生成时用的salt
|
||||
String salt = String.valueOf(redisTemplate.opsForValue().get(StrUtil.format(RedisKeyConsts.TOKEN, username)));
|
||||
UserBo user = getUserInfo(username);
|
||||
user.setSalt(salt);
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除token信息
|
||||
*
|
||||
* @param username 用户名
|
||||
*/
|
||||
@Override
|
||||
public void cleanLoginInfo(String username) {
|
||||
// 删除缓存中保存的salt
|
||||
redisTemplate.delete(StrUtil.format(RedisKeyConsts.TOKEN, username));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库中保存的用户信息,主要是加密后的密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return UserBo
|
||||
*/
|
||||
@Override
|
||||
public UserBo getUserInfo(String userName) {
|
||||
List<User> users = userDao.selectByNav(EntityPropNav.build("username", userName));
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
return userBoMapper.userToBo(users.get(0));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户角色,强烈建议从缓存中获取
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getUserRole(Long userId) {
|
||||
List<User> users = userDao.selectByNav(EntityPropNav.build("id", userId));
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
Long roleId = users.get(0).getRoleId();
|
||||
Role role = roleDao.selectOneById(roleId);
|
||||
return role.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.odboy.zilean.bo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 权限BO
|
||||
* @time: 2019/8/8 3:43
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
public class PermissionBo implements Serializable {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.odboy.zilean.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 用户Bo
|
||||
* @time: 2019/8/9 6:19
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class UserBo implements Serializable {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String encryptPwd;
|
||||
private String salt;
|
||||
private List<String> roles;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
|
||||
import cn.odboy.zilean.entity.DictData;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 字典数据DAO
|
||||
* @time: 2019/8/8 10:35
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IDictDataDao extends BaseDao<DictData> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
|
||||
import cn.odboy.zilean.entity.DictType;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 字典类型DAO
|
||||
* @time: 2019/8/8 10:36
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IDictTypeDao extends BaseDao<DictType> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
|
||||
import cn.odboy.zilean.entity.OperationLog;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 操作日志DAO
|
||||
* @time: 2019/8/8 10:37
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IOperationLogDao extends BaseDao<OperationLog> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
|
||||
import cn.odboy.zilean.entity.Permission;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 菜单权限DAO
|
||||
* @time: 2019/8/8 10:37
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IPermissionDao extends BaseDao<Permission> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
|
||||
import cn.odboy.zilean.entity.Role;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 角色DAO
|
||||
* @time: 2019/8/8 10:37
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IRoleDao extends BaseDao<Role> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
|
||||
import cn.odboy.zilean.entity.RolePermission;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 角色菜单权限关联DAO
|
||||
* @time: 2019/8/8 10:37
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IRolePermissionDao extends BaseDao<RolePermission> {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.odboy.zilean.dao;
|
||||
|
||||
import cn.odboy.zilean.entity.User;
|
||||
import cn.odboy.zilean.mybatis.core.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 用户DAO
|
||||
* @time: 2019/8/8 10:38
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Repository
|
||||
public interface IUserDao extends BaseDao<User> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 字典数据
|
||||
* @time: 2019/8/3 7:43
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "dict_data")
|
||||
public class DictData extends BaseEntity {
|
||||
/**
|
||||
* 类型简称(eg. PayMode)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '类型简称(eg. PayMode)'")
|
||||
private String abbr;
|
||||
/**
|
||||
* 数据标题(eg. 支付宝)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '数据标题(eg. 支付宝)'")
|
||||
private String title;
|
||||
/**
|
||||
* 数据内容(eg. alipay)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '数据内容(eg. alipay)'")
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 字典类型
|
||||
* @time: 2019/8/3 7:43
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "dict_type")
|
||||
public class DictType extends BaseEntity {
|
||||
/**
|
||||
* 类型名称(eg. 付款方式)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) UNIQUE NOT NULL COMMENT '类型名称(eg. 付款方式)'")
|
||||
private String name;
|
||||
/**
|
||||
* 类型简称(eg. PayMode)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) UNIQUE NOT NULL COMMENT '类型简称(eg. PayMode)'")
|
||||
private String abbr;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 操作日志
|
||||
* @time: 2019/8/8 2:42
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "operation_log")
|
||||
public class OperationLog extends BaseEntity {
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
@Column(columnDefinition = "TINYINT(1) NOT NULL COMMENT '操作类型'")
|
||||
private Byte opType;
|
||||
/**
|
||||
* 操作内容
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) NOT NULL COMMENT '操作内容'")
|
||||
private String content;
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
@Column(columnDefinition = "BIGINT(20) NOT NULL COMMENT '操作人'")
|
||||
private Long userId;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 权限(可访问菜单)
|
||||
* @time: 2019/8/3 7:43
|
||||
* @blog: www.odboy.cn
|
||||
* <p>
|
||||
* 字段 type 是标示是菜单资源还是普通资源
|
||||
* 菜单资源的意义就是导航菜单,会显示到左侧导航,
|
||||
* 普通资源就是菜单内的按钮或者提交路径,
|
||||
* 这个时候 pid的意义就比较重要了,pid就是上级菜单的id,
|
||||
* 对于页面普通资源来说,就是相应的导航菜单的url
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "permission")
|
||||
public class Permission extends BaseEntity {
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
@Column(columnDefinition = "BIGINT(20) COMMENT '父ID'")
|
||||
private Long pid;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '标题'")
|
||||
private String title;
|
||||
/**
|
||||
* 权限编码(eg. user:list)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) COMMENT '权限编码(eg. user:list)'")
|
||||
private String code;
|
||||
/**
|
||||
* 页面URL
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) COMMENT '页面URL'")
|
||||
private String pageUrl;
|
||||
/**
|
||||
* 资源类型
|
||||
* 0、菜单资源 1、普通资源
|
||||
*/
|
||||
@Column(columnDefinition = "TINYINT(1) NOT NULL COMMENT '0、菜单资源 1、普通资源'")
|
||||
private Byte type;
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) COMMENT '菜单图标'")
|
||||
private String ico;
|
||||
/**
|
||||
* 资源是否可用
|
||||
* 0、禁用 1、启用
|
||||
*/
|
||||
@Column(columnDefinition = "TINYINT(1) NOT NULL COMMENT '资源是否可用'")
|
||||
private Byte status;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 角色
|
||||
* @time: 2019/8/3 7:43
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "role")
|
||||
public class Role extends BaseEntity {
|
||||
/**
|
||||
* 角色名称(eg. 超级管理员)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '角色名称(eg. 超级管理员)'")
|
||||
private String abbr;
|
||||
/**
|
||||
* 角色简称(eg. admin)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '角色简称(eg. admin)'")
|
||||
private String title;
|
||||
/**
|
||||
* 角色描述(eg. 拥有至高权限)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) COMMENT '角色描述(eg. 拥有至高权限)'")
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 角色权限关联关系
|
||||
* @time: 2019/8/3 7:43
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "role_permission")
|
||||
public class RolePermission extends BaseEntity {
|
||||
/**
|
||||
* 角色Id
|
||||
*/
|
||||
@Column(columnDefinition = "BIGINT(20) NOT NULL COMMENT '角色Id'")
|
||||
private Long roleId;
|
||||
/**
|
||||
* 权限Id
|
||||
*/
|
||||
@Column(columnDefinition = "BIGINT(20) NOT NULL COMMENT '权限Id'")
|
||||
private Long permissionId;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package cn.odboy.zilean.entity;
|
||||
|
||||
import cn.odboy.zilean.mybatis.entity.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 用户
|
||||
* @time: 2019/8/3 7:43
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@Table(name = "user")
|
||||
public class User extends BaseEntity {
|
||||
/**
|
||||
* 邮箱账号
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(20) UNIQUE NOT NULL COMMENT '邮箱账号'")
|
||||
private String username;
|
||||
/**
|
||||
* 密码(加密)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(18) NOT NULL COMMENT '密码(加密)'")
|
||||
private String userpwd;
|
||||
/**
|
||||
* 头像(JPG,小于500k,70*100px)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) COMMENT '头像(JPG,小于500k,70*100px)'")
|
||||
private String logoUrl;
|
||||
/**
|
||||
* 性别(0男、1女)
|
||||
*/
|
||||
@Column(columnDefinition = "TINYINT(1) COMMENT '性别(0男、1女)'")
|
||||
private Byte sex;
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(8) COMMENT '真实姓名'")
|
||||
private String realName;
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@Column(columnDefinition = "DATE COMMENT '生日'")
|
||||
private Date birth;
|
||||
/**
|
||||
* 联系方式
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(11) COMMENT '联系方式'")
|
||||
private String phoneNum;
|
||||
/**
|
||||
* 参加工作时间
|
||||
*/
|
||||
@Column(columnDefinition = "DATE COMMENT '参加工作时间'")
|
||||
private Date joinWorkDate;
|
||||
/**
|
||||
* 职业
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(100) COMMENT '职业'")
|
||||
private String maritalStatus;
|
||||
/**
|
||||
* 家乡
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) COMMENT '家乡'")
|
||||
private String hometown;
|
||||
/**
|
||||
* 背景音乐
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(255) COMMENT '背景音乐'")
|
||||
private String bgmUrl;
|
||||
/**
|
||||
* 签名(座右铭)
|
||||
*/
|
||||
@Column(columnDefinition = "VARCHAR(100) COMMENT '签名(座右铭)'")
|
||||
private String autograph;
|
||||
/**
|
||||
* 上一次登录时间
|
||||
*/
|
||||
@Column(columnDefinition = "DATETIME COMMENT '上一次登录时间'")
|
||||
private Date lastLoginTime;
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@Column(columnDefinition = "BIGINT(20) COMMENT '角色ID'")
|
||||
private Long roleId;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.odboy.zilean.map;
|
||||
|
||||
import cn.odboy.zilean.bo.PermissionBo;
|
||||
import cn.odboy.zilean.entity.Permission;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO PermissionBo转换器
|
||||
* @time: 2019/8/8 3:48
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface PermissionBoMapper {
|
||||
/**
|
||||
* PermissionBo 转 Permission
|
||||
*
|
||||
* @param permissionBo PermissionBo
|
||||
* @return Permission
|
||||
*/
|
||||
Permission boToPermission(PermissionBo permissionBo);
|
||||
|
||||
/**
|
||||
* Permission 转 PermissionBo
|
||||
*
|
||||
* @param permission Permission
|
||||
* @return PermissionBo
|
||||
*/
|
||||
PermissionBo permissionToBo(Permission permission);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.odboy.zilean.map;
|
||||
|
||||
import cn.odboy.zilean.bo.UserBo;
|
||||
import cn.odboy.zilean.entity.User;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO UserBo转换器
|
||||
* @time: 2019/8/8 3:48
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface UserBoMapper {
|
||||
/**
|
||||
* UserBo 转 User
|
||||
*
|
||||
* @param userBo UserBo
|
||||
* @return User
|
||||
*/
|
||||
User boToUser(UserBo userBo);
|
||||
|
||||
/**
|
||||
* User 转 UserBo
|
||||
*
|
||||
* @param user User
|
||||
* @return UserBo
|
||||
*/
|
||||
UserBo userToBo(User user);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.odboy.zilean.service;
|
||||
|
||||
import cn.odboy.zilean.dao.IUserDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author: Odboy
|
||||
* @version: Jdk 1.8
|
||||
* @desc: TODO 用户Service
|
||||
* @time: 2019/8/8 10:48
|
||||
* @blog: www.odboy.cn
|
||||
*/
|
||||
@Service
|
||||
public class UserService {
|
||||
/**
|
||||
* 自动注入: 用户DAO
|
||||
*/
|
||||
@Autowired
|
||||
private IUserDao userDao;
|
||||
}
|
||||
Reference in New Issue
Block a user