forked from github/dataease
feat: 添加权限数据结构
This commit is contained in:
parent
665cbd9b1e
commit
00a51d9a0c
@ -1,6 +1,6 @@
|
||||
package com.fit2cloud.commons.auth.bean;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.Permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -10,10 +10,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ExtPermissionBean extends Permission {
|
||||
private String url;
|
||||
|
||||
public PermissionKey getKey(){
|
||||
return PermissionKey.builder().resourceId(getResourceId()).url(url).build();
|
||||
}
|
||||
public class ExtPermissionBean {
|
||||
private String path;
|
||||
private String permission;
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.fit2cloud.commons.auth.bean;
|
||||
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.User;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.fit2cloud.commons.auth.dao;
|
||||
|
||||
|
||||
|
||||
import com.fit2cloud.commons.auth.bean.ExtPermissionBean;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@ -10,22 +11,23 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface ExtUserMapper {
|
||||
|
||||
@Select("select password from user where user_id = #{userId,jdbcType=VARCHAR} ")
|
||||
@Select("select password from sys_user where user_id = #{userId,jdbcType=VARCHAR} ")
|
||||
String getPassword(String userId);
|
||||
|
||||
@Select("select role_id from role_user where user_id = #{userId,jdbcType=VARCHAR} ")
|
||||
@Select("select role_id from sys_users_roles where user_id = #{userId,jdbcType=VARCHAR} ")
|
||||
List<String> getRole(String userId);
|
||||
|
||||
@Select({
|
||||
"select resource_id from permission p " ,
|
||||
"left join role_user ru on p.relation_id = ru.role_id " ,
|
||||
"where type = 'role' and ru.user_id = #{userId,jdbcType=VARCHAR} "
|
||||
"select sm.permission ",
|
||||
"from sys_users_roles sur ",
|
||||
"LEFT JOIN sys_roles_menus srm on srm.role_id = sur.role_id ",
|
||||
"LEFT JOIN sys_menu sm on sm.menu_id = srm.menu_id ",
|
||||
"where sur.user_id = #{userId,jdbcType=VARCHAR} "
|
||||
})
|
||||
List<String> getPermission(String userId);
|
||||
|
||||
@Select({
|
||||
"select p.*,r.url ",
|
||||
"from permission p left join resource r on p.resource_id = r.id"
|
||||
})
|
||||
@Select("select path,permission from sys_menu where path is not null")
|
||||
List<ExtPermissionBean> getPermissions();
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("org_user")
|
||||
public class OrgUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableField("org_id")
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private String userId;
|
||||
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("organization")
|
||||
public class Organization implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 上级部门ID
|
||||
*/
|
||||
@TableField("pid")
|
||||
private Integer pid;
|
||||
|
||||
/**
|
||||
* 部门级别
|
||||
*/
|
||||
@TableField("level")
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Long createTime;
|
||||
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("permission")
|
||||
public class Permission implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 关联ID
|
||||
*/
|
||||
@TableField("relation_id")
|
||||
private String relationId;
|
||||
|
||||
/**
|
||||
* 资源ID
|
||||
*/
|
||||
@TableField("resource_id")
|
||||
private String resourceId;
|
||||
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("resource")
|
||||
public class Resource implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 资源名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 资源描述
|
||||
*/
|
||||
@TableField("desc")
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 资源地址
|
||||
*/
|
||||
@TableField("url")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Long createTime;
|
||||
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("role")
|
||||
public class Role implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("role_user")
|
||||
public class RoleUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableField("role_id")
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private String userId;
|
||||
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("user")
|
||||
public class User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@TableField("user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@TableField("password")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
@TableField("valid")
|
||||
private Boolean valid;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
@TableField("phone_number")
|
||||
private Integer phoneNumber;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@TableField("email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Long createTime;
|
||||
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.OrgUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrgUserMapper extends BaseMapper<OrgUser> {
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.Organization;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrganizationMapper extends BaseMapper<Organization> {
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.Permission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionMapper extends BaseMapper<Permission> {
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.Resource;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface ResourceMapper extends BaseMapper<Resource> {
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.Role;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.RoleUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleUserMapper extends BaseMapper<RoleUser> {
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.fit2cloud.commons.auth.mapper;
|
||||
|
||||
import com.fit2cloud.commons.auth.entity.User;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cyw
|
||||
* @since 2021-02-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package com.fit2cloud.commons.auth.service;
|
||||
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fit2cloud.commons.auth.bean.UserBean;
|
||||
import com.fit2cloud.commons.auth.dao.ExtUserMapper;
|
||||
import com.fit2cloud.commons.auth.entity.User;
|
||||
import com.fit2cloud.commons.auth.mapper.UserMapper;
|
||||
import com.fit2cloud.commons.auth.entity.SysUser;
|
||||
import com.fit2cloud.commons.auth.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
@ -18,11 +19,12 @@ public class UserService {
|
||||
private ExtUserMapper extUserMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private UserMapper userMapper;
|
||||
private SysUserMapper sysUserMapper;
|
||||
public UserBean getUser(String username){
|
||||
User user = userMapper.selectById(username);
|
||||
if (ObjectUtil.isNull(user))return null;
|
||||
String password = user.getPassword();
|
||||
SysUser sysUser = sysUserMapper.selectById(username);
|
||||
|
||||
if (ObjectUtil.isNull(sysUser))return null;
|
||||
String password = sysUser.getPassword();
|
||||
List<String> roles = extUserMapper.getRole(username);
|
||||
String role = roles.stream().collect(Collectors.joining(","));
|
||||
List<String> permissions = extUserMapper.getPermission(username);
|
||||
|
@ -1,14 +1,15 @@
|
||||
package com.fit2cloud.commons.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fit2cloud.commons.auth.bean.ExtPermissionBean;
|
||||
import com.fit2cloud.commons.auth.dao.ExtUserMapper;
|
||||
import com.fit2cloud.commons.auth.entity.Permission;
|
||||
import com.fit2cloud.commons.auth.service.ShiroService;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
@Service
|
||||
public class ShiroServiceImpl implements ShiroService {
|
||||
@ -44,29 +45,15 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
filterChainDefinitionMap.put("/downline", "anon");
|
||||
// 放行 end ----------------------------------------------------------
|
||||
filterChainDefinitionMap.put("/logout", "logout");
|
||||
//List<Resource> resources = resourceMapper.selectList(null);
|
||||
QueryWrapper<Permission> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("type", "role");
|
||||
/*List<ExtPermissionBean> extPermissionBeans = extUserMapper.getPermissions();
|
||||
|
||||
List<ExtPermissionBean> extPermissionBeans = extUserMapper.getPermissions();
|
||||
|
||||
extPermissionBeans.forEach(item -> {
|
||||
StringJoiner f2cPerms = new StringJoiner(",", "f2cPerms[", "]");
|
||||
f2cPerms.add(item.getPermission());
|
||||
filterChainDefinitionMap.put(item.getPath(), "jwt," + f2cPerms);
|
||||
});
|
||||
|
||||
if (CollectionUtils.isNotEmpty(extPermissionBeans)){
|
||||
Map<PermissionKey, List<ExtPermissionBean>> resourcePerMap = extPermissionBeans.stream().collect(Collectors.groupingBy(ExtPermissionBean::getKey));
|
||||
resourcePerMap.entrySet().stream().forEach(entry -> {
|
||||
PermissionKey permissionKey = entry.getKey();
|
||||
String url = permissionKey.getUrl();
|
||||
String resourceId = permissionKey.getResourceId();
|
||||
//List<ExtPermissionBean> permissionList = entry.getValue();
|
||||
//StringJoiner f2cRoles = new StringJoiner(",", "f2cRoles[", "]");
|
||||
StringJoiner f2cPerms = new StringJoiner(",", "f2cPerms[", "]");
|
||||
f2cPerms.add(resourceId);
|
||||
*//*permissionList.forEach(per -> {
|
||||
String roleId = per.getRelationId();
|
||||
f2cRoles.add(roleId);
|
||||
});*//*
|
||||
filterChainDefinitionMap.put(url, "jwt," + f2cPerms);
|
||||
});
|
||||
}*/
|
||||
filterChainDefinitionMap.put("/**", "jwt");
|
||||
return filterChainDefinitionMap;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package com.fit2cloud.system.api;
|
||||
|
||||
import com.fit2cloud.common.db.PageUtils;
|
||||
import com.fit2cloud.common.db.Pager;
|
||||
import com.fit2cloud.commons.auth.entity.User;
|
||||
import com.fit2cloud.commons.auth.mapper.UserMapper;
|
||||
/*import com.fit2cloud.commons.auth.entity.User;
|
||||
import com.fit2cloud.commons.auth.mapper.UserMapper;*/
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -22,7 +22,7 @@ public class BusiApi {
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
/*@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -33,5 +33,5 @@ public class BusiApi {
|
||||
List<User> users = userMapper.selectList(null);
|
||||
Pager<List<User>> pageInfo = PageUtils.setPageInfo(page, users);
|
||||
return pageInfo;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -1,8 +1,128 @@
|
||||
CREATE TABLE test_users (
|
||||
id bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
username varchar(100) NOT NULL,
|
||||
first_name varchar(50) NOT NULL,
|
||||
last_name varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY UK_username (username)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
DROP TABLE IF EXISTS `sys_dept`;
|
||||
CREATE TABLE `sys_dept` (
|
||||
`dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`pid` bigint(20) DEFAULT NULL COMMENT '上级部门',
|
||||
`sub_count` int(5) DEFAULT 0 COMMENT '子部门数目',
|
||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||
`dept_sort` int(5) DEFAULT 999 COMMENT '排序',
|
||||
`enabled` bit(1) NOT NULL COMMENT '状态',
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`dept_id`) USING BTREE,
|
||||
KEY `inx_pid` (`pid`),
|
||||
KEY `inx_enabled` (`enabled`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_dict`;
|
||||
CREATE TABLE `sys_dict` (
|
||||
`dict_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`name` varchar(255) NOT NULL COMMENT '字典名称',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`dict_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='数据字典';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_dict_detail`;
|
||||
CREATE TABLE `sys_dict_detail` (
|
||||
`detail_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`dict_id` bigint(11) DEFAULT NULL COMMENT '字典id',
|
||||
`label` varchar(255) NOT NULL COMMENT '字典标签',
|
||||
`value` varchar(255) NOT NULL COMMENT '字典值',
|
||||
`dict_sort` int(5) DEFAULT NULL COMMENT '排序',
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`detail_id`) USING BTREE,
|
||||
KEY `FK5tpkputc6d9nboxojdbgnpmyb` (`dict_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='数据字典详情';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_menu`;
|
||||
CREATE TABLE `sys_menu` (
|
||||
`menu_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`pid` bigint(20) DEFAULT NULL COMMENT '上级菜单ID',
|
||||
`sub_count` int(5) DEFAULT 0 COMMENT '子菜单数目',
|
||||
`type` int(11) DEFAULT NULL COMMENT '菜单类型',
|
||||
`title` varchar(255) DEFAULT NULL COMMENT '菜单标题',
|
||||
`name` varchar(255) DEFAULT NULL COMMENT '组件名称',
|
||||
`component` varchar(255) DEFAULT NULL COMMENT '组件',
|
||||
`menu_sort` int(5) DEFAULT NULL COMMENT '排序',
|
||||
`icon` varchar(255) DEFAULT NULL COMMENT '图标',
|
||||
`path` varchar(255) DEFAULT NULL COMMENT '链接地址',
|
||||
`i_frame` bit(1) DEFAULT NULL COMMENT '是否外链',
|
||||
`cache` bit(1) DEFAULT b'0' COMMENT '缓存',
|
||||
`hidden` bit(1) DEFAULT b'0' COMMENT '隐藏',
|
||||
`permission` varchar(255) DEFAULT NULL COMMENT '权限',
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`menu_id`) USING BTREE,
|
||||
UNIQUE KEY `uniq_title` (`title`),
|
||||
UNIQUE KEY `uniq_name` (`name`),
|
||||
KEY `inx_pid` (`pid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统菜单';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_role`;
|
||||
CREATE TABLE `sys_role` (
|
||||
`role_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`role_id`) USING BTREE,
|
||||
UNIQUE KEY `uniq_name` (`name`),
|
||||
KEY `role_name_index` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色表';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
CREATE TABLE `sys_user` (
|
||||
`user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`dept_id` bigint(20) DEFAULT NULL COMMENT '部门名称',
|
||||
`username` varchar(255) DEFAULT NULL COMMENT '用户名',
|
||||
`nick_name` varchar(255) DEFAULT NULL COMMENT '昵称',
|
||||
`gender` varchar(2) DEFAULT NULL COMMENT '性别',
|
||||
`phone` varchar(255) DEFAULT NULL COMMENT '手机号码',
|
||||
`email` varchar(255) DEFAULT NULL COMMENT '邮箱',
|
||||
`avatar_name` varchar(255) DEFAULT NULL COMMENT '头像地址',
|
||||
`avatar_path` varchar(255) DEFAULT NULL COMMENT '头像真实路径',
|
||||
`password` varchar(255) DEFAULT NULL COMMENT '密码',
|
||||
`is_admin` bit(1) DEFAULT b'0' COMMENT '是否为admin账号',
|
||||
`enabled` bigint(20) DEFAULT NULL COMMENT '状态:1启用、0禁用',
|
||||
`create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新着',
|
||||
`pwd_reset_time` datetime DEFAULT NULL COMMENT '修改密码的时间',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`user_id`) USING BTREE,
|
||||
UNIQUE KEY `UK_kpubos9gc2cvtkb0thktkbkes` (`email`) USING BTREE,
|
||||
UNIQUE KEY `username` (`username`) USING BTREE,
|
||||
UNIQUE KEY `uniq_username` (`username`),
|
||||
UNIQUE KEY `uniq_email` (`email`),
|
||||
KEY `FK5rwmryny6jthaaxkogownknqp` (`dept_id`) USING BTREE,
|
||||
KEY `FKpq2dhypk2qgt68nauh2by22jb` (`avatar_name`) USING BTREE,
|
||||
KEY `inx_enabled` (`enabled`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sys_users_roles`;
|
||||
CREATE TABLE `sys_users_roles` (
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`user_id`,`role_id`) USING BTREE,
|
||||
KEY `FKq4eq273l04bpu4efj0jd0jb98` (`role_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户角色关联';
|
||||
|
Loading…
Reference in New Issue
Block a user