a
554325746@qq.com
2019-12-25 7340eb0b160eacbbd0f3c2289e3ac6150da235f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
    }
}