saas初始 #1
|
@ -6,6 +6,13 @@ package com.muyu.auth.form;
|
|||
* @author muyu
|
||||
*/
|
||||
public class LoginBody {
|
||||
|
||||
/**
|
||||
* 登录公司名称
|
||||
*/
|
||||
private Integer firmName;
|
||||
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
@ -16,6 +23,8 @@ public class LoginBody {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
|
||||
|
||||
public String getUsername () {
|
||||
return username;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ public class SecurityConstants {
|
|||
*/
|
||||
public static final String DETAILS_FIRM_ID = "firm_id";
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
public static final String DETAILS_DEPT_ID = "dept_id";
|
||||
|
||||
/**
|
||||
* 用户名字段
|
||||
*/
|
||||
|
@ -51,5 +56,5 @@ public class SecurityConstants {
|
|||
*/
|
||||
public static final String ROLE_PERMISSION = "role_permission";
|
||||
|
||||
public static final String SAAS_KEY = "ent_code";
|
||||
public static final String SAAS_KEY = "ent-code";
|
||||
}
|
||||
|
|
|
@ -151,6 +151,16 @@ public class JwtUtils {
|
|||
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份信息获取SAAS标识
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @return SAAS标识
|
||||
*/
|
||||
public static String getSaaSKey(Claims claims) {
|
||||
return getValue(claims, SecurityConstants.SAAS_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份信息获取键值
|
||||
*
|
||||
|
@ -162,4 +172,13 @@ public class JwtUtils {
|
|||
public static String getValue (Claims claims, String key) {
|
||||
return Convert.toStr(claims.get(key), "");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @return 值
|
||||
*/
|
||||
public static String getDeptId(Claims claims) {
|
||||
return getValue(claims, SecurityConstants.DETAILS_DEPT_ID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author: DongZeLiang
|
||||
|
@ -66,7 +63,7 @@ public class ManyDataSource implements ApplicationRunner{
|
|||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||
// 企业列表 企业CODE,端口,IP
|
||||
Map<Object, Object> dataSourceMap = new HashMap<>();
|
||||
dataSourceInfoList()
|
||||
Objects.requireNonNull(dataSourceInfoList())
|
||||
.stream()
|
||||
.map(entInfo -> DataSourceInfo.hostAndPortBuild(entInfo.getEntCode(), entInfo.getIp(), entInfo.getPort()))
|
||||
.forEach(dataSourceInfo -> {
|
||||
|
|
|
@ -11,7 +11,7 @@ public class DatasourceContent {
|
|||
|
||||
public final static String USER_NAME = "root";
|
||||
|
||||
public final static String PASSWORD = "root";
|
||||
public final static String PASSWORD = "bwie-8666";
|
||||
|
||||
public final static String IP = "159.75.188.178";
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public class TokenService {
|
|||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||
claimsMap.put(SecurityConstants.SAAS_KEY,loginUser.getSysUser().getDatabaseName());
|
||||
claimsMap.put(SecurityConstants.DETAILS_DEPT_ID,loginUser.getSysUser().getDeptId());
|
||||
|
||||
// 接口返回信息
|
||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||
|
|
|
@ -66,11 +66,15 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
|||
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
||||
return unauthorizedResponse(exchange, "令牌验证失败");
|
||||
}
|
||||
String saaSKey = JwtUtils.getSaaSKey(claims);
|
||||
String deptId = JwtUtils.getDeptId(claims);
|
||||
|
||||
// 设置用户信息到请求
|
||||
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
||||
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
||||
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
||||
addHeader(mutate, SecurityConstants.SAAS_KEY,saaSKey);
|
||||
addHeader(mutate,SecurityConstants.DETAILS_DEPT_ID,deptId);
|
||||
// 内部请求来源参数清除
|
||||
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||
|
|
|
@ -194,7 +194,7 @@ public class SysRoleController extends BaseController {
|
|||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public Result selectAuthUserAll (Long roleId, Long[] userIds) {
|
||||
public Result selectAuthUserAll (@RequestParam("roleId")Long roleId,@RequestParam("userIds") Long[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
|
|
@ -128,4 +128,22 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById (Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ancestors查询部门及子部门
|
||||
* @param ancestors
|
||||
* @return
|
||||
*/
|
||||
|
||||
List<SysDept> findByAncestors(@Param("ancestors") String ancestors);
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门ID查询对应的部门数据行
|
||||
* @param deptId 部门ID
|
||||
* @return 部门对象
|
||||
*/
|
||||
SysDept findById(@Param("deptId") String deptId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.constant.UserConstants;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.datascope.annotation.DataScope;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.*;
|
||||
import com.muyu.system.domain.vo.TreeSelect;
|
||||
import com.muyu.system.mapper.SysDeptMapper;
|
||||
import com.muyu.system.mapper.SysRoleMapper;
|
||||
import com.muyu.system.mapper.SysUserMapper;
|
||||
import com.muyu.system.service.SysDeptService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -36,6 +38,12 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
|
|
|
@ -109,6 +109,13 @@
|
|||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<select id="findById" resultType="com.muyu.common.system.domain.SysDept">
|
||||
select * from sys_dept where dept_id = #{deptId}
|
||||
</select>
|
||||
<select id="findByAncestors" resultType="com.muyu.common.system.domain.SysDept">
|
||||
select * from sys_dept where ancestors like concat(#{ancestors},'%')
|
||||
</select>
|
||||
|
||||
<insert id="insertDept" parameterType="com.muyu.common.system.domain.SysDept">
|
||||
insert into sys_dept(
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="loginIp" column="login_ip"/>
|
||||
<result property="loginDate" column="login_date"/>
|
||||
<result property="databaseName" column="database_name"/>
|
||||
<result property="firmId" column="firm_id"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
|
@ -48,6 +50,8 @@
|
|||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id,
|
||||
u.database_name,
|
||||
u.firm_id,
|
||||
u.dept_id,
|
||||
u.user_name,
|
||||
u.nick_name,
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<module>cloud-modules-system</module>
|
||||
<module>cloud-modules-gen</module>
|
||||
<module>cloud-modules-file</module>
|
||||
<module>cloud-test</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
|
|
Loading…
Reference in New Issue