2026-07-09 d41fe2e95f3f64c6e3a7229acd9e74e673513a0a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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);
    }
 
}