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.InternalAuditPerson; import com.gkhy.exam.system.mapper.ExStudentMapper; import com.gkhy.exam.system.mapper.InternalAuditPersonMapper; import com.gkhy.exam.system.mapper.SysDeptMapper; import com.gkhy.exam.system.mapper.SysUserMapper; import com.gkhy.exam.system.service.InternalAuditPersonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service public class InternalAuditPersonServiceImpl extends ServiceImpl implements InternalAuditPersonService { @Autowired private InternalAuditPersonMapper personMapper; @Autowired private ExStudentMapper exStudentMapper; @Override public CommonPage selectPersonList(InternalAuditPerson person) { if (!SecurityUtils.adminUser()){ if (person.getCompanyId()==null){ throw new ApiException("非管理员操作,企业id不可为空"); } } PageUtils.startPage(); List internalAuditPeople = personMapper.selectPersonList(person); return CommonPage.restPage(internalAuditPeople); } @Override public CommonResult insertPerson(InternalAuditPerson person) { SysUser user = SecurityUtils.getLoginUser().getUser(); ExStudent exStudent = exStudentMapper.selectStudentById(Long.valueOf(person.getPersonId())); if (user.getDeptId()!=null){ if (user.getDeptId().equals(exStudent.getDeptId())){ throw new ApiException("请勿选择本部门成员"); } } person.setCreateBy(SecurityUtils.getUsername()); person.setCreateTime(LocalDateTime.now()); personMapper.insert(person); return CommonResult.success(); } @Override public CommonResult updatePerson(InternalAuditPerson person) { person.setUpdateBy(SecurityUtils.getUsername()); person.setUpdateTime(LocalDateTime.now()); personMapper.updateById(person); return CommonResult.success(); } @Override public CommonResult deletedPerson(Integer personId) { InternalAuditPerson internalAuditPerson = new InternalAuditPerson(); internalAuditPerson.setUpdateTime(LocalDateTime.now()); internalAuditPerson.setUpdateBy(SecurityUtils.getUsername()); internalAuditPerson.setId(personId); internalAuditPerson.setDelFlag(2); personMapper.updateById(internalAuditPerson); return CommonResult.success(); } }