forked from dyf/fys-Multi-tenant
新增设备分组
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -37,7 +39,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
* @return 设备分组
|
||||
*/
|
||||
@Override
|
||||
public DeviceGroupVo queryById(Long id){
|
||||
public DeviceGroupVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增设备分组
|
||||
*
|
||||
@ -74,8 +77,21 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(DeviceGroupBo bo) {
|
||||
|
||||
// 验证分组名称唯一性
|
||||
DeviceGroup deviceGroup = baseMapper.selectOne(new QueryWrapper<DeviceGroup>().eq("group_name", bo.getGroupName()));
|
||||
if (deviceGroup != null) {
|
||||
throw new RuntimeException("分组名称已存在,请勿重复添加");
|
||||
}
|
||||
|
||||
// 验证父分组是否存在(如果提供了parentId)
|
||||
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
|
||||
if (bo.getParentId() != null && pDeviceGroup == null) {
|
||||
throw new RuntimeException("父分组不存在");
|
||||
}
|
||||
|
||||
DeviceGroup add = MapstructUtils.convert(bo, DeviceGroup.class);
|
||||
validEntityBeforeSave(add);
|
||||
// validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
@ -83,6 +99,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备分组
|
||||
*
|
||||
@ -99,8 +116,8 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(DeviceGroup entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
private void validEntityBeforeSave(DeviceGroup entity) {
|
||||
// TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,8 +129,8 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.equipment.domain.bo.DeviceRepairRecordsBo;
|
||||
import com.fuyuanshen.equipment.domain.vo.DeviceRepairRecordsVo;
|
||||
|
||||
Reference in New Issue
Block a user