const system = require("../../../system");
const Dao = require("../../dao.base");
class PatentAnalysisDao extends Dao {
  constructor() {
    super(Dao.getModelName(PatentAnalysisDao));
  }

  async all(params) {
    params = params || {};
    let sql = [];
    sql.push("SELECT");
    sql.push("*");
    sql.push("FROM rp_patent_analysis");
    sql.push("WHERE 1 = 1");

    return await this.customQuery(sql.join(" "), params);
  }

  async countByCondition(params) {
    params = params || {};
    let sql = [];
    sql.push("SELECT");
    sql.push("COUNT(1) AS num");
    sql.push("FROM rp_patent_analysis");
    sql.push("WHERE deleted_at IS NULL");

    this.setCondition(sql, params);
    let list = await this.customQuery(sql.join(" "), params);
    if (!list || list.length == 0) {
      return 0;
    }
    return list[0].num || 0;
  }

  async listByCondition(params) {
    params.startRow = Number(params.startRow || 0);
    params.pageSize = Number(params.pageSize || 10);

    let sql = [];
    sql.push("SELECT");
    sql.push("*");
    sql.push("FROM rp_patent_analysis");
    sql.push("WHERE deleted_at IS NULL");
    this.setCondition(sql, params);

    sql.push("ORDER BY created_at DESC");
    sql.push("LIMIT :startRow, :pageSize");
    return await this.customQuery(sql.join(" "), params);
  }

  async setCondition(sql, params) {
  }
}
module.exports = PatentAnalysisDao;