conflict-test-feat-20240117-001 #88

Merged
chenhao merged 12 commits from conflict-test-feat-20240117-001 into test 2024-02-02 07:44:18 +08:00
4 changed files with 14 additions and 17 deletions
Showing only changes of commit a5b635b5be - Show all commits

View File

@ -737,14 +737,14 @@ func (m *Mysql) GetWithdrawOrdersByMid(ctx *gin.Context, tx *sqlx.Tx, mid, st, e
} }
// 获取指定任务中所有已经执行成功的xxl_job任务 // 获取指定任务中所有已经执行成功的xxl_job任务
func (m *Mysql) GetSuccessXxlJobLogs(ctx *gin.Context, tx *sqlx.Tx, jobId int64, errorPrefix string) (list []*dbstruct.XxlJobLog, err error) { func (m *Mysql) GetSuccessXxlJobLogs(ctx *gin.Context, tx *sqlx.Tx, jobIdsStr string, errorPrefix string) (list []*dbstruct.XxlJobLog, err error) {
list = make([]*dbstruct.XxlJobLog, 0) list = make([]*dbstruct.XxlJobLog, 0)
sqlStr := fmt.Sprintf("select * from %s where job_id = ? and trigger_code = 200 and handle_code = 200 and trigger_msg not like (?%%)", TableXxlJobLog) sqlStr := fmt.Sprintf("select * from %s where job_id in (%s) and trigger_code = 200 and handle_code = 200 and trigger_msg not like ?", TableXxlJobLog, jobIdsStr)
if tx != nil { if tx != nil {
err = tx.SelectContext(ctx, &list, sqlStr, jobId, errorPrefix) err = tx.SelectContext(ctx, &list, sqlStr, "%"+errorPrefix)
} else { } else {
db := m.getDBXxlJob() db := m.getDBXxlJob()
err = db.SelectContext(ctx, &list, sqlStr, jobId, errorPrefix) err = db.SelectContext(ctx, &list, sqlStr, "%"+errorPrefix)
} }
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
err = nil err = nil
@ -758,7 +758,10 @@ func (m *Mysql) GetSuccessXxlJobLogs(ctx *gin.Context, tx *sqlx.Tx, jobId int64,
// 删除指定任务中所有已经执行成功的xxl_job任务 // 删除指定任务中所有已经执行成功的xxl_job任务
func (m *Mysql) DeleteSuccessXxlJobLogs(ctx *gin.Context, tx *sqlx.Tx, ids []int64) (err error) { func (m *Mysql) DeleteSuccessXxlJobLogs(ctx *gin.Context, tx *sqlx.Tx, ids []int64) (err error) {
sqlStr := fmt.Sprintf("delete * from %s where id in (%s)", TableXxlJobLog, util.Convert2SqlArr(ids)) if len(ids) == 0 {
return
}
sqlStr := fmt.Sprintf("delete from %s where id in (%s)", TableXxlJobLog, util.Convert2SqlArr(ids))
if tx != nil { if tx != nil {
_, err = tx.ExecContext(ctx, sqlStr) _, err = tx.ExecContext(ctx, sqlStr)
} else { } else {

View File

@ -25,11 +25,11 @@ func NewXxlJob(store *dao.Store, cfg *configcenter.XxlJobConfig) (x *XxlJob) {
} }
} }
func (x *XxlJob) ClearSuccXxlJobLogs(ctx *gin.Context, jobId int64, errorPrefix string) (err error) { func (x *XxlJob) ClearSuccXxlJobLogs(ctx *gin.Context, jobIdsStr string, errorPrefix string) (err error) {
// 查出当天所有已成功的日志 // 查出当天所有已成功的日志
list, err := x.store.GetSuccessXxlJobLogs(ctx, nil, jobId, errorPrefix) list, err := x.store.GetSuccessXxlJobLogs(ctx, nil, jobIdsStr, errorPrefix)
if err != nil { if err != nil {
logger.Error("GetSuccessXxlJobLogs fail, err: %v, jodId: %v, errorPrefix: %v", err, jobId, errorPrefix) logger.Error("GetSuccessXxlJobLogs fail, err: %v, jodId: %v, errorPrefix: %v", err, jobIdsStr, errorPrefix)
return return
} }
ids := make([]int64, 0) ids := make([]int64, 0)

View File

@ -15,7 +15,6 @@ import (
"service/library/contentaudit/textaudit" "service/library/contentaudit/textaudit"
"service/library/logger" "service/library/logger"
"service/library/redis" "service/library/redis"
"strconv"
"strings" "strings"
"time" "time"
@ -187,15 +186,10 @@ func (s *CronService) ClearContentAuditBatchExecutionLogs(ctx context.Context, p
if len(inParams) < 2 { if len(inParams) < 2 {
return "Wrong executor params format!" return "Wrong executor params format!"
} }
jobId := inParams[0] jobIdsStr := inParams[0]
errorPrefix := inParams[1] errorPrefix := inParams[1]
jobIdVal, err := strconv.Atoi(jobId) err := _DefaultXxlJob.ClearSuccXxlJobLogs(&gin.Context{}, jobIdsStr, errorPrefix)
if err != nil {
return err.Error()
}
err = _DefaultXxlJob.ClearSuccXxlJobLogs(&gin.Context{}, int64(jobIdVal), errorPrefix)
if err != nil { if err != nil {
return err.Error() return err.Error()
} }

View File

@ -98,4 +98,4 @@ xxl_job:
executor_ip: "127.0.0.1" executor_ip: "127.0.0.1"
executor_port: "9801" executor_port: "9801"
registry_key: "golang-jobs-executor" registry_key: "golang-jobs-executor"
log_path: "/Users/erwin/log/wishpal-ironfan/xxl_job" log_path: "/app/ironfan/log/xxl_job/"