task_status.go 496 B

1234567891011121314151617181920212223
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. )
  6. const (
  7. // insert
  8. _inTaskStatusSQL = "INSERT INTO task_status(type, status, date, message) VALUES %s ON DUPLICATE KEY UPDATE status=VALUES(status), message=VALUES(message)"
  9. )
  10. // InsertTaskStatus insert task status
  11. func (d *Dao) InsertTaskStatus(c context.Context, val string) (rows int64, err error) {
  12. if val == "" {
  13. return
  14. }
  15. res, err := d.db.Exec(c, fmt.Sprintf(_inTaskStatusSQL, val))
  16. if err != nil {
  17. return
  18. }
  19. return res.RowsAffected()
  20. }