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.domain.entity.SysUser;
|
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.ExStudent;
|
import com.gkhy.exam.system.domain.InternalAuditEvaluate;
|
import com.gkhy.exam.system.mapper.ExStudentMapper;
|
import com.gkhy.exam.system.mapper.InternalAuditEvaluateMapper;
|
import com.gkhy.exam.system.mapper.SysUserMapper;
|
import com.gkhy.exam.system.service.InternalAuditEvaluateService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service
|
public class InternalAuditEvaluateServiceImpl extends ServiceImpl<InternalAuditEvaluateMapper, InternalAuditEvaluate> implements InternalAuditEvaluateService {
|
|
@Autowired
|
private InternalAuditEvaluateMapper evaluateMapper;
|
|
@Autowired
|
private ExStudentMapper exStudentMapper;
|
|
|
|
@Override
|
public CommonPage selectEvaluateList(InternalAuditEvaluate evaluate) {
|
if (!SecurityUtils.adminUser()){
|
if (evaluate.getCompanyId()==null){
|
throw new ApiException("非管理员操作,企业id不可为空");
|
}
|
}
|
PageUtils.startPage();
|
List<InternalAuditEvaluate> internalAuditEvaluates = evaluateMapper.selectEvaluateList(evaluate);
|
return CommonPage.restPage(internalAuditEvaluates);
|
}
|
|
@Override
|
public CommonResult insertEvaluate(InternalAuditEvaluate evaluate) {
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
if (!user.getUserType().equals(0)&&!user.getUserType().equals(1)){
|
throw new ApiException("普通用户无法添加相关数据");
|
}
|
ExStudent exStudent = exStudentMapper.selectStudentById(Long.valueOf(evaluate.getPersonId()));
|
if (user.getDeptId().equals(exStudent.getDeptId())){
|
throw new ApiException("请勿选择本部门成员");
|
}
|
evaluate.setCreateBy(SecurityUtils.getUsername());
|
evaluate.setCreateTime(LocalDateTime.now());
|
evaluateMapper.insert(evaluate);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult updateEvaluate(InternalAuditEvaluate evaluate) {
|
evaluate.setUpdateBy(SecurityUtils.getUsername());
|
evaluate.setUpdateTime(LocalDateTime.now());
|
evaluateMapper.updateById(evaluate);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult deletedEvaluate(Integer evaluateId) {
|
InternalAuditEvaluate internalAuditEvaluate = new InternalAuditEvaluate();
|
internalAuditEvaluate.setId(evaluateId);
|
internalAuditEvaluate.setUpdateBy(SecurityUtils.getUsername());
|
internalAuditEvaluate.setUpdateTime(LocalDateTime.now());
|
internalAuditEvaluate.setDelFlag(2);
|
evaluateMapper.updateById(internalAuditEvaluate);
|
return CommonResult.success();
|
}
|
}
|