interface.go 6.7 KB

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