refactor(系统设置): 模版名称校验优化

This commit is contained in:
wangjiahao 2024-03-25 23:54:37 +08:00
parent d2ae4bdb7e
commit 39589481d0
8 changed files with 67 additions and 13 deletions

View File

@ -25,6 +25,8 @@ public interface ExtVisualizationTemplateMapper{
Long checkCategoryTemplateName(@Param("templateName") String templateName,@Param("categories") List<String> categories);
Long checkCategoryTemplateBatchNames(@Param("templateNames") List<String> templateNames,@Param("categories") List<String> categories,@Param("templateArray") List<String> templateArray);
List<String> findTemplateCategories(@Param("templateId") String templateId);
List<String> findTemplateArrayCategories(@Param("templateArray") List<String> templateArray);

View File

@ -183,6 +183,16 @@ public class TemplateManageService implements TemplateManageApi {
}
}
@Override
public String checkCategoryTemplateBatchNames(TemplateManageRequest request) {
Long result = extTemplateMapper.checkCategoryTemplateBatchNames(request.getTemplateNames(),request.getCategories(),request.getTemplateArray());
if (result == 0) {
return CommonConstants.CHECK_RESULT.NONE;
} else {
return CommonConstants.CHECK_RESULT.EXIST_ALL;
}
}
//分类名称检查
public String categoryNameCheck(String optType, String name, String id) {
QueryWrapper<VisualizationTemplateCategory> wrapper = new QueryWrapper<>();

View File

@ -118,6 +118,27 @@
</foreach>
</select>
<select id="checkCategoryTemplateBatchNames" resultType="Long">
SELECT
count(1)
FROM
visualization_template vt
LEFT JOIN visualization_template_category_map vtcm ON vt.id = vtcm.template_id
WHERE
vt.NAME in
<foreach collection="templateNames" item="templateName" index="index" open="(" close=")" separator=",">
#{templateName}
</foreach>
AND vtcm.category_id IN
<foreach collection="categories" item="categoryId" index="index" open="(" close=")" separator=",">
#{categoryId}
</foreach>
and vt.id not in
<foreach collection="templateArray" item="templateId" index="index" open="(" close=")" separator=",">
#{templateId}
</foreach>
</select>
<delete id="deleteCategoryMapByTemplate">
delete from visualization_template_category_map tcm
<where>

View File

@ -62,6 +62,13 @@ export function categoryTemplateNameCheck(data) {
})
}
export function checkCategoryTemplateBatchNames(data) {
return request.post({
url: '/templateManage/categoryTemplateNameCheck',
data: data
})
}
export function batchDelete(data) {
return request.post({
url: '/templateManage/batchDelete',

View File

@ -122,6 +122,7 @@ const state = reactive({
},
recover: false,
templateInfo: {
id: null,
level: '1',
pid: props.pid,
categories: [],
@ -184,17 +185,22 @@ const saveTemplate = () => {
const editTemplate = () => {
const nameCheckRequest = {
pid: state.templateInfo.pid,
id: state.templateInfo.id,
name: state.templateInfo.name,
categories: state.templateInfo.categories,
optType: props.optType
}
//
nameCheck(nameCheckRequest).then(response => {
save(state.templateInfo).then(response => {
ElMessage.success(t('编辑成功'))
emits('refresh', getRefreshPInfo())
emits('closeEditTemplateDialog')
})
if (response.data.indexOf('exist') > -1) {
ElMessage.warning('当前名称已在模版管理中存在,请修改')
} else {
save(state.templateInfo).then(response => {
ElMessage.success(t('编辑成功'))
emits('refresh', getRefreshPInfo())
emits('closeEditTemplateDialog')
})
}
})
}
@ -238,11 +244,15 @@ const importTemplate = () => {
} else {
//
nameCheck(nameCheckRequest).then(response => {
save(state.templateInfo).then(response => {
ElMessage.success(t('导入成功'))
emits('refresh', getRefreshPInfo())
emits('closeEditTemplateDialog')
})
if (response.data.indexOf('exist') > -1) {
ElMessage.warning('当前名称已在模版管理中存在,请修改')
} else {
save(state.templateInfo).then(response => {
ElMessage.success(t('导入成功'))
emits('refresh', getRefreshPInfo())
emits('closeEditTemplateDialog')
})
}
})
}
})

View File

@ -199,8 +199,6 @@ import DeTemplateList from '@/views/template/component/DeTemplateList.vue'
const { t } = useI18n()
const templateEditFormRef = ref(null)
const templateListRef = ref(null)
import NoneTemplate from '@/assets/svg/dv-empty.svg'
import NoneImage from '@/assets/none.png'
import DeTemplateImport from '@/views/template/component/DeTemplateImport.vue'
import DeTemplateItem from '@/views/template/component/DeTemplateItem.vue'
import DeCategoryChange from '@/views/template/component/DeCategoryChange.vue'
@ -370,7 +368,7 @@ const handleClick = (tab, event) => {
const importRefresh = params => {
if (params.optType === 'refresh') {
templateListRef.value.nodeClick({ id: params.refreshPid, name: params.refreshPid })
templateListRef.value.nodeClick({ id: params.refreshPid, name: params.refreshPName })
} else {
showTemplateEditDialog('new', null)
}

View File

@ -53,6 +53,10 @@ public interface TemplateManageApi {
@Operation(summary = "分类名称校验")
String categoryTemplateNameCheck(@RequestBody TemplateManageRequest request);
@PostMapping("/checkCategoryTemplateBatchNames")
@Operation(summary = "分类名称批量校验")
String checkCategoryTemplateBatchNames(@RequestBody TemplateManageRequest request);
@PostMapping("/batchUpdate")
@Operation(summary = "批量更新")
void batchUpdate(@RequestBody TemplateManageBatchRequest request);

View File

@ -26,6 +26,8 @@ public class TemplateManageRequest extends VisualizationTemplateVO {
private String categoryId;
private List<String> categories;
private List<String> templateNames;
private List<String> templateArray;