字典修改
This commit is contained in:
@@ -19,8 +19,7 @@ public class DictDto implements Serializable {
|
|||||||
@JsonSerialize(using= ToStringSerializer.class)
|
@JsonSerialize(using= ToStringSerializer.class)
|
||||||
private Long dict_id;
|
private Long dict_id;
|
||||||
|
|
||||||
@JsonSerialize(using= ToStringSerializer.class)
|
private String dictCode; // 区分使用
|
||||||
private Long id; // 区分使用
|
|
||||||
|
|
||||||
/** 编码 */
|
/** 编码 */
|
||||||
private String code;
|
private String code;
|
||||||
|
|||||||
@@ -63,18 +63,37 @@ public class DictDetailServiceImpl implements DictDetailService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DictDto resources) {
|
public void create(DictDto resources) {
|
||||||
Long id = resources.getId();
|
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
||||||
DictDto dict = this.findById(id); // 字典
|
// 校验是否已经有标签
|
||||||
|
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.setDict_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||||
resources.setCode(dict.getCode());
|
resources.setCode(dictObj.getString("code"));
|
||||||
resources.setName(dict.getName());
|
resources.setName(dictObj.getString("name"));
|
||||||
resources.setCreate_id(SecurityUtils.getCurrentUserId());
|
resources.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||||
resources.setCreate_name(SecurityUtils.getCurrentNickName());
|
resources.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||||
resources.setCreate_time(DateUtil.now());
|
resources.setCreate_time(DateUtil.now());
|
||||||
resources.setUpdate_optid(SecurityUtils.getCurrentUserId());
|
resources.setUpdate_optid(SecurityUtils.getCurrentUserId());
|
||||||
resources.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
resources.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
||||||
resources.setUpdate_time(DateUtil.now());
|
resources.setUpdate_time(DateUtil.now());
|
||||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
|
||||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(resources));
|
JSONObject json = JSONObject.parseObject(JSON.toJSONString(resources));
|
||||||
wo.insert(json);
|
wo.insert(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ public class DictServiceImpl implements DictService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DictDto dto) {
|
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();
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
String nickName = SecurityUtils.getCurrentNickName();
|
||||||
String date = DateUtil.now();
|
String date = DateUtil.now();
|
||||||
@@ -87,7 +90,6 @@ public class DictServiceImpl implements DictService {
|
|||||||
dto.setUpdate_optname(nickName);
|
dto.setUpdate_optname(nickName);
|
||||||
dto.setUpdate_time(date);
|
dto.setUpdate_time(date);
|
||||||
dto.setCreate_time(date);
|
dto.setCreate_time(date);
|
||||||
WQLObject wo = WQLObject.getWQLObject("sys_dict");
|
|
||||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||||
wo.insert(json);
|
wo.insert(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,16 +43,16 @@
|
|||||||
IF 输入.flag = "1"
|
IF 输入.flag = "1"
|
||||||
PAGEQUERY
|
PAGEQUERY
|
||||||
SELECT
|
SELECT
|
||||||
dict.*
|
code,
|
||||||
|
name
|
||||||
FROM
|
FROM
|
||||||
sys_dict dict
|
sys_dict dict
|
||||||
WHERE
|
WHERE
|
||||||
ISNULL(dict.label)
|
1 = 1
|
||||||
OR
|
|
||||||
dict.label = ""
|
|
||||||
OPTION 输入.blurry <> ""
|
OPTION 输入.blurry <> ""
|
||||||
(dict.code like "%" 输入.blurry "%" or dict.name like "%" 输入.blurry "%")
|
(dict.code like "%" 输入.blurry "%" or dict.name like "%" 输入.blurry "%")
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
|
GROUP BY code, name
|
||||||
ENDSELECT
|
ENDSELECT
|
||||||
ENDPAGEQUERY
|
ENDPAGEQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|||||||
@@ -126,11 +126,9 @@ export default {
|
|||||||
},
|
},
|
||||||
// 选中字典后,设置字典详情数据
|
// 选中字典后,设置字典详情数据
|
||||||
handleCurrentChange(val) {
|
handleCurrentChange(val) {
|
||||||
console.log(val)
|
|
||||||
if (val) {
|
if (val) {
|
||||||
this.$refs.dictDetail.query.code = val.code
|
this.$refs.dictDetail.query.code = val.code
|
||||||
this.$refs.dictDetail.form.id = val.dict_id
|
this.$refs.dictDetail.form.dictCode = val.code
|
||||||
this.$refs.dictDetail.dict_id = val.dict_id
|
|
||||||
this.$refs.dictDetail.crud.toQuery()
|
this.$refs.dictDetail.crud.toQuery()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user