chall.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/workflow/model"
  5. )
  6. // ChallByIDs get chall list by ids.
  7. func (d *Dao) ChallByIDs(c context.Context, cids []int64) (res map[int64]*model.Chall, err error) {
  8. if len(cids) <= 0 {
  9. return
  10. }
  11. res = make(map[int64]*model.Chall)
  12. cList := make([]*model.Chall, 0, len(cids))
  13. if err = d.ReadORM.Table("workflow_chall").Select("id, business, dispatch_state, dispatch_time").Where("id IN (?)", cids).Find(&cList).Error; err != nil {
  14. return
  15. }
  16. for _, c := range cList {
  17. res[c.ID] = c
  18. }
  19. return
  20. }
  21. // UpDispatchStateByIDs update by ids.
  22. func (d *Dao) UpDispatchStateByIDs(c context.Context, cids []int64, dispatchState int64) (err error) {
  23. err = d.WriteORM.Table("workflow_chall").Where("id IN (?)", cids).Update("dispatch_state", dispatchState).Error
  24. return
  25. }
  26. // UpDispatchStateAdminIDByIds .
  27. func (d *Dao) UpDispatchStateAdminIDByIds(c context.Context, cids []int64, dispatchState, assignAdminid int64) (err error) {
  28. err = d.WriteORM.Table("workflow_chall").Where("id IN (?)", cids).Update("dispatch_state", dispatchState).Update("assignee_adminid", assignAdminid).Error
  29. return
  30. }