package com.cowr.ssjygl.sandfarm; import com.cowr.common.Const; import com.cowr.common.base.BaseService; import com.cowr.common.view.PageParam; import com.cowr.model.Sandfarm; import com.jfinal.kit.StrKit; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; import java.util.ArrayList; import java.util.List; /** * Generated by COWR Sat Apr 04 17:23:04 CST 2020 * TableName: sandfarm * Remarks: 生产点(采砂场) * PrimaryKey: id */ public class SandfarmService extends BaseService { public static final SandfarmService me = new SandfarmService(); public Page find(PageParam pp, String name, Integer del) { String selectsql = "select * "; String fromsql = "from sandfarm t where 1=1 \n"; List paraList = new ArrayList<>(); if (del != null && (del == Const.LOGIC_DEL_VALID || del == Const.LOGIC_DEL_INVALID)) { fromsql += " and t.del = ? \n"; paraList.add(del); } if (StrKit.notBlank(name)) { fromsql += " and t.name like ? \n"; paraList.add("%" + name.trim() + "%"); } String totalRowSql = "select count(*) " + fromsql; String findSql = selectsql + fromsql; // 前端传了排序字段,并且排序字段存在相关表中 if (StrKit.notBlank(pp.getSort_field()) && Sandfarm.dao.hasColunm(pp.getSort_field())) { findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field(); if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) { findSql += " " + Const.ORDER_BY_ASC; } else { findSql += " " + Const.ORDER_BY_DESC; } } return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); } public List list() { return Sandfarm.dao.find("select * from sandfarm t where t.del = 0 "); } }