package com.gkhy.exam.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.exam.common.api.CommonPage; import com.gkhy.exam.common.api.CommonResult; import com.gkhy.exam.common.exception.ApiException; import com.gkhy.exam.common.utils.PageUtils; import com.gkhy.exam.common.utils.SecurityUtils; import com.gkhy.exam.system.domain.SupplierSure; import com.gkhy.exam.system.domain.SupplierSurePerformance; import com.gkhy.exam.system.mapper.SupplierSureMapper; import com.gkhy.exam.system.mapper.SupplierSurePerformanceMapper; import com.gkhy.exam.system.mapper.SupplierSureQualityMapper; import com.gkhy.exam.system.service.SupplierSureService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service public class SupplierSureServiceImpl extends ServiceImpl implements SupplierSureService { @Autowired private SupplierSureMapper supplierSureMapper; @Autowired private SupplierSurePerformanceMapper performanceMapper; @Autowired private SupplierSureQualityMapper qualityMapper; @Override public CommonPage selectSupplierList(SupplierSure sure) { if (!SecurityUtils.adminUser()){ if (sure.getCompanyId()==null){ throw new ApiException("非管理员操作,企业id不可为空"); } } PageUtils.startPage(); List supplierSures = supplierSureMapper.selectSupplierList(sure); return CommonPage.restPage(supplierSures); } @Override public CommonResult insertSupplier(SupplierSure sure) { sure.setCreateTime(LocalDateTime.now()); sure.setCreateBy(SecurityUtils.getUsername()); supplierSureMapper.insert(sure); performanceMapper.savePerformance(sure.getId()); qualityMapper.saveQuality(sure.getId()); return CommonResult.success(); } @Override public CommonResult updateSupplier(SupplierSure sure) { sure.setUpdateBy(SecurityUtils.getUsername()); sure.setUpdateTime(LocalDateTime.now()); supplierSureMapper.updateById(sure); return CommonResult.success(); } @Override public CommonResult deletedSupplier(Integer supplierId) { SupplierSure supplierSure = new SupplierSure(); supplierSure.setId(supplierId); supplierSure.setUpdateTime(LocalDateTime.now()); supplierSure.setUpdateBy(SecurityUtils.getUsername()); supplierSure.setDelFlag(2); supplierSureMapper.updateById(supplierSure); return CommonResult.success(); } }