🍒 fix(dict): 修复字典数据编码校验逻辑
This commit is contained in:
parent
9fe23a4c50
commit
b5b03b90ca
@ -326,9 +326,9 @@ public enum ErrorCodeEnum
|
||||
D3001,
|
||||
|
||||
/// <summary>
|
||||
/// 字典类型下面有字典值禁止删除
|
||||
/// 字典编码已存在
|
||||
/// </summary>
|
||||
[ErrorCodeItemMetadata("字典类型下面有字典值禁止删除")]
|
||||
[ErrorCodeItemMetadata("字典编码已存在")]
|
||||
D3002,
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -61,7 +61,10 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
[DisplayName("增加字典值")]
|
||||
public async Task AddDictData(AddDictDataInput input)
|
||||
{
|
||||
var isExist = await _sysDictDataRep.IsAnyAsync(u => u.Value == input.Value && u.DictTypeId == input.DictTypeId);
|
||||
var isExist = await _sysDictDataRep.IsAnyAsync(u => u.Code != null && u.Code == input.Code && u.DictTypeId == input.DictTypeId);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3002);
|
||||
|
||||
isExist = await _sysDictDataRep.IsAnyAsync(u => u.Value != null && u.Value == input.Value && u.DictTypeId == input.DictTypeId);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3003);
|
||||
|
||||
var dictType = await _sysDictDataRep.Change<SysDictType>().GetByIdAsync(input.DictTypeId);
|
||||
@ -86,7 +89,10 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
var isExist = await _sysDictDataRep.IsAnyAsync(u => u.Id == input.Id);
|
||||
if (!isExist) throw Oops.Oh(ErrorCodeEnum.D3004);
|
||||
|
||||
isExist = await _sysDictDataRep.IsAnyAsync(u => u.Value == input.Value && u.DictTypeId == input.DictTypeId && u.Id != input.Id);
|
||||
isExist = await _sysDictDataRep.IsAnyAsync(u => u.Code != null && u.Code == input.Code && u.DictTypeId == input.DictTypeId && u.Id != input.Id);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3002);
|
||||
|
||||
isExist = await _sysDictDataRep.IsAnyAsync(u => u.Value != null && u.Value == input.Value && u.DictTypeId == input.DictTypeId && u.Id != input.Id);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3003);
|
||||
|
||||
var dictType = await _sysDictDataRep.Change<SysDictType>().GetByIdAsync(input.DictTypeId);
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="8" :md="8" :lg="8" :xl="8" class="mb20">
|
||||
<el-form-item label="编码">
|
||||
<el-form-item label="编码" prop="code">
|
||||
<el-input v-model="state.ruleForm.code" placeholder="编码" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -57,10 +57,10 @@
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
<el-form-item label="拓展数据">
|
||||
<div style="display: flex; flex-direction: column; gap: 10px; width: 100%">
|
||||
<el-input v-model="state.ruleForm.extData" placeholder="请输入拓展数据" clearable type="textarea" :rows="12" style="width: 100%" />
|
||||
<div style="width: 100%">
|
||||
<el-button type="primary" @click="formatJSON" style="width: 100%">格式化JSON</el-button>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px; width: 100%;">
|
||||
<el-input v-model="state.ruleForm.extData" placeholder="请输入拓展数据" clearable type="textarea" :rows="12" style="width: 100%;" />
|
||||
<div style="width: 100%;">
|
||||
<el-button type="primary" @click="formatJSON" style="width: 100%;">格式化JSON</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
@ -156,4 +156,4 @@ const formatJSON = () => {
|
||||
|
||||
// 导出对象
|
||||
defineExpose({ openDialog });
|
||||
</script>
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user