interface.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. func NewStoreEntry(cfg *config.AppConfig, Db *kptstore.DB) *StoreEntry {
  31. return &StoreEntry{
  32. Cfg: cfg,
  33. DB: Db,
  34. WxClient: nil,
  35. }
  36. }
  37. //go:generate mockgen -destination mock/kptservice.go -package kptservicemock kpt-tmr-group/module/backend KptService
  38. type KptService interface {
  39. PastureService // 牧场相关操作
  40. SystemService // 系统相关操作
  41. WxAppletService // 小程序相关
  42. StatisticService // 统计分析
  43. }
  44. type PastureService interface {
  45. // CreateGroupPasture 牧场管理相关
  46. CreateGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  47. EditGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  48. SearchGroupPastureList(ctx context.Context, req *operationPb.SearchPastureRequest) (*operationPb.SearchPastureResponse, error)
  49. DeleteGroupPasture(ctx context.Context, pastureId int64) error
  50. ResetPasswordGroupPasture(ctx context.Context, pastureId int64) error
  51. IsShowGroupPasture(ctx context.Context, req *operationPb.IsShowGroupPasture) error
  52. // ParentCattleCategoryList 牧畜类别
  53. ParentCattleCategoryList(ctx context.Context) map[operationPb.CattleCategoryParent_Kind]string
  54. AddCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  55. EditCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  56. IsShowCattleCategory(ctx context.Context, req *operationPb.IsShowCattleCategory) error
  57. DeleteCattleCategory(ctx context.Context, cattleCategoryId int64) error
  58. SearchCattleCategoryList(ctx context.Context, req *operationPb.SearchCattleCategoryRequest) (*operationPb.SearchCattleCategoryResponse, error)
  59. // ParentForageCategoryList 饲料类别相关
  60. ParentForageCategoryList(ctx context.Context) map[operationPb.ForageCategoryParent_Kind]string
  61. AddForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  62. EditForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  63. IsShowForageCategory(ctx context.Context, req *operationPb.IsShowForageCategory) error
  64. DeleteForageCategory(ctx context.Context, cattleCategoryId int64) error
  65. SearchForageCategoryList(ctx context.Context, req *operationPb.SearchForageCategoryRequest) (*operationPb.SearchForageCategoryResponse, error)
  66. // CreateForage 饲料相关
  67. CreateForage(ctx context.Context, req *operationPb.AddForageRequest) error
  68. EditForage(ctx context.Context, req *operationPb.AddForageRequest) error
  69. SearchForageList(ctx context.Context, req *operationPb.SearchForageListRequest) (*operationPb.SearchForageListResponse, error)
  70. ForageEnumList(ctx context.Context) *operationPb.ForageEnumListResponse
  71. DeleteForageList(ctx context.Context, ids []int64) error
  72. IsShowForage(ctx context.Context, req *operationPb.IsShowForage) error
  73. ExcelImportForage(ctx context.Context, req io.Reader) error
  74. ExcelExportForage(ctx context.Context, req *operationPb.SearchForageListRequest) (*bytes.Buffer, error)
  75. ExcelTemplateForage(ctx context.Context) (*bytes.Buffer, error)
  76. // CreateFeedFormula 饲料配方
  77. CreateFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  78. EditFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  79. SearchFeedFormulaList(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error)
  80. IsShowFeedFormula(ctx context.Context, req *operationPb.IsShowModifyFeedFormula) error
  81. DeleteFeedFormula(ctx context.Context, feedFormulaId int64) error
  82. ExcelImportFeedFormula(ctx context.Context, req io.Reader) error
  83. ExcelExportFeedFormula(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error)
  84. ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
  85. }
  86. type SystemService interface {
  87. // Auth 系统用户相关
  88. Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
  89. GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)
  90. CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  91. SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
  92. EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  93. DeleteSystemUser(ctx context.Context, userId int64) error
  94. ResetPasswordSystemUser(ctx context.Context, userId int64) error
  95. DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
  96. IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
  97. GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error)
  98. // CreateSystemRole 系统角色相关
  99. CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  100. EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  101. DeleteSystemRole(ctx context.Context, roleId int64) error
  102. GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
  103. SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
  104. // CreateSystemMenu 系统菜单权限
  105. CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  106. EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  107. IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
  108. SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
  109. DeleteSystemMenu(ctx context.Context, menuId int64) error
  110. // SearchMobileList 移动端
  111. SearchMobileList(ctx context.Context, req *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error)
  112. }
  113. type StatisticService interface {
  114. SearchFormulaEstimateList(ctx context.Context, req *operationPb.SearchFormulaEstimateRequest) (*operationPb.SearchFormulaEstimateResponse, error)
  115. }
  116. type WxAppletService interface {
  117. GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
  118. }