字典判重复,用户排序显示
This commit is contained in:
@@ -40,4 +40,11 @@ public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, J
|
||||
* @return
|
||||
*/
|
||||
List<DictDetail> findByLabelAndDict_Id(String label, Long dict_id);
|
||||
|
||||
/**
|
||||
* 根据label查数据
|
||||
* @param label
|
||||
* @return
|
||||
*/
|
||||
List<DictDetail> findByLabel(String label);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
public void update(DictDetail resources) {
|
||||
DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
|
||||
ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
|
||||
List<DictDetail> label = dictDetailRepository.findByLabelAndDict_Id(resources.getLabel(), resources.getDict().getId());
|
||||
if (ObjectUtil.isNotEmpty(label)) throw new BadRequestException("字典[" + resources.getLabel() + "]已存在");
|
||||
resources.setId(dictDetail.getId());
|
||||
dictDetailRepository.save(resources);
|
||||
// 清理缓存
|
||||
|
||||
@@ -80,6 +80,8 @@ public class DictServiceImpl implements DictService {
|
||||
delCaches(resources);
|
||||
Dict dict = dictRepository.findById(resources.getId()).orElseGet(Dict::new);
|
||||
ValidationUtil.isNull( dict.getId(),"Dict","id",resources.getId());
|
||||
Dict dict1 = dictRepository.findByName(resources.getName());
|
||||
if (ObjectUtil.isNotEmpty(dict1)) throw new BadRequestException("字典[" + resources.getName() + "]已存在");
|
||||
dict.setName(resources.getName());
|
||||
dict.setDescription(resources.getDescription());
|
||||
dictRepository.save(dict);
|
||||
|
||||
@@ -285,7 +285,7 @@ export default {
|
||||
}).then(() => {
|
||||
crudDept.edit(data).then(res => {
|
||||
this.crud.notify(this.dict.label.dept_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
// this.crud.toQuery()
|
||||
this.crud.toQuery()
|
||||
}).catch(err => {
|
||||
data.enabled = !data.enabled
|
||||
console.log(err.response.data.message)
|
||||
|
||||
@@ -269,7 +269,7 @@ export default {
|
||||
return CRUD({
|
||||
title: '用户',
|
||||
url: 'api/users',
|
||||
sort: ['deptId', 'nickName', 'username'],
|
||||
sort: ['deptId', 'username'],
|
||||
crudMethod: { ...crudUser }
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user