package cn.iocoder.yudao.module.hrm.service.employee;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeEducationSaveReqVO;
|
import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeEducationDO;
|
import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeEducationMapper;
|
import jakarta.annotation.Resource;
|
import org.springframework.stereotype.Service;
|
import org.springframework.validation.annotation.Validated;
|
|
import java.util.List;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.EMPLOYEE_EDUCATION_NOT_EXISTS;
|
|
/**
|
* 员工教育经历 Service 实现类
|
*
|
* @author 芋道源码
|
*/
|
@Service
|
@Validated
|
public class HrmEmployeeEducationServiceImpl implements HrmEmployeeEducationService {
|
|
@Resource
|
private HrmEmployeeEducationMapper educationMapper;
|
|
@Override
|
public Long createEducation(HrmEmployeeEducationSaveReqVO createReqVO) {
|
HrmEmployeeEducationDO education = BeanUtils.toBean(createReqVO, HrmEmployeeEducationDO.class);
|
educationMapper.insert(education);
|
return education.getId();
|
}
|
|
@Override
|
public void updateEducation(HrmEmployeeEducationSaveReqVO updateReqVO) {
|
validateEducationExists(updateReqVO.getId());
|
HrmEmployeeEducationDO updateObj = BeanUtils.toBean(updateReqVO, HrmEmployeeEducationDO.class);
|
educationMapper.updateById(updateObj);
|
}
|
|
@Override
|
public void deleteEducation(Long id) {
|
validateEducationExists(id);
|
educationMapper.deleteById(id);
|
}
|
|
private void validateEducationExists(Long id) {
|
if (educationMapper.selectById(id) == null) {
|
throw exception(EMPLOYEE_EDUCATION_NOT_EXISTS);
|
}
|
}
|
|
@Override
|
public List<HrmEmployeeEducationDO> getEducationListByEmployeeId(Long employeeId) {
|
return educationMapper.selectByEmployeeId(employeeId);
|
}
|
|
}
|