interface.go 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. }
  42. type PastureService interface {
  43. // CreateGroupPasture 牧场管理相关
  44. CreateGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  45. EditGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
  46. SearchGroupPastureList(ctx context.Context, req *operationPb.SearchPastureRequest) (*operationPb.SearchPastureResponse, error)
  47. DeleteGroupPasture(ctx context.Context, pastureId int64) error
  48. ResetPasswordGroupPasture(ctx context.Context, pastureId int64) error
  49. IsShowGroupPasture(ctx context.Context, req *operationPb.IsShowGroupPasture) error
  50. // ParentCattleCategoryList 牧畜类别
  51. ParentCattleCategoryList(ctx context.Context) map[operationPb.CattleCategoryParent_Kind]string
  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. // ParentForageCategoryList 饲料类别相关
  58. ParentForageCategoryList(ctx context.Context) map[operationPb.ForageCategoryParent_Kind]string
  59. AddForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  60. EditForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
  61. IsShowForageCategory(ctx context.Context, req *operationPb.IsShowForageCategory) error
  62. DeleteForageCategory(ctx context.Context, cattleCategoryId int64) error
  63. SearchForageCategoryList(ctx context.Context, req *operationPb.SearchForageCategoryRequest) (*operationPb.SearchForageCategoryResponse, error)
  64. // CreateForage 饲料相关
  65. CreateForage(ctx context.Context, req *operationPb.AddForageRequest) error
  66. EditForage(ctx context.Context, req *operationPb.AddForageRequest) error
  67. SearchForageList(ctx context.Context, req *operationPb.SearchForageListRequest) (*operationPb.SearchForageListResponse, 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. // CreateFeedFormula 饲料配方
  75. CreateFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  76. EditFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  77. SearchFeedFormulaList(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error)
  78. IsShowFeedFormula(ctx context.Context, req *operationPb.IsShowModifyFeedFormula) error
  79. DeleteFeedFormula(ctx context.Context, feedFormulaId int64) error
  80. ExcelImportFeedFormula(ctx context.Context, req io.Reader) error
  81. ExcelExportFeedFormula(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error)
  82. ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
  83. EncodeNumber(ctx context.Context) string
  84. DistributeFeedFormula(ctx context.Context, req *operationPb.DistributeFeedFormulaRequest) 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) (*model.PastureCommonResponse, error)
  115. SearchInventoryStatistics(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*model.PastureCommonResponse, error)
  116. InventoryStatisticsExcelExport(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*bytes.Buffer, error)
  117. SearchUserMaterialsStatistics(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*model.PastureCommonResponse, error)
  118. UserMaterialsStatisticsExcelExport(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*bytes.Buffer, error)
  119. SearchPriceStatistics(ctx context.Context, req *operationPb.SearchPriceStatisticsRequest) (*model.PastureCommonResponse, error)
  120. SearchFeedStatistics(ctx context.Context, req *operationPb.SearchFeedStatisticsRequest) (*model.PastureCommonResponse, error)
  121. FeedChartStatistics(ctx context.Context, req *operationPb.FeedChartStatisticsRequest) (*model.PastureCommonResponse, error)
  122. CowsAnalysis(ctx context.Context, req *operationPb.CowsAnalysisRequest) (*model.PastureCommonResponse, error)
  123. SearchAccuracyAggStatistics(ctx context.Context, req *operationPb.AccuracyAggStatisticsRequest) (*model.PastureCommonResponse, error)
  124. SearchMixFeedStatistics(ctx context.Context, req *operationPb.MixFeedStatisticsRequest) (*model.PastureCommonResponse, error)
  125. SearchSprinkleStatistics(ctx context.Context, req *operationPb.SprinkleStatisticsRequest) (*model.PastureCommonResponse, error)
  126. SearchProcessAnalysis(ctx context.Context, req *operationPb.ProcessAnalysisRequest) (*model.PastureCommonResponse, error)
  127. GetDataByName(ctx context.Context, req *operationPb.GetDataByNameRequest) (*model.PastureCommonResponse, error)
  128. GetTrainNumber(ctx context.Context, req *operationPb.TrainNumberRequest) (*operationPb.TrainNumberResponse, error)
  129. SearchAnalysisAccuracy(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.SearchAnalysisAccuracyResponse, error)
  130. TopPasture(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.GetPastureTopResponse, error)
  131. ExecutionTime(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.ExecTimeResponse, error)
  132. SprinkleFeedTime(ctx context.Context, req *operationPb.SprinkleFeedTimeRequest) (*model.SprinkleFeedTimeResponse, error)
  133. }
  134. type WxAppletService interface {
  135. GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
  136. }