/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.wechat.dao;

import com.wechat.global.base.dao.Pagination;
import com.wechat.global.base.dao.PagingResult;
import com.wechat.global.base.dao.impl.BaseDao;
import com.wechat.model.dbEntity.MdeJobAdvertised;
import com.wechat.model.dbEntity.MdeJobAdvertisedEntity;
import com.wechat.model.dbEntity.MdeJobInvitationRel;
import com.wechat.model.dto.AvailableAndUsedCountDto;
import com.wechat.model.dto.JobAdvertisedListDto;
import com.wechat.model.dto.JobRepFormPvDto;
import com.wechat.model.dto.ShowOfJobsDto;
import com.wechat.model.responseDto.JobAdvertisedNologinResp;
import com.wechat.model.responseDto.JobAdvertisedRes;
import com.wechat.model.responseDto.JobAdvertisedResp;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 单表生成DAO接口
 *
 * @author tangwc
 * @version 2018-05-23
 */
@Repository
public class MdeJobAdvertisedDao extends BaseDao {
    public MdeJobAdvertised getInfoById(int id, String lang) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        map.put("lang", lang);
        return super.selectOne("MdeJobAdvertisedMapper.get", map);
    }

    public MdeJobAdvertisedEntity getJobAdvertisedById(int id) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        return super.selectOne("MdeJobAdvertisedMapper.getInfoById", map);
    }


    /**
     * 根据id查询全部相关职位的详情
     *
     * @param id
     * @param lang
     * @return
     */
    public List<ShowOfJobsDto> getInfoByIds(List<String> idList) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("idList", idList);
        return super.select("MdeJobAdvertisedMapper.getInfoByIds", map);
    }


    /**
     * 获取推荐职位
     *
     * @param limi
     * @return
     */
    public List<MdeJobAdvertised> getRecommentJobs(int limitSize) {
        return super.select("MdeJobAdvertisedMapper.getRecommentJobs", limitSize);
    }

    /**
     * 获取推荐职位-分页查询
     *
     * @param limi
     * @return
     */
    public PagingResult<JobAdvertisedListDto> getPagingRecommentJobs(Pagination page) {
        return super.selectPagination("MdeJobAdvertisedMapper.getPagingRecommentJobs", "MdeJobAdvertisedMapper.getPagingRecommentJobsCount", page);
    }


    /**
     * 优选职位
     *
     * @param userCode
     * @param recommentJobsLimitSize
     * @return
     */
