public class LugiaPlanPoaBidPrice extends Model<LugiaPlanPoaBidPrice> {
public static final LugiaPlanPoaBidPrice dao = new LugiaPlanPoaBidPrice();
public int getId() {
return getInt("id");
}
public int getAppId() {
return getInt("app_id");
}
public int getMarketId() {
return getInt("market_id");
}
public int getPlanId() {
return getInt("plan_id");
}
public Date getDth() {
return getDate("dth");
}
public BigDecimal getPrice() {
return getBigDecimal("price");
}
public static final LugiaPlanPoaBidPrice findFirstPoaBidPrice(int planId, String date) {
return dao.findFirst("select * from lugia_plan_poa_bid_price where plan_id=? and dth=?", planId, date);
}
public void saveOrUpdate() {
LugiaPlanPoaBidPrice inDb = dao.findFirst("select * from lugia_plan_poa_bid_price where dth=? and plan_id=? and app_id=? and market_id=?",
get("dth"), get("plan_id"), get("app_id"), get("market_id"));
if (inDb == null) {
this.save();//新的记录主键重复
} else {
this.set("id", inDb.getId());
this.update();
}
}
}