package com.mortals.xhx.module.staff.service.impl;

import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.module.staff.dao.StaffDao;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.dao.ibatis.StaffLeaveDaoImpl;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.vo.StaffInfoVo;
import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * StaffService
 * 员工基本信息 service实现
 *
 * @author zxfei
 * @date 2023-04-07
 */
@Service("staffService")
public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, StaffEntity, Long> implements StaffService {


    @Autowired
    private StaffDaoImpl staffDao;

    @Autowired
    private StaffLeaveDaoImpl staffLeaveDao;


    @Override
    protected String getExtKey(StaffEntity data) {
        //工号作为redis 扩展key
        return data.getWorkNum();
    }

    @Override
    public StaffInfoVo queryAll() {
        StaffInfoVo staffInfoVo = new StaffInfoVo();
        //在职
        staffInfoVo.setInWorkStaff(staffDao.queryInWork());
        //全职
        staffInfoVo.setFullStaff(staffDao.queryFull());
        //正式
        staffInfoVo.setFormalStaff(staffDao.queryFormal());
        //兼职
        staffInfoVo.setConcurrentlyStaff(staffDao.queryConcurrently());
        //试用
        staffInfoVo.setOnTrialStaff(staffDao.queryOnTrial());
        //实习
        staffInfoVo.setPricateStaff(staffDao.queryPricate());
        //待离职
        staffInfoVo.setResignationStaff(staffLeaveDao.queryResignation());
        return staffInfoVo;
    }

    @Override
    public int queryDeptNum(Long deptId) {
        return staffDao.queryPersonNum(deptId);
    }

    @Override
    public int queryAllPerson() {
        return staffDao.queryInWork();
    }



}