食谱计划生成优化、小程序接口
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package com.stdiet.common.utils;
|
||||
|
||||
import com.stdiet.common.core.domain.entity.SysRole;
|
||||
import com.stdiet.common.core.domain.entity.SysUser;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
@ -7,6 +9,9 @@ import com.stdiet.common.constant.HttpStatus;
|
||||
import com.stdiet.common.core.domain.model.LoginUser;
|
||||
import com.stdiet.common.exception.CustomException;
|
||||
|
||||
import javax.management.relation.Role;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 安全服务工具类
|
||||
*
|
||||
@ -14,6 +19,8 @@ import com.stdiet.common.exception.CustomException;
|
||||
*/
|
||||
public class SecurityUtils
|
||||
{
|
||||
public static final String[] managerRolePower = {"after_sale_manager","operations","personnel","sales_manager","admin","manager","admin-dev"};
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
@ -87,4 +94,32 @@ public class SecurityUtils
|
||||
{
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为管理人员
|
||||
*/
|
||||
public static boolean isManager(LoginUser loginUser)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(loginUser != null && loginUser.getUser() != null){
|
||||
SysUser user = loginUser.getUser();
|
||||
List<SysRole> roleList = user.getRoles();
|
||||
if(roleList != null && roleList.size() > 0){
|
||||
for (SysRole role : roleList) {
|
||||
for (String power : managerRolePower) {
|
||||
if(power.equals(role.getRoleKey())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CustomException("操作异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,21 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return isNull(str) || NULLSTR.equals(str.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断多个字符串是否为空,一个为空则返回true
|
||||
*
|
||||
* @param str String
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(String ... str) {
|
||||
for (String value : str) {
|
||||
if(isEmpty(value)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个字符串是否为非空串
|
||||
*
|
||||
|
Reference in New Issue
Block a user