食谱计划生成优化、小程序接口

This commit is contained in:
xiezhijun
2021-07-13 18:21:49 +08:00
parent 89cb00b71c
commit 19339fd973
30 changed files with 997 additions and 101 deletions

View File

@ -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;
}
}

View File

@ -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;
}
/**
* * 判断一个字符串是否为非空串
*