郑永安
2023-06-19 f65443d8abeaedc9d102324565e8368e7c9d90c8
src/main/java/com/gk/firework/Service/ServiceImpl/TransportCarrierServiceImpl.java
对比新文件
@@ -0,0 +1,112 @@
package com.gk.firework.Service.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.firework.Domain.Exception.BusinessException;
import com.gk.firework.Domain.TransportCarrier;
import com.gk.firework.Domain.UserInfo;
import com.gk.firework.Domain.Utils.FilterObject;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Mapper.TransportCarrierMapper;
import com.gk.firework.Service.TransportCarrierService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map;
@Service("transportCarrierService")
public class TransportCarrierServiceImpl extends ServiceImpl<TransportCarrierMapper, TransportCarrier> implements TransportCarrierService {
    /**
    * @Description: 分页查询承运人
    * @date 2021/3/30 10:05
    */
    @Override
    public IPage selectPage(Page<TransportCarrier> page, Map filter) {
        //负责人
        String name = (String) filter.get("name");
        //单位名称
        String companyName = (String) filter.get("companyname");
        LambdaQueryWrapper<TransportCarrier> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(TransportCarrier::getName, name)
                .like(TransportCarrier::getCompanyname, companyName)
                .eq(TransportCarrier::getValidflag,true)
                .orderByDesc(TransportCarrier::getCreatetime);
        return this.page(page, queryWrapper);
    }
    /**
    * @Description: 新增承运人
    * @date 2021/3/30 10:05
    */
    @Override
    public void addCarrier(TransportCarrier transportCarrier, UserInfo user) {
        transportCarrier.setCreateby(user.getId());
        transportCarrier.setCreatetime(new Date());
        transportCarrier.setCreatebyname(user.getUsername());
        transportCarrier.setValidflag(true);
        this.save(transportCarrier);
    }
    /**
    * @Description: 修改承运人
    * @date 2021/3/30 10:08
    */
    @Override
    public void modCarrier(TransportCarrier transportCarrier, UserInfo user) {
        transportCarrier.setUpdateby(user.getId());
        transportCarrier.setUpdatebyname(user.getUsername());
        transportCarrier.setUpdatetime(new Date());
        this.updateById(transportCarrier);
    }
    @Override
    public void delCarrier(Long id, UserInfo user) {
        TransportCarrier transportCarrier = new TransportCarrier();
        transportCarrier.setId(id);
        transportCarrier.setUpdateby(user.getId());
        transportCarrier.setUpdatebyname(user.getUsername());
        transportCarrier.setUpdatetime(new Date());
        transportCarrier.setValidflag(false);
        this.updateById(transportCarrier);
    }
    /**
    * @Description: 承运人 校验
    * @date 2021/4/6 16:10
    */
    @Override
    public void checkCarrier(TransportCarrier transportCarrier) {
        if (StringUtils.isBlank(transportCarrier.getCompanyname())) {
            throw new BusinessException("单位名称不能为空");
        }
        if (StringUtils.isBlank(transportCarrier.getNumber())) {
            throw new BusinessException("危险货物道路运输资质证号不能为空");
        }
        if (StringUtils.isBlank(transportCarrier.getAddress())) {
            throw new BusinessException("地址不能为空");
        }
        if (StringUtils.isBlank(transportCarrier.getName())) {
            throw new BusinessException("负责人姓名不能为空");
        }
        if (StringUtils.isBlank(transportCarrier.getPhone())) {
            throw new BusinessException("负责人联系电话不能为空");
        }
        if (transportCarrier.getValidtime() == null) {
            throw new BusinessException("证件有效期不能为空");
        }
    }
}