package com.staffing.custom.service.impl;

import java.util.List;

import com.staffing.common.core.domain.entity.SysUser;
import com.staffing.common.utils.DateUtils;
import com.staffing.common.utils.SecurityUtils;
import com.staffing.custom.domain.StEmployeeFundRecord;
import com.staffing.custom.domain.StTaskSign;
import com.staffing.custom.mapper.StEmployeeFundRecordMapper;
import com.staffing.custom.mapper.StTaskSignMapper;
import com.staffing.custom.service.IStTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Service;
import com.staffing.custom.mapper.StEmployeeMapper;
import com.staffing.custom.domain.StEmployee;
import com.staffing.custom.service.IStEmployeeService;

/**
 * 员工Service业务层处理
 * 
 * @author staffing
 * @date 2024-08-27
 */
@Service
public class StEmployeeServiceImpl implements IStEmployeeService 
{
    @Autowired
    private StEmployeeMapper stEmployeeMapper;

    @Autowired
    private StTaskSignMapper stTaskSignMapper;

    @Autowired
    private StEmployeeFundRecordMapper stEmployeeFundRecordMapper;

    @Autowired
    private IStTaskService stTaskService;
    /**
     * 查询员工
     * 
     * @param id 员工主键
     * @return 员工
     */
    @Override
    public StEmployee selectStEmployeeById(Long id)
    {
        return stEmployeeMapper.selectStEmployeeById(id);
    }

    public StEmployee selectStEmployeeByPhone(String phone){
        return stEmployeeMapper.selectStEmployeeByPhone(phone);
    }

    /**
     * 查询员工列表
     * 
     * @param stEmployee 员工
     * @return 员工
     */
    @Override
    public List<StEmployee> selectStEmployeeList(StEmployee stEmployee)
    {
        return stEmployeeMapper.selectStEmployeeList(stEmployee);
    }

    /**
     * 新增员工
     * 
     * @param stEmployee 员工
     * @return 结果
     */
    @Override
    public int insertStEmployee(StEmployee stEmployee)
    {
        return stEmployeeMapper.insertStEmployee(stEmployee);
    }

    /**
     * 修改员工
     * 
     * @param stEmployee 员工
     * @return 结果
     */
    @Override
    public int updateStEmployee(StEmployee stEmployee)
    {
        stTaskService.updateTaskUserInfo(stEmployee);

        stEmployee.setUpdateTime(DateUtils.getNowDate());
        return stEmployeeMapper.updateStEmployee(stEmployee);
    }

    @Override
    public int updateStEmployeeOrNull(StEmployee stEmployee)
    {
        stTaskService.updateTaskUserInfo(stEmployee);

        stEmployee.setUpdateTime(DateUtils.getNowDate());
        stEmployeeMapper.updateStEmployeeOrNull(stEmployee);
        return 1;
    }


    /**
     * 批量删除员工
     * 
     * @param ids 需要删除的员工主键
     * @return 结果
     */
    @Override
    public int deleteStEmployeeByIds(Long[] ids)
    {
        return stEmployeeMapper.deleteStEmployeeByIds(ids);
    }

    /**
     * 删除员工信息
     * 
     * @param id 员工主键
     * @return 结果
     */
    @Override
    public int deleteStEmployeeById(Long id)
    {
        return stEmployeeMapper.deleteStEmployeeById(id);
    }
}
