mop-audit-manage-svr.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package client
  2. import (
  3. "context"
  4. "encoding/json"
  5. "errors"
  6. "mop-account-system/common"
  7. "mop-account-system/config"
  8. )
  9. //获取审核配置的roleId列表
  10. type GetAuditRolesRspData struct {
  11. UpdatorId string `json:"updatorId"`
  12. UpdatorName string `json:"updatorName"`
  13. UpdateTime int64 `json:"updateTime"`
  14. RoleInfos []struct {
  15. RoleId string `json:"roleId"`
  16. RoleName string `json:"roleName"`
  17. } `json:"roleInfos"`
  18. }
  19. type GetAuditRolesRsp struct {
  20. Errcode string `json:"errcode"`
  21. Error string `json:"error"`
  22. Data GetAuditRolesRspData `json:"data"`
  23. }
  24. func GetAuditRoles(ctx context.Context) (*GetAuditRolesRspData, error) {
  25. url := config.Cfg.AuditManageHost + "/api/v1/mop/mop-audit-manage-svr/operation/audit-roles"
  26. var headers = map[string]string{
  27. "Accept": "application/json, text/plain, */*",
  28. "Content-Type": "application/json",
  29. }
  30. rsp, err := Request(ctx).SetHeaders(headers).Get(url)
  31. if err != nil {
  32. common.GinLog.Errorln("GetAuditRoles status err:" + err.Error())
  33. return nil, err
  34. }
  35. if rsp.StatusCode() != 200 {
  36. common.GinLog.Errorln("GetAuditRoles status err:" + rsp.String())
  37. return nil, errors.New("status err")
  38. }
  39. var rspInfo GetAuditRolesRsp
  40. err = json.Unmarshal(rsp.Body(), &rspInfo)
  41. if err != nil {
  42. common.GinLog.Errorln("json.Unmarshal err:" + err.Error())
  43. return nil, err
  44. }
  45. common.GinLog.Infof("GetAuditRoles rsp:%+v", rspInfo)
  46. return &rspInfo.Data, nil
  47. }
  48. //根据成员列表查询未处理的代办
  49. type GetAccountTodosRspData struct {
  50. Total int `json:"total"`
  51. List []struct {
  52. TodoType string `json:"todoType"`
  53. OrganizatioName string `json:"organizatioName"`
  54. AppId string `json:"appId"`
  55. Sequence int `json:"sequence"`
  56. AppName string `json:"appName"`
  57. ApplicationTime int64 `json:"applicationTime"`
  58. AuditorName string `json:"auditorName"`
  59. Status string `json:"status"`
  60. } `json:"list"`
  61. }
  62. type GetAccountTodosRsp struct {
  63. Errcode string `json:"errcode"`
  64. Error string `json:"error"`
  65. Data GetAccountTodosRspData `json:"data"`
  66. }
  67. func GetAccountTodos(ctx context.Context, list []string) (*GetAccountTodosRspData, error) {
  68. url := config.Cfg.AuditManageHost + "/api/v1/mop/mop-audit-manage-svr/operation/todos" + "?pageNo=0&pageSize=10"
  69. var headers = map[string]string{
  70. "Accept": "application/json, text/plain, */*",
  71. "Content-Type": "application/json",
  72. }
  73. type ReqData struct {
  74. UserIds []string `json:"userIds"`
  75. }
  76. req := ReqData{UserIds: list}
  77. rsp, err := Request(ctx).SetHeaders(headers).SetBody(req).Post(url)
  78. if err != nil {
  79. common.GinLog.Errorln("GetAccountTodos status err:" + err.Error())
  80. return nil, err
  81. }
  82. if rsp.StatusCode() != 200 {
  83. common.GinLog.Errorln("GetAccountTodos status err:" + rsp.String())
  84. return nil, errors.New("status err")
  85. }
  86. var rspInfo GetAccountTodosRsp
  87. err = json.Unmarshal(rsp.Body(), &rspInfo)
  88. if err != nil {
  89. common.GinLog.Errorln("json.Unmarshal err:" + err.Error())
  90. return nil, err
  91. }
  92. common.GinLog.Infof("GetAccountTodos rsp:%+v", rspInfo)
  93. return &rspInfo.Data, nil
  94. }