interface.go 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. }
  85. type SystemService interface {
  86. // Auth 系统用户相关
  87. Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
  88. GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)
  89. CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  90. SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
  91. EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
  92. DeleteSystemUser(ctx context.Context, userId int64) error
  93. ResetPasswordSystemUser(ctx context.Context, userId int64) error
  94. DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
  95. IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
  96. GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error)
  97. // CreateSystemRole 系统角色相关
  98. CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  99. EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
  100. DeleteSystemRole(ctx context.Context, roleId int64) error
  101. GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
  102. SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
  103. // CreateSystemMenu 系统菜单权限
  104. CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  105. EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
  106. IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
  107. SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
  108. DeleteSystemMenu(ctx context.Context, menuId int64) error
  109. // SearchMobileList 移动端
  110. SearchMobileList(ctx context.Context, req *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error)
  111. }
  112. type StatisticService interface {
  113. SearchFormulaEstimateList(ctx context.Context, req *operationPb.SearchFormulaEstimateRequest) (*model.PastureCommonResponse, error)
  114. SearchInventoryStatistics(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*model.PastureCommonResponse, error)
  115. InventoryStatisticsExcelExport(ctx context.Context, req *operationPb.SearchInventoryStatisticsRequest) (*bytes.Buffer, error)
  116. SearchUserMaterialsStatistics(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*model.PastureCommonResponse, error)
  117. UserMaterialsStatisticsExcelExport(ctx context.Context, req *operationPb.SearchUserMaterialsStatisticsRequest) (*bytes.Buffer, error)
  118. SearchPriceStatistics(ctx context.Context, req *operationPb.SearchPriceStatisticsRequest) (*model.PastureCommonResponse, error)
  119. SearchFeedStatistics(ctx context.Context, req *operationPb.SearchFeedStatisticsRequest) (*model.PastureCommonResponse, error)
  120. FeedChartStatistics(ctx context.Context, req *operationPb.FeedChartStatisticsRequest) (*model.PastureCommonResponse, error)
  121. CowsAnalysis(ctx context.Context, req *operationPb.CowsAnalysisRequest) (*model.PastureCommonResponse, error)
  122. SearchAccuracyAggStatistics(ctx context.Context, req *operationPb.AccuracyAggStatisticsRequest) (*model.PastureCommonResponse, error)
  123. SearchMixFeedStatistics(ctx context.Context, req *operationPb.MixFeedStatisticsRequest) (*model.PastureCommonResponse, error)
  124. SearchSprinkleStatistics(ctx context.Context, req *operationPb.SprinkleStatisticsRequest) (*model.PastureCommonResponse, error)
  125. SearchProcessAnalysis(ctx context.Context, req *operationPb.ProcessAnalysisRequest) (*model.PastureCommonResponse, error)
  126. GetTrainNumber(ctx context.Context, req *operationPb.TrainNumberRequest) (*operationPb.TrainNumberResponse, error)
  127. SearchAnalysisAccuracy(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.SearchAnalysisAccuracyResponse, error)
  128. }
  129. type WxAppletService interface {
  130. GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
  131. }