From bfc221b9de8106630865f8a9daf91b56926e99b8 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Wed, 24 Feb 2021 11:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 13 ++ .../controller/SysPermissionController.java | 20 +++ .../tms/controller/SysRoleController.java | 20 +++ .../SysRolePermissionController.java | 20 +++ .../tms/controller/SysUserRoleController.java | 20 +++ .../com/msdw/tms/dao/SysPermissionMapper.java | 18 +++ .../java/com/msdw/tms/dao/SysRoleMapper.java | 18 +++ .../msdw/tms/dao/SysRolePermissionMapper.java | 18 +++ .../com/msdw/tms/dao/SysUserRoleMapper.java | 18 +++ .../com/msdw/tms/entity/SysPermission.java | 90 ++++++++++++++ .../java/com/msdw/tms/entity/SysRole.java | 60 +++++++++ .../msdw/tms/entity/SysRolePermission.java | 39 ++++++ .../java/com/msdw/tms/entity/SysUserRole.java | 39 ++++++ .../tms/service/ISysPermissionService.java | 16 +++ .../service/ISysRolePermissionService.java | 16 +++ .../com/msdw/tms/service/ISysRoleService.java | 16 +++ .../msdw/tms/service/ISysUserRoleService.java | 16 +++ .../impl/SysPermissionServiceImpl.java | 20 +++ .../impl/SysRolePermissionServiceImpl.java | 20 +++ .../tms/service/impl/SysRoleServiceImpl.java | 20 +++ .../service/impl/SysUserRoleServiceImpl.java | 20 +++ .../tms/util/MyBatisPlusCodeGenerator.java | 115 ++++++++++++++++++ .../mapper/tms/SysPermissionMapper.xml | 22 ++++ .../resources/mapper/tms/SysRoleMapper.xml | 16 +++ .../mapper/tms/SysRolePermissionMapper.xml | 12 ++ .../mapper/tms/SysUserRoleMapper.xml | 12 ++ 26 files changed, 714 insertions(+) create mode 100644 src/main/java/com/msdw/tms/controller/SysPermissionController.java create mode 100644 src/main/java/com/msdw/tms/controller/SysRoleController.java create mode 100644 src/main/java/com/msdw/tms/controller/SysRolePermissionController.java create mode 100644 src/main/java/com/msdw/tms/controller/SysUserRoleController.java create mode 100644 src/main/java/com/msdw/tms/dao/SysPermissionMapper.java create mode 100644 src/main/java/com/msdw/tms/dao/SysRoleMapper.java create mode 100644 src/main/java/com/msdw/tms/dao/SysRolePermissionMapper.java create mode 100644 src/main/java/com/msdw/tms/dao/SysUserRoleMapper.java create mode 100644 src/main/java/com/msdw/tms/entity/SysPermission.java create mode 100644 src/main/java/com/msdw/tms/entity/SysRole.java create mode 100644 src/main/java/com/msdw/tms/entity/SysRolePermission.java create mode 100644 src/main/java/com/msdw/tms/entity/SysUserRole.java create mode 100644 src/main/java/com/msdw/tms/service/ISysPermissionService.java create mode 100644 src/main/java/com/msdw/tms/service/ISysRolePermissionService.java create mode 100644 src/main/java/com/msdw/tms/service/ISysRoleService.java create mode 100644 src/main/java/com/msdw/tms/service/ISysUserRoleService.java create mode 100644 src/main/java/com/msdw/tms/service/impl/SysPermissionServiceImpl.java create mode 100644 src/main/java/com/msdw/tms/service/impl/SysRolePermissionServiceImpl.java create mode 100644 src/main/java/com/msdw/tms/service/impl/SysRoleServiceImpl.java create mode 100644 src/main/java/com/msdw/tms/service/impl/SysUserRoleServiceImpl.java create mode 100644 src/main/java/com/msdw/tms/util/MyBatisPlusCodeGenerator.java create mode 100644 src/main/resources/mapper/tms/SysPermissionMapper.xml create mode 100644 src/main/resources/mapper/tms/SysRoleMapper.xml create mode 100644 src/main/resources/mapper/tms/SysRolePermissionMapper.xml create mode 100644 src/main/resources/mapper/tms/SysUserRoleMapper.xml diff --git a/pom.xml b/pom.xml index 0d3ac1b..1888f60 100644 --- a/pom.xml +++ b/pom.xml @@ -225,6 +225,19 @@ pagehelper 5.1.2 + + + + com.baomidou + mybatis-plus-generator + 3.3.1 + + + org.freemarker + freemarker + 2.3.28 + compile + diff --git a/src/main/java/com/msdw/tms/controller/SysPermissionController.java b/src/main/java/com/msdw/tms/controller/SysPermissionController.java new file mode 100644 index 0000000..3828387 --- /dev/null +++ b/src/main/java/com/msdw/tms/controller/SysPermissionController.java @@ -0,0 +1,20 @@ +package com.msdw.tms.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 菜单权限表 前端控制器 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@RestController +@RequestMapping("/sys-permission") +public class SysPermissionController { + +} diff --git a/src/main/java/com/msdw/tms/controller/SysRoleController.java b/src/main/java/com/msdw/tms/controller/SysRoleController.java new file mode 100644 index 0000000..76cef81 --- /dev/null +++ b/src/main/java/com/msdw/tms/controller/SysRoleController.java @@ -0,0 +1,20 @@ +package com.msdw.tms.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 用户角色表 前端控制器 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@RestController +@RequestMapping("/sys-role") +public class SysRoleController { + +} diff --git a/src/main/java/com/msdw/tms/controller/SysRolePermissionController.java b/src/main/java/com/msdw/tms/controller/SysRolePermissionController.java new file mode 100644 index 0000000..c678b79 --- /dev/null +++ b/src/main/java/com/msdw/tms/controller/SysRolePermissionController.java @@ -0,0 +1,20 @@ +package com.msdw.tms.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 角色权限中间表 前端控制器 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@RestController +@RequestMapping("/sys-role-permission") +public class SysRolePermissionController { + +} diff --git a/src/main/java/com/msdw/tms/controller/SysUserRoleController.java b/src/main/java/com/msdw/tms/controller/SysUserRoleController.java new file mode 100644 index 0000000..fb47650 --- /dev/null +++ b/src/main/java/com/msdw/tms/controller/SysUserRoleController.java @@ -0,0 +1,20 @@ +package com.msdw.tms.controller; + + +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 用户角色中间表 前端控制器 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@RestController +@RequestMapping("/sys-user-role") +public class SysUserRoleController { + +} diff --git a/src/main/java/com/msdw/tms/dao/SysPermissionMapper.java b/src/main/java/com/msdw/tms/dao/SysPermissionMapper.java new file mode 100644 index 0000000..a3f94f8 --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/SysPermissionMapper.java @@ -0,0 +1,18 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.msdw.tms.entity.SysPermission; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 菜单权限表 Mapper 接口 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Mapper +public interface SysPermissionMapper extends BaseMapper { + +} diff --git a/src/main/java/com/msdw/tms/dao/SysRoleMapper.java b/src/main/java/com/msdw/tms/dao/SysRoleMapper.java new file mode 100644 index 0000000..e30fa9d --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/SysRoleMapper.java @@ -0,0 +1,18 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.msdw.tms.entity.SysRole; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 用户角色表 Mapper 接口 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Mapper +public interface SysRoleMapper extends BaseMapper { + +} diff --git a/src/main/java/com/msdw/tms/dao/SysRolePermissionMapper.java b/src/main/java/com/msdw/tms/dao/SysRolePermissionMapper.java new file mode 100644 index 0000000..e294523 --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/SysRolePermissionMapper.java @@ -0,0 +1,18 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.msdw.tms.entity.SysRolePermission; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 角色权限中间表 Mapper 接口 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Mapper +public interface SysRolePermissionMapper extends BaseMapper { + +} diff --git a/src/main/java/com/msdw/tms/dao/SysUserRoleMapper.java b/src/main/java/com/msdw/tms/dao/SysUserRoleMapper.java new file mode 100644 index 0000000..a4a1339 --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/SysUserRoleMapper.java @@ -0,0 +1,18 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.msdw.tms.entity.SysUserRole; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 用户角色中间表 Mapper 接口 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Mapper +public interface SysUserRoleMapper extends BaseMapper { + +} diff --git a/src/main/java/com/msdw/tms/entity/SysPermission.java b/src/main/java/com/msdw/tms/entity/SysPermission.java new file mode 100644 index 0000000..d769846 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/SysPermission.java @@ -0,0 +1,90 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 菜单权限表 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Data +@TableName("sys_permission") +public class SysPermission implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 权限标识符 + */ + private String code; + + /** + * 名称 + */ + private String name; + + /** + * 父权限id + */ + private Long parentId; + + /** + * 层级 + */ + private Integer level; + + /** + * 是否是菜单:1、是,0、不是(0目前为按钮) + */ + private Integer menuOrNot; + + /** + * 状态:0、启用,1、禁用 + */ + private Integer status; + + /** + * 路径 + */ + private String url; + + /** + * 页面路径 + */ + private String menuUrl; + + /** + * 排序 + */ + private Integer sort; + + /** + * 图标 + */ + private String icon; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date motifyTime; +} diff --git a/src/main/java/com/msdw/tms/entity/SysRole.java b/src/main/java/com/msdw/tms/entity/SysRole.java new file mode 100644 index 0000000..6a6ffac --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/SysRole.java @@ -0,0 +1,60 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 用户角色表 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Data +@TableName("sys_role") +public class SysRole implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 角色名称 + */ + private String name; + + /** + * 角色描述 + */ + private String description; + + /** + * 是否删除:0、未删除,1、删除 + */ + private Integer delOrNot; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date motifyTime; + + /** + * 编码 + */ + private String code; +} diff --git a/src/main/java/com/msdw/tms/entity/SysRolePermission.java b/src/main/java/com/msdw/tms/entity/SysRolePermission.java new file mode 100644 index 0000000..b4add0e --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/SysRolePermission.java @@ -0,0 +1,39 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 角色权限中间表 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Data +@TableName("sys_role_permission") +public class SysRolePermission implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 角色id + */ + private Long roleId; + + /** + * 权限id + */ + private Long permissionId; +} diff --git a/src/main/java/com/msdw/tms/entity/SysUserRole.java b/src/main/java/com/msdw/tms/entity/SysUserRole.java new file mode 100644 index 0000000..aa886f5 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/SysUserRole.java @@ -0,0 +1,39 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 用户角色中间表 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Data +@TableName("sys_user_role") +public class SysUserRole implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 角色id + */ + private Long roleId; +} diff --git a/src/main/java/com/msdw/tms/service/ISysPermissionService.java b/src/main/java/com/msdw/tms/service/ISysPermissionService.java new file mode 100644 index 0000000..0786537 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ISysPermissionService.java @@ -0,0 +1,16 @@ +package com.msdw.tms.service; + +import com.msdw.tms.entity.SysPermission; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 菜单权限表 服务类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +public interface ISysPermissionService extends IService { + +} diff --git a/src/main/java/com/msdw/tms/service/ISysRolePermissionService.java b/src/main/java/com/msdw/tms/service/ISysRolePermissionService.java new file mode 100644 index 0000000..08bfc35 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ISysRolePermissionService.java @@ -0,0 +1,16 @@ +package com.msdw.tms.service; + +import com.msdw.tms.entity.SysRolePermission; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 角色权限中间表 服务类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +public interface ISysRolePermissionService extends IService { + +} diff --git a/src/main/java/com/msdw/tms/service/ISysRoleService.java b/src/main/java/com/msdw/tms/service/ISysRoleService.java new file mode 100644 index 0000000..8d5af9c --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ISysRoleService.java @@ -0,0 +1,16 @@ +package com.msdw.tms.service; + +import com.msdw.tms.entity.SysRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户角色表 服务类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +public interface ISysRoleService extends IService { + +} diff --git a/src/main/java/com/msdw/tms/service/ISysUserRoleService.java b/src/main/java/com/msdw/tms/service/ISysUserRoleService.java new file mode 100644 index 0000000..dc900c5 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ISysUserRoleService.java @@ -0,0 +1,16 @@ +package com.msdw.tms.service; + +import com.msdw.tms.entity.SysUserRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户角色中间表 服务类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +public interface ISysUserRoleService extends IService { + +} diff --git a/src/main/java/com/msdw/tms/service/impl/SysPermissionServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/SysPermissionServiceImpl.java new file mode 100644 index 0000000..30d305e --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/SysPermissionServiceImpl.java @@ -0,0 +1,20 @@ +package com.msdw.tms.service.impl; + +import com.msdw.tms.dao.SysPermissionMapper; +import com.msdw.tms.entity.SysPermission; +import com.msdw.tms.service.ISysPermissionService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 菜单权限表 服务实现类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Service +public class SysPermissionServiceImpl extends ServiceImpl implements ISysPermissionService { + +} diff --git a/src/main/java/com/msdw/tms/service/impl/SysRolePermissionServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/SysRolePermissionServiceImpl.java new file mode 100644 index 0000000..713fac2 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/SysRolePermissionServiceImpl.java @@ -0,0 +1,20 @@ +package com.msdw.tms.service.impl; + +import com.msdw.tms.dao.SysRolePermissionMapper; +import com.msdw.tms.entity.SysRolePermission; +import com.msdw.tms.service.ISysRolePermissionService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 角色权限中间表 服务实现类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Service +public class SysRolePermissionServiceImpl extends ServiceImpl implements ISysRolePermissionService { + +} diff --git a/src/main/java/com/msdw/tms/service/impl/SysRoleServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/SysRoleServiceImpl.java new file mode 100644 index 0000000..58b4856 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,20 @@ +package com.msdw.tms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.msdw.tms.dao.SysRoleMapper; +import com.msdw.tms.entity.SysRole; +import com.msdw.tms.service.ISysRoleService; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户角色表 服务实现类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Service +public class SysRoleServiceImpl extends ServiceImpl implements ISysRoleService { + +} diff --git a/src/main/java/com/msdw/tms/service/impl/SysUserRoleServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/SysUserRoleServiceImpl.java new file mode 100644 index 0000000..336895a --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/SysUserRoleServiceImpl.java @@ -0,0 +1,20 @@ +package com.msdw.tms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.msdw.tms.dao.SysUserRoleMapper; +import com.msdw.tms.entity.SysUserRole; +import com.msdw.tms.service.ISysUserRoleService; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户角色中间表 服务实现类 + *

