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.SgOtherBo;
|
import com.ruoyi.oa.domain.vo.SgOtherVo;
|
import com.ruoyi.oa.domain.SgOther;
|
import com.ruoyi.oa.mapper.SgOtherMapper;
|
import com.ruoyi.oa.service.ISgOtherService;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Collection;
|
|
/**
|
* 施工交付-其他Service业务层处理
|
*
|
* @author ruoyi
|
* @date 2022-10-10
|
*/
|
@Service
|
public class SgOtherServiceImpl extends ServicePlusImpl<SgOtherMapper, SgOther, SgOtherVo> implements ISgOtherService {
|
|
@Override
|
public SgOtherVo queryById(Long id){
|
return getVoById(id);
|
}
|
|
@Override
|
public TableDataInfo<SgOtherVo> queryPageList(SgOtherBo bo) {
|
PagePlus<SgOther, SgOtherVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo));
|
return PageUtils.buildDataInfo(result);
|
}
|
|
@Override
|
public List<SgOtherVo> queryList(SgOtherBo bo) {
|
return listVo(buildQueryWrapper(bo));
|
}
|
|
private LambdaQueryWrapper<SgOther> buildQueryWrapper(SgOtherBo bo) {
|
Map<String, Object> params = bo.getParams();
|
LambdaQueryWrapper<SgOther> lqw = Wrappers.lambdaQuery();
|
lqw.like(StringUtils.isNotBlank(bo.getName()), SgOther::getName, bo.getName());
|
lqw.eq(bo.getBuildingId() != null, SgOther::getBuildingId, bo.getBuildingId());
|
lqw.eq(bo.getConstructionBatchId() != null, SgOther::getConstructionBatchId, bo.getConstructionBatchId());
|
lqw.eq(bo.getManufacturerId() != null, SgOther::getManufacturerId, bo.getManufacturerId());
|
lqw.eq(bo.getSchoolId() != null, SgOther::getSchoolId, bo.getSchoolId());
|
return lqw;
|
}
|
|
@Override
|
public Boolean insertByBo(SgOtherBo bo) {
|
SgOther add = BeanUtil.toBean(bo, SgOther.class);
|
validEntityBeforeSave(add);
|
boolean flag = save(add);
|
if (flag) {
|
bo.setId(add.getId());
|
}
|
return flag;
|
}
|
|
@Override
|
public Boolean updateByBo(SgOtherBo bo) {
|
SgOther update = BeanUtil.toBean(bo, SgOther.class);
|
validEntityBeforeSave(update);
|
return updateById(update);
|
}
|
|
/**
|
* 保存前的数据校验
|
*
|
* @param entity 实体类数据
|
*/
|
private void validEntityBeforeSave(SgOther entity){
|
//TODO 做一些数据校验,如唯一约束
|
}
|
|
@Override
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
if(isValid){
|
//TODO 做一些业务上的校验,判断是否需要校验
|
}
|
return removeByIds(ids);
|
}
|
}
|