Merge branch 'master' of gitee.com:darlk/ShengTangManage into develop

This commit is contained in:
huangdeliang
2021-07-14 18:09:43 +08:00
41 changed files with 1307 additions and 95 deletions

View File

@ -137,6 +137,29 @@ public class AliyunVideoUtils {
return client.createUploadVideo(createUploadVideoRequest);
}
/**
* 根据视频ID获取对应播放凭证
* @param videoId
* @return
* @throws Exception
*/
public static String getVideoPlayAuth(String videoId) throws Exception{
com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient();
GetVideoPlayAuthRequest getVideoPlayAuthRequest = new GetVideoPlayAuthRequest()
.setVideoId(videoId);
GetVideoPlayAuthResponse response = client.getVideoPlayAuth(getVideoPlayAuthRequest);
if(response != null){
GetVideoPlayAuthResponseBody body = response.body;
if(body != null && StringUtils.isNotEmpty(body.playAuth)){
return body.playAuth;
}
}
return null;
}
/**
*
* @param key

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