appeal.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package dao
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/workflow/model"
  6. "github.com/jinzhu/gorm"
  7. )
  8. // consts for workflow business_state
  9. const (
  10. BusStCreated = int8(1) // 未处理
  11. BusStRead = int8(2) // 已回复已读
  12. BusStAutoClosed = int8(5) // 过期自动关闭
  13. BusStNotRead = int8(6) // 已回复未读
  14. )
  15. // Appeals .
  16. func (d *Dao) Appeals(c context.Context, ids []int64) (appeals []*model.Appeal, err error) {
  17. err = d.ReadORM.Table("workflow_appeal").Where("id in (?)", ids).Find(&appeals).Error
  18. return
  19. }
  20. // SetAppealTransferState will close expired feedback 关闭超时的申诉 (用户未评价)
  21. func (d *Dao) SetAppealTransferState(c context.Context, ids []int64, transferState int8) (err error) {
  22. err = d.WriteORM.Table("workflow_appeal").Where("id IN (?)", ids).Update("transfer_state", transferState).
  23. Update("ttime", time.Now().Format("2006-01-02 15:04:05")).Error
  24. return
  25. }
  26. // TxSetWeight db覆盖权重值
  27. func (d *Dao) TxSetWeight(tx *gorm.DB, newWeight map[int64]int64) (err error) {
  28. for id, weight := range newWeight {
  29. if err = tx.Table("workflow_appeal").Where("id = ?", id).Update("weight", weight).Error; err != nil {
  30. return
  31. }
  32. }
  33. return
  34. }
  35. // SetAppealAssignState .
  36. func (d *Dao) SetAppealAssignState(c context.Context, ids []int64, assignState int8) (err error) {
  37. return d.WriteORM.Table("workflow_appeal").Where("id in (?)", ids).Update("assign_state", assignState).Error
  38. }
  39. // LastEvent return last event of appeal_id
  40. func (d *Dao) LastEvent(id int64) (e *model.Event, err error) {
  41. e = new(model.Event)
  42. err = d.ReadORM.Table("workflow_event").Where("appeal_id = ?", id).Last(e).Error
  43. return
  44. }