package com.zhongshu.card.server.core.dao.projectAbout.impl;

import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
import com.zhongshu.card.client.model.projectAbout.ProjectExcelTemplateSearch;
import com.zhongshu.card.client.model.school.CardInfoSearch;
import com.zhongshu.card.server.core.dao.BaseImpl;
import com.zhongshu.card.server.core.dao.projectAbout.ProjectExcelTemplateDao;
import com.zhongshu.card.server.core.dao.projectAbout.extend.ProjectExcelTemplateDaoExtend;
import com.zhongshu.card.server.core.dao.school.extend.CardInfoDaoExtend;
import com.zhongshu.card.server.core.domain.projectAbout.ProjectExcelTemplate;
import com.zhongshu.card.server.core.domain.school.CardInfo;
import com.zhongshu.card.server.core.util.CommonUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @Author TRX
 * @CreateDate: 2023/4/12
 * @Version: 1.0
 */
public class ProjectExcelTemplateDaoImpl extends BaseImpl implements ProjectExcelTemplateDaoExtend {

    @Autowired
    private DBHelper dbHelper;

    @Override
    public Page<ProjectExcelTemplate> page(Pageable pageable, ProjectExcelTemplateSearch param) {
        Criteria criteria = buildCriteriaNotOid(param);

        if (StringUtils.isNotEmpty(param.getMark())) {
            criteria.and("mark").is(param.getMark());
        }

        Sort sort = buildSort(param);
        Query query = Query.query(criteria);
        query.with(sort);
        return dbHelper.pages(query, pageable, ProjectExcelTemplate.class);
    }

}
