sunty
2019-08-01 49aafc75edad4497abe99e37a6146321891fbffb
add dbtable enable determination
2个文件已修改
22 ■■■■■ 已修改文件
controllers/dbtablesCon.go 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/model.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dbtablesCon.go
@@ -7,6 +7,7 @@
    "github.com/gin-gonic/gin"
    "github.com/satori/go.uuid"
    "log"
    "time"
    "webserver/extend/code"
    "webserver/extend/config"
    "webserver/extend/esutil"
@@ -159,6 +160,26 @@
    url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
        "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexType + "/" + tableId + "?refresh=wait_for"
    dbtable.PriInsert() // 添加时间和创建人
    currentTime := time.Now()
    startTime := dbtable.StartTime
    endTime := ""
    if dbtable.EndTime != "" {
        endTime = dbtable.EndTime
    }
    st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
    if endTime != "" {
        et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
        if et.After(currentTime) && st.Before(currentTime) {
            dbtable.Enable = 1
        } else {
            dbtable.Enable = 0
        }
    } else if st.Before(currentTime) && endTime == "" {
        dbtable.Enable = 1
    } else {
        dbtable.Enable = 0
    }
    dbTableByte, err := json.Marshal(dbtable)
    if err != nil {
        log.Fatalf("Json marshaling failed:%s", err)
models/model.go
@@ -15,7 +15,6 @@
    dp.CreateTime = time.Now().Format("2006-01-02 15:04:05")
    dp.CreateBy = "admin"
    dp.IsDelete = 0
    dp.Enable = 1
}
func (dp *BaseEntity) PriUpdate() {