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