package com.willalp.clockingin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.willalp.clockingin.domain.BizLeave;
import com.willalp.clockingin.mapper.BizLeaveMapper;
import com.willalp.clockingin.service.IBizLeaveService;
import com.willalp.common.utils.DateUtils;
import com.willalp.common.utils.SecurityUtils;
import com.willalp.common.utils.StringUtils;
import com.willalp.files.domain.HsOrgPersonnelFiles;
import com.willalp.files.service.IHsOrgPersonnelFilesService;
import com.willalp.flow.service.IBizLeaveImgService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 请假Service业务层处理
 *
 * @author 一只闲鹿
 * @date 2020-11-29
 */
@Service
@AllArgsConstructor
public class BizLeaveServiceImpl extends ServiceImpl<BizLeaveMapper, BizLeave> implements IBizLeaveService {
    @Resource
    private BizLeaveMapper bizLeaveMapper;

    @Resource
    private IHsOrgPersonnelFilesService orgPersonnelFilesService;

    @Resource
    private IBizLeaveImgService leaveImgService;

    /**
     * 查询请假
     *
     * @param id 请假ID
     * @return 请假
     */
    @Override
    public BizLeave selectBizLeaveById(Long id) {
        return bizLeaveMapper.selectBizLeaveById(id);
    }

    /**
     * 查询请假列表
     *
     * @param bizLeave 请假
     * @return 请假
     */
    @Override
    public List<BizLeave> selectBizLeaveList(BizLeave bizLeave) {
        return bizLeaveMapper.selectBizLeaveList(bizLeave);
    }

    @Override
    public List<BizLeave> selectPersonnelList(BizLeave bizLeave) {
        return bizLeaveMapper.selectPersonnelList(bizLeave);
    }

    /**
     * 新增请假
     *
     * @param bizLeave 请假
     * @return 结果
     */
    @Override
    public int insertBizLeave(BizLeave bizLeave) {
        bizLeave.setCreateBy(SecurityUtils.getUsername());
        bizLeave.setCreateTime(DateUtils.getNowDate());
        return bizLeaveMapper.insert(bizLeave);
    }

    /**
     * 修改请假
     *
     * @param bizLeave 请假
     * @return 结果
     */
    @Override
    public int updateBizLeave(BizLeave bizLeave) {
        bizLeave.setUpdateTime(DateUtils.getNowDate());
        return bizLeaveMapper.updateBizLeave(bizLeave);
    }

    /**
     * 批量删除请假
     *
     * @param ids 需要删除的请假ID
     * @return 结果
     */
    @Override
    public int deleteBizLeaveByIds(Long[] ids) {
        return bizLeaveMapper.deleteBizLeaveByIds(ids);
    }

    /**
     * 删除请假信息
     *
     * @param id 请假ID
     * @return 结果
     */
    @Override
    public int deleteBizLeaveById(Long id) {
        return bizLeaveMapper.deleteBizLeaveById(id);
    }
}
