feat commit

入驻企业权限控制,入驻企业的企业管理功能,用户管理功能
pull/2/head
玉安君 2024-03-28 22:27:18 +08:00
parent a78b4f3fc1
commit 0ad5f18336
6 changed files with 39 additions and 26 deletions

View File

@ -109,6 +109,25 @@ public class JwtUtils {
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
}
/**
*
* @param token
* @return
*/
public static String getCompanySign (String token) {
Claims claims = parseToken(token);
return getValue(claims, SecurityConstants.COMPANY_SIGN);
}
/**
*
* @param claims
* @return
*/
public static String getCompanySign (Claims claims) {
return getValue(claims, SecurityConstants.COMPANY_SIGN);
}
/**
*
*

View File

@ -36,12 +36,8 @@ public class SecurityUtils {
/**
*
*/
public static String formatToken (String token) {
// 如果前端设置了令牌前缀,则裁剪掉前缀
if (StringUtils.isNotEmpty(token) && token.startsWith(TokenConstants.PREFIX)) {
token = token.replaceFirst(TokenConstants.PREFIX, StringUtils.EMPTY);
}
return token;
public static String getCompanySign () {
return SecurityContextHolder.getCompanySign();
}
/**

View File

@ -66,11 +66,13 @@ public class AuthFilter implements GlobalFilter, Ordered {
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
return unauthorizedResponse(exchange, "令牌验证失败");
}
String companySign = JwtUtils.getCompanySign(claims);
// 设置用户信息到请求
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
addHeader(mutate, SecurityConstants.COMPANY_SIGN, companySign);
// 内部请求来源参数清除
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
return chain.filter(exchange.mutate().request(mutate.build()).build());

View File

@ -36,8 +36,7 @@ public class SysDeptController extends BaseController {
@Autowired
private SysDeptService deptService;
@Autowired
private RedisService redisService;
/**
*
@ -45,8 +44,7 @@ public class SysDeptController extends BaseController {
@RequiresPermissions("system:dept:list")
@GetMapping("/list")
public Result list (SysDept dept, HttpServletRequest request) {
String companySign = getCompanySign(request);
dept.setCompanySign(companySign);
dept.setCompanySign(SecurityUtils.getCompanySign());
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
}
@ -124,15 +122,15 @@ public class SysDeptController extends BaseController {
}
public String getCompanySign(HttpServletRequest request){
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
if ("companySign".equals(cookie.getName())){
return cookie.getValue();
}
}
throw new RuntimeException("公司标识无法获取");
}
// public String getCompanySign(HttpServletRequest request){
// Cookie[] cookies = request.getCookies();
// for (Cookie cookie : cookies) {
// if ("companySign".equals(cookie.getName())){
// return cookie.getValue();
// }
// }
// throw new RuntimeException("公司标识无法获取");
// }
}

View File

@ -288,6 +288,8 @@ public class SysUserController extends BaseController {
@RequiresPermissions("system:user:list")
@GetMapping("/deptTree")
public Result deptTree (SysDept dept) {
String companySign = SecurityUtils.getCompanySign();
dept.setCompanySign(companySign);
return success(deptService.selectDeptTreeList(dept));
}
}

View File

@ -43,13 +43,9 @@
<select id="selectDeptList" parameterType="com.zhilian.common.system.domain.SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<choose>
<when test="'ZL' == companySign">
</when>
<otherwise>
and d.company_sign = #{companySign,jdbcType=VARCHAR}
</otherwise>
</choose>
<if test="companySign != null and companySign != '' and 'ZL' != companySign">
and d.company_sign = #{companySign}
</if>
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>