package cn.com.ty.lift.business.push.service;

import cn.com.ty.lift.business.project.dao.entity.Region;
import cn.com.ty.lift.business.push.entity.InspectionTips;
import cn.com.ty.lift.business.push.entity.RepairTips;
import cn.com.ty.lift.business.push.entity.TaskTips;
import cn.com.ty.lift.business.push.mapper.PushUserMapper;
import cn.com.ty.lift.common.constants.CommonEnum;
import cn.com.ty.lift.common.model.PushUserInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 推送用户
 *
 * @author wcz
 * @since 2020/4/24
 */
@Service
public class PushUserService extends ServiceImpl<PushUserMapper, PushUserInfo> {

    public PushUserInfo listByUserId(Long mtCompanyId, Long userId){
        return baseMapper.listByUserId(mtCompanyId, userId);
    }

    public List<PushUserInfo> listByUserIds(Long mtCompanyId, List<Long> userIds){
        return baseMapper.listByUserIds(mtCompanyId, userIds);
    }

    public List<PushUserInfo> listByRoleCodes(Long mtCompanyId, List<String> roleCodes){
        return baseMapper.listByRoleCodes(mtCompanyId, roleCodes);
    }

    public List<PushUserInfo> listByRoleCode(Long mtCompanyId, String roleCode){
        return baseMapper.listByRoleCode(mtCompanyId, roleCode);
    }
    /**
     * 查询公司下总经理
     */
    public List<PushUserInfo> listHighDirector(Long mtCompanyId){
        return baseMapper.listByRoleCode(mtCompanyId, CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode());
    }
    /**
     * 查询公司下管理员
     */
    public List<PushUserInfo> listEnterpriseAdmin(Long mtCompanyId){
        return baseMapper.listByRoleCode(mtCompanyId, CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode());
    }
    /**
     * 根据急修id和维保公司id查询region
     */
    public Region findRegionByEmergencyRepair(Long repairId, Long mtCompanyId){
        return baseMapper.findRegionByEmergencyRepair(repairId, mtCompanyId);
    }
    /**
     * 根据年检id和维保公司id查询region
     */
    public Region findRegionByAnnualInspection(Long inspectionId, Long mtCompanyId){
        return baseMapper.findRegionByAnnualInspection(inspectionId, mtCompanyId);
    }
    /**
     * 根据项目id和维保公司id查询region
     */
    public Region findRegionByProject(Long projectId, Long mtCompanyId){
        return baseMapper.findRegionByProject(projectId, mtCompanyId);
    }

    /**
     * 查询有年检的维保公司
     */
    public IPage<InspectionTips> pageMtCompanyByAnnualInspection(IPage<InspectionTips> page, int days){
        return baseMapper.pageMtCompanyByAnnualInspection(page, days);
    }
    /**
     * 查询有急修的维保公司
     */
    public List<RepairTips> listMtCompanyByEmergencyRepairForDirector(){
        return baseMapper.listMtCompanyByEmergencyRepairForDirector();
    }

    public List<RepairTips> listMtCompanyByEmergencyRepairForRegion(){
        return baseMapper.listMtCompanyByEmergencyRepairForRegion();
    }

    public IPage<TaskTips> pageRepairAndMaintainForClerk(IPage<TaskTips> page){
        return baseMapper.pageRepairAndMaintainForClerk(page);
    }

    public List<TaskTips> listMaintainForEnterpriseAdmin(){
        return baseMapper.listMaintainForEnterpriseAdmin();
    }
}
