interface.go 6.2 KB

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