interface.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package backend
  2. import (
  3. "context"
  4. "kpt-calf-feed/config"
  5. "kpt-calf-feed/service/wechat"
  6. "kpt-calf-feed/store/kptstore"
  7. operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
  8. "gitee.com/xuyiping_admin/pkg/di"
  9. "go.uber.org/dig"
  10. )
  11. var Module = di.Options(di.Provide(NewStore))
  12. type Hub struct {
  13. dig.In
  14. OpsService KptService
  15. }
  16. type StoreEntry struct {
  17. dig.In
  18. Cfg *config.AppConfig
  19. DB *kptstore.DB
  20. HttpClient *wechat.ClientService
  21. }
  22. func NewStore(store StoreEntry) KptService {
  23. return &store
  24. }
  25. func NewStoreEntry(cfg *config.AppConfig, Db *kptstore.DB) *StoreEntry {
  26. return &StoreEntry{
  27. Cfg: cfg,
  28. DB: Db,
  29. HttpClient: nil,
  30. }
  31. }
  32. //go:generate mockgen -destination mock/kptservice.go -package kptservicemock kpt-calf-feed/module/backend KptService
  33. type KptService interface {
  34. SystemService // 系统相关操作
  35. }
  36. //go:generate mockgen -destination mock/SystemService.go -package kptservicemock kpt-calf-feed/module/backend SystemService
  37. type SystemService interface {
  38. // Auth 系统用户相关
  39. Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
  40. GetCurrentUserName(ctx context.Context) (string, error)
  41. GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)
  42. CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  43. SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
  44. EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  45. DeleteSystemUser(ctx context.Context, userId int64) error
  46. ResetPasswordSystemUser(ctx context.Context, userId int64) error
  47. DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
  48. IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
  49. GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error)
  50. // CreateSystemRole 系统角色相关
  51. CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  52. EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  53. DeleteSystemRole(ctx context.Context, roleId int64) error
  54. GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
  55. SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
  56. // CreateSystemMenu 系统菜单权限
  57. CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  58. EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  59. IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
  60. SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
  61. DeleteSystemMenu(ctx context.Context, menuId int64) error
  62. }