+ * + * @author Qyq + * @since 2021-02-24 + */ +@Service +public class SysUserRoleServiceImpl extends ServiceImpl implements ISysUserRoleService { + +} diff --git a/src/main/java/com/msdw/tms/util/MyBatisPlusCodeGenerator.java b/src/main/java/com/msdw/tms/util/MyBatisPlusCodeGenerator.java new file mode 100644 index 0000000..e7f58ca --- /dev/null +++ b/src/main/java/com/msdw/tms/util/MyBatisPlusCodeGenerator.java @@ -0,0 +1,115 @@ +package com.msdw.tms.util; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.InjectionConfig; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.po.TableInfo; +import com.baomidou.mybatisplus.generator.config.rules.DateType; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author: LvFang + * @Date: Created in 2019/6/11. + * @Description: + */ +public class MyBatisPlusCodeGenerator { + + //包名 + public static final String PACKAGE_NAME = "com.msdw.tms"; + + public static void main(String[] args) { + String[] tables = new String[] {"sys_role","sys_role_permission","sys_user_role"};//表名数组 + String[] tablePrefixs = new String[] {""};//去掉前缀 + executeCode(PACKAGE_NAME,tables,tablePrefixs); + } + + private static void executeCode(String pack, String[] tables, String[] tablePrefixs) { + // 代码生成器 + AutoGenerator mpg = new AutoGenerator(); + + // 全局配置 + GlobalConfig gc = new GlobalConfig(); + // 是否覆盖已有文件 + gc.setFileOverride(false); + // 生成文件的输出目录 + String projectPath = System.getProperty("user.dir");//user.dir 表示当前工程路径无需替换 + gc.setOutputDir(projectPath + "/src/main/java"); + //设置bean命名规范 + gc.setEntityName("%s"); + // 开发人员 + gc.setAuthor("Qyq"); + // 是否打开输出目录 + gc.setOpen(false); + // 开启 BaseResultMap + gc.setBaseResultMap(true); + // 指定生成的主键的ID类型 + gc.setIdType(IdType.ID_WORKER); + // 时间类型对应策略: 只使用 java.util.date 代替 + gc.setDateType(DateType.ONLY_DATE); + mpg.setGlobalConfig(gc); + + // 数据源配置 + DataSourceConfig config= new DataSourceConfig(); + // 从试图获取 + config.setUrl("jdbc:mysql://localhost:3306/msdw_tms?serverTimezone=UTC"); + config.setDriverName("com.mysql.cj.jdbc.Driver"); + config.setUsername("root"); + config.setPassword("root"); + mpg.setDataSource(config); + + // 包配置 + PackageConfig pc = new PackageConfig(); + // 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名 + pc.setParent(pack); + // Entity包名 + pc.setEntity("entity"); + mpg.setPackageInfo(pc); + + // 自定义配置 + InjectionConfig cfg = new InjectionConfig() { + @Override + public void initMap() { + // to do nothing + } + }; + List focList = new ArrayList<>(); + focList.add(new FileOutConfig("/templates/mapper.xml.ftl") { + public String outputFile(TableInfo tableInfo) { + // 自定义输入文件名称 + if (StringUtils.isEmpty(pc.getModuleName())) { + return projectPath + "/src/main/resources/mapper/tms/" + tableInfo.getXmlName() + StringPool.DOT_XML; + }else { + return projectPath + "/src/main/resources/mapper/tms/" + pc.getModuleName() + "/" + tableInfo.getXmlName() + StringPool.DOT_XML; + } + } + }); + cfg.setFileOutConfigList(focList); + mpg.setCfg(cfg); + mpg.setTemplate(new TemplateConfig().setXml(null)); + + // 策略配置 + StrategyConfig strategy = new StrategyConfig(); + // 数据库表映射到实体的命名策略: 下划线转驼峰命名 + strategy.setNaming(NamingStrategy.underline_to_camel); + // 数据库表字段映射到实体的命名策略: 下划线转驼峰命名 + strategy.setColumnNaming(NamingStrategy.underline_to_camel); + // 【实体】是否为lombok模型(默认 false) + strategy.setEntityLombokModel(false); + // 需要包含的表名,允许正则表达式(与exclude二选一配置) + strategy.setInclude(tables); + // 驼峰转连字符 + strategy.setControllerMappingHyphenStyle(true); + // 表前缀 + strategy.setTablePrefix(tablePrefixs); + mpg.setStrategy(strategy); + mpg.setTemplateEngine(new FreemarkerTemplateEngine()); + mpg.execute(); + } +} diff --git a/src/main/resources/mapper/tms/SysPermissionMapper.xml b/src/main/resources/mapper/tms/SysPermissionMapper.xml new file mode 100644 index 0000000..806173d --- /dev/null +++ b/src/main/resources/mapper/tms/SysPermissionMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/tms/SysRoleMapper.xml b/src/main/resources/mapper/tms/SysRoleMapper.xml new file mode 100644 index 0000000..95f2bc5 --- /dev/null +++ b/src/main/resources/mapper/tms/SysRoleMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/tms/SysRolePermissionMapper.xml b/src/main/resources/mapper/tms/SysRolePermissionMapper.xml new file mode 100644 index 0000000..ebeb487 --- /dev/null +++ b/src/main/resources/mapper/tms/SysRolePermissionMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/main/resources/mapper/tms/SysUserRoleMapper.xml b/src/main/resources/mapper/tms/SysUserRoleMapper.xml new file mode 100644 index 0000000..00527ea --- /dev/null +++ b/src/main/resources/mapper/tms/SysUserRoleMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + +