package com.basic.security.manager;
|
|
import com.basic.security.model.Log;
|
import com.basic.security.model.ModelAdapter;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.UUID;
|
|
public class LogManager extends BaseManager {
|
static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
|
|
public static boolean saveLog(String message) {
|
try {
|
ModelAdapter log = new ModelAdapter();
|
log.setString(Log.message, message);
|
log.setString(Log.id, UUID.randomUUID().toString());
|
log.setString(Log.createTime, sdf.format(new Date()));
|
log.setString("table", Log.table);
|
save(log);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return true;
|
}
|
|
public static String weatherPrefix() {
|
return "weather" + sdf2.format(new Date());
|
}
|
|
public static String findWeather() {
|
ModelAdapter weather = findOne("select * from " + Log.table + " where " + Log.message + " like '" + weatherPrefix() + "%'");
|
if (weather != null) {
|
return weather.getString(Log.message).replace(weatherPrefix(), "");
|
}
|
return "";
|
}
|
|
public static void saveWeather(String json) {
|
saveLog(weatherPrefix() + json);
|
}
|
}
|