All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.systemtool.entity.FinalLogExceptionEntity Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.fastchar.systemtool.entity;

import com.fastchar.core.FastChar;
import com.fastchar.extjs.FastExtHelper;
import com.fastchar.extjs.core.FastExtEntity;
import com.fastchar.database.FastPage;
import com.fastchar.database.info.FastSqlInfo;
import com.fastchar.utils.FastDateUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class FinalLogExceptionEntity extends FastExtEntity {
    private static final long serialVersionUID = 1L;

    public static FinalLogExceptionEntity dao() {
        return FastChar.getOverrides().singleInstance(FinalLogExceptionEntity.class);
    }

    public static FinalLogExceptionEntity newInstance() {
        return FastChar.getOverrides().newInstance(FinalLogExceptionEntity.class);
    }

    @Override
    public String getTableName() {
        return "final_log_exception";
    }

    @Override
    public String getTableDetails() {
        return "系统异常日志";
    }

    @Override
    public String getEntityCode() {
        return this.getClass().getSimpleName();
    }

    @Override
    public FastPage showList(int page, int pageSize) {


        String sqlStr = "select t.*" +
                " from final_log_exception as t" +
                " ";
        FastSqlInfo sqlInfo = toSelectSql(sqlStr);
        return selectBySql(page, pageSize, sqlInfo.getSql(), sqlInfo.toParams());
    }

    @Override
    public void setDefaultValue() {
        set("logDateTime", FastDateUtils.getDateString());
    }

    @Override
    public void convertValue() {
        super.convertValue();

    }


    public void clearData(int keepDay) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Calendar minCalendar = Calendar.getInstance();
        minCalendar.add(Calendar.DAY_OF_MONTH, -(keepDay + 1));
        String sqlStr = "delete from final_log_exception where date_format(logDateTime,'%Y-%m-%d') <= ? ";
        String format = simpleDateFormat.format(minCalendar.getTime());
        int updateBySql = updateBySql(sqlStr, format);
        if (updateBySql > 0) {
            FastExtHelper.addWaitInfo("系统异常日志清除", "已成功删除" +
                    format + "之前的" + updateBySql + "条系统异常日志!");
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy