forked from dyf/fys-Multi-tenant
不同的一级目录下的分组应当可以重名
This commit is contained in:
@ -31,7 +31,7 @@ public class DeviceGroupBo extends BaseEntity {
|
|||||||
* 分组名称
|
* 分组名称
|
||||||
*/
|
*/
|
||||||
@Schema(title = "分组名称")
|
@Schema(title = "分组名称")
|
||||||
@NotBlank(message = "分组名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "分组名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,6 +43,7 @@ public class DeviceGroupBo extends BaseEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 父分组ID
|
* 父分组ID
|
||||||
|
* parent_id
|
||||||
*/
|
*/
|
||||||
@Schema(title = "父分组ID")
|
@Schema(title = "父分组ID")
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|||||||
@ -120,7 +120,14 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
|||||||
public Boolean insertByBo(DeviceGroupBo bo) {
|
public Boolean insertByBo(DeviceGroupBo bo) {
|
||||||
|
|
||||||
// 验证分组名称唯一性
|
// 验证分组名称唯一性
|
||||||
DeviceGroup deviceGroup = baseMapper.selectOne(new QueryWrapper<DeviceGroup>().eq("group_name", bo.getGroupName()));
|
QueryWrapper<DeviceGroup> queryWrapper = new QueryWrapper<DeviceGroup>().eq("group_name", bo.getGroupName());
|
||||||
|
if (bo.getParentId() != null) {
|
||||||
|
queryWrapper.eq("parent_id", bo.getParentId());
|
||||||
|
} else {
|
||||||
|
queryWrapper.isNull("parent_id");
|
||||||
|
}
|
||||||
|
DeviceGroup deviceGroup = baseMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
if (deviceGroup != null) {
|
if (deviceGroup != null) {
|
||||||
throw new RuntimeException("分组名称已存在,请勿重复添加!!!");
|
throw new RuntimeException("分组名称已存在,请勿重复添加!!!");
|
||||||
}
|
}
|
||||||
@ -159,9 +166,23 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
|||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
private void validEntityBeforeSave(DeviceGroup entity) {
|
private void validEntityBeforeSave(DeviceGroup bo) {
|
||||||
// TODO 做一些数据校验,如唯一约束
|
// TODO 做一些数据校验,如唯一约束
|
||||||
|
// 验证分组名称唯一性
|
||||||
|
QueryWrapper<DeviceGroup> queryWrapper = new QueryWrapper<DeviceGroup>().eq("group_name", bo.getGroupName());
|
||||||
|
if (bo.getParentId() != null) {
|
||||||
|
queryWrapper.eq("parent_id", bo.getParentId());
|
||||||
|
} else {
|
||||||
|
queryWrapper.isNull("parent_id");
|
||||||
}
|
}
|
||||||
|
DeviceGroup deviceGroup = baseMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (deviceGroup != null && deviceGroup.getId() != bo.getId()) {
|
||||||
|
throw new RuntimeException("分组名称已存在,请勿重复添加!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除设备分组信息
|
* 校验并批量删除设备分组信息
|
||||||
@ -210,7 +231,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
|||||||
* @return 是否解绑成功
|
* @return 是否解绑成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean groupUnbind( Long[] deviceId) {
|
public Boolean groupUnbind(Long[] deviceId) {
|
||||||
|
|
||||||
if (deviceId != null && deviceId.length > 0) {
|
if (deviceId != null && deviceId.length > 0) {
|
||||||
// 创建更新条件
|
// 创建更新条件
|
||||||
|
|||||||
@ -125,10 +125,10 @@
|
|||||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceMac != null">
|
<if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
|
||||||
and d.device_mac = #{criteria.deviceMac}
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceImei != null">
|
<if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
|
||||||
and d.device_imei = #{criteria.deviceImei}
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceType != null">
|
<if test="criteria.deviceType != null">
|
||||||
|
|||||||
Reference in New Issue
Block a user