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.PurchaseContract;
|
import com.gkhy.exam.system.mapper.PurchaseContractMapper;
|
import com.gkhy.exam.system.service.PurchaseContractService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service
|
public class PurchaseContractServiceImpl extends ServiceImpl<PurchaseContractMapper, PurchaseContract> implements PurchaseContractService {
|
|
@Autowired
|
private PurchaseContractMapper contractMapper;
|
|
|
@Override
|
public CommonPage selectContractList(PurchaseContract purchaseContract) {
|
if (!SecurityUtils.adminUser()){
|
if (purchaseContract.getCompanyId()==null){
|
throw new ApiException("非管理员操作,企业id不可为空");
|
}
|
}
|
PageUtils.startPage();
|
List<PurchaseContract> purchaseContracts = contractMapper.selectContractList(purchaseContract);
|
return CommonPage.restPage(purchaseContracts);
|
}
|
|
@Override
|
public CommonResult insertContract(PurchaseContract purchaseContract) {
|
purchaseContract.setCreateTime(LocalDateTime.now());
|
purchaseContract.setCreateBy(SecurityUtils.getUsername());
|
contractMapper.insert(purchaseContract);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult updateContract(PurchaseContract purchaseContract) {
|
purchaseContract.setUpdateBy(SecurityUtils.getUsername());
|
purchaseContract.setUpdateTime(LocalDateTime.now());
|
contractMapper.updateById(purchaseContract);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult deletedContract(Integer contractId) {
|
PurchaseContract purchaseContract = new PurchaseContract();
|
purchaseContract.setUpdateBy(SecurityUtils.getUsername());
|
purchaseContract.setUpdateTime(LocalDateTime.now());
|
purchaseContract.setId(contractId);
|
purchaseContract.setDelFlag(2);
|
contractMapper.updateById(purchaseContract);
|
return CommonResult.success();
|
}
|
}
|