mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-03-22 10:47:17 +08:00
update 客户端管理新增客户端key唯一校验逻辑
This commit is contained in:
@@ -76,6 +76,9 @@ public class SysClientController extends BaseController {
|
|||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysClientBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysClientBo bo) {
|
||||||
|
if (!sysClientService.checkClickKeyUnique(bo)) {
|
||||||
|
return R.fail("新增客户端'" + bo.getClientKey() + "'失败,客户端key已存在");
|
||||||
|
}
|
||||||
return toAjax(sysClientService.insertByBo(bo));
|
return toAjax(sysClientService.insertByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +90,9 @@ public class SysClientController extends BaseController {
|
|||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysClientBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysClientBo bo) {
|
||||||
|
if (!sysClientService.checkClickKeyUnique(bo)) {
|
||||||
|
return R.fail("修改客户端'" + bo.getClientKey() + "'失败,客户端key已存在");
|
||||||
|
}
|
||||||
return toAjax(sysClientService.updateByBo(bo));
|
return toAjax(sysClientService.updateByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,4 +55,12 @@ public interface ISysClientService {
|
|||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验客户端key是否唯一
|
||||||
|
*
|
||||||
|
* @param client 客户端信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
boolean checkClickKeyUnique(SysClientBo client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.dromara.system.service.impl;
|
package org.dromara.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@@ -135,4 +136,19 @@ public class SysClientServiceImpl implements ISysClientService {
|
|||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验客户端key是否唯一
|
||||||
|
*
|
||||||
|
* @param client 客户端信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean checkClickKeyUnique(SysClientBo client) {
|
||||||
|
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysClient>()
|
||||||
|
.eq(SysClient::getClientKey, client.getClientKey())
|
||||||
|
.ne(ObjectUtil.isNotNull(client.getId()), SysClient::getId, client.getId()));
|
||||||
|
return !exist;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user