mirror of
https://github.com/dataease/dataease.git
synced 2025-02-25 20:42:55 +08:00
refactror(应用): 应用编辑权限控制优化
This commit is contained in:
parent
6352725ca1
commit
7486653ce0
@ -85,11 +85,7 @@ public class DatasourceController {
|
|||||||
@ApiOperation("查询数据源详情")
|
@ApiOperation("查询数据源详情")
|
||||||
@PostMapping("/get/{id}")
|
@PostMapping("/get/{id}")
|
||||||
public DatasourceDTO getDatasource(@PathVariable String id) throws Exception {
|
public DatasourceDTO getDatasource(@PathVariable String id) throws Exception {
|
||||||
DatasourceUnionRequest request = new DatasourceUnionRequest();
|
return datasourceService.getDataSourceDetails(id);
|
||||||
request.setUserId("1");
|
|
||||||
request.setId(id);
|
|
||||||
List<DatasourceDTO> datasourceList = datasourceService.getDatasourceList(request);
|
|
||||||
return CollectionUtils.isNotEmpty(datasourceList) ? datasourceList.get(0) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询当前用户数据源")
|
@ApiOperation("查询当前用户数据源")
|
||||||
|
@ -15,7 +15,7 @@ public interface ExtDataSourceMapper {
|
|||||||
|
|
||||||
List<DatasourceDTO> findByPanelId(@Param("panelId") String panelId);
|
List<DatasourceDTO> findByPanelId(@Param("panelId") String panelId);
|
||||||
|
|
||||||
|
DatasourceDTO queryDetails(@Param("datasourceId") String datasourceId,@Param("userId") String userId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,5 +130,12 @@
|
|||||||
WHERE panel_view.panel_id = #{panelId}
|
WHERE panel_view.panel_id = #{panelId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryDetails" resultMap="BaseResultMapDTO">
|
||||||
|
select datasource.*,
|
||||||
|
get_auths(id, 'link', #{userId}) as `privileges`
|
||||||
|
from datasource
|
||||||
|
where id = #{datasourceId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -152,6 +152,12 @@ public class DatasourceService {
|
|||||||
request.setSort("update_time desc");
|
request.setSort("update_time desc");
|
||||||
List<DatasourceDTO> datasourceDTOS = extDataSourceMapper.queryUnion(request);
|
List<DatasourceDTO> datasourceDTOS = extDataSourceMapper.queryUnion(request);
|
||||||
datasourceDTOS.forEach(datasourceDTO -> {
|
datasourceDTOS.forEach(datasourceDTO -> {
|
||||||
|
datasourceTrans(datasourceDTO);
|
||||||
|
});
|
||||||
|
return datasourceDTOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void datasourceTrans(DatasourceDTO datasourceDTO){
|
||||||
types().forEach(dataSourceType -> {
|
types().forEach(dataSourceType -> {
|
||||||
if (dataSourceType.getType().equalsIgnoreCase(datasourceDTO.getType())) {
|
if (dataSourceType.getType().equalsIgnoreCase(datasourceDTO.getType())) {
|
||||||
datasourceDTO.setTypeDesc(dataSourceType.getName());
|
datasourceDTO.setTypeDesc(dataSourceType.getName());
|
||||||
@ -206,10 +212,15 @@ public class DatasourceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return datasourceDTOS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatasourceDTO getDataSourceDetails(String datasourceId){
|
||||||
|
DatasourceDTO result = extDataSourceMapper.queryDetails(datasourceId,String.valueOf(AuthUtils.getUser().getUserId()));
|
||||||
|
if(result != null){
|
||||||
|
this.datasourceTrans(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
|
public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
|
||||||
//如果没有查询条件增加一个默认的条件
|
//如果没有查询条件增加一个默认的条件
|
||||||
if (CollectionUtils.isEmpty(request.getConditions())) {
|
if (CollectionUtils.isEmpty(request.getConditions())) {
|
||||||
|
@ -814,8 +814,8 @@ public class PanelGroupService {
|
|||||||
// dataset check
|
// dataset check
|
||||||
if (CollectionUtils.isEmpty(datasetTablesInfo)) {
|
if (CollectionUtils.isEmpty(datasetTablesInfo)) {
|
||||||
return new PanelExport2App("this panel don't have dataset");
|
return new PanelExport2App("this panel don't have dataset");
|
||||||
} else if (datasetTablesInfo.stream().filter(datasetTable -> datasetTable.getType().equals("excel")).collect(Collectors.toList()).size() > 0) {
|
} else if (datasetTablesInfo.stream().filter(datasetTable -> datasetTable.getType().equals("excel") || datasetTable.getType().equals("api")).collect(Collectors.toList()).size() > 0) {
|
||||||
return new PanelExport2App("this panel have dataset witch type is excel");
|
return new PanelExport2App("this panel have dataset witch type is excel or api");
|
||||||
}
|
}
|
||||||
|
|
||||||
//datasource check
|
//datasource check
|
||||||
|
@ -224,6 +224,7 @@ import {
|
|||||||
import { deleteLogAndResource, logGrid } from '@/api/appTemplateMarket/log'
|
import { deleteLogAndResource, logGrid } from '@/api/appTemplateMarket/log'
|
||||||
import { findOneWithParent } from '@/api/panel/panel'
|
import { findOneWithParent } from '@/api/panel/panel'
|
||||||
import AppTemplateApply from '@/views/panel/appTemplate/component/AppTemplateApply'
|
import AppTemplateApply from '@/views/panel/appTemplate/component/AppTemplateApply'
|
||||||
|
import { hasDataPermission } from '@/utils/permission'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AppTemplateLog',
|
name: 'AppTemplateLog',
|
||||||
@ -308,7 +309,8 @@ export default {
|
|||||||
panelName: item.panelName,
|
panelName: item.panelName,
|
||||||
datasourcePrivileges: item.datasourcePrivileges,
|
datasourcePrivileges: item.datasourcePrivileges,
|
||||||
panelPrivileges: item.panelPrivileges,
|
panelPrivileges: item.panelPrivileges,
|
||||||
datasetPrivileges: item.datasetPrivileges
|
datasetPrivileges: item.datasetPrivileges,
|
||||||
|
appMarketEdit: hasDataPermission('manage', item.datasourcePrivileges)
|
||||||
}
|
}
|
||||||
this.$refs.templateEditApply.init(param)
|
this.$refs.templateEditApply.init(param)
|
||||||
},
|
},
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
>
|
>
|
||||||
<treeselect
|
<treeselect
|
||||||
v-model="attachForm.panelGroupPid"
|
v-model="attachForm.panelGroupPid"
|
||||||
:disabled="!(formType === 'add' ? true : hasDataPermission('manage', outerParams.panelPrivileges))"
|
:disabled="baseInfoDisabledCheck(outerParams.panelPrivileges)"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:options="panelGroupList"
|
:options="panelGroupList"
|
||||||
:normalizer="normalizer"
|
:normalizer="normalizer"
|
||||||
@ -103,7 +103,7 @@
|
|||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="attachForm.panelName"
|
v-model="attachForm.panelName"
|
||||||
:disabled="!(formType === 'add' ? true : hasDataPermission('manage', outerParams.panelPrivileges))"
|
:disabled="baseInfoDisabledCheck(outerParams.panelPrivileges)"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
@ -112,7 +112,7 @@
|
|||||||
>
|
>
|
||||||
<treeselect
|
<treeselect
|
||||||
v-model="attachForm.datasetGroupPid"
|
v-model="attachForm.datasetGroupPid"
|
||||||
:disabled="!(formType === 'add' ? true : hasDataPermission('manage', outerParams.datasetPrivileges))"
|
:disabled="baseInfoDisabledCheck(outerParams.datasetPrivileges)"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:options="datasetGroupList"
|
:options="datasetGroupList"
|
||||||
:normalizer="normalizer"
|
:normalizer="normalizer"
|
||||||
@ -128,7 +128,7 @@
|
|||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="attachForm.datasetGroupName"
|
v-model="attachForm.datasetGroupName"
|
||||||
:disabled="!(formType === 'add' ? true : hasDataPermission('manage', outerParams.panelPrivileges))"
|
:disabled="baseInfoDisabledCheck(outerParams.datasetPrivileges)"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -138,13 +138,7 @@
|
|||||||
:model="form"
|
:model="form"
|
||||||
:rules="rule"
|
:rules="rule"
|
||||||
size="small"
|
size="small"
|
||||||
:disabled="
|
:disabled="disabled"
|
||||||
params &&
|
|
||||||
params.id &&
|
|
||||||
params.showModel &&
|
|
||||||
params.showModel === 'show' &&
|
|
||||||
!canEdit
|
|
||||||
"
|
|
||||||
class="de-form-item"
|
class="de-form-item"
|
||||||
label-width="180px"
|
label-width="180px"
|
||||||
label-position="right"
|
label-position="right"
|
||||||
@ -218,13 +212,7 @@
|
|||||||
ref="dsConfig"
|
ref="dsConfig"
|
||||||
:datasource-type="datasourceType"
|
:datasource-type="datasourceType"
|
||||||
:form="form"
|
:form="form"
|
||||||
:disabled="
|
:disabled="disabled"
|
||||||
params &&
|
|
||||||
params.id &&
|
|
||||||
params.showModel &&
|
|
||||||
params.showModel === 'show' &&
|
|
||||||
!canEdit
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
<plugin-com
|
<plugin-com
|
||||||
v-if="datasourceType.isPlugin"
|
v-if="datasourceType.isPlugin"
|
||||||
@ -306,6 +294,7 @@ import msgCfm from '@/components/msgCfm'
|
|||||||
import { dsGroupTree } from '@/api/dataset/dataset'
|
import { dsGroupTree } from '@/api/dataset/dataset'
|
||||||
import { appApply, appEdit, groupTree } from '@/api/panel/panel'
|
import { appApply, appEdit, groupTree } from '@/api/panel/panel'
|
||||||
import { deepCopy } from '@/components/canvas/utils/utils'
|
import { deepCopy } from '@/components/canvas/utils/utils'
|
||||||
|
import { hasDataPermission } from '@/utils/permission'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DsForm',
|
name: 'DsForm',
|
||||||
@ -587,7 +576,9 @@ export default {
|
|||||||
this.queryTreeData()
|
this.queryTreeData()
|
||||||
let { id, showModel, type, name } = this.$route.query
|
let { id, showModel, type, name } = this.$route.query
|
||||||
this.params = this.$route.query
|
this.params = this.$route.query
|
||||||
if (this.positionCheck('appMarket')) {
|
const appMarketCheck = this.positionCheck('appMarket')
|
||||||
|
if (appMarketCheck) {
|
||||||
|
this.appMarketEdit = this.outerParams.appMarketEdit === undefined ? true : this.outerParams.appMarketEdit
|
||||||
id = this.outerParams.datasourceId
|
id = this.outerParams.datasourceId
|
||||||
showModel = this.outerParams.showModel
|
showModel = this.outerParams.showModel
|
||||||
type = this.outerParams.datasourceType
|
type = this.outerParams.datasourceType
|
||||||
@ -615,16 +606,18 @@ export default {
|
|||||||
this.changeType(true)
|
this.changeType(true)
|
||||||
} else {
|
} else {
|
||||||
this.canEdit = true
|
this.canEdit = true
|
||||||
this.disabled = false
|
|
||||||
if (type) {
|
if (type) {
|
||||||
this.typeMap = name
|
this.typeMap = name
|
||||||
this.setType()
|
this.setType()
|
||||||
this.changeType()
|
this.changeType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.disabled = Boolean(id) && showModel === 'show' && !this.canEdit
|
this.disabled = appMarketCheck ? !this.appMarketEdit : (Boolean(id) && showModel === 'show' && !this.canEdit)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
baseInfoDisabledCheck(privileges) {
|
||||||
|
return !(this.formType === 'add' ? true : hasDataPermission('manage', privileges))
|
||||||
|
},
|
||||||
normalizer(node) {
|
normalizer(node) {
|
||||||
// 去掉children=null的属性
|
// 去掉children=null的属性
|
||||||
if (node.children === null || node.children === 'null') {
|
if (node.children === null || node.children === 'null') {
|
||||||
@ -720,12 +713,6 @@ export default {
|
|||||||
changeEdit() {
|
changeEdit() {
|
||||||
this.canEdit = true
|
this.canEdit = true
|
||||||
this.formType = 'modify'
|
this.formType = 'modify'
|
||||||
this.disabled =
|
|
||||||
this.params &&
|
|
||||||
this.params.id &&
|
|
||||||
this.params.showModel &&
|
|
||||||
this.params.showModel === 'show' &&
|
|
||||||
!this.canEdit
|
|
||||||
},
|
},
|
||||||
edit(row) {
|
edit(row) {
|
||||||
this.formType = 'modify'
|
this.formType = 'modify'
|
||||||
@ -742,12 +729,6 @@ export default {
|
|||||||
this.form.configuration = JSON.parse(this.form.configuration)
|
this.form.configuration = JSON.parse(this.form.configuration)
|
||||||
this.originConfiguration = JSON.stringify(this.form.configuration)
|
this.originConfiguration = JSON.stringify(this.form.configuration)
|
||||||
}
|
}
|
||||||
this.disabled =
|
|
||||||
this.params &&
|
|
||||||
this.params.id &&
|
|
||||||
this.params.showModel &&
|
|
||||||
this.params.showModel === 'show' &&
|
|
||||||
!this.canEdit
|
|
||||||
this.changeEdit()
|
this.changeEdit()
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
|
Loading…
Reference in New Issue
Block a user