mirror of
https://gitee.com/xiaonuobase/snowy.git
synced 2026-10-06 06:52:58 +08:00
【底座】采纳 #IJZBV8 建议,优化代码生成的其他问题
This commit is contained in:
+8
@@ -49,6 +49,14 @@ public interface SysRoleApi {
|
||||
**/
|
||||
void grantForGenMenuAndButton(String menuId);
|
||||
|
||||
/**
|
||||
* 代码生成权限授权
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/11/1 15:58
|
||||
**/
|
||||
void grantForGenPermission(String moduleName, String busName, String genType);
|
||||
|
||||
/**
|
||||
* 获取资源授权树
|
||||
*
|
||||
|
||||
+4
@@ -577,6 +577,9 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
|
||||
// 授权菜单
|
||||
sysRoleApi.grantForGenMenuAndButton(menuId);
|
||||
|
||||
// 授权权限
|
||||
sysRoleApi.grantForGenPermission(genModuleName, genBasic.getBusName(), genBasic.getGenType());
|
||||
|
||||
//前端代码移动到前端
|
||||
FileUtil.moveContent(FileUtil.file(tempFolder + File.separator + "frontend"), FileUtil.file(genProjectFrontendPath), true);
|
||||
|
||||
@@ -879,6 +882,7 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
|
||||
bindingJsonObject.set("subEditButtonId", IdWorker.getIdStr());
|
||||
bindingJsonObject.set("subDeleteButtonId", IdWorker.getIdStr());
|
||||
bindingJsonObject.set("subDetailButtonId", IdWorker.getIdStr());
|
||||
bindingJsonObject.set("subBatchDeleteButtonId", IdWorker.getIdStr());
|
||||
// 子表导入按钮ID(主子表类型使用)
|
||||
bindingJsonObject.set("subImportButtonId", IdWorker.getIdStr());
|
||||
// 子表导出按钮ID(主子表类型使用)
|
||||
|
||||
+1
@@ -284,6 +284,7 @@ public class ${className}Controller {
|
||||
* @date ${genTime}
|
||||
*/
|
||||
@Operation(summary = "下载${subFunctionName}导入模板")
|
||||
@SaCheckPermission("/${moduleName}/${busName}/sub/downloadImportTemplate")
|
||||
@GetMapping(value = "/${moduleName}/${busName}/sub/downloadImportTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void subDownloadImportTemplate(HttpServletResponse response) throws IOException {
|
||||
${subClassNameFirstLower}Service.downloadImportTemplate(response);
|
||||
|
||||
@@ -162,6 +162,7 @@ public class ${className}Controller {
|
||||
* @date ${genTime}
|
||||
*/
|
||||
@Operation(summary = "下载${functionName}导入模板")
|
||||
@SaCheckPermission("/${moduleName}/${busName}/downloadImportTemplate")
|
||||
@GetMapping(value = "/${moduleName}/${busName}/downloadImportTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws IOException {
|
||||
${classNameFirstLower}Service.downloadImportTemplate(response);
|
||||
|
||||
@@ -187,6 +187,7 @@ public class ${className}Controller {
|
||||
* @date ${genTime}
|
||||
*/
|
||||
@Operation(summary = "下载${functionName}导入模板")
|
||||
@SaCheckPermission("/${moduleName}/${busName}/downloadImportTemplate")
|
||||
@GetMapping(value = "/${moduleName}/${busName}/downloadImportTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public void downloadImportTemplate(HttpServletResponse response) throws IOException {
|
||||
${classNameFirstLower}Service.downloadImportTemplate(response);
|
||||
|
||||
+16
-19
@@ -1,37 +1,34 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
title="详情${functionName}"
|
||||
title="详情"
|
||||
:width="700"
|
||||
v-model:open="open"
|
||||
:destroy-on-close="true"
|
||||
@close="onClose"
|
||||
>
|
||||
<a-descriptions :column="1" bordered size="small">
|
||||
<% for(var i = 0; i < configList.~size; i++) { %>
|
||||
<% if(!configList[i].needTableId && configList[i].whetherDetail) { %>
|
||||
<a-descriptions-item label="${configList[i].fieldRemark}">
|
||||
<% if(configList[i].effectType == 'select' || configList[i].effectType == 'radio') { %>
|
||||
<a-tag :color="$TOOL.dictTypeColor('${configList[i].dictTypeCode}', formData.${configList[i].fieldNameCamelCase})">{{ $TOOL.dictTypeData('${configList[i].dictTypeCode}', formData.${configList[i].fieldNameCamelCase}) }}</a-tag>
|
||||
<% } else if (configList[i].effectType == 'checkbox') { %>
|
||||
<a-tag v-for="textValue in JSON.parse(formData.${configList[i].fieldNameCamelCase} || '[]')" :key="textValue" :color="$TOOL.dictTypeColor('${configList[i].dictTypeCode}', textValue)">{{ $TOOL.dictTypeData('${configList[i].dictTypeCode}', textValue) }}</a-tag>
|
||||
<% } else if (configList[i].effectType == 'imageUpload') {%>
|
||||
<a-image v-if="formData.${configList[i].fieldNameCamelCase}" :src="formData.${configList[i].fieldNameCamelCase}" style="width: 100px; height: 100px" />
|
||||
<% for(var i = 0; i < subConfigList.~size; i++) { %>
|
||||
<% if(!subConfigList[i].needTableId && subConfigList[i].whetherDetail) { %>
|
||||
<a-descriptions-item label="${subConfigList[i].fieldRemark}">
|
||||
<% if(subConfigList[i].effectType == 'select' || subConfigList[i].effectType == 'radio') { %>
|
||||
<a-tag :color="$TOOL.dictTypeColor('${subConfigList[i].dictTypeCode}', formData.${subConfigList[i].fieldNameCamelCase})">{{ $TOOL.dictTypeData('${subConfigList[i].dictTypeCode}', formData.${subConfigList[i].fieldNameCamelCase}) }}</a-tag>
|
||||
<% } else if (subConfigList[i].effectType == 'checkbox') { %>
|
||||
<a-tag v-for="textValue in JSON.parse(formData.${subConfigList[i].fieldNameCamelCase} || '[]')" :key="textValue" :color="$TOOL.dictTypeColor('${subConfigList[i].dictTypeCode}', textValue)">{{ $TOOL.dictTypeData('${subConfigList[i].dictTypeCode}', textValue) }}</a-tag>
|
||||
<% } else if (subConfigList[i].effectType == 'imageUpload') {%>
|
||||
<a-image v-if="formData.${subConfigList[i].fieldNameCamelCase}" :src="formData.${subConfigList[i].fieldNameCamelCase}" style="width: 100px; height: 100px" />
|
||||
<span v-else>无</span>
|
||||
<% } else if (configList[i].effectType == 'fileUpload') {%>
|
||||
<a-button v-if="formData.${configList[i].fieldNameCamelCase}" type="link" @click="downloadFile(formData.${configList[i].fieldNameCamelCase})">下载文件</a-button>
|
||||
<% } else if (subConfigList[i].effectType == 'fileUpload') {%>
|
||||
<a-button v-if="formData.${subConfigList[i].fieldNameCamelCase}" type="link" @click="downloadFile(formData.${subConfigList[i].fieldNameCamelCase})">下载文件</a-button>
|
||||
<span v-else>无</span>
|
||||
<% } else if (configList[i].effectType == 'editor') {%>
|
||||
<div v-html="formData.${configList[i].fieldNameCamelCase}"></div>
|
||||
<% } else if (subConfigList[i].effectType == 'editor') {%>
|
||||
<div v-html="formData.${subConfigList[i].fieldNameCamelCase}"></div>
|
||||
<% } else { %>
|
||||
{{ formData.${configList[i].fieldNameCamelCase} }}
|
||||
{{ formData.${subConfigList[i].fieldNameCamelCase} }}
|
||||
<% } %>
|
||||
</a-descriptions-item>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</a-descriptions>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
@@ -47,7 +44,7 @@
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
open.value = true
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ id: record.id }).then((data) => {
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ ${subDbTableKeyCamelCase}: record.${subDbTableKeyCamelCase} }).then((data) => {
|
||||
formData.value = data
|
||||
})
|
||||
}
|
||||
|
||||
+6
-5
@@ -165,6 +165,7 @@
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
:id-key="'${subDbTableKeyCamelCase}'"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatch${subClassName}"
|
||||
/>
|
||||
@@ -204,10 +205,10 @@
|
||||
<% } %>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="formRef.onOpen(record, selectedTreeKey)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Detail'], 'and')" />
|
||||
<a @click="detailRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Detail')">详情</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Edit'], 'and')" />
|
||||
<a @click="formRef.onOpen(record, selectedTreeKey)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-popconfirm title="确定要删除吗?" @confirm="delete${subClassName}(record)">
|
||||
<a-button type="link" danger size="small" v-if="hasPerm('${classNameFirstLower}Delete')">删除</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -393,7 +394,7 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
]
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'])) {
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete', '${classNameFirstLower}Detail'])) {
|
||||
columns.push({
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
@@ -529,7 +530,7 @@
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
const params = selectedRowKeys.value.map((m) => {
|
||||
return {
|
||||
id: m
|
||||
${subDbTableKeyCamelCase}: m
|
||||
}
|
||||
})
|
||||
${classNameFirstLower}Api.${subClassNameFirstLower}Export(params).then((res) => {
|
||||
|
||||
+2
-5
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
title="详情${functionName}"
|
||||
title="详情"
|
||||
:width="700"
|
||||
v-model:open="open"
|
||||
:destroy-on-close="true"
|
||||
@@ -29,9 +29,6 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
</a-descriptions>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
@@ -47,7 +44,7 @@
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
open.value = true
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ id: record.id }).then((data) => {
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ ${dbTableKeyCamelCase}: record.${dbTableKeyCamelCase} }).then((data) => {
|
||||
formData.value = data
|
||||
})
|
||||
}
|
||||
|
||||
+35
-12
@@ -97,7 +97,7 @@
|
||||
:row-selection="options.rowSelection"
|
||||
:scroll="{ x: 'max-content' }"
|
||||
:expandedRowKeys="expandedRowKeys"
|
||||
@expand="onExpand"
|
||||
@onExpand="onExpand"
|
||||
>
|
||||
<template #operator>
|
||||
<a-space>
|
||||
@@ -118,6 +118,7 @@
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
:id-key="'${dbTableKeyCamelCase}'"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatch${className}"
|
||||
/>
|
||||
@@ -157,10 +158,10 @@
|
||||
<% } %>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Detail'], 'and')" />
|
||||
<a @click="detailRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Detail')">详情</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Edit'], 'and')" />
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-popconfirm title="确定要删除吗?" @confirm="delete${className}(record)">
|
||||
<a-button type="link" danger size="small" v-if="hasPerm('${classNameFirstLower}Delete')">删除</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -184,6 +185,16 @@
|
||||
<template #icon><export-outlined /></template>
|
||||
导出
|
||||
</a-button>
|
||||
<xn-batch-button
|
||||
v-if="hasPerm('${classNameFirstLower}SubDelete')"
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
size="small"
|
||||
:id-key="'${subDbTableKeyCamelCase}'"
|
||||
:selectedRowKeys="subSelectedRowKeysMap[record.${dbTableKeyCamelCase}] || []"
|
||||
@batchCallBack="(params) => deleteSubBatch${subClassName}(params, record.${dbTableKeyCamelCase})"
|
||||
/>
|
||||
</a-space>
|
||||
</div>
|
||||
<a-table
|
||||
@@ -191,6 +202,7 @@
|
||||
:data-source="subDataMap[record.${dbTableKeyCamelCase}] || []"
|
||||
:loading="subLoadingMap[record.${dbTableKeyCamelCase}]"
|
||||
:row-key="(subRecord) => subRecord.${subDbTableKeyCamelCase}"
|
||||
:row-selection="{ selectedRowKeys: subSelectedRowKeysMap[record.${dbTableKeyCamelCase}] || [], onChange: (keys) => onSubSelectChange(keys, record.${dbTableKeyCamelCase}) }"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
bordered
|
||||
@@ -225,10 +237,10 @@
|
||||
<% } %>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="subFormRef.onOpen(subRecord, record.${dbTableKeyCamelCase})" v-if="hasPerm('${classNameFirstLower}SubEdit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}SubEdit', '${classNameFirstLower}SubDetail'], 'and')" />
|
||||
<a @click="subDetailRef.onOpen(subRecord)" v-if="hasPerm('${classNameFirstLower}SubDetail')">详情</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}SubDetail', '${classNameFirstLower}SubDelete'], 'and')" />
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}SubDetail', '${classNameFirstLower}SubEdit'], 'and')" />
|
||||
<a @click="subFormRef.onOpen(subRecord, record.${dbTableKeyCamelCase})" v-if="hasPerm('${classNameFirstLower}SubEdit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}SubEdit', '${classNameFirstLower}SubDelete'], 'and')" />
|
||||
<a-popconfirm title="确定要删除吗?" @confirm="deleteSub${subClassName}(subRecord, record.${dbTableKeyCamelCase})">
|
||||
<a-button type="link" danger size="small" v-if="hasPerm('${classNameFirstLower}SubDelete')">删除</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -311,7 +323,7 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
]
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'])) {
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete', '${classNameFirstLower}Detail'])) {
|
||||
columns.push({
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
@@ -333,12 +345,11 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
]
|
||||
if (hasPerm(['${classNameFirstLower}SubEdit', '${classNameFirstLower}SubDelete'])) {
|
||||
if (hasPerm(['${classNameFirstLower}SubEdit', '${classNameFirstLower}SubDelete', '${classNameFirstLower}SubDetail'])) {
|
||||
subColumns.push({
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
align: 'center',
|
||||
width: 150
|
||||
align: 'center'
|
||||
})
|
||||
}
|
||||
const selectedRowKeys = ref([])
|
||||
@@ -518,7 +529,7 @@
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
const params = selectedRowKeys.value.map((m) => {
|
||||
return {
|
||||
id: m
|
||||
${dbTableKeyCamelCase}: m
|
||||
}
|
||||
})
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Export(params).then((res) => {
|
||||
@@ -533,6 +544,7 @@
|
||||
// 子表数据管理
|
||||
const subDataMap = ref({})
|
||||
const subLoadingMap = ref({})
|
||||
const subSelectedRowKeysMap = ref({})
|
||||
const expandedRowKeys = ref([])
|
||||
// 展开行时加载子表数据
|
||||
const onExpand = (expanded, record) => {
|
||||
@@ -543,6 +555,10 @@
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter(key => key !== record.${dbTableKeyCamelCase})
|
||||
}
|
||||
}
|
||||
// 子表选择项变更
|
||||
const onSubSelectChange = (keys, masterKey) => {
|
||||
subSelectedRowKeysMap.value[masterKey] = keys
|
||||
}
|
||||
// 加载子表数据
|
||||
const loadSubData = (masterKey) => {
|
||||
subLoadingMap.value[masterKey] = true
|
||||
@@ -566,6 +582,13 @@
|
||||
loadSubData(masterKey)
|
||||
})
|
||||
}
|
||||
// 批量删除子表记录
|
||||
const deleteSubBatch${subClassName} = (params, masterKey) => {
|
||||
${classNameFirstLower}Api.${subClassNameFirstLower}Delete(params).then(() => {
|
||||
subSelectedRowKeysMap.value[masterKey] = []
|
||||
loadSubData(masterKey)
|
||||
})
|
||||
}
|
||||
// 子表表单提交成功后的回调
|
||||
const lastSubFormMasterKey = ref('')
|
||||
const onSubFormSuccess = () => {
|
||||
|
||||
+1
-4
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
title="详情${subFunctionName}"
|
||||
title="详情"
|
||||
:width="700"
|
||||
v-model:open="open"
|
||||
:destroy-on-close="true"
|
||||
@@ -29,9 +29,6 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
</a-descriptions>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
title="详情${functionName}"
|
||||
title="详情"
|
||||
:width="700"
|
||||
v-model:open="open"
|
||||
:destroy-on-close="true"
|
||||
@@ -29,9 +29,6 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
</a-descriptions>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
@@ -47,7 +44,7 @@
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
open.value = true
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ id: record.id }).then((data) => {
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ ${dbTableKeyCamelCase}: record.${dbTableKeyCamelCase} }).then((data) => {
|
||||
formData.value = data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
:id-key="'${dbTableKeyCamelCase}'"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatch${className}"
|
||||
/>
|
||||
@@ -155,10 +156,10 @@
|
||||
<% } %>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Detail'], 'and')" />
|
||||
<a @click="detailRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Detail')">详情</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Edit'], 'and')" />
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-popconfirm title="确定要删除吗?" @confirm="delete${className}(record)">
|
||||
<a-button type="link" danger size="small" v-if="hasPerm('${classNameFirstLower}Delete')">删除</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -230,7 +231,7 @@
|
||||
<% } %>
|
||||
]
|
||||
// 操作栏通过权限判断是否显示
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'])) {
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete', '${classNameFirstLower}Detail'])) {
|
||||
columns.push({
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
@@ -358,7 +359,7 @@
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
const params = selectedRowKeys.value.map((m) => {
|
||||
return {
|
||||
id: m
|
||||
${dbTableKeyCamelCase}: m
|
||||
}
|
||||
})
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Export(params).then((res) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<xn-form-container
|
||||
title="详情${functionName}"
|
||||
title="详情"
|
||||
:width="700"
|
||||
v-model:open="open"
|
||||
:destroy-on-close="true"
|
||||
@@ -29,9 +29,6 @@
|
||||
<% } %>
|
||||
<% } %>
|
||||
</a-descriptions>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||
</template>
|
||||
</xn-form-container>
|
||||
</template>
|
||||
|
||||
@@ -47,7 +44,7 @@
|
||||
// 打开抽屉
|
||||
const onOpen = (record) => {
|
||||
open.value = true
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ id: record.id }).then((data) => {
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Detail({ ${dbTableKeyCamelCase}: record.${dbTableKeyCamelCase} }).then((data) => {
|
||||
formData.value = data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -141,13 +141,14 @@
|
||||
<span>导出</span>
|
||||
</a-button>
|
||||
<xn-batch-button
|
||||
v-if="hasPerm('${classNameFirstLower}BatchDelete')"
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatch${className}"
|
||||
/>
|
||||
v-if="hasPerm('${classNameFirstLower}BatchDelete')"
|
||||
buttonName="批量删除"
|
||||
icon="DeleteOutlined"
|
||||
buttonDanger
|
||||
:id-key="'${dbTableKeyCamelCase}'"
|
||||
:selectedRowKeys="selectedRowKeys"
|
||||
@batchCallBack="deleteBatch${className}"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
@@ -184,10 +185,10 @@
|
||||
<% } %>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space>
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Detail'], 'and')" />
|
||||
<a @click="detailRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Detail')">详情</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Detail', '${classNameFirstLower}Edit'], 'and')" />
|
||||
<a @click="formRef.onOpen(record)" v-if="hasPerm('${classNameFirstLower}Edit')">编辑</a>
|
||||
<a-divider type="vertical" v-if="hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'], 'and')" />
|
||||
<a-popconfirm title="确定要删除吗?" @confirm="delete${className}(record)">
|
||||
<a-button type="link" danger size="small" v-if="hasPerm('${classNameFirstLower}Delete')">删除</a-button>
|
||||
</a-popconfirm>
|
||||
@@ -264,7 +265,7 @@
|
||||
<% } %>
|
||||
]
|
||||
// 操作栏通过权限判断是否显示
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete'])) {
|
||||
if (hasPerm(['${classNameFirstLower}Edit', '${classNameFirstLower}Delete', '${classNameFirstLower}Detail'])) {
|
||||
columns.push({
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
@@ -541,7 +542,7 @@
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
const params = selectedRowKeys.value.map((m) => {
|
||||
return {
|
||||
id: m
|
||||
${dbTableKeyCamelCase}: m
|
||||
}
|
||||
})
|
||||
${classNameFirstLower}Api.${classNameFirstLower}Export(params).then((res) => {
|
||||
|
||||
@@ -38,11 +38,9 @@ INSERT INTO `SYS_RESOURCE` VALUES ('${deleteButtonId}', '${menuId}', '删除${fu
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${detailButtonId}', '${menuId}', '详情${functionName}', NULL, '${classNameFirstLower}Detail', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 5, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${batchDeleteButtonId}', '${menuId}', '批量删除${functionName}', NULL, '${classNameFirstLower}BatchDelete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 6, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${importButtonId}', '${menuId}', '导入${functionName}', NULL, '${classNameFirstLower}Import', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 6, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${importButtonId}', '${menuId}', '导入${functionName}', NULL, '${classNameFirstLower}Import', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${exportButtonId}', '${menuId}', '导出${functionName}', NULL, '${classNameFirstLower}Export', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 8, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${exportButtonId}', '${menuId}', '导出${functionName}', NULL, '${classNameFirstLower}Export', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subAddButtonId}', '${menuId}', '新增${subFunctionName}', NULL, '${classNameFirstLower}SubAdd', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 8, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
@@ -52,9 +50,11 @@ INSERT INTO `SYS_RESOURCE` VALUES ('${subDeleteButtonId}', '${menuId}', '删除$
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subDetailButtonId}', '${menuId}', '详情${subFunctionName}', NULL, '${classNameFirstLower}SubDetail', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 11, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subImportButtonId}', '${menuId}', '导入${subFunctionName}', NULL, '${classNameFirstLower}SubImport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 12, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subBatchDeleteButtonId}', '${menuId}', '批量删除${subFunctionName}', NULL, '${classNameFirstLower}SubBatchDelete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 12, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subExportButtonId}', '${menuId}', '导出${subFunctionName}', NULL, '${classNameFirstLower}SubExport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 13, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subImportButtonId}', '${menuId}', '导入${subFunctionName}', NULL, '${classNameFirstLower}SubImport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 13, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${subExportButtonId}', '${menuId}', '导出${subFunctionName}', NULL, '${classNameFirstLower}SubExport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 14, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
<% } else { %>
|
||||
INSERT INTO `SYS_RESOURCE` VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', NULL, '${classNameFirstLower}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
@@ -38,11 +38,9 @@ INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${deleteButtonId}', '${menuId}', '
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${detailButtonId}', '${menuId}', '详情${functionName}', NULL, '${classNameFirstLower}Detail', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '5', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${batchDeleteButtonId}', '${menuId}', '批量删除${functionName}', NULL, '${classNameFirstLower}BatchDelete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '6', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${importButtonId}', '${menuId}', '导入${functionName}', NULL, '${classNameFirstLower}Import', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '6', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${importButtonId}', '${menuId}', '导入${functionName}', NULL, '${classNameFirstLower}Import', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '7', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${exportButtonId}', '${menuId}', '导出${functionName}', NULL, '${classNameFirstLower}Export', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '8', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${exportButtonId}', '${menuId}', '导出${functionName}', NULL, '${classNameFirstLower}Export', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '7', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subAddButtonId}', '${menuId}', '新增${subFunctionName}', NULL, '${classNameFirstLower}SubAdd', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '8', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
@@ -52,9 +50,11 @@ INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subDeleteButtonId}', '${menuId}',
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subDetailButtonId}', '${menuId}', '详情${subFunctionName}', NULL, '${classNameFirstLower}SubDetail', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '11', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subImportButtonId}', '${menuId}', '导入${subFunctionName}', NULL, '${classNameFirstLower}SubImport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '12', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subBatchDeleteButtonId}', '${menuId}', '批量删除${subFunctionName}', NULL, '${classNameFirstLower}SubBatchDelete', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '12', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subExportButtonId}', '${menuId}', '导出${subFunctionName}', NULL, '${classNameFirstLower}SubExport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '13', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subImportButtonId}', '${menuId}', '导入${subFunctionName}', NULL, '${classNameFirstLower}SubImport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '13', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${subExportButtonId}', '${menuId}', '导出${subFunctionName}', NULL, '${classNameFirstLower}SubExport', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '14', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
<% } else { %>
|
||||
INSERT INTO "SNOWY"."SYS_RESOURCE" VALUES ('${addButtonId}', '${menuId}', '新增${functionName}', NULL, '${classNameFirstLower}Add', 'BUTTON', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
+3
-2
@@ -145,8 +145,9 @@ public class SysButtonServiceImpl extends ServiceImpl<SysButtonMapper, SysButton
|
||||
JSONUtil.createObj().set("title", "编辑" + subFunctionName).set("code", classNameFirstLower + "SubEdit").set("sortCode", 9),
|
||||
JSONUtil.createObj().set("title", "删除" + subFunctionName).set("code", classNameFirstLower + "SubDelete").set("sortCode", 10),
|
||||
JSONUtil.createObj().set("title", "详情" + subFunctionName).set("code", classNameFirstLower + "SubDetail").set("sortCode", 11),
|
||||
JSONUtil.createObj().set("title", "导入" + subFunctionName).set("code", classNameFirstLower + "SubImport").set("sortCode", 12),
|
||||
JSONUtil.createObj().set("title", "导出" + subFunctionName).set("code", classNameFirstLower + "SubExport").set("sortCode", 13));
|
||||
JSONUtil.createObj().set("title", "批量删除" + subFunctionName).set("code", classNameFirstLower + "SubBatchDelete").set("sortCode", 12),
|
||||
JSONUtil.createObj().set("title", "导入" + subFunctionName).set("code", classNameFirstLower + "SubImport").set("sortCode", 13),
|
||||
JSONUtil.createObj().set("title", "导出" + subFunctionName).set("code", classNameFirstLower + "SubExport").set("sortCode", 14));
|
||||
} else {
|
||||
buttonList = CollectionUtil.newArrayList(
|
||||
JSONUtil.createObj().set("title", "新增" + functionName).set("code", classNameFirstLower + "Add").set("sortCode", 1),
|
||||
|
||||
+43
@@ -33,6 +33,7 @@ import vip.xiaonuo.sys.modular.resource.enums.SysResourceCategoryEnum;
|
||||
import vip.xiaonuo.sys.modular.resource.service.SysButtonService;
|
||||
import vip.xiaonuo.sys.modular.resource.service.SysMenuService;
|
||||
import vip.xiaonuo.sys.modular.role.entity.SysRole;
|
||||
import vip.xiaonuo.sys.modular.role.param.SysRoleGrantPermissionParam;
|
||||
import vip.xiaonuo.sys.modular.role.param.SysRoleGrantResourceParam;
|
||||
import vip.xiaonuo.sys.modular.role.param.SysRoleSelectorRoleParam;
|
||||
import vip.xiaonuo.sys.modular.role.service.SysRoleService;
|
||||
@@ -108,6 +109,48 @@ public class SysRoleApiProvider implements SysRoleApi {
|
||||
sysRelationService.saveRelationBatchWithAppend(superAdminRoleId, menuIdList, SysRelationCategoryEnum.SYS_ROLE_HAS_RESOURCE.getValue(), extJsonList);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void grantForGenPermission(String moduleName, String busName, String genType) {
|
||||
String superAdminRoleId = sysRoleService.getOne(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getCode, SysBuildInEnum.BUILD_IN_ROLE_CODE.getValue())).getId();
|
||||
List<String> apiUrls = CollectionUtil.newArrayList(
|
||||
"/" + moduleName + "/" + busName + "/page",
|
||||
"/" + moduleName + "/" + busName + "/add",
|
||||
"/" + moduleName + "/" + busName + "/edit",
|
||||
"/" + moduleName + "/" + busName + "/delete",
|
||||
"/" + moduleName + "/" + busName + "/detail",
|
||||
"/" + moduleName + "/" + busName + "/downloadImportTemplate",
|
||||
"/" + moduleName + "/" + busName + "/importData",
|
||||
"/" + moduleName + "/" + busName + "/exportData"
|
||||
);
|
||||
if("TREE".equals(genType) || "LEFT_TREE_TABLE".equals(genType)) {
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/tree");
|
||||
}
|
||||
if("MASTER_DETAIL".equals(genType) || "LEFT_TREE_TABLE".equals(genType)) {
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/page");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/add");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/edit");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/delete");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/detail");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/downloadImportTemplate");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/importData");
|
||||
apiUrls.add("/" + moduleName + "/" + busName + "/sub/exportData");
|
||||
}
|
||||
List<SysRoleGrantPermissionParam.SysRoleGrantPermission> grantInfoList = apiUrls.stream().map(apiUrl -> {
|
||||
SysRoleGrantPermissionParam.SysRoleGrantPermission sysRoleGrantPermission = new SysRoleGrantPermissionParam.SysRoleGrantPermission();
|
||||
sysRoleGrantPermission.setApiUrl(apiUrl);
|
||||
sysRoleGrantPermission.setScopeCategory("ALL");
|
||||
sysRoleGrantPermission.setScopeDefineOrgIdList(CollectionUtil.newArrayList());
|
||||
return sysRoleGrantPermission;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
SysRoleGrantPermissionParam sysRoleGrantPermissionParam = new SysRoleGrantPermissionParam();
|
||||
sysRoleGrantPermissionParam.setId(superAdminRoleId);
|
||||
sysRoleGrantPermissionParam.setGrantInfoList(grantInfoList);
|
||||
sysRoleService.grantPermissionWithAppend(sysRoleGrantPermissionParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> resourceTreeSelector() {
|
||||
return sysRoleService.resourceTreeSelector(false).stream().map(JSONUtil::parseObj).collect(Collectors.toList());
|
||||
|
||||
+8
@@ -128,6 +128,14 @@ public interface SysRoleService extends IService<SysRole> {
|
||||
**/
|
||||
void grantPermission(SysRoleGrantPermissionParam sysRoleGrantPermissionParam);
|
||||
|
||||
/**
|
||||
* 给角色授权权限(追加方式)
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/29 10:12
|
||||
**/
|
||||
void grantPermissionWithAppend(SysRoleGrantPermissionParam sysRoleGrantPermissionParam);
|
||||
|
||||
/**
|
||||
* 获取角色下的用户
|
||||
*
|
||||
|
||||
+16
-1
@@ -310,12 +310,27 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
|
||||
@Override
|
||||
public void grantPermission(SysRoleGrantPermissionParam sysRoleGrantPermissionParam) {
|
||||
this.grantPermission(sysRoleGrantPermissionParam, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grantPermissionWithAppend(SysRoleGrantPermissionParam sysRoleGrantPermissionParam) {
|
||||
this.grantPermission(sysRoleGrantPermissionParam, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给角色授权权限
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2022/4/29 10:12
|
||||
**/
|
||||
public void grantPermission(SysRoleGrantPermissionParam sysRoleGrantPermissionParam, boolean clear) {
|
||||
String id = sysRoleGrantPermissionParam.getId();
|
||||
List<String> apiUrlList = sysRoleGrantPermissionParam.getGrantInfoList().stream()
|
||||
.map(SysRoleGrantPermissionParam.SysRoleGrantPermission::getApiUrl).collect(Collectors.toList());
|
||||
List<String> extJsonList = sysRoleGrantPermissionParam.getGrantInfoList().stream()
|
||||
.map(JSONUtil::toJsonStr).collect(Collectors.toList());
|
||||
sysRelationService.saveRelationBatchWithClear(id, apiUrlList, SysRelationCategoryEnum.SYS_ROLE_HAS_PERMISSION.getValue(),
|
||||
sysRelationService.saveRelationBatchWithAppend(id, apiUrlList, SysRelationCategoryEnum.SYS_ROLE_HAS_PERMISSION.getValue(),
|
||||
extJsonList);
|
||||
// 刷新拥有该角色的所有在线用户的权限缓存
|
||||
List<String> userIdList = sysRelationService.getRelationObjectIdListByTargetIdAndCategory(
|
||||
|
||||
Reference in New Issue
Block a user