interface.go 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. HttpClient *wechat.ClientService
  24. }
  25. func NewStore(store StoreEntry) KptService {
  26. return &store
  27. }
  28. func NewStoreEntry(cfg *config.AppConfig, Db *kptstore.DB) *StoreEntry {
  29. return &StoreEntry{
  30. Cfg: cfg,
  31. DB: Db,
  32. HttpClient: nil,
  33. }
  34. }
  35. //go:generate mockgen -destination mock/kptservice.go -package kptservicemock kpt-tmr-group/module/backend KptService
  36. type KptService interface {
  37. PastureService // 牧场相关操作
  38. SystemService // 系统相关操作
  39. WxAppletService // 小程序相关
  40. StatisticService // 统计分析
  41. PastureSyncService // 牧场端数据同步
  42. }
  43. type PastureService interface {
  44. // CreateGroupPasture 牧场管理相关
  45. CreateGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  46. EditGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  47. SearchGroupPastureList(ctx context.Context, req *operationPb.SearchPastureRequest) (*operationPb.SearchPastureResponse, error)
  48. DeleteGroupPasture(ctx context.Context, pastureId int64) error
  49. ResetPasswordGroupPasture(ctx context.Context, pastureId int64) error
  50. IsShowGroupPasture(ctx context.Context, req *operationPb.IsShowGroupPasture) error
  51. // AddCattleCategory 牧畜类别
  52. AddCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  53. EditCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  54. IsShowCattleCategory(ctx context.Context, req *operationPb.IsShowCattleCategory) error
  55. DeleteCattleCategory(ctx context.Context, cattleCategoryId int64) error
  56. SearchCattleCategoryList(ctx context.Context, req *operationPb.SearchCattleCategoryRequest) (*operationPb.SearchCattleCategoryResponse, error)
  57. // AddForageCategory 饲料类别相关
  58. AddForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  59. EditForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  60. IsShowForageCategory(ctx context.Context, req *operationPb.IsShowForageCategory) error
  61. DeleteForageCategory(ctx context.Context, cattleCategoryId int64) error
  62. SearchForageCategoryList(ctx context.Context, req *operationPb.SearchForageCategoryRequest) (*operationPb.SearchForageCategoryResponse, error)
  63. // CreateForage 饲料相关
  64. CreateForage(ctx context.Context, req *operationPb.AddForageRequest) error
  65. EditForage(ctx context.Context, req *operationPb.AddForageRequest) error
  66. SearchForageList(ctx context.Context, req *operationPb.SearchForageListRequest) (*operationPb.SearchForageListResponse, error)
  67. ForageListSort(ctx context.Context, req *operationPb.ForageListSortRequest) error
  68. ForageEnumList(ctx context.Context) *operationPb.ForageEnumListResponse
  69. DeleteForageList(ctx context.Context, ids []int64) error
  70. IsShowForage(ctx context.Context, req *operationPb.IsShowForage) error
  71. ExcelImportForage(ctx context.Context, req io.Reader) error
  72. ExcelExportForage(ctx context.Context, req *operationPb.SearchForageListRequest) (*bytes.Buffer, error)
  73. ExcelTemplateForage(ctx context.Context) (*bytes.Buffer, error)
  74. SmallMaterial(ctx context.Context, req *operationPb.SmallMaterialRequest) (*model.PastureCommonResponse, error)
  75. // CreateFeedFormula 饲料配方
  76. CreateFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  77. EditFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  78. SearchFeedFormulaList(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error)
  79. IsShowFeedFormula(ctx context.Context, req *operationPb.IsShowModifyFeedFormula) error
  80. DeleteFeedFormula(ctx context.Context, feedFormulaId int64) error
  81. ExcelImportFeedFormula(ctx context.Context, req io.Reader) error
  82. ExcelExportFeedFormula(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error)
  83. ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
  84. EncodeNumber(ctx context.Context) string
  85. DistributeFeedFormula(ctx context.Context, req *operationPb.DistributeFeedFormulaRequest) error
  86. FeedFormulaUsage(ctx context.Context, req *operationPb.FeedFormulaUsageRequest) error
  87. }
  88. type SystemService interface {
  89. // Auth 系统用户相关
  90. Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
  91. GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)
  92. CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  93. SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
  94. EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  95. DeleteSystemUser(ctx context.Context, userId int64) error
  96. ResetPasswordSystemUser(ctx context.Context, userId int64) error
  97. DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
  98. IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
  99. GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error)
  100. // CreateSystemRole 系统角色相关
  101. CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  102. EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  103. DeleteSystemRole(ctx context.Context, roleId int64) error
  104. GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
  105. SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
  106. // CreateSystemMenu 系统菜单权限
  107. CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  108. EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  109. IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
  110. SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
  111. DeleteSystemMenu(ctx context.Context, menuId int64) error
  112. // SearchMobileList 移动端
  113. SearchMobileList(ctx context.Context, req *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error)
  114. }
  115. type StatisticService interface {
  116. SearchFormulaEstimateList(ctx context.Context, req *operationPb.SearchFormulaEstimateRequest) (*model.PastureCommonResponse, error)
  117. SearchInventoryStatistics(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*model.PastureCommonResponse, error)
  118. InventoryStatisticsExcelExport(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*bytes.Buffer, error)
  119. SearchUserMaterialsStatistics(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*model.PastureCommonResponse, error)
  120. UserMaterialsStatisticsExcelExport(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*bytes.Buffer, error)
  121. SearchPriceStatistics(ctx context.Context, req *operationPb.SearchPriceStatisticsRequest) (*model.PastureCommonResponse, error)
  122. SearchFeedStatistics(ctx context.Context, req *operationPb.SearchFeedStatisticsRequest) (*model.FeedStatisticsResponse, error)
  123. FeedChartStatistics(ctx context.Context, req *operationPb.FeedChartStatisticsRequest) (*model.PastureCommonResponse, error)
  124. CowsAnalysis(ctx context.Context, req *operationPb.CowsAnalysisRequest) (*model.PastureCommonResponse, error)
  125. SearchAccuracyAggStatistics(ctx context.Context, req *operationPb.AccuracyAggStatisticsRequest) (*model.PastureCommonResponse, error)
  126. SearchMixFeedStatistics(ctx context.Context, req *operationPb.MixFeedStatisticsRequest) (*model.PastureCommonResponse, error)
  127. SearchSprinkleStatistics(ctx context.Context, req *operationPb.SprinkleStatisticsRequest) (*model.PastureCommonResponse, error)
  128. SearchProcessAnalysis(ctx context.Context, req *operationPb.ProcessAnalysisRequest) (*model.PastureCommonResponse, error)
  129. GetDataByName(ctx context.Context, req *operationPb.GetDataByNameRequest) (*model.PastureCommonResponse, error)
  130. GetTrainNumber(ctx context.Context, req *operationPb.TrainNumberRequest) (*operationPb.TrainNumberResponse, error)
  131. SearchAnalysisAccuracy(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.SearchAnalysisAccuracyResponse, error)
  132. TopPasture(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.GetPastureTopResponse, error)
  133. ExecutionTime(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.ExecTimeResponse, error)
  134. SprinkleFeedTime(ctx context.Context, req *operationPb.SprinkleFeedTimeRequest) (*model.SprinkleFeedTimeResponse, error)
  135. }
  136. type WxAppletService interface {
  137. GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
  138. }
  139. type PastureSyncService interface {
  140. CategorySyncData(ctx context.Context, req *operationPb.CategorySyncRequest) error
  141. CategoryDeleteData(ctx context.Context, req *operationPb.CategoryDeleteRequest) error
  142. }