package com.ruoyi.oa.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.PageUtils;
|
import com.ruoyi.common.core.page.PagePlus;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
import org.springframework.stereotype.Service;
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.ruoyi.oa.domain.bo.SgExchangeBo;
|
import com.ruoyi.oa.domain.vo.SgExchangeVo;
|
import com.ruoyi.oa.domain.SgExchange;
|
import com.ruoyi.oa.mapper.SgExchangeMapper;
|
import com.ruoyi.oa.service.ISgExchangeService;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Collection;
|
|
/**
|
* 交换设备Service业务层处理
|
*
|
* @author ruoyi
|
* @date 2022-05-13
|
*/
|
@Service
|
public class SgExchangeServiceImpl extends ServicePlusImpl<SgExchangeMapper, SgExchange, SgExchangeVo> implements ISgExchangeService {
|
|
@Override
|
public SgExchangeVo queryById(Long id){
|
return getVoById(id);
|
}
|
|
@Override
|
public TableDataInfo<SgExchangeVo> queryPageList(SgExchangeBo bo) {
|
PagePlus<SgExchange, SgExchangeVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo));
|
return PageUtils.buildDataInfo(result);
|
}
|
|
@Override
|
public List<SgExchangeVo> queryList(SgExchangeBo bo) {
|
return listVo(buildQueryWrapper(bo));
|
}
|
|
private LambdaQueryWrapper<SgExchange> buildQueryWrapper(SgExchangeBo bo) {
|
Map<String, Object> params = bo.getParams();
|
LambdaQueryWrapper<SgExchange> lqw = Wrappers.lambdaQuery();
|
lqw.eq(SgExchange::getSchoolId, bo.getSchoolId());
|
lqw.eq(StringUtils.isNotBlank(bo.getNetworkPort()), SgExchange::getNetworkPort, bo.getNetworkPort());
|
lqw.eq(StringUtils.isNotBlank(bo.getIdnexA()), SgExchange::getIdnexA, bo.getIdnexA());
|
lqw.eq(StringUtils.isNotBlank(bo.getCascadePort()), SgExchange::getCascadePort, bo.getCascadePort());
|
lqw.eq(StringUtils.isNotBlank(bo.getIndexB()), SgExchange::getIndexB, bo.getIndexB());
|
lqw.eq(bo.getBuildingId() != null, SgExchange::getBuildingId, bo.getBuildingId());
|
lqw.eq(bo.getOrganizationId() != null, SgExchange::getOrganizationId, bo.getOrganizationId());
|
lqw.eq(bo.getConstructionBatchId() != null, SgExchange::getConstructionBatchId, bo.getConstructionBatchId());
|
lqw.eq(bo.getManufacturerId() != null, SgExchange::getManufacturerId, bo.getManufacturerId());
|
lqw.like(bo.getModel() != null, SgExchange::getModel, bo.getModel());
|
lqw.orderByDesc(SgExchange::getUpdateTime);
|
return lqw;
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public Boolean insertByBo(SgExchangeBo bo) {
|
SgExchange add = BeanUtil.toBean(bo, SgExchange.class);
|
validEntityBeforeSave(add);
|
boolean flag = save(add);
|
if (flag) {
|
bo.setId(add.getId());
|
}
|
return flag;
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public Boolean updateByBo(SgExchangeBo bo) {
|
SgExchange update = BeanUtil.toBean(bo, SgExchange.class);
|
validEntityBeforeSave(update);
|
return updateById(update);
|
}
|
|
/**
|
* 保存前的数据校验
|
*
|
* @param entity 实体类数据
|
*/
|
private void validEntityBeforeSave(SgExchange entity){
|
//TODO 做一些数据校验,如唯一约束
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
if(isValid){
|
//TODO 做一些业务上的校验,判断是否需要校验
|
}
|
return removeByIds(ids);
|
}
|
}
|