Commit f5b51324 by 宋祥

1.文档权限管理可设置用户是否能下载,文档预览增加下载权限校验

parent b696dbfb
......@@ -40,6 +40,7 @@ public class HGWD003 extends DaoEPBase {
public static final String FIELD_EXT_ID = "extId"; /* 外部系统主键ID*/
public static final String FIELD_ORG_ID = "orgId"; /* 部门编码*/
public static final String FIELD_ORG_CNAME = "orgCname"; /* 部门名称*/
public static final String FIELD_DOWNLOAD_FLAG = "downloadFlag"; /* 是否可以下载,0=否,1=是*/
public static final String COL_ID = "ID";
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 企业编码*/
......@@ -59,6 +60,7 @@ public class HGWD003 extends DaoEPBase {
public static final String COL_EXT_ID = "EXT_ID"; /* 外部系统主键ID*/
public static final String COL_ORG_ID = "ORG_ID"; /* 部门编码*/
public static final String COL_ORG_CNAME = "ORG_CNAME"; /* 部门名称*/
public static final String COL_DOWNLOAD_FLAG = "DOWNLOAD_FLAG"; /* 是否可以下载,0=否,1=是*/
public static final String QUERY = "HGWD003.query";
public static final String COUNT = "HGWD003.count";
......@@ -84,6 +86,7 @@ public class HGWD003 extends DaoEPBase {
private String extId = " "; /* 外部系统主键ID*/
private String orgId = " "; /* 部门编码*/
private String orgCname = " "; /* 部门名称*/
private Integer downloadFlag = 0; /* 是否可以下载,0=否,1=是*/
/**
* initialize the metadata.
......@@ -164,6 +167,9 @@ public class HGWD003 extends DaoEPBase {
eiColumn.setDescName("部门名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_DOWNLOAD_FLAG);
eiColumn.setDescName("是否可以下载");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -423,6 +429,14 @@ public class HGWD003 extends DaoEPBase {
this.orgCname = orgCname;
}
public Integer getDownloadFlag() {
return downloadFlag;
}
public void setDownloadFlag(Integer downloadFlag) {
this.downloadFlag = downloadFlag;
}
/**
* get the value from Map.
*
......@@ -449,6 +463,7 @@ public class HGWD003 extends DaoEPBase {
setExtId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_EXT_ID)), extId));
setOrgId(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_ORG_ID)), orgId));
setOrgCname(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_ORG_CNAME)), orgCname));
setDownloadFlag(NumberUtils.toInteger(StringUtils.toString(map.get(FIELD_DOWNLOAD_FLAG)), downloadFlag));
}
/**
......@@ -476,6 +491,7 @@ public class HGWD003 extends DaoEPBase {
map.put(FIELD_EXT_ID, StringUtils.toString(extId, eiMetadata.getMeta(FIELD_EXT_ID)));
map.put(FIELD_ORG_ID, StringUtils.toString(orgId, eiMetadata.getMeta(FIELD_ORG_ID)));
map.put(FIELD_ORG_CNAME, StringUtils.toString(orgCname, eiMetadata.getMeta(FIELD_ORG_CNAME)));
map.put(FIELD_DOWNLOAD_FLAG, StringUtils.toString(downloadFlag, eiMetadata.getMeta(FIELD_DOWNLOAD_FLAG)));
return map;
}
......
......@@ -308,9 +308,11 @@ public class ServiceHGWD001D extends TreeService {
* @return
*/
public List queryChildNode(String projCode, String parentId, String ename) {
String userId = UserSessionUtils.getLoginName();
// 查询项目来源
HGSC001 dbSc001 = HGSCTools.Hgsc001.queryByCode(projCode);
boolean isAuth = !ProjectSourceEnum.SPARE.getCode().equals(dbSc001.getProjectSource());
// true:需要权限
boolean isSourceAuth = !ProjectSourceEnum.SPARE.getCode().equals(dbSc001.getProjectSource());
List<Map> results = new ArrayList();
Map queryMap = new HashMap();
queryMap.put("parentId", parentId);
......@@ -320,17 +322,28 @@ public class ServiceHGWD001D extends TreeService {
return results;
}
List<String> fileIds = dbWd001s.stream().map(HGWD001::getFileId).distinct().collect(Collectors.toList());
List<HGWD003> hgwd003s = HGWDTools.HgWd003.list(fileIds);
// 查询目录授权人数
Map<String, List<HGWD003>> dbWd003Map = HGWDTools.HgWd003.map(fileIds);
for (HGWD001 dbWd001 : dbWd001s) {
Map leafMap = buildLeaf(parentId, dbWd001.getFileId(), dbWd001.getFileName(), HgWdConstant.LeafType.C);
Long count = hgwd003s.stream().filter(hgwd003 -> hgwd003.getFileId().equals(dbWd001.getFileId())).count();
// 已授权人员信息
List<HGWD003> dbWd003s = dbWd003Map == null ? null : dbWd003Map.get(dbWd001.getFileId());
leafMap.put("projCode", dbWd001.getProjCode());
leafMap.put("projName", dbWd001.getProjName());
leafMap.put("ename", dbWd001.getProjCode());
leafMap.put("type", dbWd001.getFileType());
leafMap.put("leafLevel", dbWd001.getLeafLevel());
leafMap.put("count", count);
leafMap.put("isAuth", isAuth ? "1" : "0");
leafMap.put("count", dbWd003s == null ? 0 : dbWd003s.size());
if (isSourceAuth) {
leafMap.put("isAuth", "1");
// 从已授权的信息中查找出自己
HGWD003 dbWd003 = dbWd003s == null ? null : dbWd003s.stream().filter(item
-> item.getUserId().equals(userId)).findFirst().orElse(null);
leafMap.put("downloadFlag", dbWd003 == null ? "0" : dbWd003.getDownloadFlag());
} else {
leafMap.put("isAuth", "0");
leafMap.put("downloadFlag", "1");
}
results.add(leafMap);
}
// 设置叶子节点
......
......@@ -3,11 +3,9 @@ package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.sc.enums.ProjectSourceEnum;
import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.wd.utils.HgWdUtils;
import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.util.CommonMethod;
......@@ -81,10 +79,10 @@ public class ServiceHGWD002 extends ServiceBase {
}
public void builder(EiInfo eiInfo){
public void builder(EiInfo eiInfo) {
String[] orderBy = eiInfo.getBlock(EiConstant.resultBlock).getString("orderBy").split(",");
if (orderBy.length>0){
StringBuilder orderByStr= new StringBuilder();
if (orderBy.length > 0) {
StringBuilder orderByStr = new StringBuilder();
for (int i = 0; i < orderBy.length; i++) {
if (i != 0 && i != orderByStr.length() - 1) {
orderByStr.append(",");
......@@ -139,15 +137,15 @@ public class ServiceHGWD002 extends ServiceBase {
orderByStr.append(orderBy[i].replace("updatedTime desc", "b.updatedTime desc"));
break;
default:
if (!orderBy[i].isEmpty()){
if (!orderBy[i].isEmpty()) {
orderByStr.append(orderBy[i]);
}else {
} else {
orderByStr.append(orderBy[i]);
}
break;
}
}
eiInfo.getBlock(EiConstant.resultBlock).set("orderBy",orderByStr);
eiInfo.getBlock(EiConstant.resultBlock).set("orderBy", orderByStr);
}
}
}
......@@ -12,13 +12,11 @@ import com.baosight.hggp.hg.wd.constant.HgWdConstant;
import com.baosight.hggp.hg.wd.constant.HgWdSqlConstant;
import com.baosight.hggp.hg.wd.domain.HGWD001;
import com.baosight.hggp.hg.wd.domain.HGWD003;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.wd.utils.HgWdUtils;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
......
......@@ -17,7 +17,8 @@
A.USER_ID as "userId", <!-- 用户ID -->
A.REMARK as "remark", <!-- 备注 -->
A.IS_PROJECT_MANAGER as "isProjectManager", <!-- 是否项目经理,0=否,1=是 -->
A.EXT_ID as "extId" <!-- 外部系统ID -->
A.EXT_ID as "extId", <!-- 外部系统ID -->
A.DOWNLOAD_FLAG as "downloadFlag" <!-- 是否可以下载,0=否,1=是 -->
</sql>
<sql id="columnB">
......@@ -148,6 +149,7 @@
UPDATE ${hggpSchema}.HGWD003
SET
IS_PROJECT_MANAGER = #isProjectManager#,
DOWNLOAD_FLAG = #downloadFlag#,
<include refid="SqlBase.updateRevise"/>
WHERE ID = #id#
</update>
......
......@@ -4,9 +4,9 @@ $(function () {
$("#HGWD002").css("padding-bottom", "8px")
sessionStorage.removeItem("__user_id__")
setTimeout(() => {
let parendId = $("inqu_status-0-parentId").val();
if (!isBlank(parendId)){
resultGrid.dataSource.page(1);
let parentId = $("inqu_status-0-parentId").val();
if (!isBlank(parentId)) {
query();
}
// 显示授权按钮
showAuthButton();
......@@ -89,24 +89,21 @@ $(function () {
IPLATUI.EFTree = {
"docTree": {
query: function (inInfo, model) {
if (model == null) {
return inInfo;
}
let label = model.label;
// 选中树节点
selectTreeId(label);
// 设置选中节点
treeSelectClick(model);
inInfo.set("inqu_status-0-projCode", $("#inqu_status-0-projCode").val());
return inInfo;
},
select: function (e) {
var _data = this.dataItem(e.node);
var labelValue = _data.label;
var typeValue = _data.type;
const eNameValue = _data.ename;
setTreeNodeValue(_data);
$("[name = 'inqu_status-0-parentId']").val(labelValue);
$("[name = 'inqu_status-0-fileId']").val(_data.id);
$("[name = 'inqu_status-0-leafLevel']").val(_data.leafLevel==null?0:_data.leafLevel);
$("[name = 'inqu_status-0-projCode']").val(_data.projCode);
$("[name = 'inqu_status-0-type']").val(typeValue);
$("[name = 'inqu_status-0-fileName']").val(_data.text);
resultGrid.dataSource.page(1);
// 显示授权按钮
showAuthButton();
let nodeData = this.dataItem(e.node);
// 设置选中节点
treeSelectClick(nodeData);
},
/*ROOT:{label: 'root',text: '组织机构'},*/
template: function (node) {
......@@ -135,7 +132,7 @@ $(function () {
companyCode: '',
leafLevel: '',
type: '',
isAuth: '1'
downloadFlag: '0'
},
// expandLevel:1,
/**
......@@ -251,32 +248,93 @@ let showDownloadRecord = function (fileId, docId) {
}
/**
* 选中树节点
*
* @param treeId
*/
let selectTreeId = function (treeId) {
// 刷新树节点
const tree = $("#docTree").data("kendoTreeView");
// 选中的节点
selectTreeNode(tree, treeId);
}
/**
* 选中树节点
*
* @param tree
* @param treeId
*/
let selectTreeNode = (tree, treeId) => {
if (!tree || treeId == null) {
return
}
setTimeout(() => {
let barDataItem = tree.dataSource.get(treeId);
if (barDataItem) {
let barElement = tree.findByUid(barDataItem.uid);
// 刷新完成后选中对应的树节点
tree.select(barElement);
} else {
selectTreeNode(tree, treeId)
}
}, 300)
}
/**
* 树点击事件
*
* @param nodeData
*/
let treeSelectClick = function (nodeData) {
// 设置选择的树节点信息
setTreeNodeValue(nodeData);
// 显示授权按钮
showAuthButton();
// 刷新列表
query();
}
/**
* 设置树节点的值
*
* @param nodeData
*/
let setTreeNodeValue = function (nodeData) {
let leafLevel = nodeData.leafLevel == null ? 0 : nodeData.leafLevel;
IPLATUI.EFTree.docTree.selectTreeNode.fileId = nodeData.label;
IPLATUI.EFTree.docTree.selectTreeNode.parentId = nodeData.parentId;
IPLATUI.EFTree.docTree.selectTreeNode.fileName = nodeData.text;
IPLATUI.EFTree.docTree.selectTreeNode.companyCode = nodeData.companyCode;
IPLATUI.EFTree.docTree.selectTreeNode.projCode = nodeData.projCode;
IPLATUI.EFTree.docTree.selectTreeNode.leafLevel = nodeData.leafLevel;
IPLATUI.EFTree.docTree.selectTreeNode.isAuth = nodeData.isAuth;
IPLATUI.EFTree.docTree.selectTreeNode.leafLevel = leafLevel;
IPLATUI.EFTree.docTree.selectTreeNode.downloadFlag = nodeData.downloadFlag == null ? 0
: nodeData.downloadFlag;
$("[name = 'inqu_status-0-parentId']").val(nodeData.label);
$("[name = 'inqu_status-0-fileId']").val(nodeData.id);
$("[name = 'inqu_status-0-projCode']").val(nodeData.projCode);
$("[name = 'inqu_status-0-leafLevel']").val(leafLevel);
$("[name = 'inqu_status-0-type']").val(nodeData.type);
$("[name = 'inqu_status-0-fileName']").val(nodeData.text);
}
/**
* 显示授权按钮
*/
let showAuthButton = function () {
let leafType = IPLATUI.EFTree.docTree.selectTreeNode.leafLevel;
// C:目录
let leafType = IPLATUI.EFTree.docTree.selectTreeNode.leafLevel;
if (leafType && leafType > 0) {
$("#PREVIEW").attr("disabled", false);
$("#DOWNLOAD").attr("disabled", false);
$("#PREVIEW").show();
} else {
$("#PREVIEW").hide();
}
// 是否可以下载
let downloadFlag = IPLATUI.EFTree.docTree.selectTreeNode.downloadFlag;
if (downloadFlag === "1") {
$("#DOWNLOAD").show();
} else {
$("#PREVIEW").attr("disabled", true);
$("#DOWNLOAD").attr("disabled", true);
$("#DOWNLOAD").hide();
}
}
......
......@@ -41,7 +41,11 @@
<EF:EFColumn ename="orgCname" cname="部门名称" enable="false" width="120" align="center"/>
<EF:EFColumn ename="userId" cname="用户账号" enable="false" width="100" align="center"/>
<EF:EFColumn ename="userName" cname="用户姓名" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="isProjectManager" cname="是否项目经理" width="100" align="center"
<EF:EFComboColumn ename="isProjectManager" cname="是否项目经理" width="120" align="center"
required="true" copy="true">
<EF:EFCodeOption codeName="hggp.common.yesNo"/>
</EF:EFComboColumn>
<EF:EFComboColumn ename="downloadFlag" cname="是否可以下载" width="120" align="center"
required="true" copy="true">
<EF:EFCodeOption codeName="hggp.common.yesNo"/>
</EF:EFComboColumn>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment