You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.4 KiB
83 lines
2.4 KiB
package #(packageName).model;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.jfinal.kit.Kv;
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
/**
|
|
* 作者:#(Author)
|
|
* 时间:#(CurrentTime)
|
|
*/
|
|
public class #(className)Model {
|
|
|
|
/**
|
|
* 功能:增加#(ClassMemo)
|
|
* 作者:#(Author)
|
|
* 时间:#(CurrentTime)
|
|
* @return
|
|
*/
|
|
public int add#(ClassName)(#(add_Params))
|
|
{
|
|
Record record=new Record();
|
|
#(setRecordAddParams)
|
|
Db.save("#(table_name)","#(pk)",record);
|
|
return record.getInt("#(pk)");
|
|
}
|
|
/**
|
|
* 功能:修改#(ClassMemo)
|
|
* 作者:#(Author)
|
|
* 时间:#(CurrentTime)
|
|
* @return
|
|
*/
|
|
public void update#(ClassName)(#(update_Params))
|
|
{
|
|
Record record = Db.findById("#(table_name)", "#(pk)", #(pk));
|
|
#(setRecordUpdateParams)
|
|
Db.update("#(table_name)","#(pk)",record);
|
|
return;
|
|
}
|
|
/**
|
|
* 功能:删除#(ClassMemo)
|
|
* 作者:#(Author)
|
|
* 时间:#(CurrentTime)
|
|
* @return
|
|
*/
|
|
public void delete#(ClassName)ById(#(delete_Params))
|
|
{
|
|
//Record record = Db.findById("#(table_name)", "#(pk)", #(pk));
|
|
//record.set("b_use",0);
|
|
//Db.update("#(table_name)","#(pk)",record);
|
|
Db.deleteById("#(table_name)","#(pk)",#(pk));
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* 功能:获取#(ClassMemo)分页数据
|
|
* 作者:#(Author)
|
|
* 时间:#(CurrentTime)
|
|
* @return
|
|
*/
|
|
public Page<Record> get#(ClassName)Page(int page,int limit)
|
|
{
|
|
//Kv kv=Kv.by("startDate",startDate).set("endDate",endDate);
|
|
SqlPara sqlPara = Db.getSqlPara("#(className).get#(ClassName)Page");
|
|
String sql = sqlPara.getSql();
|
|
String totalRowSql = "select count(*) from (" + sql + " ) as t100";
|
|
String findSql = "select * from (" + sql + " ) as t100 #(sort_condition)";
|
|
Page<Record> pageRecord = Db.paginateByFullSql(page, limit, totalRowSql, findSql);
|
|
return pageRecord;
|
|
}
|
|
/**
|
|
* 功能:获取#(ClassMemo)某一条记录信息
|
|
* 作者:#(Author)
|
|
* 时间:#(CurrentTime)
|
|
* @return
|
|
*/
|
|
public Record get#(ClassName)ById(#(delete_Params)) {
|
|
return Db.findById("#(table_name)","#(pk)",#(pk));
|
|
}
|
|
}
|