interface.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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/service/wechat"
  9. "kpt-tmr-group/store/kptstore"
  10. operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
  11. "gitee.com/xuyiping_admin/pkg/di"
  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. //go:generate mockgen -destination mock/PastureService.go -package kptservicemock kpt-tmr-group/module/backend PastureService
  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. // AddCattleCategory 牧畜类别
  53. AddCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  54. EditCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
  55. IsShowCattleCategory(ctx context.Context, req *operationPb.IsShowCattleCategory) error
  56. DeleteCattleCategory(ctx context.Context, cattleCategoryId int64) error
  57. SearchCattleCategoryList(ctx context.Context, req *operationPb.SearchCattleCategoryRequest) (*operationPb.SearchCattleCategoryResponse, error)
  58. // AddForageCategory 饲料类别相关
  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. ForageListSort(ctx context.Context, req *operationPb.ForageListSortRequest) error
  69. ForageEnumList(ctx context.Context) *operationPb.ForageEnumListResponse
  70. DeleteForageList(ctx context.Context, ids []int64) error
  71. IsShowForage(ctx context.Context, req *operationPb.IsShowForage) error
  72. ExcelImportForage(ctx context.Context, req io.Reader) error
  73. ExcelExportForage(ctx context.Context, req *operationPb.SearchForageListRequest) (*bytes.Buffer, error)
  74. ExcelTemplateForage(ctx context.Context) (*bytes.Buffer, error)
  75. SmallMaterial(ctx context.Context, req *operationPb.SmallMaterialRequest) (*model.PastureCommonResponse, error)
  76. // CreateFeedFormula 饲料配方
  77. CreateFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  78. EditFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
  79. AddFeedByFeedFormula(ctx context.Context, req *operationPb.GroupAddFeedFormulaDetail) error
  80. EditFeedByFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaDetail) error
  81. FeedFormulaDetailBySort(ctx context.Context, req *operationPb.GroupAddFeedFormulaDetail) error
  82. FeedFormulaDetailIsModify(ctx context.Context, req *operationPb.AddFeedFormulaDetail) error
  83. DeleteFeedFormulaDetail(ctx context.Context, req *operationPb.GroupAddFeedFormulaDetail) error
  84. SearchFeedFormulaDetail(ctx context.Context, req *operationPb.AddFeedFormulaDetail) (*operationPb.FeedFormulaDetailResponse, error)
  85. MixedFeedFormula(ctx context.Context, req *operationPb.MixedFeedFormulaRequest) error
  86. SearchFeedFormulaList(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error)
  87. IsShowFeedFormula(ctx context.Context, req *operationPb.IsShowModifyFeedFormula) error
  88. DeleteFeedFormula(ctx context.Context, feedFormulaId int64) error
  89. ExcelImportFeedFormula(ctx context.Context, req io.Reader) error
  90. ExcelExportFeedFormula(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error)
  91. ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
  92. EncodeNumber(ctx context.Context) string
  93. DistributeFeedFormula(ctx context.Context, req *operationPb.DistributeFeedFormulaRequest) error
  94. CancelDistributeFeedFormula(ctx context.Context, req *operationPb.DistributeFeedFormulaRequest) error
  95. EditRecodeFeedFormula(ctx context.Context, req *operationPb.EditRecodeFeedFormulaRequest) (*operationPb.EditRecodeFeedFormulaResponse, error)
  96. FeedFormulaDetailList(ctx context.Context, req *operationPb.FeedFormulaDetailRequest) (*operationPb.FeedFormulaDetailResponse, error)
  97. FeedFormulaUsage(ctx context.Context, req *operationPb.FeedFormulaUsageRequest) (*operationPb.FeedFormulaUsageResponse, error)
  98. ForageListByGroup(ctx context.Context) (*operationPb.SearchForageListResponse, error)
  99. }
  100. //go:generate mockgen -destination mock/SystemService.go -package kptservicemock kpt-tmr-group/module/backend SystemService
  101. type SystemService interface {
  102. // Auth 系统用户相关
  103. Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
  104. GetCurrentUserName(ctx context.Context) string
  105. GetUserInfo(ctx context.Context) (*operationPb.UserAuth, error)
  106. CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  107. SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
  108. EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  109. DeleteSystemUser(ctx context.Context, userId int64) error
  110. ResetPasswordSystemUser(ctx context.Context, userId int64) error
  111. DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
  112. IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
  113. GetSystemUserPermissions(ctx context.Context) (*operationPb.SystemUserMenuPermissions, error)
  114. // CreateSystemRole 系统角色相关
  115. CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  116. EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  117. DeleteSystemRole(ctx context.Context, roleId int64) error
  118. GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
  119. SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
  120. // CreateSystemMenu 系统菜单权限
  121. CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  122. EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  123. IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
  124. SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
  125. DeleteSystemMenu(ctx context.Context, menuId int64) error
  126. // SearchMobileList 移动端
  127. SearchMobileList(ctx context.Context, req *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error)
  128. }
  129. //go:generate mockgen -destination mock/StatisticService.go -package kptservicemock kpt-tmr-group/module/backend StatisticService
  130. type StatisticService interface {
  131. SearchFormulaEstimateList(ctx context.Context, req *operationPb.SearchFormulaEstimateRequest) (*model.PastureCommonResponse, error)
  132. SearchInventoryStatistics(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*model.PastureCommonResponse, error)
  133. InventoryStatisticsExcelExport(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*bytes.Buffer, error)
  134. SearchUserMaterialsStatistics(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*model.PastureCommonResponse, error)
  135. UserMaterialsStatisticsExcelExport(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*bytes.Buffer, error)
  136. SearchPriceStatistics(ctx context.Context, req *operationPb.SearchPriceStatisticsRequest) (*model.PastureCommonResponse, error)
  137. SearchFeedStatistics(ctx context.Context, req *operationPb.SearchFeedStatisticsRequest) (*model.FeedStatisticsResponse, error)
  138. FeedChartStatistics(ctx context.Context, req *operationPb.FeedChartStatisticsRequest) (*model.PastureCommonResponse, error)
  139. CowsAnalysis(ctx context.Context, req *operationPb.CowsAnalysisRequest) (*model.PastureCommonResponse, error)
  140. SearchAccuracyAggStatistics(ctx context.Context, req *operationPb.AccuracyAggStatisticsRequest) (*model.PastureCommonResponse, error)
  141. SearchMixFeedStatistics(ctx context.Context, req *operationPb.MixFeedStatisticsRequest) (*model.PastureCommonResponse, error)
  142. SearchSprinkleStatistics(ctx context.Context, req *operationPb.SprinkleStatisticsRequest) (*model.PastureCommonResponse, error)
  143. SearchProcessAnalysis(ctx context.Context, req *operationPb.ProcessAnalysisRequest) (*model.PastureCommonResponse, error)
  144. AnalysisMixedSprinkleDetail(ctx context.Context, req *operationPb.ProcessMixedSprinkleDetailRequest) (*model.PastureCommonResponse, error)
  145. GetDataByName(ctx context.Context, req *operationPb.GetDataByNameRequest) (*model.PastureCommonResponse, error)
  146. GetTrainNumber(ctx context.Context, req *operationPb.TrainNumberRequest) (*operationPb.TrainNumberResponse, error)
  147. SearchAnalysisAccuracy(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.SearchAnalysisAccuracyResponse1, error)
  148. TopPasture(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.GetPastureTopResponse, error)
  149. ExecutionTime(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.ExecTimeResponse, error)
  150. SprinkleFeedTime(ctx context.Context, req *operationPb.SprinkleFeedTimeRequest) (*model.SprinkleFeedTimeResponse, error)
  151. FeedMixedAndTmrName(ctx context.Context, req *operationPb.MixedCategoryTmrName) (*model.PastureCommonResponse, error)
  152. FeedTemplateHistory(ctx context.Context, req *operationPb.FeedTemplateHistoryRequest) (*model.PastureFeedTemplateHistoryResponse, error)
  153. BarnHistory(ctx context.Context, req *operationPb.BarnHistoryRequest) (*model.PastureBarnHistoryResponse, error)
  154. SpillageAllHistory(ctx context.Context, req *operationPb.BarnHistoryRequest) (*model.PastureBarnHistoryResponse, error)
  155. }
  156. //go:generate mockgen -destination mock/WxAppletService.go -package kptservicemock kpt-tmr-group/module/backend WxAppletService
  157. type WxAppletService interface {
  158. GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
  159. }
  160. //go:generate mockgen -destination mock/PastureSyncService.go -package kptservicemock kpt-tmr-group/module/backend PastureSyncService
  161. type PastureSyncService interface {
  162. CategorySyncData(ctx context.Context, req *operationPb.CategorySyncRequest) error
  163. CategoryDeleteData(ctx context.Context, req *operationPb.CategoryDeleteRequest) error
  164. FeedFormulaSyncData(ctx context.Context, req *operationPb.FeedFormulaSyncRequest) error
  165. FeedSyncData(ctx context.Context, req *operationPb.FeedFormulaSyncRequest) error
  166. FeedFormulaDetailListSyncData(ctx context.Context, req *operationPb.FeedFormulaSyncRequest) error
  167. }