package com.gkhy.exam.system.service.impl;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
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.InternalAuditPlan;
|
import com.gkhy.exam.system.mapper.InternalAuditPlanMapper;
|
import com.gkhy.exam.system.service.InternalAuditPlanService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service
|
public class InternalAuditPlanServiceImpl extends ServiceImpl<InternalAuditPlanMapper, InternalAuditPlan> implements InternalAuditPlanService {
|
|
@Autowired
|
private InternalAuditPlanMapper planMapper;
|
|
|
|
|
@Override
|
public CommonPage selectPlanList(InternalAuditPlan plan) {
|
if (!SecurityUtils.adminUser()){
|
if (plan.getCompanyId()==null){
|
throw new ApiException("非管理员操作,企业id不可为空");
|
}
|
}
|
PageUtils.startPage();
|
List<InternalAuditPlan> internalAuditPlans = planMapper.selectPlanList(plan);
|
return CommonPage.restPage(internalAuditPlans);
|
}
|
|
@Override
|
public CommonResult insertPlan(InternalAuditPlan plan) {
|
List<InternalAuditPlan> internalAuditPlans = planMapper.selectList(
|
Wrappers.<InternalAuditPlan>lambdaQuery()
|
.eq(InternalAuditPlan::getCompanyId, plan.getCompanyId())
|
.eq(InternalAuditPlan::getYear, plan.getYear())
|
.eq(InternalAuditPlan::getDelFlag,1));
|
if (internalAuditPlans.size()>0){
|
throw new ApiException("当前企业已有相关数据");
|
}
|
plan.setCreateBy(SecurityUtils.getUsername());
|
plan.setCreateTime(LocalDateTime.now());
|
planMapper.insert(plan);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult updatePlan(InternalAuditPlan plan) {
|
plan.setUpdateBy(SecurityUtils.getUsername());
|
plan.setUpdateTime(LocalDateTime.now());
|
planMapper.updateById(plan);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult deletedPlan(Integer planId) {
|
InternalAuditPlan internalAuditPlan = new InternalAuditPlan();
|
internalAuditPlan.setDelFlag(2);
|
internalAuditPlan.setUpdateTime(LocalDateTime.now());
|
internalAuditPlan.setUpdateBy(SecurityUtils.getUsername());
|
internalAuditPlan.setId(planId);
|
planMapper.updateById(internalAuditPlan);
|
return CommonResult.success();
|
}
|
}
|