rcvr.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package impl
  2. import (
  3. "context"
  4. "gd_admin/apis"
  5. "gd_admin/impl/action"
  6. "gd_admin/impl/admin"
  7. "gd_admin/impl/auth"
  8. "gd_admin/impl/dbmodel"
  9. "gd_admin/impl/rbac"
  10. "gd_admin/common.in/task"
  11. "github.com/astaxie/beego/orm"
  12. )
  13. // 具体实现
  14. type Rcvr struct {
  15. }
  16. func (c *Rcvr) AdminLogin(ctx context.Context, req *apis.AdminLoginReq, reply *apis.AdminLoginReply) error {
  17. t1 := func() error {
  18. return admin.AdminLogin(ctx, req, reply)
  19. }
  20. return task.Do(ctx, t1)
  21. }
  22. func (c *Rcvr) AdminRegister(ctx context.Context, req *apis.AdminRegisterReq, reply *apis.AdminRegisterReply) error {
  23. t1 := func() error {
  24. return admin.AdminRegister(ctx, req, reply)
  25. }
  26. return task.Do(ctx, t1)
  27. }
  28. func (c *Rcvr) AdminDelete(ctx context.Context, req *apis.AdminDeleteReq, reply *apis.AdminDeleteReply) error {
  29. t1 := func() error {
  30. return admin.AdminDelete(ctx, req, reply)
  31. }
  32. return task.Do(ctx, t1)
  33. }
  34. func (c *Rcvr) AdminModify(ctx context.Context, req *apis.AdminModifyReq, reply *apis.AdminModifyReply) error {
  35. t1 := func() error {
  36. return admin.AdminModify(ctx, req, reply)
  37. }
  38. return task.Do(ctx, t1)
  39. }
  40. func (c *Rcvr) AdminGetAll(ctx context.Context, req *apis.AdminGetAllReq, reply *apis.AdminGetAllReply) error {
  41. t1 := func() error {
  42. return admin.AdminGetAll(ctx, req, reply)
  43. }
  44. return task.Do(ctx, t1)
  45. }
  46. func (c *Rcvr) GetRbacAccess(ctx context.Context, req *apis.GetAccessReq, reply *apis.GetAccessReply) error {
  47. t1 := func() error {
  48. return rbac.GetAccess(ctx, req, reply)
  49. }
  50. return task.Do(ctx, t1)
  51. }
  52. func (c *Rcvr) GetRbacGroupList(ctx context.Context, req *apis.GetRbacGroupListReq, reply *apis.GetRbacGroupListReply) error {
  53. t1 := func() error {
  54. return rbac.GetGroupList(ctx, req, reply)
  55. }
  56. return task.Do(ctx, t1)
  57. }
  58. func (c *Rcvr) UpdateRbacGroup(ctx context.Context, req *apis.UpdateRbacGroupReq, reply *apis.UpdateRbacGroupReply) error {
  59. t1 := func() error {
  60. return rbac.UpdateGroup(ctx, req, reply)
  61. }
  62. return task.Do(ctx, t1)
  63. }
  64. func (c *Rcvr) DeleteRbacGroup(ctx context.Context, req *apis.DeleteRbacGroupReq, reply *apis.DeleteRbacGroupReply) error {
  65. t1 := func() error {
  66. return rbac.DeleteGroup(ctx, req, reply)
  67. }
  68. return task.Do(ctx, t1)
  69. }
  70. func (c *Rcvr) AddRbacGroup(ctx context.Context, req *apis.AddRbacGroupReq, reply *apis.AddRbacGroupReply) error {
  71. t1 := func() error {
  72. return rbac.AddGroup(ctx, req, reply)
  73. }
  74. return task.Do(ctx, t1)
  75. }
  76. func (c *Rcvr) GetNodeList(ctx context.Context, req *apis.GetNodeListReq, reply *apis.GetNodeListReply) error {
  77. t1 := func() error {
  78. return rbac.GetList(ctx, req, reply)
  79. }
  80. return task.Do(ctx, t1)
  81. }
  82. func (c *Rcvr) UpdateAdminStatus(ctx context.Context, req *apis.UpdateStatusReq, reply *apis.UpdateStatusReply) error {
  83. t1 := func() error {
  84. return admin.UpdateStatus(ctx, req, reply)
  85. }
  86. return task.Do(ctx, t1)
  87. }
  88. func (c *Rcvr) GetInfo(ctx context.Context, req *apis.GetInfoReq, reply *apis.GetInfoReply) error {
  89. t1 := func() error {
  90. return admin.GetInfo(ctx, req, reply)
  91. }
  92. return task.Do(ctx, t1)
  93. }
  94. // AddActionLog 添加用户行为日志
  95. func (c *Rcvr) AddActionLog(ctx context.Context, req *apis.AddActionLogReq, reply *apis.AddActionLogReply) error {
  96. t1 := func() error {
  97. return action.Add(ctx, req, reply)
  98. }
  99. return task.Do(ctx, t1)
  100. }
  101. // GetActionLog 获取用户行为日志
  102. func (c *Rcvr) GetActionLog(ctx context.Context, req *apis.GetLogReq, reply *apis.GetLogReply) error {
  103. t1 := func() error {
  104. return action.Log(ctx, req, reply)
  105. }
  106. return task.Do(ctx, t1)
  107. }
  108. // 获取oss sts授权
  109. func (r *Rcvr) AuthGetOSSInfo(ctx context.Context, req *apis.AuthGetOSSInfoReq, reply *apis.AuthGetOSSInfoReply) (err error) {
  110. t1 := func() error {
  111. return auth.AuthGetOSSInfo(ctx, req, reply)
  112. }
  113. return task.Do(ctx, t1)
  114. }
  115. func RegisterOrmModel() {
  116. orm.RegisterModel(new(apis.AdminInfo),
  117. new(admin.AdminLoginLog),
  118. new(dbmodel.TGdAdminRbacAccess),
  119. new(dbmodel.TGdAdminRbacGroup),
  120. new(dbmodel.TGdAdminRbacNode),
  121. new(dbmodel.Action))
  122. }