fix: ne_state table issue
This commit is contained in:
@@ -1453,6 +1453,15 @@ func XormDeleteDataByWhere(where, table string) (int64, error) {
|
|||||||
return affected, nil
|
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) {
|
func XormDeleteDataById(id int, table string) (int64, error) {
|
||||||
log.Debug("XormDeleteDataByWhere processing... ")
|
log.Debug("XormDeleteDataByWhere processing... ")
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ type BarProcessor struct {
|
|||||||
type BarParams struct {
|
type BarParams struct {
|
||||||
Duration int `json:"duration"`
|
Duration int `json:"duration"`
|
||||||
TableName string `json:"tableName"`
|
TableName string `json:"tableName"`
|
||||||
ColName string `json:"colName"` // column name of time string
|
ColName string `json:"colName"` // column name of time string
|
||||||
Extras string `json:"extras"` // extras condition for where
|
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) {
|
func (s *BarProcessor) Execute(data any) (any, error) {
|
||||||
@@ -74,10 +75,19 @@ 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)
|
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 err != nil {
|
if params.SessFlag {
|
||||||
// panic(fmt.Sprintf("Failed to XormDeleteDataByWhere:%v", err))
|
affected, err = dborm.XormDeleteDataByWhere(where, params.TableName)
|
||||||
return nil, err
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回结果,用于记录执行结果
|
// 返回结果,用于记录执行结果
|
||||||
|
|||||||
Reference in New Issue
Block a user