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.InspectionSpecification;
|
import com.gkhy.exam.system.mapper.InspectionSpecificationMapper;
|
import com.gkhy.exam.system.service.InspectionSpecificationService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service
|
public class InspectionSpecificationServiceImpl extends ServiceImpl<InspectionSpecificationMapper, InspectionSpecification> implements InspectionSpecificationService {
|
|
|
@Autowired
|
private InspectionSpecificationMapper specificationMapper;
|
|
@Override
|
public CommonPage selectSpecificationList(InspectionSpecification specification) {
|
if(!SecurityUtils.adminUser()){
|
if (specification.getCompanyId()==null){
|
throw new ApiException("非管理员操作,企业id不可为空");
|
}
|
}
|
PageUtils.startPage();
|
List<InspectionSpecification> inspectionSpecifications = specificationMapper.selectSpecificationList(specification);
|
return CommonPage.restPage(inspectionSpecifications);
|
}
|
|
@Override
|
public CommonResult insertSpecification(InspectionSpecification specification) {
|
specification.setCreateBy(SecurityUtils.getUsername());
|
specification.setCreateTime(LocalDateTime.now());
|
specificationMapper.insert(specification);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult updateSpecification(InspectionSpecification specification) {
|
specification.setUpdateBy(SecurityUtils.getUsername());
|
specification.setUpdateTime(LocalDateTime.now());
|
specificationMapper.updateById(specification);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult deletedSpecification(Integer specificationId) {
|
InspectionSpecification inspectionSpecification = new InspectionSpecification();
|
inspectionSpecification.setId(specificationId);
|
inspectionSpecification.setUpdateBy(SecurityUtils.getUsername());
|
inspectionSpecification.setUpdateTime(LocalDateTime.now());
|
inspectionSpecification.setDelFlag(2);
|
specificationMapper.updateById(inspectionSpecification);
|
return CommonResult.success();
|
}
|
}
|