interface.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package backend
  2. import (
  3. "bytes"
  4. "context"
  5. "io"
  6. "kpt-tmr-group/config"
  7. "kpt-tmr-group/pkg/di"
  8. operationPb "kpt-tmr-group/proto/go/backend/operation"
  9. "kpt-tmr-group/service/wechat"
  10. "kpt-tmr-group/store/kptstore"
  11. "go.uber.org/dig"
  12. )
  13. var Module = di.Options(di.Provide(NewStore))
  14. type Hub struct {
  15. dig.In
  16. OpsService KptService
  17. }
  18. type StoreEntry struct {
  19. dig.In
  20. Cfg *config.AppConfig
  21. DB *kptstore.DB
  22. //SSO *sso.Cache
  23. // AsynqClient asynqsvc.Client
  24. // Cache *redis.Client
  25. WxClient *wechat.ClientService
  26. }
  27. func NewStore(store StoreEntry) KptService {
  28. return &store
  29. }
  30. type KptService interface {
  31. Operation
  32. SystemOperation
  33. WxAppletService
  34. }
  35. type Operation interface {
  36. // CreateGroupPasture 牧场管理相关
  37. CreateGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  38. EditGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  39. SearchGroupPastureList(ctx context.Context, req *operationPb.SearchPastureRequest) (*operationPb.SearchPastureResponse, error)
  40. DeleteGroupPasture(ctx context.Context, pastureId int64) error
  41. ResetPasswordGroupPasture(ctx context.Context, pastureId int64) error
  42. IsShowGroupPasture(ctx context.Context, req *operationPb.IsShowGroupPasture) error
  43. // ParentCattleCategoryList 牧畜类别
  44. ParentCattleCategoryList(ctx context.Context) map[operationPb.CattleCategoryParent_Kind]string
  45. AddCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  46. EditCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  47. IsShowCattleCategory(ctx context.Context, req *operationPb.IsShowCattleCategory) error
  48. DeleteCattleCategory(ctx context.Context, cattleCategoryId int64) error
  49. SearchCattleCategoryList(ctx context.Context, req *operationPb.SearchCattleCategoryRequest) (*operationPb.SearchCattleCategoryResponse, error)
  50. // ParentForageCategoryList 饲料类别相关
  51. ParentForageCategoryList(ctx context.Context) map[operationPb.ForageCategoryParent_Kind]string
  52. AddForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  53. EditForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  54. IsShowForageCategory(ctx context.Context, req *operationPb.IsShowForageCategory) error
  55. DeleteForageCategory(ctx context.Context, cattleCategoryId int64) error
  56. SearchForageCategoryList(ctx context.Context, req *operationPb.SearchForageCategoryRequest) (*operationPb.SearchForageCategoryResponse, error)
  57. // CreateForage 饲料相关
  58. CreateForage(ctx context.Context, req *operationPb.AddForageRequest) error
  59. EditForage(ctx context.Context, req *operationPb.AddForageRequest) error
  60. SearchForageList(ctx context.Context, req *operationPb.SearchForageListRequest) (*operationPb.SearchForageListResponse, error)
  61. ForageEnumList(ctx context.Context) *operationPb.ForageEnumList
  62. DeleteForageList(ctx context.Context, ids []int64) error
  63. IsShowForage(ctx context.Context, req *operationPb.IsShowForage) error
  64. ExcelImportForage(ctx context.Context, req io.Reader) error
  65. ExcelExportForage(ctx context.Context, req *operationPb.SearchForageListRequest) (*bytes.Buffer, error)
  66. ExcelTemplateForage(ctx context.Context) (*bytes.Buffer, error)
  67. // CreateFeedFormula 饲料配方
  68. CreateFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  69. EditFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  70. SearchFeedFormulaList(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error)
  71. IsShowFeedFormula(ctx context.Context, req *operationPb.IsShowModifyFeedFormula) error
  72. DeleteFeedFormula(ctx context.Context, feedFormulaId int64) error
  73. ExcelImportFeedFormula(ctx context.Context, req io.Reader) error
  74. ExcelExportFeedFormula(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error)
  75. ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
  76. }
  77. type SystemOperation interface {
  78. // Auth 系统用户相关
  79. Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
  80. GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)
  81. CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  82. SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
  83. EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  84. DeleteSystemUser(ctx context.Context, userId int64) error
  85. ResetPasswordSystemUser(ctx context.Context, userId int64) error
  86. DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
  87. IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
  88. GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error)
  89. // CreateSystemRole 系统角色相关
  90. CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  91. EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  92. DeleteSystemRole(ctx context.Context, roleId int64) error
  93. GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
  94. SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
  95. // CreateSystemMenu 系统菜单权限
  96. CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  97. EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  98. IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
  99. SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
  100. DeleteSystemMenu(ctx context.Context, menuId int64) error
  101. // SearchMobileList 移动端
  102. SearchMobileList(ctx context.Context, req *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error)
  103. }
  104. type WxAppletService interface {
  105. GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
  106. }