Commit 499c23f3 by 李小龙

saas实体+登录接口

parent 87d7f125
Showing with 2497 additions and 8 deletions
......@@ -22,6 +22,11 @@
<artifactId>server-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.makeit</groupId>
<artifactId>server-service</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
......
package com.makeit.controller.saas;
import com.makeit.common.dto.LoginDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.service.saas.SaasUserService;
import com.makeit.utils.user.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "saas端-登录")
@RestController
@RequestMapping("/saas/login")
public class SaasLoginController {
@Autowired
private SaasUserService saasUserService;
@ApiOperation("登录")
@PostMapping("login")
public ApiResponseEntity<UserLoginVO> login(@RequestBody LoginDTO loginDTO) {
return ApiResponseUtils.success(saasUserService.login(loginDTO));
}
@ApiOperation("退出登录")
@PostMapping("logout")
public ApiResponseEntity<?> logout() {
saasUserService.logout();
return ApiResponseUtils.success();
}
}
......@@ -4,12 +4,12 @@ public class HeaderConst {
public static final String TENANT_ID = Const.TENANT_ID;
//public static final String PLATFORM_TOKEN = "platformToken";
public static final String PLATFORM_TOKEN = "platformToken";
public static final String TOKEN = "token";
public static final String WECHAT_TOKEN = "wechatToken";
//public static final String CUSTOMER_TOKEN = "customerToken";
// public static final String CUSTOMER_TOKEN = "customerToken";
public static final String SIGN = "sign";
......
package com.makeit.enums.biz.auth;
import com.makeit.utils.sys.SysDictUtil;
public class TenantEnum {
public enum DataScopeTypeEnum {
ALL("datascope.type.all"),
SPECIAL("datascope.type.special");
private String code;
DataScopeTypeEnum(String code) {
this.code = code;
}
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
......@@ -86,6 +86,10 @@ public class RedisConst {
public static final String TOPIC_TNT_CONFIG_REFRESH = "topic:tnt:config:refresh";
public static final String TOPIC_I18N_DIC_REFRESH = "topic:i18n:dict:refresh";
public static final String PLATFORM_TOKEN_PREFIX = "plat:token:";
public static final String PLATFORM_TOKEN_ROLE_MENU_PREFIX = "plat:role:menu:token:";
}
......
package com.makeit.module.admin.saas;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel("平台端菜单 新增 编辑 详情")
@Data
public class PlatMenuDTOVO extends BaseIdDTO implements Serializable {
@NotBlank(message = "上级菜单不能为空")
@ApiModelProperty(value = "父级id")
private String parentId;
@NotBlank(message = "名称不能为空")
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "模块+类名+方法")
private String code;
@ApiModelProperty(value = "图标")
private String icon;
@ApiModelProperty(value = "排序")
private Integer sort;
@NotBlank(message = "状态不能为空")
@Pattern(regexp = "0|1", message = "状态可选值 0禁用 1启用")
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@NotBlank(message = "类型不能为空")
@Pattern(regexp = "1|2|3", message = "类型可选值 1目录 2菜单 3按钮")
@ApiModelProperty(value = "类型 1目录 2菜单 3按钮")
private String category;
@ApiModelProperty(value = "前端路径")
private String requestPath;
@ApiModelProperty(value = "组件路径")
private String componentPath;
@ApiModelProperty(value = "组件名称")
private String componentName;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "隐藏状态 0不隐藏 1隐藏")
private String hiddenStatus;
@ApiModelProperty(value = "缓存状态 0不缓存 1缓存")
private String cacheStatus;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
@TableField(exist = false)
@ApiModelProperty(value = "子集")
private List<PlatMenuDTOVO> children;
}
package com.makeit.module.admin.saas;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel("平台端菜单查询")
@Data
public class PlatMenuQueryDTO implements Serializable {
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@ApiModelProperty(value = "角色id")
private String roleId;
}
package com.makeit.module.admin.saas;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;
@ApiModel("平台端角色 列表 新增 编辑 详情")
@Data
public class PlatRoleDTOVO extends BaseIdDTO implements Serializable {
@NotBlank(message = "名称不能为空")
@Size(max = 64, message = "名称最长为64字符")
@ApiModelProperty(value = "名称")
private String name;
@NotBlank(message = "编码不能为空")
@Size(max = 64, message = "编码最长为64字符")
@Pattern(regexp = "[a-zA-Z0-9]{0,64}", message = "编码只能为大小写英文字符和数字")
@ApiModelProperty(value = "编码")
private String code;
@NotBlank(message = "状态不能为空")
@Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用")
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "数据权限 1全部 2指定租户")
private String dataScopeType;
@ApiModelProperty(value = "租户id列表 以逗号分隔")
private String dataScope;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
@ApiModelProperty(value = "关键词 查询用")
private String keyword;
}
package com.makeit.module.admin.saas;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@ApiModel("平台端角色分配菜单")
@Data
public class PlatRoleMenuDTO implements Serializable {
@ApiModelProperty(value = "角色id")
private String roleId;
// @ApiModelProperty(value = "角色id")
// private String roleId;
@ApiModelProperty(value = "菜单id集合")
private List<String> menuIdList;
}
package com.makeit.module.admin.saas;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel("平台端用户 新增 编辑 详情")
@Data
public class PlatUserDTOVO extends BaseIdDTO implements Serializable {
// @ApiModelProperty(value = "用户名")
// private String username;
@NotBlank(message = "账户不能为空")
@Size(max = 64, message = "名称最长为64字符")
@Pattern(regexp = "[a-zA-Z0-9]{0,64}", message = "账户只能为大小写英文字符和数字")
@ApiModelProperty(value = "账户")
private String account;
//@NotBlank(message = "密码不能为空")
@Size(max = 32, message = "密码最长为64字符")
@ApiModelProperty(value = "密码")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password;
@NotBlank(message = "姓名不能为空")
@Size(max = 64, message = "姓名最长为64字符")
@ApiModelProperty(value = "姓名")
private String name;
@NotBlank(message = "手机号不能为空")
@Pattern(regexp = "1[0-9]{10}",message = "手机号格式不对")
//@Size(max = 11, message = "手机号最长为64字符")
@ApiModelProperty(value = "手机号")
private String mobile;
@NotBlank(message = "状态不能为空")
@Pattern(regexp = "0|1", message = "状态可选值为 0禁用 1启用")
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@Size(max = 512, message = "备注最长512字符")
@ApiModelProperty(value = "备注")
private String remark;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", required = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
@TableField(exist = false)
@ApiModelProperty(value = "角色集合")
private List<PlatRoleDTOVO> roleList;
}
package com.makeit.module.admin.saas;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel("平台端用户 查询")
@Data
public class PlatUserQueryDTO implements Serializable {
@ApiModelProperty(value = "账户")
private String account;
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "手机号")
private String mobile;
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@ApiModelProperty(value = "角色id roleId和notRoleId只能用一个")
private String roleId;
@ApiModelProperty(value = "要排除的角色id roleId和notRoleId只能用一个")
private String notRoleId;
@ApiModelProperty(value = "关键词")
private String keyword;
}
package com.makeit.module.admin.saas;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel("平台端角色分配用户")
@Data
public class PlatUserRoleDTO implements Serializable {
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "角色id")
private String roleId;
}
package com.makeit.module.admin.saas;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class UserRoleMenuRedisVO implements Serializable {
@ApiModelProperty("id")
private String id;
@ApiModelProperty("角色列表")
private List<String> roleCodeList;
@ApiModelProperty("按钮列表")
private List<String> buttonCodeList;
}
package com.makeit.utils.user;
import com.makeit.module.admin.saas.UserRoleMenuRedisVO;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
public class PlatUserUtil {
public static PlatUserVO getUserVO() {
TokenUtil.platGetToken();
return BeanDtoVoUtils.convert(TokenUtil.getPlatUserDetail(), PlatUserVO.class);
}
public static PlatUserVO getUserVOCanNull() {
return BeanDtoVoUtils.convert(TokenUtil.getPlatUserDetail(), PlatUserVO.class);
}
public static UserLoginVO getUserVODetail() {
TokenUtil.platGetToken();
return TokenUtil.getPlatUserDetail();
}
public static UserRoleMenuRedisVO getPlatUserRoleMenu(){
return TokenUtil.getPlatUserRoleMenu();
}
public static String getUserId() {
return getUserVO().getId();
}
}
package com.makeit.utils.user;
import lombok.Data;
import java.io.Serializable;
@Data
public class PlatUserVO implements Serializable {
private String id;
private String name;
}
......@@ -13,7 +13,7 @@ public class ThreadLocalUserUtil {
private static final ThreadLocal<String> THREAD_LOCAL_TNT_TOKEN = new BizThreadLocal<>();
private static final ThreadLocal<String> THREAD_LOCAL_WECHAT_TOKEN = new BizThreadLocal<>();
private static final ThreadLocal<SysUserLoginVO> THREAD_LOCAL_TNT_USER = new BizThreadLocal<>();
private static final ThreadLocal<UserLoginVO> THREAD_LOCAL_TNT_USER = new BizThreadLocal<>();
private static final ThreadLocal<WechatUserInfo> THREAD_LOCAL_WECHAT_USER = new BizThreadLocal<>();
private static final ThreadLocal<SysUserRoleMenuRedisVO> THREAD_LOCAL_TNT_USER_ROLE_MENU = new BizThreadLocal<>();
......
package com.makeit.utils.user;
import lombok.Data;
import java.io.Serializable;
@Data
public class TntUserVO implements Serializable {
private String id;
private String name;
// private String username;
private String tenantId;
private String isTenant;
private String deptId;
public TntUserVO() {
}
public TntUserVO(String id, String name, String tenantId) {
this.id = id;
this.tenantId = tenantId;
this.name = name;
}
public TntUserVO(String id, String name) {
this.id = id;
this.name = name;
}
}
......@@ -5,6 +5,7 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.HeaderConst;
import com.makeit.enums.redis.RedisConst;
import com.makeit.exception.BusinessException;
import com.makeit.module.admin.saas.UserRoleMenuRedisVO;
import com.makeit.utils.redis.RedisTemplateUtil;
import com.makeit.utils.redis.RedisUtil;
import com.makeit.utils.request.RequestUtil;
......@@ -32,6 +33,24 @@ public class TokenUtil {
RedisTemplateUtil.delete(prefix + token);
}
}
public static String platGetToken() {
return getToken(RedisConst.PLATFORM_TOKEN_PREFIX, RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN));
}
public static UserLoginVO getPlatUserDetail() {
String token = RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN);
if (StringUtils.isNotBlank(token)) {
UserLoginVO userLoginVO = RedisUtil.get(RedisConst.PLATFORM_TOKEN_PREFIX + token);
return userLoginVO;
}
return null;
}
public static void platLogout() {
logout(RedisConst.PLATFORM_TOKEN_PREFIX, RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN));
logout(RedisConst.PLATFORM_TOKEN_ROLE_MENU_PREFIX, RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN));
}
public static String getToken(String prefix, String token) {
if (StringUtils.isBlank(token)) {
......@@ -47,9 +66,9 @@ public class TokenUtil {
RedisTemplateUtil.expire(prefix + token, RedisConst.PLATFORM_EXPIRE_MINUTES, TimeUnit.MINUTES);
}
public static SysUserLoginVO getTntUserDetail(String token) {
public static UserLoginVO getTntUserDetail(String token) {
if (StringUtils.isNotBlank(token)) {
SysUserLoginVO userLoginVO = RedisTemplateUtil.get(RedisConst.TOKEN_PREFIX + token, SysUserLoginVO.class);
UserLoginVO userLoginVO = RedisTemplateUtil.get(RedisConst.TOKEN_PREFIX + token, UserLoginVO.class);
return userLoginVO;
}
return null;
......@@ -261,5 +280,20 @@ public class TokenUtil {
RedisTemplateUtil.delete(RedisConst.TOKEN_LOGIN_TMP_PREFIX + token);
}
public static <T> void platLoginRoleMenu(T t) {
login(RedisConst.PLATFORM_TOKEN_ROLE_MENU_PREFIX, RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN), t);
}
public static UserRoleMenuRedisVO getPlatUserRoleMenu() {
String token = RequestUtil.getHeader(HeaderConst.PLATFORM_TOKEN);
if (StringUtils.isNotBlank(token)) {
UserRoleMenuRedisVO userLoginVO = RedisUtil.get(RedisConst.PLATFORM_TOKEN_ROLE_MENU_PREFIX + token);
return userLoginVO;
}
return null;
}
public static <T> void platLogin(String token, T t) {
login(RedisConst.PLATFORM_TOKEN_PREFIX, token, t);
}
}
package com.makeit.utils.user;
import com.makeit.module.admin.saas.PlatMenuDTOVO;
import com.makeit.module.admin.saas.PlatRoleDTOVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class UserLoginVO implements Serializable {
@ApiModelProperty("id")
private String id;
@ApiModelProperty("账号")
private String account;
@ApiModelProperty("姓名")
private String name;
// @ApiModelProperty("用户名")
// private String username;
@ApiModelProperty("token")
private String token;
@ApiModelProperty("角色列表")
private List<PlatRoleDTOVO> roleList;
@ApiModelProperty("菜单树形列表")
private List<PlatMenuDTOVO> menuList;
@ApiModelProperty("按钮列表")
private List<PlatMenuDTOVO> buttonList;
}
......@@ -3,6 +3,7 @@ package com.makeit.utils.user.common;
import com.makeit.enums.HeaderConst;
import com.makeit.utils.user.ThreadLocalUserUtil;
import com.makeit.utils.user.TokenUtil;
import com.makeit.utils.user.UserLoginVO;
import com.makeit.utils.user.tenant.SysUserLoginVO;
import com.makeit.utils.user.wechat.WechatUserInfo;
import org.apache.commons.lang3.StringUtils;
......@@ -38,7 +39,7 @@ public class CommonUserUtil {
String wechatToken = httpHeaders.getFirst(HeaderConst.WECHAT_TOKEN);
if (StringUtils.isNotBlank(tenantToken)) {
SysUserLoginVO sysUserLoginVO = TokenUtil.getTntUserDetail(tenantToken);
UserLoginVO sysUserLoginVO = TokenUtil.getTntUserDetail(tenantToken);
if (sysUserLoginVO != null) {
return new CommonUserVO(sysUserLoginVO.getId(), sysUserLoginVO.getName());
}
......
......@@ -22,6 +22,10 @@
<artifactId>server-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
......
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* saas端菜单
* @TableName saas_menu
*/
@TableName(value ="saas_menu")
@Data
public class SaasMenu extends BaseEntity {
/**
* 父级id
*/
private String parentId;
/**
* 名称
*/
private String name;
/**
* 模块+类名+方法
*/
private String code;
/**
* 图标
*/
private String icon;
/**
* 排序
*/
private Integer sort;
/**
* 状态 0禁用 1启用
*/
private String status;
/**
* 类型 0目录 1菜单 2按钮
*/
private String category;
/**
* 前端路径
*/
private String requestPath;
/**
* 组件路径
*/
private String componentPath;
/**
* 组件名称
*/
private String componentName;
/**
* 备注
*/
private String remark;
/**
* 隐藏状态 0不隐藏 1隐藏
*/
private String hiddenStatus;
/**
* 缓存状态 0不缓存 1缓存
*/
private String cacheStatus;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* saas端操作日志
* @TableName saas_operation_log
*/
@TableName(value ="saas_operation_log")
@Data
public class SaasOperationLog extends BaseEntity {
/**
* 操作人
*/
private String saasUserId;
/**
* 租户ID
*/
private String tenantId;
/**
* 操作内容
*/
private String content;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* 隐私政策/关于我们
* @TableName saas_privacy_config
*/
@TableName(value ="saas_privacy_config")
@Data
public class SaasPrivacyConfig extends BaseEntity {
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
/**
* 分类 0-隐私政策 1-关于我们
*/
private String category;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* saas端角色
* @TableName saas_role
*/
@TableName(value ="saas_role")
@Data
public class SaasRole extends BaseEntity {
/**
* 角色名称
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 状态 0禁用 1启用
*/
private String status;
/**
* 备注
*/
private String remark;
/**
* 数据权限 1全部 2指定租户
*/
private String dataScopeType;
/**
* 数据权限 租户id列表 以逗号分隔
*/
private String dataScope;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* saas端角色菜单关联表
* @TableName saas_role_menu
*/
@TableName(value ="saas_role_menu")
@Data
public class SaasRoleMenu extends BaseEntity {
/**
* 角色id
*/
private String roleId;
/**
* 菜单id
*/
private String menuId;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* saas端用户
* @TableName saas_user
*/
@TableName(value ="saas_user")
@Data
public class SaasUser extends BaseEntity {
/**
* 姓名
*/
private String username;
/**
* 账户
*/
private String account;
/**
* 密码
*/
private String password;
/**
* 手机号
*/
private String mobile;
/**
* 状态 0禁用 1启用
*/
private String status;
/**
* 备注
*/
private String remark;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* saas端用户角色表
* @TableName saas_user_role
*/
@TableName(value ="saas_user_role")
@Data
public class SaasUserRole extends BaseEntity {
/**
* 用户id
*/
private String userId;
/**
* 角色id
*/
private String roleId;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
/**
* 租户端资源管理
* @TableName tnt_auth_menu
*/
@TableName(value ="tnt_auth_menu")
@Data
public class TntAuthMenu extends BaseEntity {
/**
* 父级id
*/
private String parentId;
/**
* 资源名称
*/
private String name;
/**
* 账号链接
*/
private String requestPath;
/**
* 排序
*/
private Integer sort;
/**
* 图标
*/
private String icon;
/**
* 类型 1目录 2菜单/功能 3按钮/应用
*/
private String resourceType;
/**
* 隐藏状态 0不隐藏 1隐藏
*/
private String hiddenStatus;
/**
* 备注
*/
private String remark;
/**
* 缓存状态 0不缓存 1缓存
*/
private String cacheStatus;
/**
* 状态 0禁用 1启用
*/
private String status;
}
\ No newline at end of file
package com.makeit.entity.saas;
import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* 租户管理
* @TableName tnt_tenant
*/
@TableName(value ="tnt_tenant")
@Data
public class TntTenant extends BaseEntity {
/**
* 名称
*/
private String name;
/**
* 状态 0停用 1启用
*/
private String status;
/**
* 租户有效期-开始时间
*/
private Date startTime;
/**
* 租户有效期-结束时间
*/
private Date endTime;
/**
* 租户管理员id
*/
private String tntUserId;
/**
* 菜单id列表 以逗号分隔
*/
private String menuList;
/**
* 告警渠道 1-短信 2-邮件 3-语音短信 4-云龄工单 5-晶奇工单
*/
private String alertChannel;
}
\ No newline at end of file
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasMenu;
/**
* @author lixl
* @description 针对表【saas_menu(saas端菜单)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasMenu
*/
public interface SaasMenuMapper extends BaseMapper<SaasMenu> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasOperationLog;
/**
* @author lixl
* @description 针对表【saas_operation_log(saas端操作日志)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasOperationLog
*/
public interface SaasOperationLogMapper extends BaseMapper<SaasOperationLog> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasPrivacyConfig;
/**
* @author lixl
* @description 针对表【saas_privacy_config(隐私政策/关于我们)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasPrivacyConfig
*/
public interface SaasPrivacyConfigMapper extends BaseMapper<SaasPrivacyConfig> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasRole;
/**
* @author lixl
* @description 针对表【saas_role(saas端角色)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasRole
*/
public interface SaasRoleMapper extends BaseMapper<SaasRole> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasRoleMenu;
/**
* @author lixl
* @description 针对表【saas_role_menu(saas端角色菜单关联表)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasRoleMenu
*/
public interface SaasRoleMenuMapper extends BaseMapper<SaasRoleMenu> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasUser;
/**
* @author lixl
* @description 针对表【saas_user(saas端用户)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasUser
*/
public interface SaasUserMapper extends BaseMapper<SaasUser> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.SaasUserRole;
/**
* @author lixl
* @description 针对表【saas_user_role(saas端用户角色表)】的数据库操作Mapper
* @createDate 2023-08-29 11:14:07
* @Entity com.makeit.entity.saas.SaasUserRole
*/
public interface SaasUserRoleMapper extends BaseMapper<SaasUserRole> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.TntAuthMenu;
/**
* @author lixl
* @description 针对表【tnt_auth_menu(租户端资源管理)】的数据库操作Mapper
* @createDate 2023-08-29 14:29:10
* @Entity com.makeit.entity.saas.TntAuthMenu
*/
public interface TntAuthMenuMapper extends BaseMapper<TntAuthMenu> {
}
package com.makeit.mapper.saas;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.saas.TntTenant;
/**
* @author lixl
* @description 针对表【tnt_tenant(租户管理)】的数据库操作Mapper
* @createDate 2023-08-29 14:29:10
* @Entity com.makeit.entity.saas.TntTenant
*/
public interface TntTenantMapper extends BaseMapper<TntTenant> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.SaasMenu;
import com.makeit.module.admin.saas.PlatMenuDTOVO;
import com.makeit.module.admin.saas.PlatMenuQueryDTO;
import java.util.List;
/**
* @author lixl
* @description 针对表【saas_menu(saas端菜单)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasMenuService extends IService<SaasMenu> {
List<PlatMenuDTOVO> list(PlatMenuQueryDTO dto);
List<PlatMenuDTOVO> tree(List<PlatMenuDTOVO> platMenuList);
List<PlatMenuDTOVO> tree(PlatMenuQueryDTO dto);
void add(PlatMenuDTOVO dto);
void edit(PlatMenuDTOVO dto);
PlatMenuDTOVO view(String id);
void del(String id);
void sync();
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.SaasOperationLog;
/**
* @author lixl
* @description 针对表【saas_operation_log(saas端操作日志)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasOperationLogService extends IService<SaasOperationLog> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.SaasPrivacyConfig;
/**
* @author lixl
* @description 针对表【saas_privacy_config(隐私政策/关于我们)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasPrivacyConfigService extends IService<SaasPrivacyConfig> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.SaasRoleMenu;
/**
* @author lixl
* @description 针对表【saas_role_menu(saas端角色菜单关联表)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasRoleMenuService extends IService<SaasRoleMenu> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.SaasRole;
/**
* @author lixl
* @description 针对表【saas_role(saas端角色)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasRoleService extends IService<SaasRole> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.SaasUserRole;
/**
* @author lixl
* @description 针对表【saas_user_role(saas端用户角色表)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasUserRoleService extends IService<SaasUserRole> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.LoginDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.module.admin.saas.PlatUserDTOVO;
import com.makeit.module.admin.saas.PlatUserQueryDTO;
import com.makeit.entity.saas.SaasUser;
import com.makeit.utils.user.UserLoginVO;
import java.util.List;
/**
* @author lixl
* @description 针对表【saas_user(saas端用户)】的数据库操作Service
* @createDate 2023-08-29 11:14:07
*/
public interface SaasUserService extends IService<SaasUser> {
PageVO<PlatUserDTOVO> page(PageReqDTO<PlatUserQueryDTO> page);
PageVO<PlatUserDTOVO> pageNoSuperAdmin(PageReqDTO<PlatUserQueryDTO> page);
List<PlatUserDTOVO> list(PlatUserQueryDTO dto);
List<PlatUserDTOVO> listNoSuperAdmin(PlatUserQueryDTO dto);
void add(PlatUserDTOVO dto);
void edit(PlatUserDTOVO dto);
void changePassword(PlatUserDTOVO dto);
PlatUserDTOVO view(String id);
void del(String id);
void changeStatus(StatusDTO dto);
UserLoginVO login(LoginDTO loginDTO);
UserLoginVO getRoleAndMenuList();
UserLoginVO getUserVO();
void logout();
List<String> getDataScopeByUserId();
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.TntAuthMenu;
/**
* @author lixl
* @description 针对表【tnt_auth_menu(租户端资源管理)】的数据库操作Service
* @createDate 2023-08-29 14:29:10
*/
public interface TntAuthMenuService extends IService<TntAuthMenu> {
}
package com.makeit.service.saas;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.saas.TntTenant;
/**
* @author lixl
* @description 针对表【tnt_tenant(租户管理)】的数据库操作Service
* @createDate 2023-08-29 14:29:10
*/
public interface TntTenantService extends IService<TntTenant> {
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.SaasMenu;
import com.makeit.entity.saas.SaasRoleMenu;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.biz.auth.SysEnum;
import com.makeit.enums.id.TreeConst;
import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action;
import com.makeit.mapper.saas.SaasMenuMapper;
import com.makeit.module.admin.saas.PlatMenuDTOVO;
import com.makeit.module.admin.saas.PlatMenuQueryDTO;
import com.makeit.service.saas.SaasMenuService;
import com.makeit.service.saas.SaasRoleMenuService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.RegexPatternTypeFilter;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* <p>
* 平台端菜单 服务实现类
* </p>
*
* @author eugene young
* @since 2022-05-10
*/
@Service
public class SaasMenuServiceImpl extends ServiceImpl<SaasMenuMapper, SaasMenu> implements SaasMenuService {
@Autowired
private SaasRoleMenuService platRoleMenuService;
private static final Logger logger = LoggerFactory.getLogger(SaasMenuServiceImpl.class);
//TODO 根据名称搜
//全查出来 根据名称筛选 保留父级
//TODO
//要不要用 sql做一个没绑定当前角色的菜单列表
//还是mybatis plus notin 查询
//现在是重复添加中间表 没有效果
//这里排除当前角色没有绑定的菜单 不该做 菜单树形
@Override
public List<PlatMenuDTOVO> list(PlatMenuQueryDTO dto) {
//查找角色绑的菜单 是否一定要返回树形 能不能直接返回中间表数据
// 直接返回中间表数据的话 代码可以放role那边
//TODO join
List<String> menuIdList = new ArrayList<>(10);
menuIdList.add(-1 + "");
if (StringUtils.isNotBlank(dto.getRoleId())) {
List<SaasRoleMenu> platRoleList = platRoleMenuService.list(new QueryWrapper<SaasRoleMenu>().lambda()
.in(SaasRoleMenu::getRoleId, dto.getRoleId()));
menuIdList.addAll(StreamUtil.map(platRoleList, SaasRoleMenu::getMenuId));
}
List<SaasMenu> platMenuList = list(new QueryWrapper<SaasMenu>().lambda()
.like(StringUtils.isNotBlank(dto.getName()), SaasMenu::getName, dto.getName())
.eq(StringUtils.isNotBlank(dto.getStatus()), SaasMenu::getStatus, dto.getStatus())
.in(StringUtils.isNotBlank(dto.getRoleId()), SaasMenu::getId, menuIdList)
//.orderByAsc(PlatMenu::getParentId)
.orderByAsc(SaasMenu::getSort)
.orderByAsc(SaasMenu::getCreatedAt)
);
return BeanDtoVoUtils.listVo(platMenuList, PlatMenuDTOVO.class);
}
@Override
public List<PlatMenuDTOVO> tree(List<PlatMenuDTOVO> platMenuList) {
Map<String, PlatMenuDTOVO> map = StreamUtil.toMap(platMenuList, PlatMenuDTOVO::getId);
List<PlatMenuDTOVO> topList = StreamUtil.filter(platMenuList, e -> TreeConst.TOP_LEVEL.equals(e.getParentId()));
platMenuList.forEach(e -> {
PlatMenuDTOVO parent = map.get(e.getParentId());
if (parent != null) {
List<PlatMenuDTOVO> children = parent.getChildren();
if (children == null) {
children = new ArrayList<>(10);
parent.setChildren(children);
}
children.add(e);
}
});
return topList;
}
@Override
public List<PlatMenuDTOVO> tree(PlatMenuQueryDTO dto) {
List<PlatMenuDTOVO> platMenuList = list(dto);
return tree(platMenuList);
}
private void checkCode(PlatMenuDTOVO dto) {
SaasMenu old = getOne(new QueryWrapper<SaasMenu>().lambda()
.eq(SaasMenu::getCode, dto.getCode()));
if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
}
}
@Transactional
@Override
public void add(PlatMenuDTOVO dto) {
checkCode(dto);
save(BeanDtoVoUtils.convert(dto, SaasMenu.class));
}
@Transactional
@Override
public void edit(PlatMenuDTOVO dto) {
checkCode(dto);
updateById(BeanDtoVoUtils.convert(dto, SaasMenu.class));
}
@Override
public PlatMenuDTOVO view(String id) {
return BeanDtoVoUtils.convert(getById(id), PlatMenuDTOVO.class);
}
@Transactional
@Override
public void del(String id) {
List<SaasMenu> list = new ArrayList<>(10);
List<SaasMenu> children = list(new QueryWrapper<SaasMenu>().lambda()
.eq(SaasMenu::getParentId, id));
while (!children.isEmpty()) {
list.addAll(children);
List<String> idList = StreamUtil.map(children, SaasMenu::getId);
idList.add(-1 + "");
children = list(new QueryWrapper<SaasMenu>().lambda()
.in(SaasMenu::getParentId, idList));
}
List<String> idList = StreamUtil.map(list, SaasMenu::getId);
idList.add(id);
remove(new QueryWrapper<SaasMenu>().lambda()
.in(SaasMenu::getId, idList));
}
@Override
@Transactional
public void sync() {
List<SaasMenu> exitList = list(new QueryWrapper<SaasMenu>().lambda()
.isNotNull(SaasMenu::getCode)
.in(SaasMenu::getCategory, SysEnum.MenuTypeEnum.MENU.getValue(), SysEnum.MenuTypeEnum.BUTTON.getValue())
.orderByDesc(SaasMenu::getCreatedAt)
);
Map<String, SaasMenu> exitCodeMap = StreamUtil.toMapDep(exitList, SaasMenu::getCode);
//查询数据库中已存在的权限
List<SaasMenu> exitButtonList = StreamUtil.filter(exitList, e -> SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCode()));
Map<String, SaasMenu> exitButtonCodeMap = StreamUtil.toMapDep(exitButtonList, SaasMenu::getCode);
//加载项目中的权限
List<SaasMenu> loadActionList = this.load();
Set<String> loadActionCodeList = loadActionList.stream().map(SaasMenu::getCode).collect(Collectors.toSet());
//新增加的权限
List<SaasMenu> addActionList = loadActionList.stream().filter(item ->
!exitButtonCodeMap.containsKey(item.getCode())).collect(Collectors.toList());
//删除的权限
List<SaasMenu> deleteActionList = exitButtonList.stream().filter(item ->
!loadActionCodeList.contains(item.getCode())).collect(Collectors.toList());
saveBatch(StreamUtil.filter(addActionList, e -> TreeConst.TOP_LEVEL.equals(e.getParentId())));
addActionList.forEach(e -> {
if (TreeConst.TOP_LEVEL.equals(e.getParentId())) {
exitCodeMap.put(e.getCode(), e);
}
});
List<SaasMenu> buttonList = new ArrayList<>(10);
addActionList.forEach(e -> {
if (!TreeConst.TOP_LEVEL.equals(e.getParentId())) {
String groupCode = getGroupCode(e.getCode());
SaasMenu buttonGroup = exitCodeMap.get(groupCode);
if (buttonGroup != null) {
e.setParentId(buttonGroup.getId());
} else {
e.setParentId(e.getId());
}
buttonList.add(e);
}
if (StringUtils.isBlank(e.getParentId())) {
e.setParentId(TreeConst.TOP_LEVEL);
}
});
saveBatch(buttonList);
List<String> removeIdList = StreamUtil.map(deleteActionList, SaasMenu::getId);
removeIdList.add(-1 + "");
removeByIds(removeIdList);
}
private List<SaasMenu> load() {
Set<String> buttonCodeSet = new HashSet<>(16);
List<SaasMenu> buttonList = new ArrayList<>();
// 禁止默认过滤条件设置false
final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
//插入匹配过滤条件
provider.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(".*Controller")));
final Set<BeanDefinition> classes = provider.findCandidateComponents("com.makeit.controller.platform");
//从bean中加载数据
for (BeanDefinition bean : classes) {
try {
Class<?> clazz = Class.forName(bean.getBeanClassName());
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(Action.class)) {
Action action = method.getAnnotation(Action.class);
Arrays.asList(action.code()).forEach(e -> {
if (buttonCodeSet.contains(e)) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
} else {
buttonCodeSet.add(e);
}
// String groupName = action.module();
// String groupCode = null;
//
// if (StringUtils.isBlank(groupName)) {
// Api api = clazz.getAnnotation(Api.class);
// if (api != null) {
// groupName = api.tags()[0];
// }
// }
//
// groupCode = getGroupCode(action.code());
//
// if (StringUtils.isNotBlank(groupCode) && !buttonCodeSet.contains(groupCode)) {
// buttonCodeSet.add(groupCode);
// buttonList.add(generateButtonGroup(groupName, groupCode));
// }
SaasMenu button = new SaasMenu();
button.setName(action.name());
button.setCode(e);
button.setSort(0);
button.setStatus(CommonEnum.YES.getValue());
button.setCategory(SysEnum.MenuTypeEnum.BUTTON.getValue());
button.setHiddenStatus(CommonEnum.NO.getValue());
button.setCacheStatus(CommonEnum.NO.getValue());
buttonList.add(button);
});
}
}
} catch (ClassNotFoundException e) {
logger.info("ex_" + e.getMessage(), e);
}
}
return buttonList;
}
private String getGroupCode(String code) {
if (code.contains(":")) {
return code.substring(0, code.lastIndexOf(":"));
}
if (code.contains(".")) {
return code.substring(0, code.lastIndexOf("."));
}
return code;
}
private SaasMenu generateButtonGroup(String name, String code) {
SaasMenu button = new SaasMenu();
button.setName(name);
button.setCode(code);
button.setParentId(TreeConst.TOP_LEVEL);
button.setSort(0);
button.setStatus(CommonEnum.YES.getValue());
button.setCategory(SysEnum.MenuTypeEnum.BUTTON.getValue());
button.setHiddenStatus(CommonEnum.NO.getValue());
button.setCacheStatus(CommonEnum.NO.getValue());
return button;
}
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.SaasOperationLog;
import com.makeit.mapper.saas.SaasOperationLogMapper;
import com.makeit.service.saas.SaasOperationLogService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【saas_operation_log(saas端操作日志)】的数据库操作Service实现
* @createDate 2023-08-29 11:14:07
*/
@Service
public class SaasOperationLogServiceImpl extends ServiceImpl<SaasOperationLogMapper, SaasOperationLog>
implements SaasOperationLogService{
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.SaasPrivacyConfig;
import com.makeit.mapper.saas.SaasPrivacyConfigMapper;
import com.makeit.service.saas.SaasPrivacyConfigService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【saas_privacy_config(隐私政策/关于我们)】的数据库操作Service实现
* @createDate 2023-08-29 11:14:07
*/
@Service
public class SaasPrivacyConfigServiceImpl extends ServiceImpl<SaasPrivacyConfigMapper, SaasPrivacyConfig>
implements SaasPrivacyConfigService{
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.SaasRoleMenu;
import com.makeit.mapper.saas.SaasRoleMenuMapper;
import com.makeit.service.saas.SaasRoleMenuService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【saas_role_menu(saas端角色菜单关联表)】的数据库操作Service实现
* @createDate 2023-08-29 11:14:07
*/
@Service
public class SaasRoleMenuServiceImpl extends ServiceImpl<SaasRoleMenuMapper, SaasRoleMenu>
implements SaasRoleMenuService{
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.SaasRole;
import com.makeit.mapper.saas.SaasRoleMapper;
import com.makeit.service.saas.SaasRoleService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【saas_role(saas端角色)】的数据库操作Service实现
* @createDate 2023-08-29 11:14:07
*/
@Service
public class SaasRoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
implements SaasRoleService{
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.SaasUserRole;
import com.makeit.mapper.saas.SaasUserRoleMapper;
import com.makeit.service.saas.SaasUserRoleService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【saas_user_role(saas端用户角色表)】的数据库操作Service实现
* @createDate 2023-08-29 11:14:07
*/
@Service
public class SaasUserRoleServiceImpl extends ServiceImpl<SaasUserRoleMapper, SaasUserRole>
implements SaasUserRoleService{
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.dto.LoginDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.saas.SaasMenu;
import com.makeit.entity.saas.SaasRole;
import com.makeit.entity.saas.SaasRoleMenu;
import com.makeit.entity.saas.SaasUser;
import com.makeit.entity.saas.SaasUserRole;
import com.makeit.entity.saas.TntTenant;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.biz.auth.SysEnum;
import com.makeit.enums.biz.auth.TenantEnum;
import com.makeit.enums.id.IdConst;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.saas.SaasUserMapper;
import com.makeit.module.admin.saas.PlatMenuDTOVO;
import com.makeit.module.admin.saas.PlatRoleDTOVO;
import com.makeit.module.admin.saas.PlatUserDTOVO;
import com.makeit.module.admin.saas.PlatUserQueryDTO;
import com.makeit.module.admin.saas.UserRoleMenuRedisVO;
import com.makeit.service.saas.SaasMenuService;
import com.makeit.service.saas.SaasRoleMenuService;
import com.makeit.service.saas.SaasRoleService;
import com.makeit.service.saas.SaasUserRoleService;
import com.makeit.service.saas.SaasUserService;
import com.makeit.service.saas.TntTenantService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.id.IdGen;
import com.makeit.utils.user.PasswordUtils;
import com.makeit.utils.user.UserLoginVO;
import com.makeit.utils.user.PlatUserUtil;
import com.makeit.utils.user.PlatUserVO;
import com.makeit.utils.user.TokenUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
* @author lixl
* @description 针对表【saas_user(saas端用户)】的数据库操作Service实现
* @createDate 2023-08-29 11:14:07
*/
@Service
public class SaasUserServiceImpl extends ServiceImpl<SaasUserMapper, SaasUser>
implements SaasUserService{
@Autowired
private SaasRoleService saasRoleService;
@Autowired
private SaasUserRoleService saasUserRoleService;
@Autowired
private SaasMenuService saasMenuService;
@Autowired
private SaasRoleMenuService saasRoleMenuService;
@Autowired
private TntTenantService tntTenantService;
// @Autowired
// private TntLoginLogService tntLoginLogService;
//TODO
//要不要用 sql做一个没绑定当前角色的用户列表
//还是mybatis plus notin 查询
//现在是重复添加中间表 没有效果
public PageVO<PlatUserDTOVO> pageInternal(PageReqDTO<PlatUserQueryDTO> page, Consumer<LambdaQueryWrapper<SaasUser>> consumer) {
PlatUserQueryDTO dto = page.getData();
Page<SaasUser> p = PageUtil.toMpPage(page);
//TODO join
List<String> userIdList = new ArrayList<>(10);
userIdList.add(-1 + "");
if (StringUtils.isNotBlank(dto.getRoleId())) {
List<SaasUserRole> userRoleList = saasUserRoleService.list(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getRoleId, dto.getRoleId()));
userIdList.addAll(StreamUtil.map(userRoleList, SaasUserRole::getUserId));
}
if (StringUtils.isNotBlank(dto.getNotRoleId())) {
List<SaasUserRole> userRoleList = saasUserRoleService.list(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getRoleId, dto.getNotRoleId()));
userIdList.addAll(StreamUtil.map(userRoleList, SaasUserRole::getUserId));
}
LambdaQueryWrapper<SaasUser> lambdaQueryWrapper = new QueryWrapper<SaasUser>().lambda()
.like(StringUtils.isNotBlank(dto.getAccount()), SaasUser::getAccount, dto.getAccount())
.like(StringUtils.isNotBlank(dto.getName()), SaasUser::getUsername, dto.getName())
.like(StringUtils.isNotBlank(dto.getMobile()), SaasUser::getMobile, dto.getMobile())
.and(StringUtils.isNotBlank(dto.getKeyword()), qw -> {
qw.like(StringUtils.isNotBlank(dto.getKeyword()), SaasUser::getAccount, dto.getKeyword())
.or()
.like(StringUtils.isNotBlank(dto.getKeyword()), SaasUser::getUsername, dto.getKeyword());
})
.eq(StringUtils.isNotBlank(dto.getStatus()), SaasUser::getStatus, dto.getStatus())
.in(StringUtils.isNotBlank(dto.getRoleId()), SaasUser::getId, userIdList)
.notIn(StringUtils.isNotBlank(dto.getNotRoleId()), SaasUser::getId, userIdList);
if (consumer != null) {
consumer.accept(lambdaQueryWrapper);
}
lambdaQueryWrapper.orderByDesc(SaasUser::getId);
Page<SaasUser> pageList = page(p, lambdaQueryWrapper);
return PageUtil.toPageVO(BeanDtoVoUtils.listVo(pageList.getRecords(), PlatUserDTOVO.class), pageList);
}
@Override
public PageVO<PlatUserDTOVO> page(PageReqDTO<PlatUserQueryDTO> page) {
return pageInternal(page, null);
}
@Override
public PageVO<PlatUserDTOVO> pageNoSuperAdmin(PageReqDTO<PlatUserQueryDTO> page) {
return pageInternal(page, qw -> qw.ne(SaasUser::getId, IdConst.SUPER_ADMIN_ID));
}
@Override
public List<PlatUserDTOVO> list(PlatUserQueryDTO dto) {
PageReqDTO<PlatUserQueryDTO> page = new PageReqDTO<>();
page.setPage(1);
page.setLimit(-1);
page.setData(dto);
return pageInternal(page, null).getList();
}
@Override
public List<PlatUserDTOVO> listNoSuperAdmin(PlatUserQueryDTO dto) {
PageReqDTO<PlatUserQueryDTO> page = new PageReqDTO<>();
page.setPage(1);
page.setLimit(-1);
page.setData(dto);
return pageInternal(page, qw -> qw.ne(SaasUser::getId, IdConst.SUPER_ADMIN_ID)).getList();
}
private void check(PlatUserDTOVO dto) {
List<SaasUser> userList = list(
new QueryWrapper<SaasUser>().lambda()
.eq(SaasUser::getAccount, dto.getAccount())
.or()
.eq(SaasUser::getUsername, dto.getName())
.or()
.eq(SaasUser::getMobile, dto.getMobile())
);
userList.forEach(e -> {
if (e.getAccount().equals(dto.getAccount()) && !e.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_ACCOUNT_DUPLICATE);
}
if (e.getUsername().equals(dto.getName()) && !e.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_NAME_DUPLICATE);
}
if (e.getMobile().equals(dto.getMobile()) && !e.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_MOBILE_DUPLICATE);
}
});
}
private void setRoleList(PlatUserDTOVO dto) {
saasUserRoleService.remove(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getUserId, dto.getId()));
if (dto.getRoleList() != null) {
List<SaasUserRole> userRoleList = StreamUtil.map(dto.getRoleList(), e -> {
SaasUserRole platUserRole = new SaasUserRole();
platUserRole.setUserId(dto.getId());
platUserRole.setRoleId(e.getId());
return platUserRole;
});
saasUserRoleService.saveBatch(userRoleList);
}
}
private void getRoleList(PlatUserDTOVO userVO) {
List<SaasUserRole> userRoleList = saasUserRoleService.list(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getUserId, userVO.getId())
.orderByAsc(SaasUserRole::getId)
);
List<String> roleIdList = StreamUtil.map(userRoleList, SaasUserRole::getRoleId);
roleIdList.add(-1 + "");
List<SaasRole> roleList = saasRoleService.list(new QueryWrapper<SaasRole>().lambda()
.in(SaasRole::getId, roleIdList));
Map<String, SaasRole> roleMap = StreamUtil.toMap(roleList, SaasRole::getId);
LinkedHashSet<SaasRole> newList = new LinkedHashSet<>(10);
userRoleList.forEach(e -> {
SaasRole role = roleMap.get(e.getRoleId());
if (role != null) {
newList.add(role);
}
});
userVO.setRoleList(BeanDtoVoUtils.listVo(new ArrayList<>(newList), PlatRoleDTOVO.class));
}
private void setPassword(SaasUser user) {
if (StringUtils.isNotBlank(user.getPassword())) {
PasswordUtils.validatePasswordFormat(user.getPassword());
user.setPassword(PasswordUtils.encryptPassword(user.getPassword()));
}
}
@Transactional
@Override
public void add(PlatUserDTOVO dto) {
check(dto);
SaasUser user = BeanDtoVoUtils.convert(dto, SaasUser.class);
if (StringUtils.isBlank(user.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_PASSWORD_NOT_BLANK);
}
setPassword(user);
save(user);
dto.setId(user.getId());
setRoleList(dto);
}
@Transactional
@Override
public void edit(PlatUserDTOVO dto) {
dto.setAccount(null);
superCantEdit(dto);
check(dto);
SaasUser user = BeanDtoVoUtils.convert(dto, SaasUser.class);
setPassword(user);
updateById(user);
setRoleList(dto);
}
@Transactional
@Override
public void changePassword(PlatUserDTOVO dto) {
SaasUser user = getById(dto.getId());
user.setPassword(dto.getPassword());
setPassword(user);
updateById(user);
}
@Override
public PlatUserDTOVO view(String id) {
PlatUserDTOVO userVO = BeanDtoVoUtils.convert(getById(id), PlatUserDTOVO.class);
getRoleList(userVO);
return userVO;
}
@Transactional
@Override
public void del(String id) {
superCantDo(id);
removeById(id);
}
@Transactional
@Override
public void changeStatus(StatusDTO dto) {
superCantDo(dto.getId());
if (Arrays.stream(CommonEnum.values()).noneMatch(e -> e.getValue().equals(dto.getStatus()))) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
SaasUser user = getById(dto.getId());
if (user.getStatus().equals(dto.getStatus())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
user.setStatus(dto.getStatus());
updateById(user);
}
private void superCantDo(String id) {
if (IdConst.SUPER_ADMIN_ID.equals(id)) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_SUPER_ADMIN_CANT_DO);
}
}
private void superCantEdit(PlatUserDTOVO dto) {
if (IdConst.SUPER_ADMIN_ID.equals(dto.getId())) {
if (dto.getRoleList() != null && !dto.getRoleList().isEmpty()) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_SUPER_ADMIN_CANT_EDIT);
}
SaasUser platUser = getById(dto.getId());
if (!platUser.getAccount().equals(dto.getAccount())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_SUPER_ADMIN_CANT_EDIT);
}
if (!platUser.getStatus().equals(dto.getStatus())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_USER_SUPER_ADMIN_CANT_EDIT);
}
}
}
private void fillMenuList(List<SaasMenu> menuList, UserLoginVO userLoginVO) {
List<SaasMenu> buttonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCategory()));
List<SaasMenu> nonButtonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.CATALOGUE.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()));
List<PlatMenuDTOVO> menuVOList = saasMenuService.tree(BeanDtoVoUtils.listVo(nonButtonList, PlatMenuDTOVO.class));
userLoginVO.setButtonList(BeanDtoVoUtils.listVo(buttonList, PlatMenuDTOVO.class));
userLoginVO.setMenuList(menuVOList);
}
private void supperRoleMenuList(UserLoginVO userLoginVO) {
List<SaasMenu> menuList = saasMenuService.list(new QueryWrapper<SaasMenu>().lambda()
.eq(SaasMenu::getStatus, CommonEnum.YES.getValue())
);
fillMenuList(menuList, userLoginVO);
}
private void setRoleMenuToRedis(UserLoginVO userLoginVO) {
UserRoleMenuRedisVO platUserRoleMenuRedisVO = new UserRoleMenuRedisVO();
platUserRoleMenuRedisVO.setId(userLoginVO.getId());
if (userLoginVO.getRoleList() != null) {
platUserRoleMenuRedisVO.setRoleCodeList(StreamUtil.map(userLoginVO.getRoleList(), PlatRoleDTOVO::getCode));
}
if (userLoginVO.getButtonList() != null) {
platUserRoleMenuRedisVO.setButtonCodeList(StreamUtil.map(userLoginVO.getButtonList(), PlatMenuDTOVO::getCode));
}
TokenUtil.platLoginRoleMenu(platUserRoleMenuRedisVO);
}
private UserLoginVO getRoleAndMenuList(UserLoginVO userLoginVO) {
//TODO 用join做
//TODO 只返回必要字段 菜单和角色
if (IdConst.SUPER_ADMIN_ID.equals(userLoginVO.getId())) {
supperRoleMenuList(userLoginVO);
setRoleMenuToRedis(userLoginVO);
return userLoginVO;
}
List<SaasUserRole> userRoleList = saasUserRoleService.list(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getUserId, userLoginVO.getId()));
List<String> roleIdList = StreamUtil.map(userRoleList, SaasUserRole::getRoleId);
roleIdList.add(-1 + "");
List<SaasRole> roleList = saasRoleService.list(new QueryWrapper<SaasRole>().lambda()
.in(SaasRole::getId, roleIdList)
.eq(SaasRole::getStatus, CommonEnum.YES.getValue())
);
roleIdList = StreamUtil.map(roleList, SaasRole::getId);
roleIdList.add(-1 + "");
List<SaasRoleMenu> roleMenuList = saasRoleMenuService.list(new QueryWrapper<SaasRoleMenu>().lambda()
.in(SaasRoleMenu::getRoleId, roleIdList));
List<String> menuIdList = StreamUtil.map(roleMenuList, SaasRoleMenu::getMenuId);
menuIdList.add(-1 + "");
List<SaasMenu> menuList = saasMenuService.list(new QueryWrapper<SaasMenu>().lambda()
.in(SaasMenu::getId, menuIdList)
.eq(SaasMenu::getStatus, CommonEnum.YES.getValue())
);
userLoginVO.setRoleList(BeanDtoVoUtils.listVo(roleList, PlatRoleDTOVO.class));
fillMenuList(menuList, userLoginVO);
setRoleMenuToRedis(userLoginVO);
return userLoginVO;
}
@Override
public UserLoginVO getRoleAndMenuList() {
PlatUserVO platUser = PlatUserUtil.getUserVO();
UserLoginVO platUserLoginVO = new UserLoginVO();
platUserLoginVO.setId(platUser.getId());
getRoleAndMenuList(platUserLoginVO);
return platUserLoginVO;
}
@Override
public UserLoginVO getUserVO() {
return PlatUserUtil.getUserVODetail();
}
@Override
public UserLoginVO login(LoginDTO loginDTO) {
if (StringUtils.isBlank(loginDTO.getAccount())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
if (StringUtils.isBlank(loginDTO.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR);
}
SaasUser platUser = getOne(new QueryWrapper<SaasUser>().lambda()
.eq(SaasUser::getAccount, loginDTO.getAccount())
.or()
.eq(SaasUser::getMobile, loginDTO.getAccount())
);
if (platUser == null) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
if (CommonEnum.NO.getValue().equals(platUser.getStatus())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_HAS_DISABLED);
}
if (!PasswordUtils.validatePassword(loginDTO.getPassword(), platUser.getPassword())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_AUTH_USER_PASSWORD);
}
UserLoginVO userLoginVO = BeanDtoVoUtils.convert(platUser, UserLoginVO.class);
String token = IdGen.getUUID();
userLoginVO.setToken(token);
//getRoleAndMenuList(userLoginVO);
TokenUtil.platLogin(token, userLoginVO);
//tntLoginLogService.addPlatform(userLoginVO.getId());
return userLoginVO;
}
@Override
public void logout() {
TokenUtil.platLogout();
}
//要不要放 TntTenantServiceImpl
@Override
public List<String> getDataScopeByUserId() {//要不要缓存
PlatUserVO userVO = PlatUserUtil.getUserVO();
if (IdConst.SUPER_ADMIN_ID.equals(userVO.getId())) {
List<String> tenantIdList = StreamUtil.map(tntTenantService.list(), TntTenant::getId);//还是要直接返回null 那边直接不过滤
tenantIdList.add(-1 + "");
return tenantIdList;
} else {
List<SaasUserRole> userRoleList = saasUserRoleService.list(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getUserId, userVO.getId()));
List<String> roleIdList = StreamUtil.map(userRoleList, SaasUserRole::getRoleId);
roleIdList.add(-1 + "");
List<SaasRole> roleList = saasRoleService.list(new QueryWrapper<SaasRole>().lambda()
.in(SaasRole::getId, roleIdList)
.eq(SaasRole::getStatus, CommonEnum.YES.getValue())
);
boolean allFlag = false;
allFlag = roleList.stream().anyMatch(e -> TenantEnum.DataScopeTypeEnum.ALL.getValue().equals(e.getDataScopeType()));
if (allFlag) {
List<String> tenantIdList = StreamUtil.map(tntTenantService.list(), TntTenant::getId);//还是要直接返回null 那边直接不过滤
tenantIdList.add(-1 + "");
return tenantIdList;
}
List<String> tenantIdList = roleList.stream().map(SaasRole::getDataScope).filter(StringUtils::isNotBlank).map(e -> new ArrayList<>(Arrays.asList(e.split(","))))
.flatMap(e -> e.stream()).collect(Collectors.toList());
tenantIdList.add(-1 + "");
return tenantIdList;
}
}
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.TntAuthMenu;
import com.makeit.mapper.saas.TntAuthMenuMapper;
import com.makeit.service.saas.TntAuthMenuService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【tnt_auth_menu(租户端资源管理)】的数据库操作Service实现
* @createDate 2023-08-29 14:29:10
*/
@Service
public class TntAuthMenuServiceImpl extends ServiceImpl<TntAuthMenuMapper, TntAuthMenu>
implements TntAuthMenuService{
}
package com.makeit.service.saas.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.saas.TntTenant;
import com.makeit.mapper.saas.TntTenantMapper;
import com.makeit.service.saas.TntTenantService;
import org.springframework.stereotype.Service;
/**
* @author lixl
* @description 针对表【tnt_tenant(租户管理)】的数据库操作Service实现
* @createDate 2023-08-29 14:29:10
*/
@Service
public class TntTenantServiceImpl extends ServiceImpl<TntTenantMapper, TntTenant>
implements TntTenantService{
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasMenuMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasMenu">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="icon" column="icon" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="CHAR"/>
<result property="category" column="category" jdbcType="VARCHAR"/>
<result property="requestPath" column="request_path" jdbcType="VARCHAR"/>
<result property="componentPath" column="component_path" jdbcType="VARCHAR"/>
<result property="componentName" column="component_name" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="hiddenStatus" column="hidden_status" jdbcType="CHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="cacheStatus" column="cache_status" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,parent_id,name,
code,icon,sort,
status,category,request_path,
component_path,component_name,remark,
hidden_status,created_at,updated_at,
del_flag,cache_status,created_by_name,
update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasOperationLogMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasOperationLog">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="saasUserId" column="saas_user_id" jdbcType="VARCHAR"/>
<result property="tenantId" column="tenant_id" jdbcType="CHAR"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,saas_user_id,tenant_id,
content,created_at,updated_at,
del_flag,created_by_name,update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasPrivacyConfigMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasPrivacyConfig">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="category" column="category" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,title,content,
category,created_at,updated_at,
del_flag,created_by_name,update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasRoleMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasRole">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="CHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="dataScopeType" column="data_scope_type" jdbcType="CHAR"/>
<result property="dataScope" column="data_scope" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,name,code,
status,remark,data_scope_type,
data_scope,created_at,updated_at,
del_flag,created_by_name,update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasRoleMenuMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasRoleMenu">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="roleId" column="role_id" jdbcType="VARCHAR"/>
<result property="menuId" column="menu_id" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,role_id,menu_id,
created_at,updated_at,del_flag,
created_by_name,update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasUserMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasUser">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="username" column="username" jdbcType="VARCHAR"/>
<result property="account" column="account" jdbcType="VARCHAR"/>
<result property="password" column="password" jdbcType="VARCHAR"/>
<result property="mobile" column="mobile" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="CHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByNameName" column="created_by_name_name" jdbcType="VARCHAR"/>
<result property="updateByNameName" column="update_by_name_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,username,account,
password,mobile,status,
remark,created_at,updated_at,
del_flag,created_by_name_name,update_by_name_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.SaasUserRoleMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.SaasUserRole">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="roleId" column="role_id" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,user_id,role_id,
created_at,updated_at,del_flag,
created_by_name,update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.TntAuthMenuMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.TntAuthMenu">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="requestPath" column="request_path" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="icon" column="icon" jdbcType="VARCHAR"/>
<result property="resourceType" column="resource_type" jdbcType="VARCHAR"/>
<result property="hiddenStatus" column="hidden_status" jdbcType="CHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="cacheStatus" column="cache_status" jdbcType="CHAR"/>
<result property="status" column="status" jdbcType="CHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,parent_id,name,
request_path,sort,icon,
resource_type,hidden_status,remark,
cache_status,status,created_at,
updated_at,del_flag,created_by_name,
update_by_name
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.saas.TntTenantMapper">
<resultMap id="BaseResultMap" type="com.makeit.entity.saas.TntTenant">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="tntUserId" column="tnt_user_id" jdbcType="VARCHAR"/>
<result property="menuList" column="menu_list" jdbcType="VARCHAR"/>
<result property="alertChannel" column="alert_channel" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="CHAR"/>
<result property="createdByName" column="created_by_name" jdbcType="VARCHAR"/>
<result property="updateByName" column="update_by_name" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,name,status,
start_time,end_time,tnt_user_id,
menu_list,alert_channel,created_at,
updated_at,del_flag,created_by_name,
update_by_name
</sql>
</mapper>
......@@ -24,6 +24,11 @@
<artifactId>server-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.makeit</groupId>
<artifactId>saas-module</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -110,11 +110,11 @@ sa-token:
interceptor:
## 登录拦截路径
authenticationTntPath: /**
authenticationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/sys/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html
authenticationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/sys/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html,/saas/login/**,/error
## 权限拦截路径
authorizationTntPath: /**
authorizationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/sys/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html
authorizationTntPathIgnore: /swagger-resources/**,/v2/api-docs/**,/sys/login/**,/sys/dictionaryCategory/getDictionaryCategoryByList,/mobile/**,/doc.html,/saas/login/**,/error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment