字典修改

This commit is contained in:
2022-12-01 16:31:07 +08:00
parent e4bda3cc41
commit 2e1b5ce5ac
5 changed files with 33 additions and 15 deletions

View File

@@ -19,8 +19,7 @@ public class DictDto implements Serializable {
@JsonSerialize(using= ToStringSerializer.class)
private Long dict_id;
@JsonSerialize(using= ToStringSerializer.class)
private Long id; // 区分使用
private String dictCode; // 区分使用
/** 编码 */
private String code;

View File

@@ -63,18 +63,37 @@ public class DictDetailServiceImpl implements DictDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(DictDto resources) {
Long id = resources.getId();
DictDto dict = this.findById(id); // 字典
WQLObject wo = WQLObject.getWQLObject("sys_dict");
// 校验是否已经有标签
JSONObject object = wo.query("label = '" + resources.getLabel() + "' " +
"AND code = '" + resources.getDictCode() + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(object)) throw new BadRequestException("标签["+ resources.getLabel() + "]已存在");
JSONObject dictObj = wo.query("code = '" + resources.getDictCode() + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(dictObj.getString("label"))) {
// 空就赋值
dictObj.put("label", resources.getLabel());
dictObj.put("value", resources.getValue());
dictObj.put("dict_sort", resources.getDict_sort());
dictObj.put("dict_type", resources.getDict_type());
dictObj.put("para1", resources.getPara1());
dictObj.put("para2", resources.getPara2());
dictObj.put("para3", resources.getPara3());
dictObj.put("update_optid", SecurityUtils.getCurrentUserId());
dictObj.put("update_optname", SecurityUtils.getCurrentNickName());
dictObj.put("update_time", DateUtil.now());
wo.update(dictObj);
return;
}
// 插入新的数据
resources.setDict_id(IdUtil.getSnowflake(1, 1).nextId());
resources.setCode(dict.getCode());
resources.setName(dict.getName());
resources.setCode(dictObj.getString("code"));
resources.setName(dictObj.getString("name"));
resources.setCreate_id(SecurityUtils.getCurrentUserId());
resources.setCreate_name(SecurityUtils.getCurrentNickName());
resources.setCreate_time(DateUtil.now());
resources.setUpdate_optid(SecurityUtils.getCurrentUserId());
resources.setUpdate_optname(SecurityUtils.getCurrentNickName());
resources.setUpdate_time(DateUtil.now());
WQLObject wo = WQLObject.getWQLObject("sys_dict");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(resources));
wo.insert(json);
}

View File

@@ -77,6 +77,9 @@ public class DictServiceImpl implements DictService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(DictDto dto) {
WQLObject wo = WQLObject.getWQLObject("sys_dict");
JSONObject object = wo.query("code = '" + dto.getCode() + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(object)) throw new BadRequestException("字典[" + dto.getCode() + "]已存在");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String date = DateUtil.now();
@@ -87,7 +90,6 @@ public class DictServiceImpl implements DictService {
dto.setUpdate_optname(nickName);
dto.setUpdate_time(date);
dto.setCreate_time(date);
WQLObject wo = WQLObject.getWQLObject("sys_dict");
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.insert(json);
}

View File

@@ -43,16 +43,16 @@
IF 输入.flag = "1"
PAGEQUERY
SELECT
dict.*
code,
name
FROM
sys_dict dict
WHERE
ISNULL(dict.label)
OR
dict.label = ""
1 = 1
OPTION 输入.blurry <> ""
(dict.code like "%" 输入.blurry "%" or dict.name like "%" 输入.blurry "%")
ENDOPTION
GROUP BY code, name
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -126,11 +126,9 @@ export default {
},
// 选中字典后,设置字典详情数据
handleCurrentChange(val) {
console.log(val)
if (val) {
this.$refs.dictDetail.query.code = val.code
this.$refs.dictDetail.form.id = val.dict_id
this.$refs.dictDetail.dict_id = val.dict_id
this.$refs.dictDetail.form.dictCode = val.code
this.$refs.dictDetail.crud.toQuery()
}
}