workflow.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/app/interface/main/dm2/model"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. "go-common/library/net/metadata"
  10. )
  11. const (
  12. _workFlowTagList = "/x/internal/workflow/tag/v3/list"
  13. _workFlowAppealAdd = "/x/internal/workflow/appeal/v3/add"
  14. _workFlowAppealDelete = "/x/internal/workflow/appeal/v3/delete"
  15. )
  16. // WorkFlowTagList get tag list from workflow
  17. func (d *Dao) WorkFlowTagList(c context.Context, bid, rid int64) (data []*model.WorkFlowTag, err error) {
  18. var (
  19. res *model.WorkFlowTagListResp
  20. params = url.Values{}
  21. uri = d.conf.Host.API + _workFlowTagList
  22. ip = metadata.String(c, metadata.RemoteIP)
  23. )
  24. params.Set("bid", strconv.FormatInt(bid, 10))
  25. params.Set("rid", strconv.FormatInt(rid, 10))
  26. if err = d.httpCli.Get(c, uri, ip, params, &res); err != nil {
  27. log.Error("WorkFlowTagList(params:%v),error(%v)", params, err)
  28. return
  29. }
  30. if err = ecode.Int(res.Code); err != ecode.OK {
  31. log.Error("WorkFlowTagList(params:%v),error(%v)", params, err)
  32. return
  33. }
  34. data = res.Data
  35. err = nil
  36. return
  37. }
  38. // WorkFlowAppealAdd add a record to workflow
  39. func (d *Dao) WorkFlowAppealAdd(c context.Context, req *model.WorkFlowAppealAddReq) (err error) {
  40. var (
  41. res *model.CommonResponse
  42. uri = d.conf.Host.API + _workFlowAppealAdd
  43. ip = metadata.String(c, metadata.RemoteIP)
  44. )
  45. if err = d.httpCli.Post(c, uri, ip, req.Params(), &res); err != nil {
  46. log.Error("WorkFlowAppealAdd(req:%+v),error(%v)", req.Params(), err)
  47. return
  48. }
  49. if err = ecode.Int(res.Code); err != ecode.OK {
  50. log.Error("WorkFlowAppealAdd(req:%+v),error(%v)", req, err)
  51. return
  52. }
  53. err = nil
  54. return
  55. }
  56. // WorkFlowAppealDelete .
  57. func (d *Dao) WorkFlowAppealDelete(c context.Context, bid, oid, subtitleID int64) (err error) {
  58. var (
  59. res *model.CommonResponse
  60. params = url.Values{}
  61. uri = d.conf.Host.API + _workFlowAppealDelete
  62. ip = metadata.String(c, metadata.RemoteIP)
  63. )
  64. params.Set("business", strconv.FormatInt(bid, 10))
  65. params.Set("oid", strconv.FormatInt(oid, 10))
  66. params.Set("eid", strconv.FormatInt(subtitleID, 10))
  67. if err = d.httpCli.Post(c, uri, ip, params, &res); err != nil {
  68. log.Error("WorkFlowAppealDelete(params:%v),error(%v)", params, err)
  69. return
  70. }
  71. if err = ecode.Int(res.Code); err != ecode.OK {
  72. log.Error("WorkFlowAppealDelete(params:%v),error(%v)", params, err)
  73. return
  74. }
  75. err = nil
  76. return
  77. }