fix: ne_state table issue
This commit is contained in:
@@ -1453,6 +1453,15 @@ func XormDeleteDataByWhere(where, table string) (int64, error) {
|
||||
return affected, nil
|
||||
}
|
||||
|
||||
func XormDeleteDataByWhereNoSession(where, table string) (int64, error) {
|
||||
affected, err := DbClient.XEngine.Table(table).Where(where).Delete()
|
||||
if err != nil {
|
||||
log.Error("Failed to Delete:", err)
|
||||
return 0, err
|
||||
}
|
||||
return affected, nil
|
||||
}
|
||||
|
||||
func XormDeleteDataById(id int, table string) (int64, error) {
|
||||
log.Debug("XormDeleteDataByWhere processing... ")
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ type BarParams struct {
|
||||
TableName string `json:"tableName"`
|
||||
ColName string `json:"colName"` // column name of time string
|
||||
Extras string `json:"extras"` // extras condition for where
|
||||
SessFlag bool `json:"sessFlag"` // session flag, true: session model, false: no session
|
||||
}
|
||||
|
||||
func (s *BarProcessor) Execute(data any) (any, error) {
|
||||
@@ -74,11 +75,20 @@ func (s *BarProcessor) Execute(data any) (any, error) {
|
||||
where = fmt.Sprintf("NOW()>ADDDATE(`%s`,interval %d day) and %s", params.ColName, params.Duration, params.Extras)
|
||||
}
|
||||
|
||||
affected, err := dborm.XormDeleteDataByWhere(where, params.TableName)
|
||||
var affected int64 = 0
|
||||
if params.SessFlag {
|
||||
affected, err = dborm.XormDeleteDataByWhere(where, params.TableName)
|
||||
if err != nil {
|
||||
// panic(fmt.Sprintf("Failed to XormDeleteDataByWhere:%v", err))
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
affected, err = dborm.XormDeleteDataByWhereNoSession(where, params.TableName)
|
||||
if err != nil {
|
||||
// panic(fmt.Sprintf("Failed to XormDeleteDataByWhere:%v", err))
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// 返回结果,用于记录执行结果
|
||||
return map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user