1、数据范围根据用户角色筛选;2、界面功能按钮根据权限是否显示;3、文件上传后,文件访问链接改为服务接口返回的参数内容
This commit is contained in:
@@ -177,6 +177,8 @@
|
||||
<if test="level != null">
|
||||
AND a.level=#{level,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${sqlMap.dsf}
|
||||
</trim>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
@@ -274,6 +276,8 @@
|
||||
<if test="description != null and description != ''">
|
||||
AND a.description like concat(concat('%',#{description,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${sqlMap.dsf}
|
||||
</trim>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class BaseService {
|
||||
for (String oa : StringUtils.split(officeAlias, ",")){
|
||||
if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(oa)){
|
||||
|
||||
sqlString.append(createScopeSql(r.getDataScope(),oa,user));
|
||||
sqlString.append(createScopeSql(r.getDataScope(),oa,user,null));
|
||||
dataScope.add(r.getDataScope());
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,48 @@ public abstract class BaseService {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据范围过滤
|
||||
* @param user 当前用户对象,通过“entity.getCurrentUser()”获取
|
||||
* @param configAlias 配置表别名,多个用","逗号隔开,传递空,忽略此参数
|
||||
* @return 标准连接条件对象
|
||||
*/
|
||||
public static String configScopeFilter(SysUser user, String configAlias) {
|
||||
|
||||
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
|
||||
// 进行权限过滤,多个角色权限范围之间为或者关系。
|
||||
List<Integer> dataScope = Lists.newArrayList();
|
||||
|
||||
if (StringUtils.isBlank(user.getLoginId())){
|
||||
return "";
|
||||
}
|
||||
|
||||
// 超级管理员,跳过权限过滤
|
||||
if (!user.isAdmin()){
|
||||
boolean isDataScopeAll = isContainsDataScopeAll(user.getUserRoleList());
|
||||
// 如果没有全部数据权限
|
||||
if (!isDataScopeAll){
|
||||
for (SysRole r : user.getUserRoleList()) {
|
||||
for (String c : StringUtils.split(configAlias, ",")){
|
||||
if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(c)){
|
||||
sqlString.append(createScopeSql(r.getDataScope(),"",user,c));
|
||||
dataScope.add(r.getDataScope());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
// 如果包含全部权限,则去掉之前添加的所有条件,并跳出循环。
|
||||
sqlString = new StringBuilder();
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(sqlString.toString())){
|
||||
return " AND (" + sqlString.substring(4) + ")";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -108,10 +149,12 @@ public abstract class BaseService {
|
||||
|
||||
/**
|
||||
* 过滤机构信息
|
||||
* @param dataScope 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;6:所在单位及以下数据;7:所在单位数据)
|
||||
* @param dataScope 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;
|
||||
* 4:所在部门及以下数据;5:所在部门数据;6:所在单位及以下数据;7:所在单位数据;
|
||||
* 8:操作员数据;9:审核员数据,10:审计员数据)
|
||||
* @return
|
||||
*/
|
||||
private static String createScopeSql(int dataScope,String officeAlias,SysUser user) {
|
||||
private static String createScopeSql(int dataScope,String officeAlias,SysUser user,String configAlias) {
|
||||
StringBuilder scopeSql = new StringBuilder(1024);
|
||||
|
||||
if (SysRole.DATA_SCOPE_COMPANY_AND_CHILD.equals(dataScope)){
|
||||
@@ -139,6 +182,14 @@ public abstract class BaseService {
|
||||
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
||||
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getEntity().getId() + "' AND " + officeAlias + ".type>1)");
|
||||
|
||||
}else if (SysRole.DATA_SCOPE_CREATOR.equals(dataScope)){
|
||||
scopeSql.append(" OR " + configAlias + ".is_audit !=3");
|
||||
}
|
||||
else if (SysRole.DATA_SCOPE_AUDITOR.equals(dataScope)){
|
||||
scopeSql.append(" OR " + configAlias + ".is_audit = 0 and " + configAlias + ".is_valid = 0");
|
||||
}
|
||||
else if (SysRole.DATA_SCOPE_SHOWER.equals(dataScope)){
|
||||
scopeSql.append(" OR " + configAlias + ".is_audit = 1");
|
||||
}
|
||||
|
||||
return scopeSql.toString();
|
||||
|
||||
@@ -50,12 +50,16 @@ public class AvCfgService extends BaseService{
|
||||
return avCfgDao.getAvSignSampleById(cfgId);
|
||||
}
|
||||
public Page<AvFileSampleCfg> getAvFileSampleList(Page<AvFileSampleCfg> page, AvFileSampleCfg entity){
|
||||
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
||||
entity.setPage(page);
|
||||
List<AvFileSampleCfg> list = avCfgDao.getAvFileSampleList(entity);
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
public Page<AvSignSampleCfg> getAvSignSampleList(Page<AvSignSampleCfg> page, AvSignSampleCfg entity){
|
||||
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
||||
entity.setPage(page);
|
||||
List<AvSignSampleCfg> list = avCfgDao.getAvSignSampleList(entity);
|
||||
page.setList(list);
|
||||
@@ -157,6 +161,9 @@ public class AvCfgService extends BaseService{
|
||||
srcMap.put("checksum", entity.getSrcMd5());
|
||||
String result1 = ConfigServiceUtil.postFileCfg(null, srcFile, JSONObject.fromObject(srcMap));
|
||||
logger.info("音视频源文件上传响应信息:"+result1);
|
||||
//获取文件上传响应信息(文件访问路径)
|
||||
Map<String, Object> srcRes = gson.fromJson(result1,Map.class);
|
||||
entity.setSrcUrl(srcRes.get("data").toString());
|
||||
|
||||
File smapleFile = new File(entity.getSamplePath());
|
||||
Map<String,Object> sampleMap = new HashMap();
|
||||
@@ -167,7 +174,9 @@ public class AvCfgService extends BaseService{
|
||||
sampleMap.put("checksum", entity.getSampleMd5());
|
||||
String result2 = ConfigServiceUtil.postFileCfg(null, srcFile, JSONObject.fromObject(sampleMap));
|
||||
logger.info("音视频样例文件上传响应信息:"+result2);
|
||||
|
||||
Map<String, Object> sampleRes = gson.fromJson(result1,Map.class);
|
||||
//获取文件上传响应信息(文件访问路径)
|
||||
entity.setSampleUrl(sampleRes.get("data").toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("音视频文件样例配置下发失败");
|
||||
|
||||
Reference in New Issue
Block a user