package com.sifang.modules.sunshine.SystemSetting.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.sunshine.SystemSetting.entity.CrmOrderServiceMeasures;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.common.persistence.Page;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CrmOrderServiceMeasuresDao extends BaseDao<CrmOrderServiceMeasures> {
    public List<Record> getServiceMeasuresList(Page<Record> page){
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT DISTINCT service_type FROM crm_order_service_measures");
        if(page != null){
            sb.append(" limit " + page.getPageSize() + " offset " + (page.getPageNo() - 1) * page.getPageSize());
        }
        return Db.find(sb.toString());
    }
    public long getCount(){
        StringBuffer sb = new StringBuffer();
        sb.append(" select count(DISTINCT service_type)");
        sb.append(" from crm_order_service_measures");
        return Db.queryLong(sb.toString());
    }
}
