package com.jpsoft.shinestar.modules.base.dao;

import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.base.entity.CompanyInfo;
import com.jpsoft.shinestar.modules.base.entity.PersonInfo;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Repository
public interface PersonInfoDAO {
	int insert(PersonInfo entity);
	int update(PersonInfo entity);
	int exist(Long id);
	PersonInfo get(Long id);
	int delete(Long id);
	List<PersonInfo> list();
	List<PersonInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
	List<PersonInfo> searchNew(@Param("searchParams") Map<String, Object> searchParams, @Param("sortList") List<Sort> sortList);
    PersonInfo findByNameAndPhone(String name, String phone);
	PersonInfo findByOpenId(String openId);
    List<PersonInfo> findByCompanyId(String companyId);
	List<PersonInfo> findListByCompanyCode(String companyCode);
	List<PersonInfo> findByCompanyIdAndPopedom(@Param("type") String type, @Param("companyId") String companyId);
    long countByCompanyCode(String code, Long personId);

	PersonInfo getIgnoreDelFlag(Long id);
	List<PersonInfo> findByCompanyCode(Map<String, Object> searchParams, List<Sort> sortList);

    long countByCompanyList(List<CompanyInfo> list);

    long countByCompanyListAndPopedom(@Param("type") String type, @Param("list") List<CompanyInfo> list);

	long countStudentByCompanyListAndPopedom(@Param("type") String type, @Param("list") List<CompanyInfo> list);

	List<PersonInfo> findByUpdateHealthyTime(Date startDate, int limit);

	PersonInfo findById(long id);

    long countByCompanyId(String companyId);

    long countByCompanyIds(List<String> companyIds);

    PersonInfo findByIdCardAndCompanyId(String idCard, String companyId);

	long notGuestList();

	int resetOpenId(Long personId);

	int updateHealthyCode(PersonInfo personInfo);

	List<Map> groupByHealthyCode(Map<String, Object> searchParams);

	List<Map> groupHealthyById(@Param("idList") List<Long> idList);

    PersonInfo findByPhone(String phone);

	List<Long> findByOrderProperty(@Param("searchParams") Map<String, Object> searchParams);

    PersonInfo findByNameAndIdCard(String name, String idCard);

	Page<PersonInfo> searchCanteenOutsourcerBalance(Map<String, Object> searchParams, List<Sort> sortList);

    PersonInfo findByIdIgnoreDel(Long personId);

    PersonInfo findByCarNum(String carNum);

	PersonInfo findJobNumber(String jobNumber);

	List<PersonInfo> findByHq();

	int updateNullForHqSortNo(Long personId);
}