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.CrmOrderMarkSettings;
import com.sifang.modules.sunshine.SystemSetting.utils.StringUtil;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.util.LayuiPage;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lzp
 * @date 2019/10/11 14:28
 */
@Repository
public class OrderMarkDao extends BaseDao<CrmOrderMarkSettings> {

	public List<Record> getAllMarkData(LayuiPage page,String type) {
		StringBuilder sb = new StringBuilder();
		sb.append(" SELECT a.id,a.name,a.type,a.sort,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime  ");
		sb.append(" FROM crm_order_mark_settings a");
        sb.append(" where a.status='0'  ");
        sb.append(" and a.use_type=? ");
            sb.append(" order by a.sort asc,a.create_time desc ");
		sb.append(" limit " + page.getLimit() + " offset " + (page.getPage() - 1) * page.getLimit());
		return Db.find(sb.toString(),type);
	}

	public long getAllMarkotalCount(String type) {
		StringBuilder sb = new StringBuilder();
		sb.append(" SELECT count(*) FROM crm_order_mark_settings a ");
		sb.append(" where a.status='0'  ");
		sb.append(" and a.use_type=? ");
		return Db.queryLong(sb.toString(),type);
	}


}
