| | |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.LEAVE_TYPE_CONFIG_NOT_EXISTS; |
| | | import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.LEAVE_TYPE_CONFIG_TYPE_EXISTS; |
| | | |
| | | /** |
| | | * 请假类型扣款配置 Service 实现类 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void createLeaveTypeConfig(HrmLeaveTypeConfigDO config) { |
| | | // 校验同一请假类型只允许存在一条配置 |
| | | if (leaveTypeConfigMapper.selectCount(HrmLeaveTypeConfigDO::getLeaveType, config.getLeaveType()) > 0) { |
| | | throw exception(LEAVE_TYPE_CONFIG_TYPE_EXISTS); |
| | | } |
| | | leaveTypeConfigMapper.insert(config); |
| | | } |
| | | |
| | | @Override |
| | | public void updateLeaveTypeConfig(HrmLeaveTypeConfigDO config) { |
| | | validateLeaveTypeConfigExists(config.getId()); |
| | | leaveTypeConfigMapper.updateById(config); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteLeaveTypeConfig(Long id) { |
| | | validateLeaveTypeConfigExists(id); |
| | | leaveTypeConfigMapper.deleteById(id); |
| | | } |
| | | |
| | | private void validateLeaveTypeConfigExists(Long id) { |
| | | if (leaveTypeConfigMapper.selectById(id) == null) { |
| | | throw exception(LEAVE_TYPE_CONFIG_NOT_EXISTS); |