/*	public List<MdeJobAdvertised> getRecommentJobs(String userCode, int recommentJobsLimitSize) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("userCode", userCode);
		map.put("limitSize", recommentJobsLimitSize);
		return super.select("MdeJobAdvertisedMapper.getRecommentJobsByUserCode", map);
	}*/


    /**
     * 优选职位
     *
     * @param userCode
     * @param lang
     * @param limitSize
     * @return
     */
	/*public List<MdeJobAdvertised> getSuperiorJobs(String userCode, String lang, int limitSize) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("userCode", userCode);
		map.put("lang", lang);
		map.put("limitSize", limitSize);
		return super.select("MdeJobAdvertisedMapper.getSuperiorJobs", map);
	}*/

    /**
     * 职位搜索
     *
     * @param page
     * @return
     */
    public PagingResult<JobAdvertisedListDto> searchJob(Pagination page) {
        return super.selectPagination("MdeJobAdvertisedMapper.searchJob", "MdeJobAdvertisedMapper.searchJobCount", page);
    }

    /**
     * 职位搜索
     *
     * @param page
     * @return
     */
    public PagingResult<JobAdvertisedListDto> searchPositionByKeyWord(Pagination page) {
        return super.selectPagination("MdeJobAdvertisedMapper.searchPositionByKeyWord", "MdeJobAdvertisedMapper.searchPositionByKeyWordCount", page);
    }

    /**
     * 职位搜索 (未登录)
     *
     * @param page
     * @return
     */
    public List<MdeJobAdvertised> searchJobNotLogin(Map<String, Object> param) {
        return sqlSession.selectList("MdeJobAdvertisedMapper.searchJobNotLogin", param);
    }

    /**
     * 获取相似职位
     *
     * @param jobId
     * @return
     */
    public List<JobAdvertisedListDto> getSimilarJobs(int jobId, int limitSize) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("jobId", jobId);
        map.put("limitSize", limitSize);
        return super.select("MdeJobAdvertisedMapper.getSimilarJobs", map);
    }

    /**
     * 酒店的其他职位
     *
     * @param jobId
     * @return
     */
    public List<MdeJobAdvertised> gethotelOtherPositionList(int jobId, String publisher, int limitSize) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("jobId", jobId);
        map.put("publisher", publisher);
        map.put("limitSize", limitSize);
        return super.select("MdeJobAdvertisedMapper.gethotelOtherPositionList", map);
    }

    public int insert(MdeJobAdvertised mdeJobAdvertised) {
        return super.insert("MdeJobAdvertisedMapper.insert", mdeJobAdvertised);
    }

    /**
     * 获取 企业正在招聘的职位
     *
     * @param publisher
     * @return
     */
    public List<MdeJobAdvertised> getByPublisher(String publisher) {
        return super.select("MdeJobAdvertisedMapper.getAdvertisedRecruitment", publisher);

    }

    /**
     * 获取已经投递过职位的用户code
     *
     * @param publisher
     * @return
     */
    public List<MdeJobAdvertised> getAlreadyAdvertisedByJobId(String publisher) {
        return super.select("MdeJobAdvertisedMapper.getAlreadyAdvertisedByJobId", publisher);

    }

    /**
     * 查看该企业是否发布某个职位
     *
     * @return
     */
    public MdeJobAdvertised findByPublisherAndJobId(MdeJobInvitationRel mdeJobInvitationRel) {
        return super.selectOne("MdeJobAdvertisedMapper.findByPublisherAndJobId", mdeJobInvitationRel);
    }

    public int updateJobAdvertisedStatus(Map<String, String> maps) {
        return sqlSession.update("MdeJobAdvertisedMapper.updateJobAdvertisedStatus", maps);
    }

    public List<MdeJobAdvertised> getAdvertisedRecruitment(String userCode) {
        return super.select("MdeJobAdvertisedMapper.getAdvertisedRecruitment", userCode);
    }

    /**
     * 更新职位首推状态
     */
    public int updateJobRecommend(Map<String, String> maps) {
        return sqlSession.update("MdeJobAdvertisedMapper.updateJobRecommend", maps);
    }


    /**
     * 更新招聘职位信息表
     *
     * @param mdeJobAdvertised
     * @return
     */
    public int update(MdeJobAdvertised mdeJobAdvertised) {
        return super.update("MdeJobAdvertisedMapper.update", mdeJobAdvertised);
    }

    public List<JobAdvertisedRes> getCollectionJobList(String[] jobListStr, String lang) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("jobListStr", jobListStr);
        map.put("lang", lang);
        return super.select("MdeJobAdvertisedMapper.getCollectionJobList", map);
    }

    /**
     * 查询投递该公司的总简历数
     *
     * @param userCode 企业code
     * @return
     */
    public int getAllUserCvCount(String userCode) {
        return super.count("MdeJobAdvertisedMapper.getAllUserCvCount", userCode);
    }

    /**
     * 获取邀请面试简历数量
     *
     * @param userCode 企业code
     * @return
     */
    public int inviteAuditionCount(String userCode) {
        return super.count("MdeJobAdvertisedMapper.inviteAuditionCount", userCode);
    }

    /**
     * 获取指定企业新简历数量
     *
     * @param userCode 企业code
     * @return
     */
    public int getNewCvCountByPublisher(String userCode) {
        return super.count("MdeJobAdvertisedMapper.getNewCvCountByPublisher", userCode);
    }

    /**
     * 录用简历数量
     *
     * @param userCode 企业code
     * @return
     */
    public int matriculateUserCvCount(String userCode) {
        return super.count("MdeJobAdvertisedMapper.matriculateUserCvCount", userCode);
    }

    /**
     * 淘汰简历数量
     *
     * @param userCode 企业code
     * @return
     */
    public int eliminateUserCvCount(String userCode) {
        return super.count("MdeJobAdvertisedMapper.eliminateUserCvCount", userCode);
    }

    /**
     * 已发布信息
     *
     * @param userCode
     * @return
     */
    public PagingResult<JobAdvertisedResp> alreadyPublish(Pagination page) {
        return super.selectPagination("MdeJobAdvertisedMapper.alreadyPublish",
                "MdeJobAdvertisedMapper.alreadyPublishCount", page);
    }

    /**
     * @param page
     * @return PagingResult<JobAdvertisedResp>
     * @description 已发职位关键词检索
     * @author rayson
     * @date 2023-09-12 14:52
     **/
    public PagingResult<JobAdvertisedResp> searchKeyWord(Pagination page) {
        return super.selectPagination("MdeJobAdvertisedMapper.searchKeyWord",
                "MdeJobAdvertisedMapper.searchKeyWordCount", page);
    }

    /**
     * 已发布职位个数
     *
     * @param userCode
     * @return
     */
    public int alreadyPublishNotVipCount(String userCode, String jobStatus) {
        Map<Object, Object> pageParam = new HashMap<Object, Object>();
        pageParam.put("userCode", userCode);
        pageParam.put("jobStatus", jobStatus);
        return super.count("MdeJobAdvertisedMapper.alreadyPublishNotVipCount", pageParam);
    }

    /**
     * 优选职位  大于50（未登录）
     *
     * @return
     */
    public List<MdeJobAdvertised> getNotLoginRecommentJobsRandJoin(Integer limitSize) {
        return super.select("MdeJobAdvertisedMapper.getNotLoginRecommentJobsRandJoin", limitSize);
    }

    /**
     * 优选职位  小于50（未登录）
     *
     * @return
     */
    public List<MdeJobAdvertised> getNotLoginRecommentJobsRand(Integer limitSize) {
        return super.select("MdeJobAdvertisedMapper.getNotLoginRecommentJobsRand", limitSize);
    }

    /**
     * 优选职位的数量
     *
     * @return
     */
    public int getNotLoginRecommentJobsCount() {
        return sqlSession.selectOne("MdeJobAdvertisedMapper.getNotLoginRecommentJobsCount");
    }

    /**
     * 批量更新发布日期（招聘中的职位）
     *
     * @param publisher
     * @return
     */
    public int batchUpdatePublishDate(String publisher) {
        return sqlSession.update("MdeJobAdvertisedMapper.batchUpdatePublishDate", publisher);
    }

    /**
     * 获取已发布的职位-非登录状态
     *
     * @param userCode
     * @param lang
     * @return
     */
    public List<JobAdvertisedNologinResp> getPublishingJobsByUserCodeNologin(String userCode, String lang) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userCode", userCode);
        map.put("lang", lang);
        return super.select("MdeJobAdvertisedMapper.getPublishingJobsByUserCode", map);
    }

    /**
     * 获取已发布的职位
     *
     * @param userCode
     * @param lang
     * @return
     */
    public List<JobAdvertisedResp> getPublishingJobsByUserCode(String userCode, String lang) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userCode", userCode);
        map.put("lang", lang);
        return super.select("MdeJobAdvertisedMapper.getPublishingJobsByUserCode", map);
    }


    /**
     * 获取已发布的职位
     *
     * @param userCode
     * @param lang
     * @return
     */
    public List<JobAdvertisedNologinResp> getPublishingJobsNologin(String userCode) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userCode", userCode);
        return super.select("MdeJobAdvertisedMapper.getPublishingJobsNologin", map);
    }

    /**
     * 获取酒店可首推和已首推个数
     *
     * @param userCode
     * @return
     */
    public AvailableAndUsedCountDto getAvailableAndUsedCount(String userCode) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userCode", userCode);
        return super.selectOne("MdeJobAdvertisedMapper.getAvailableAndUsedCount", map);
    }

    /**
     * 点击量查询
     *
     * @param statisticType 统计类型  按月,季度,年 统计
     * @return
     */
    public List<JobRepFormPvDto> findRepFormPvByDate(Map<String, Object> map) {
        return super.select("MdeJobAdvertisedMapper.findRepFormPvByDate", map);
    }

    /**
     * 点击量
     *
     * @param statisticType 统计类型  按月,季度,年 统计
     * @return
     */
    public Integer findGeneralPvByDate(Map<String, Object> map) {
        return super.selectOne("MdeJobAdvertisedMapper.findGeneralPvByDate", map);
    }

}