package com.sundot.airport.ledger.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sundot.airport.common.utils.DateUtils;
import com.sundot.airport.ledger.domain.ScoreEmployeeAdditional;
import com.sundot.airport.ledger.domain.vo.EmployeeAdditionalScoreVO;
import com.sundot.airport.ledger.mapper.ScoreEmployeeAdditionalMapper;
import com.sundot.airport.ledger.service.IScoreEmployeeAdditionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 员工附加分Service业务层处理
 */
@Service
public class ScoreEmployeeAdditionalServiceImpl extends ServiceImpl<ScoreEmployeeAdditionalMapper, ScoreEmployeeAdditional>
        implements IScoreEmployeeAdditionalService {

    @Autowired
    private ScoreEmployeeAdditionalMapper scoreEmployeeAdditionalMapper;

    /**
     * 查询员工附加分列表
     *
     * @param scoreEmployeeAdditional 员工附加分
     * @return 员工附加分
     */
    @Override
    public List<ScoreEmployeeAdditional> selectScoreEmployeeAdditionalList(ScoreEmployeeAdditional scoreEmployeeAdditional) {
        return scoreEmployeeAdditionalMapper.selectScoreEmployeeAdditionalList(scoreEmployeeAdditional);
    }

    /**
     * 新增员工附加分
     *
     * @param scoreEmployeeAdditional 员工附加分
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertScoreEmployeeAdditional(ScoreEmployeeAdditional scoreEmployeeAdditional) {
        scoreEmployeeAdditional.setCreateTime(DateUtils.getNowDate());
        return scoreEmployeeAdditionalMapper.insert(scoreEmployeeAdditional);
    }

    /**
     * 修改员工附加分
     *
     * @param scoreEmployeeAdditional 员工附加分
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateScoreEmployeeAdditional(ScoreEmployeeAdditional scoreEmployeeAdditional) {
        scoreEmployeeAdditional.setUpdateTime(DateUtils.getNowDate());
        return scoreEmployeeAdditionalMapper.updateById(scoreEmployeeAdditional);
    }

    /**
     * 批量删除员工附加分
     *
     * @param ids 需要删除的员工附加分主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteScoreEmployeeAdditionalByIds(Long[] ids) {
        return scoreEmployeeAdditionalMapper.deleteBatchIds(java.util.Arrays.asList(ids));
    }

    /**
     * 删除员工附加分信息
     *
     * @param id 员工附加分主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteScoreEmployeeAdditionalById(Long id) {
        return scoreEmployeeAdditionalMapper.deleteById(id);
    }

    @Override
    public List<EmployeeAdditionalScoreVO> selectTotalScoreByEmployee(ScoreEmployeeAdditional scoreEmployeeAdditional) {
        return scoreEmployeeAdditionalMapper.selectTotalScoreByEmployee(scoreEmployeeAdditional);
    }
}