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.ContractLedger;
|
import com.gkhy.exam.system.mapper.ContractLedgerMapper;
|
import com.gkhy.exam.system.service.ContractLedgerService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service
|
public class ContractLedgerServiceImpl extends ServiceImpl<ContractLedgerMapper, ContractLedger> implements ContractLedgerService {
|
|
@Autowired
|
private ContractLedgerMapper contractLedgerMapper;
|
|
@Override
|
public CommonPage selectContractLedgerList(ContractLedger contractLedger) {
|
if (!SecurityUtils.adminUser()){
|
if (contractLedger.getCompanyId()==null){
|
throw new ApiException("非管理员操作,查询条件不可为空");
|
}
|
}
|
PageUtils.startPage();
|
List<ContractLedger> contractLedgers = contractLedgerMapper.selectLedgerList(contractLedger);
|
return CommonPage.restPage(contractLedgers);
|
}
|
|
@Override
|
public CommonResult insertContractLedger(ContractLedger contractLedger) {
|
contractLedger.setCreateBy(SecurityUtils.getUsername());
|
contractLedger.setCreateTime(LocalDateTime.now());
|
int insert = contractLedgerMapper.insert(contractLedger);
|
if (insert>0){
|
return CommonResult.success();
|
}
|
return CommonResult.failed();
|
}
|
|
@Override
|
public CommonResult updateContractLedger(ContractLedger contractLedger) {
|
contractLedger.setUpdateBy(SecurityUtils.getUsername());
|
contractLedger.setUpdateTime(LocalDateTime.now());
|
int update = contractLedgerMapper.updateById(contractLedger);
|
if (update>0){
|
return CommonResult.success();
|
}
|
return CommonResult.failed();
|
}
|
|
@Override
|
public CommonResult deletedContractLedger(Integer ledgerId) {
|
ContractLedger contractLedger = new ContractLedger();
|
contractLedger.setUpdateBy(SecurityUtils.getUsername());
|
contractLedger.setUpdateTime(LocalDateTime.now());
|
contractLedger.setDelFlag(2);
|
contractLedger.setId(ledgerId);
|
int i = contractLedgerMapper.updateById(contractLedger);
|
if (i>0){
|
return CommonResult.success();
|
}
|
return CommonResult.failed();
|
}
|
}
|