Explorar el Código

framework: upgrade

Yi hace 1 año
padre
commit
44970b625f
Se han modificado 100 ficheros con 157 adiciones y 5157 borrados
  1. 3 3
      README.md
  2. 0 116
      backend/common/errors.proto
  3. 0 105
      backend/operation/enum.proto
  4. 0 190
      backend/operation/feed_formula.proto
  5. 0 35
      backend/operation/mobile.proto
  6. 0 12
      backend/operation/pagination.proto
  7. 0 299
      backend/operation/pasture.proto
  8. 0 285
      backend/operation/statistic.proto
  9. 0 220
      backend/operation/system.proto
  10. 1 1
      cmd/http.go
  11. 1 1
      config/app.go
  12. 1 1
      dep/dep.go
  13. 1 1
      dep/di.go
  14. 10 13
      go.mod
  15. 4 9
      go.sum
  16. 4 4
      http/debug/debug.go
  17. 4 4
      http/handler/dashboard/dashboard.go
  18. 5 5
      http/handler/feed/feed_formula.go
  19. 4 4
      http/handler/feed/feed_formula_detail.go
  20. 3 3
      http/handler/mobile/mobile_list.go
  21. 4 4
      http/handler/pasture/cattle_forage_category.go
  22. 5 5
      http/handler/pasture/forage_list.go
  23. 4 4
      http/handler/pasture/pasture.go
  24. 4 4
      http/handler/pasture/pasture_list.go
  25. 4 4
      http/handler/statistic/analysis.go
  26. 4 4
      http/handler/system/menu.go
  27. 4 4
      http/handler/system/role.go
  28. 4 4
      http/handler/system/user.go
  29. 1 1
      http/middleware/cors.go
  30. 2 2
      http/middleware/sentry.go
  31. 4 3
      http/middleware/sso.go
  32. 1 1
      http/util/httptt/http.go
  33. 1 1
      http/util/httptt/query_encoder.go
  34. 1 1
      main.go
  35. 1 1
      model/analysis_accuracy.go
  36. 1 1
      model/cattle_category.go
  37. 1 1
      model/feed_formula.go
  38. 1 1
      model/feed_formula_detail.go
  39. 1 1
      model/feed_formula_distribute_log.go
  40. 1 1
      model/feed_formula_edit_record.go
  41. 1 1
      model/forage.go
  42. 1 1
      model/forage_category.go
  43. 1 1
      model/formula_estimate.go
  44. 4 4
      model/group_pasture.go
  45. 1 1
      model/pasture_data.go
  46. 1 1
      model/system_group_pasture_permissions.go
  47. 1 1
      model/system_menu.go
  48. 1 1
      model/system_menu_permissions.go
  49. 1 1
      model/system_mobile.go
  50. 1 1
      model/system_mobile_permissions.go
  51. 1 1
      model/system_role.go
  52. 1 1
      model/system_user.go
  53. 6 6
      module/backend/dashboard_service.go
  54. 1 1
      module/backend/edit_record_service.go
  55. 17 8
      module/backend/feed_service.go
  56. 2 2
      module/backend/interface.go
  57. 1 1
      module/backend/mock/PastureService.go
  58. 1 1
      module/backend/mock/PastureSyncService.go
  59. 1 1
      module/backend/mock/StatisticService.go
  60. 1 1
      module/backend/mock/SystemService.go
  61. 1 1
      module/backend/mock/WxAppletService.go
  62. 1 1
      module/backend/mock/kptservice.go
  63. 4 4
      module/backend/pasture_service.go
  64. 2 2
      module/backend/pasture_sync_service.go
  65. 3 3
      module/backend/statistic_service.go
  66. 3 3
      module/backend/system_permissions.go
  67. 5 5
      module/backend/system_service.go
  68. 3 3
      module/backend/wx_applet_service.go
  69. 0 207
      pkg/apierr/apierr.go
  70. 0 761
      pkg/apierr/apierr_gen.go
  71. 0 47
      pkg/apierr/config.go
  72. 0 23
      pkg/apiok/common.go
  73. 0 133
      pkg/cleanup/entry.go
  74. 0 53
      pkg/cleanup/entry_test.go
  75. 0 19
      pkg/cputil/cp.go
  76. 0 59
      pkg/cputil/cp_test.go
  77. 0 26
      pkg/di/annotation.go
  78. 0 153
      pkg/di/hub.go
  79. 0 187
      pkg/di/hub_test.go
  80. 0 180
      pkg/di/option.go
  81. 0 157
      pkg/di/xreflect/reflect.go
  82. 0 143
      pkg/di/xreflect/reflect_test.go
  83. 0 149
      pkg/di/xreflect/stack.go
  84. 0 236
      pkg/di/xreflect/stack_test.go
  85. 0 68
      pkg/ginutil/bind.go
  86. 0 34
      pkg/ginutil/bind_proto.go
  87. 0 19
      pkg/ginutil/json_proto_response.go
  88. 0 322
      pkg/ginutil/setter.go
  89. 0 57
      pkg/grpcutil/client_conn.go
  90. 0 61
      pkg/grpcutil/error.go
  91. 0 22
      pkg/grpcutil/grpc_error.go
  92. 0 30
      pkg/jsonpb/decode.go
  93. 0 33
      pkg/jsonpb/decode_test.go
  94. 0 52
      pkg/jsonpb/encode.go
  95. 0 37
      pkg/jsonpb/encode_test.go
  96. 0 108
      pkg/jsonpb/query_decode.go
  97. 0 9
      pkg/jsonpb/query_decode_test.go
  98. 0 64
      pkg/jwt/jwt.go
  99. 0 87
      pkg/jwt/jwt_test.go
  100. 0 204
      pkg/logger/logrus/log.go

+ 3 - 3
README.md

@@ -25,9 +25,9 @@ kpt-tmr-group - 科湃腾TMR集团版
 - make test
 
 lint:
-在开发完后请记得跑下make lint做代码检查(🤔: 你可能会有疑问,为啥不配置JOB跑呢?-->  因为golangci-lint跑本项目需要6G+的内存,会触发OOM😂)
+在开发完后请记得跑下make lint做代码检查(🤔: 你可能会有疑问,为啥不配置JOB跑呢?-->  因为golang-ci-lint跑本项目需要6G+的内存,会触发OOM😂)
 
-需要更新 gomock:
+需要更新 go-mock:
 - 生成 mock 前,请确保你能够编译 & 编译完成
 - make generate
 
@@ -35,7 +35,7 @@ lint:
 - GetDataByName(公共接口,目前只兼容startTime和endTime字段)
 
 TODO 列表
-- proto3 int64 jsonpb处理后自动转成string
+- proto3 int64 jsonPb处理后自动转成string
   * ~~现在处理的方式是把int64类型改成int32类型~~
 - 用户登出没有用redis做缓存,所以后端没有提供登出接口,有以下弊端
   * 用户的token没有过期,如被人劫持,会被使用到直到token过期

+ 0 - 116
backend/common/errors.proto

@@ -1,116 +0,0 @@
-syntax = "proto3";
-
-package backend.common;
-
-option go_package = ".;commonPb";
-
-message Error {
-  enum Code {
-    OK = 0;
-
-    reserved 1 to 9999;
-
-    // ========= Common =========
-
-    // 鉴权
-    UNAUTHORIZED = 10000;
-    reserved 10001 to 10999;
-
-    // 通用请求错误
-    BAD_REQUEST = 11000;
-    INVALID_CONTENT_TYPE = 11001;
-    INVALID_CONTENT_ENCODING = 11002;
-    TOO_MANY_REQUESTS = 11003;
-    reserved 11004 to 11099;
-
-    // ========= Biz =========
-
-    // Config
-    INVALID_STORAGE_TYPE = 11100;
-    reserved 11101 to 11199;
-
-    // DataEvent
-    INVALID_DE_DATA = 11200;
-    reserved 11201 to 19999;
-
-    // Checkin
-    CHECKIN_REPEATED = 20000;
-    reserved 20001 to 20999;
-
-    // Course
-    COURSE_NOT_FOUND = 21000;
-    // 课程没有权益
-    COURSE_NOT_INTEREST = 21001;
-    reserved 21002 to 21999;
-
-    // Recommend
-    MODULE_NOT_FOUND = 22000;
-    reserved 22001 to 22999;
-
-    // User Course
-    USER_COURSE_ALREADY_ADDED = 23000;
-    USER_COURSE_NOT_FOUND = 23001;
-    reserved 23002 to 23999;
-
-    // PT
-    PT_LIMITED = 24000;
-    reserved 24001 to 24099;
-
-    // Payment 24100 - 24299
-
-    // 无效的价格
-    INVALID_PRICE = 24100;
-    // 无效的 product ID
-    INVALID_PRODUCT_ID = 24101;
-    // 无效的订单号
-    INVALID_ORDER_NUMBER = 24102;
-    // 无效的用户 ID
-    INVALID_USER_ID = 24103;
-    // 无效的收据
-    INVALID_RECEIPT = 24104;
-    // 异常的 iOS 收据,需要客户端 check 和重试
-    EMPTY_IOS_RECEIPT = 24105;
-
-    reserved 24106 to 24299;
-
-    // UserPlan 相关
-    // 免费用户限制 plan 课程数量
-    USER_PLAN_LIMITED_COURSE_COUNT = 24300;
-
-
-    // 保留业务段 24400 to 89999
-    reserved 24400 to 89999;
-
-    // ========= SYSTEM =========
-    // 服务自身错误
-    INTERNAL_ERROR = 90000;
-    reserved 90001 to 90099;
-
-    // encoding/decoding error
-
-    // JSONPB encoding/decoding with error
-    JSONPB_ERROR = 90100;
-
-    // JSON encoding/decoding with error
-    JSON_ERROR = 90101;
-
-    // PB encoding/decoding with error
-    PB_ERROR = 90102;
-    reserved 90103 to 90999;
-
-    // 依赖服务错误
-    EXTERNAL_ERROR = 91000;
-
-    reserved 91001 to max;
-  }
-
-  // 业务错误码
-  Code code = 1;
-
-  // 错误信息
-  string msg = 2;
-
-  // 补充错误信息
-  // @optional
-  repeated string errors = 3;
-}

+ 0 - 105
backend/operation/enum.proto

@@ -1,105 +0,0 @@
-syntax = "proto3";
-
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-// 字段类型
-message IsShow {
-  enum Kind {
-    INVALID = 0;  // 无效
-    OK = 1;       // 是
-    NO = 2;       // 否
-  }
-}
-
-message CattleCategoryParent {
-  enum Kind {
-    INVALID = 0;           // 所有
-    LACTATION_CAW = 1;     // 泌乳牛
-    FATTEN_CAW = 2;        // 育肥牛
-    RESERVE_CAW  = 3;      // 后备牛
-    DRY_CAW = 4;           // 干奶牛
-    PERINATAL_CAW  = 5;    // 围产牛
-    OTHER_CAW = 6;         // 其他
-  }
-}
-
-// 饲料类别
-message ForageCategoryParent {
-  enum Kind {
-    INVALID = 0;           // 无效
-    ROUGHAGE = 1;          // 粗料
-    CONCENTRATE  = 2;      // 精料(浓缩料)
-    HALF_ROUGHAGE_HALF_CONCENTRATE = 3;   // 粗料精料各半
-    OTHER = 4;        // 其他
-  }
-}
-
-// 饲料来源
-message ForageSource {
-  enum Kind {
-    INVALID = 0;           // 无效
-    SYSTEM_BUILT_IN = 1;   // 系统内置
-    USER_DEFINED = 2;      // 用户自定义
-  }
-}
-
-// 跳转延迟
-message JumpDelaType {
-  enum Kind {
-    INVALID = 0;           // 禁用
-    THREE = 1;             // 3秒
-    SIX = 2;               // 6秒
-    NINE = 3;              // 9秒
-  }
-}
-
-// 计划类型
-message ForagePlanType {
-  enum Kind {
-    INVALID = 0;           // 无
-    FORKLIFT = 1;          // 铲车
-    CONCENTRATE = 2;       // 精料
-  }
-}
-
-message DataSource {
-  enum Kind {
-    INVALID = 0;           // 无
-    BACKGROUND_ADD = 1;    // 后台手动添加
-    EXCEL_IMPORT = 2;     // excel报表导入
-    FROM_PASTURE = 3;     // 来自牧场
-  }
-}
-
-// 物料类型
-message FormulaType {
-  enum Kind {
-    INVALID = 0;                    // 无
-    FEED_FORMULA = 1;              // 饲喂配方
-    PREMIXED_FORMULA = 2;          // 预混配方
-    SUPPLEMENTARY_FORMULA = 3;     // 补料配方
-  }
-}
-
-// DashboardTopType 首页排行榜的类型
-message DashboardTopType {
-  enum Kind {
-    INVALID = 0;                    // 无
-    MIXED_ACCURATE = 1;             // 混料准确率
-    MIXED_CORRECT = 2;              // 混料正确率
-    SPRINKLE_ACCURATE = 3;          // 撒料准确率
-    Sprinkle_CORRECT = 4;           // 撒料正确率
-  }
-}
-
-// FeedFormulaEditRecordType 配方饲料修改类型
-message FeedFormulaEditRecordType {
-  enum Kind {
-    INVALID = 0;  // 无
-    INSERT = 1;   // 混料准确率
-    UPDATE = 2;   // 混料正确率
-    DELETE = 3;   // 撒料准确率
-  }
-}

+ 0 - 190
backend/operation/feed_formula.proto

@@ -1,190 +0,0 @@
-syntax = "proto3";
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-import "backend/operation/pagination.proto";
-import "backend/operation/enum.proto";
-
-message AddFeedFormulaRequest {
-  int32 id = 1;
-  string name = 2;                                       // 名称
-  string  encode_number = 3;                             // 编码
-  string colour = 4;                                     // 颜色
-  CattleCategoryParent.Kind cattle_category_id = 5;      // 畜牧类别id
-  string cattle_category_name = 6;                       // 畜牧类型名称
-  FormulaType.Kind formula_type_id = 7;                   // 配方类型id
-  string formula_type_name = 8;                           // 配方类型名称
-  DataSource.Kind data_source_id = 9;                     // 数据来源
-  string data_source_name = 10;                           // 数据来源
-  string remarks = 11;                                    // 备注
-  int32 version = 12;                                     // 版本号
-  IsShow.Kind is_show = 13;                               // 是否启用
-  IsShow.Kind is_modify = 14;                             // 是否可修改
-  int32 created_at = 15;                                  // 创建时间
-  string created_at_format = 16;                          // 创建时间格式化
-  string pasture_name = 17;                               // 牧场名称
-}
-
-message SearchFeedFormulaRequest {
-  int32 cattle_category_id = 1;    // 分类id
-  int32 formula_type_id = 2;       // 配方类型id
-  int32 data_source = 3;           // 饲料来源
-  IsShow.Kind is_show = 4;         // 是否启用
-  string name = 5;                 // 配方名称
-  string remarks = 6;              // 备注
-  PaginationModel pagination = 7;  // 分页
-}
-
-message SearchFeedFormulaListResponse {
-  int32 code = 1;
-  string msg = 2;
-  SearchFeedFormulaListData data = 3;
-}
-
-message SearchFeedFormulaListData {
-  int32 page = 1;
-  int32 page_size = 2;
-  int32 total = 3;
-  repeated AddFeedFormulaRequest list = 4;
-}
-
-// 是否启用
-message IsShowModifyFeedFormula {
-  int32 feed_formula_id = 1;
-  IsShow.Kind is_show = 2;
-  int32 edit_type = 3;      // 1 更新是否启用 2 更新 modify
-}
-
-// 配方编码
-message UniqueID {
-  int32 code = 1;
-  string msg = 2;
-  message UniqueData {
-    string encode_number = 1;
-  }
-  UniqueData data = 3;
-}
-
-// DistributeFeedFormulaRequest 饲料配方下发
-message DistributeFeedFormulaRequest {
-  repeated int32 pasture_ids = 1;          // 牧场ids集合
-  repeated int32 feed_formula_ids = 2;     // 配方ids集合
-}
-
-// EditRecodeFeedFormulaRequest 饲料配方修改记录
-message EditRecodeFeedFormulaRequest {
-  int32 pasture_id = 1;       // 牧场id
-  int32 feed_formula_id = 2;  // 饲料配方id
-  int32 start_time = 3;       // 开始时间
-  int32 end_time = 4;         // 结束时间
-}
-
-// EditRecodeFeedFormulaResponse 饲料配方修改记录
-message EditRecodeFeedFormulaResponse {
-  int32 code = 1;
-  string msg = 2;
-  repeated EditRecodeFeedFormulaData data = 3;
-}
-
-message EditRecodeFeedFormulaData {
-  int32 pasture_id = 1;
-  string pasture_name = 2;
-  string modify_time = 3;
-  string modify_detail = 4;
-}
-
-// GroupAddFeedFormulaDetail 配方添加饲料
-message GroupAddFeedFormulaDetail {
-  int32 feed_formula_id = 1;                // 配方id
-  repeated AddFeedFormulaDetail list = 2;   // 饲料详情
-}
-
-message AddFeedFormulaDetail {
-  int32 feed_formula_id = 1;    // 配方id
-  int32 forage_id = 2;          // 饲料id
-  string forage_name = 3;       // 饲料名称
-  string forage_group_name = 4;  // 饲料分组名称
-  float weight = 5;              // 重量
-  int32 stir_delay = 6;          // 搅拌延迟
-  int32 allow_error = 7;         // 允许误差
-  int32 created_at = 8;             // 创建时间
-  string created_at_format = 9;     // 创建时间格式化
-  int32 id = 10;
-  int32 sort = 11;                 // 排序
-  int32 is_lock_cow_count_ratio = 12;   // 是否锁定牛头数比例
-  PaginationModel pagination = 13;  // 分页
-  int32 pre_fit = 14;              // 预混料id
-  IsShow.Kind is_modify = 15;
-}
-
-// FeedFormulaDetailRequest 饲料配方详情
-message FeedFormulaDetailRequest {
-  int32 feed_formula_id = 1;    // 配方id
-}
-
-// FeedFormulaDetailRequest 饲料配方详情
-message FeedFormulaDetailResponse {
-  int32 code = 1;
-  string msg = 2;
-  repeated AddFeedFormulaDetail data = 3;
-}
-
-// 配方使用概况
-message FeedFormulaUsageRequest {
-  int32 feed_formula_id = 1;        // 饲料配方id
-  string start_time = 2;            // 开始时间
-  string end_time = 3;              // 结束时间
-  int32 pasture_id = 4;            // 牧场id
-}
-
-// 配方使用概况
-message FeedFormulaUsageResponse {
-  int32 code = 1;
-  string msg = 2;
-  repeated FeedFormulaUsageList data = 3;
-}
-
-// 配方使用概况
-message FeedFormulaUsageList {
-  int32 pasture_id = 1;                        // 牧场id
-  string pasture_name = 2;                     // 牧场名称
-  string mixed_fodder_accurate_ratio = 3;      // 混料准确率
-  string mixed_fodder_correct_ratio = 4;       // 混料正确率
-  string sprinkle_fodder_accurate_ratio = 5;   // 撒料准确率
-  string sprinkle_fodder_correct_ratio = 6;    // 撒料正确率
-  string add_feed_time = 7;                    // 加料时间
-  string sprinkle_time = 8;                    // 撒料时间
-  string stir_time = 9;                        // 搅拌延迟时间
-  string last_edit_time = 10;                  // 最近一次修改配方时间
-}
-
-message PastureFeedFormulaUsageResponse {
-  int32 code = 1;
-  string msg = 2;
-  PastureData data = 3;
-}
-
-message PastureData {
-  string mixed_fodder_accurate_ratio = 3;      // 混料准确率
-  string mixed_fodder_correct_ratio = 4;       // 混料正确率
-  string sprinkle_fodder_accurate_ratio = 5;   // 撒料准确率
-  string sprinkle_fodder_correct_ratio = 6;    // 撒料正确率
-  string add_feed_time = 7;                    // 加料时间
-  string sprinkle_time = 8;                    // 撒料时间
-  string stir_time = 9;                        // 搅拌延迟时间
-  string last_edit_time = 10;                  // 最近一次修改配方时间
-}
-
-message MixedFeedFormulaRequest {
-  string name = 1;                          // 配方名称
-  string colour = 2;                        // 颜色
-  int32 cattle_category_id = 3;            // 分类id
-  string cattle_category_name = 4;          // 分类名称
-  FormulaType.Kind formula_type_id = 5;     // 配方类型id
-  string formula_type_name = 6;             // 配方类型名称
-  int32 data_source_id = 7;                 // 来源id
-  string remarks = 8;                       // 备注
-  int32 feed_formula_id = 9;                // 配方id
-  repeated AddFeedFormulaDetail feed_list = 10;
-}

+ 0 - 35
backend/operation/mobile.proto

@@ -1,35 +0,0 @@
-syntax = "proto3";
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-import "backend/operation/pagination.proto";
-import "backend/operation/system.proto";
-
-message SearchMobileRequest {
-  string name = 1;       // 名称
-  PaginationModel pagination = 2; // 分页
-}
-
-message SearchMobileResponse {
-  int32 code = 1;
-  string msg = 2;
-  SearchMobileData data = 3;
-}
-
-message SearchMobileData {
-  int32 page = 1;
-  int32 total = 2;
-  int32 page_size = 3;
-  repeated  MobileData list = 4;
-}
-
-message MobileData {
-  uint32 id = 1;
-  string name = 2;
-  uint32 created_at = 3;
-  string created_at_format = 4;
-  repeated AddMenuRequest children = 15;   // 子分类
-}
-
-

+ 0 - 12
backend/operation/pagination.proto

@@ -1,12 +0,0 @@
-syntax = "proto3";
-
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-
-message PaginationModel {
-  int32 Page       = 1;
-  int32 PageSize   = 2;
-  int32 PageOffset = 3;
-}

+ 0 - 299
backend/operation/pasture.proto

@@ -1,299 +0,0 @@
-syntax = "proto3";
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-import "backend/operation/enum.proto";
-import "backend/operation/pagination.proto";
-
-message AddPastureRequest {
-  int32 id = 1;
-  string name = 2; // 牧场名称
-  string account = 3;   // 登录账号名称
-  string manager_user = 4; // 牧场负责人名称
-  string manager_phone = 5;   // 牧场负责人手机号
-  string address = 6;   // 牧场地址
-  IsShow.Kind is_show = 7;    // 是否启用
-  int32 created_at = 8;    // 创建时间
-  string created_at_format = 9;    // 创建时间格式化
-  string domain = 10;    // 牧场端域名或者ip
-  int32 pasture_id = 11;  // 牧场端id (兼容历史数据)
-}
-
-message SearchPastureRequest {
-  string name = 1;       // 牧场名称
-  string manager_user = 2; // 牧场负责人名称
-  string manager_phone = 3;   // 牧场负责人手机号
-  uint32 start_time = 4;       // 开始时间
-  uint32 end_time = 5;    // 结束时间
-  PaginationModel pagination = 6; // 分页
-}
-
-message SearchPastureResponse {
-  int32 code = 1;
-  string msg = 2;
-  SearchPastureData data = 3;
-}
-
-message SearchPastureData {
-  int32 page = 1;
-  int32 total = 2;
-  int32 page_size = 3;
-  repeated AddPastureRequest list = 4;
-}
-
-message UserPasture {
-  int32 id = 1;
-  string name = 2;
-}
-
-message IsShowGroupPasture {
-  int32 pasture_id = 1;    // 牧场id
-  IsShow.Kind is_show = 2;     // 是否开启
-}
-
-// 添加牧畜分类
-message AddCattleCategoryRequest {
-  uint32 id = 1;
-  CattleCategoryParent.Kind parent_id = 2;  // 父类id
-  string parent_name = 3;        // 父类名称
-  string name = 4;               // 牧畜分类名称
-  string number = 5;            // 畜牧类别编号
-  IsShow.Kind is_show = 6;      // 是否启用
-  uint32 created_at = 7;         // 创建时间
-  string created_at_format = 8;   // 创建时间格式
-  string data_source = 9;         // 数据来源
-}
-
-// 是否启用
-message IsShowCattleCategory {
-  int32 cattle_category_id = 1;
-  IsShow.Kind is_show = 2;
-}
-
-// 畜牧分类查询列表
-message SearchCattleCategoryRequest {
-  int32 parent_id = 1;
-  IsShow.Kind is_show = 2;
-  string name = 3;
-  PaginationModel pagination = 4; // 分页
-}
-
-message SearchCattleCategoryResponse {
-  int32 code = 1;
-  string msg = 2;
-  SearchCattleCategoryData data = 3;
-}
-
-message SearchCattleCategoryData {
-  int32 page = 1;
-  int32 total = 2;
-  int32 page_size = 3;
-  repeated AddCattleCategoryRequest list = 4;
-}
-
-// 添加饲料分类
-message AddForageCategoryRequest {
-  uint32 id = 1;
-  ForageCategoryParent.Kind parent_id = 2;  // 父类id
-  string parent_name = 3;        // 父类名称
-  string name = 4;               // 牧畜分类名称
-  string number = 5;            // 畜牧类别编号
-  IsShow.Kind is_show = 6;      // 是否启用
-  uint32 created_at = 7;         // 创建时间
-  string created_at_format = 8;   // 创建时间格式
-  string data_source = 9;         // 数据来源
-}
-
-// 是否启用
-message IsShowForageCategory {
-  int32 forage_category_id = 1;
-  IsShow.Kind is_show = 2;
-}
-
-// 饲料分类查询列表
-message SearchForageCategoryRequest {
-  int32 parent_id = 1;
-  IsShow.Kind is_show = 2;
-  string name = 3;
-  string number = 4;
-  PaginationModel pagination = 5; // 分页
-}
-
-message SearchForageCategoryResponse {
-  int32 code = 1;
-  string msg = 2;
-  SearchForageCategoryData data = 3;
-}
-
-message SearchForageCategoryData {
-  int32 page = 1;
-  int32 total = 2;
-  int32 page_size = 3;
-  repeated AddForageCategoryRequest list = 4;
-}
-
-// 饲料列表
-message AddForageRequest {
-  int32 id = 1;
-  string name = 2;                      // 饲料名称
-  int32 category_id = 3;                // 饲料分类id
-  string category_name = 4;             // 饲料分类名称
-  FormulaType.Kind material_type_key = 5;        // 物料类型key
-  string material_type_name = 6;        // 物料类型名称
-  string unique_encode = 7;              // 唯一编码
-  ForageSource.Kind forage_source_id = 8;       // 饲料来源id
-  string forage_source_name = 9;                // 饲料来源名称
-  ForagePlanType.Kind plan_type_id = 10;       // 计划类型id
-  string plan_type_name = 11;                  // 计划类型名称
-  string  small_material_scale = 12;           // 小料称
-  int32 allow_error = 13;                     // 允许误差 (单位kg)
-  int32 package_weight = 14;                  // 包装重量 (单位kg)
-  int32 price = 15;                          // 单价(单位分)
-  int32 jump_weight = 16;                    // 跳转重量域(单位kg)
-  JumpDelaType.Kind jump_delay = 17;         // 跳转延迟
-  IsShow.Kind confirm_start = 18;            // 确认开始
-  int32  relay_locations = 19;               // 继电器位置
-  IsShow.Kind jmp = 20;                     // 无上域
-  string backup1 = 21;                      // 备用字段1
-  string backup2 = 22;                      // 备用字段2
-  string backup3 = 23;                      // 备用字段3
-  int32 created_at = 24;                    // 创建时间
-  string created_at_format = 25;            // 创建时间格式化
-  IsShow.Kind is_show = 26;                  // 是否启用
-  string data_source = 27;                   // 饲料来源
-}
-
-message SearchForageListRequest {
-  string name = 1;              // 饲料名称
-  int32 category_id = 2;        // 饲料分类id
-  uint32 forage_source_id = 3;   // 饲料来源
-  IsShow.Kind is_show = 4;       // 是否启用
-  uint32 allow_error = 5;        // 允许误差
-  uint32 jump_weight = 6;        // 跳转重量域
-  JumpDelaType.Kind  jump_delay = 7;   // 跳转延迟
-  PaginationModel pagination = 8;   // 分页
-}
-
-message ForageListSortRequest {
-  repeated ForageListSort list = 1;
-}
-
-message ForageListSort {
-  int64 id = 1;
-  int64 sort = 2;
-}
-
-message SmallMaterialRequest {
-  string api_name = 1;        // 牧场端接口标识名称
-  int32 pasture_id = 2;       // 牧场id
-  string info_name = 3;       //
-}
-
-message SearchForageListResponse {
- int32 code = 1;
- string msg = 2;
- SearchForageList data = 3;
-}
-
-message SearchForageList {
-  int32 page = 1;
-  int32 page_size = 2;
-  int32 total = 3;
-  repeated AddForageRequest list = 4;
-}
-
-// 是否启用
-message IsShowForage {
-  int32 forage_id = 1;
-  IsShow.Kind is_show = 2;
-}
-
-message ForageEnumListResponse {
-  int32 code = 1;
-  string msg = 2;
-  ForageEnumList data = 3;
-}
-
-message ForageEnumList {
-  repeated ForageSourceEnum forage_source = 1;                    // 饲料来源
-  repeated ForagePlanTypeEnum forage_plan_type = 2;               // 饲料计划类型
-  repeated JumpDelaTypeEnum jump_dela_type = 3;                   // 跳转延迟类型
-  repeated CattleParentCategoryEnum cattle_parent_category = 4;   // 畜牧分类
-  repeated ForageParentCategoryEnum forage_parent_category = 5;   // 饲料分类
-  repeated IsShowEnum is_show = 6;
-  repeated FormulaTypeEnum formula_type = 7;                      // 配方类型
-  repeated FormulaOptionEnum formula_list = 8;                    // 所有配方列表
-  repeated IsShowEnum confirm_start = 9;                          // 确认开始
-  repeated FormulaOptionEnum formulation_evaluation = 10;         // 配方评估查询方式
-  repeated FormulaOptionEnum use_materials_list = 11;             // 用料分析-列表显示
-  repeated FormulaOptionEnum use_materials_type = 12;             // 用料分析-统计类型
-  repeated FormulaOptionEnum price_materials_type = 13;           // 价格分析-统计类型
-  repeated FormulaOptionEnum jump_type = 14;                      // 准确性-跳转方式
-  repeated FormulaOptionEnum statistics_type = 15;                // 准确性-统计类型
-}
-
-message ForageSourceEnum {
-  ForageSource.Kind value = 1;
-  string label = 2;
-}
-
-message ForagePlanTypeEnum {
-  ForagePlanType.Kind value = 1;
-  string label = 2;
-}
-
-message JumpDelaTypeEnum {
-  JumpDelaType.Kind value = 1;
-  string label = 2;
-}
-
-message CattleParentCategoryEnum {
-  CattleCategoryParent.Kind value = 1;
-  string label = 2;
-}
-
-message ForageParentCategoryEnum {
-  ForageCategoryParent.Kind value = 1;
-  string label = 2;
-}
-
-message IsShowEnum {
-  IsShow.Kind value = 1;
-  string label = 2;
-}
-
-message FormulaTypeEnum {
-  FormulaType.Kind value = 1;
-  string label = 2;
-}
-
-message FormulaOptionEnum {
-  int32 value = 1;
-  string label = 2;
-}
-// 牧场端分类数据同步
-message CategorySyncRequest {
-  string key_word = 1;         // 关键字
-  int32 pasture_id = 2;        // 牧场id
-  int32 parent_id = 3;         // 一类id
-  string parent_name = 4;      // 一类名称
-  string name = 5;             // 分类名称
-  string number = 6;           // 分类编号
-  IsShow.Kind is_show = 7;     // 是否展示
-  IsShow.Kind is_delete = 8;   // 是否删除
-  int32 id = 9;                // 牧场端数据id
-}
-
-// 牧场端分类数据删除
-message CategoryDeleteRequest {
-  string key_word = 1;    // 关键字
-  int32 pasture_id = 2;   // 牧场id
-  int32 data_id = 3;
-}
-
-message FeedFormulaSyncRequest {
-  int32 pasture_id = 1;    // 牧场id
-  int32 page = 2;          // 返回数据条数
-  int32 page_size = 3;     // 返回数据条数
-}

+ 0 - 285
backend/operation/statistic.proto

@@ -1,285 +0,0 @@
-syntax = "proto3";
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-
-import "backend/operation/pagination.proto";
-import "backend/operation/enum.proto";
-import "backend/operation/pasture.proto";
-
-// SearchFormulaEstimateRequest 配方评估
-message SearchFormulaEstimateRequest {
-  string start_time  = 1;     // 开始时间
-  string end_time    = 2;     // 结束时间
-  int32 search_type = 3;      // 查询方式  0 安照配方 1 按照栏舍
-  string api_name = 4;        // 牧场端接口标识名称
-  int32 pasture_id = 5;       // 牧场id
-  int32 template_id = 6;     // 配方模板id
-  int32 barn_id = 7;          // 栏舍id
-  PaginationModel pagination = 8; // 分页
-}
-
-// SearchInventoryStatisticsRequest 库存管理-库存统计
-message SearchInventoryStatisticsRequest {
-  string start_time  = 1;     // 开始时间
-  string end_time    = 2;     // 结束时间
-  string api_name = 3;        // 牧场端接口标识名称
-  string feed_name = 4;       // 饲料名称
-  int32 pasture_id = 5;       // 牧场id
-  PaginationModel pagination = 6; // 分页
-}
-
-// SearchUserMaterialsStatisticsRequest 库存管理-用料分析
-message SearchUserMaterialsStatisticsRequest {
-  string start_time  = 1;     // 开始时间
-  string end_time    = 2;     // 结束时间
-  string api_name = 3;        // 牧场端接口标识名称
-  int32 pasture_id = 4;       // 牧场id
-  int32 error_check = 5;       // 误差是否选中 0 未选中 1 选中
-  int32 type_check = 6;        // 返回实际或理论 1 理论 2 实际
-  string feed_name = 7;        // 名称
-  PaginationModel pagination = 8; // 分页
-}
-
-// SearchPriceStatisticsRequest 库存管理-价格分析
-message SearchPriceStatisticsRequest {
-  string start_time  = 1;     // 开始时间
-  string end_time    = 2;     // 结束时间
-  string api_name = 3;        // 牧场端接口标识名称
-  int32 pasture_id = 4;       // 牧场id
-  string feed_name = 5;        // 名称
-  PaginationModel pagination = 6; // 分页
-}
-
-// SearchFeedStatisticsRequest 饲喂效率-效率统计
-message SearchFeedStatisticsRequest {
-  string start_time  = 1;            // 开始时间
-  string api_name = 2;               // 牧场端接口标识名称
-  repeated int32 pasture_id = 3;     // 牧场id
-  string formula_template = 4;       // 配方模板名称
-  string barn_name = 5;               // 栏舍名称
-  string cattle_category_name = 6;   // 畜牧类别名称
-  int32 cattle_category_id = 7;     // 畜牧类别id
-  int32 class_number = 8;            // 班次
-  PaginationModel pagination = 9;   // 分页
-  string end_time = 10;            // 结束时间
-}
-
-// FeedChartStatisticsRequest 饲喂效率chart图表
-message FeedChartStatisticsRequest {
-  string start_time = 1;     // 开始时间
-  string end_time = 2;       // 结束时间
-  int32 pasture_id = 3;      // 牧场id
-  int32 status = 4;
-  string api_type = 5;       // mr 泌乳牛干物质采食量 sl 牛栏剩料率 hl 混料时间统计 zh 转化率 cbft 成本分析
-}
-
-// CowsAnalysisRequest 饲喂效率-牛群评估
-message CowsAnalysisRequest {
-  string start_time = 1;     // 开始时间
-  string api_name = 2;       // 牧场端接口标识名称
-  int32 pasture_id = 3;      // 牧场id
-  PaginationModel pagination = 4;   // 分页
-}
-
-// AccuracyAggStatisticsRequest 准确性分析-汇总统计
-message AccuracyAggStatisticsRequest {
-  string start_time = 1;     // 开始时间
-  string end_time = 2;       // 结束时间
-  int32 pasture_id = 3;      // 牧场id
-  string fname = 4;         // 查询名称
-  string sort = 5;
-  string status = 6;
-  int32 genre = 7;
-  int32 isdate = 8;
-  int32 hlwc1 = 9;
-  int32 hlwc2 = 10;
-  int32 hlzq1 = 11;
-  int32 hlzq2 = 12;
-  int32 hlzql1 = 13;
-  int32 hlzql2 = 14;
-  int32 slwc1 = 15;
-  int32 slwc2 = 16;
-  int32 slzq1 = 17;
-  int32 slzq2 = 18;
-  int32 slzql1 = 19;
-  int32 slzql2 = 20;
-  string projname = 21;
-  string Times = 22;
-  bool is_error = 23;
-}
-
-// MixFeedStatisticsRequest 准确性分析-混料统计
-message MixFeedStatisticsRequest {
-  string start_time  = 1;            // 开始时间
-  string end_time = 2;               // 结束时间
-  string api_name = 3;               // 牧场端接口标识名称
-  int32 pasture_id = 4;              // 牧场id
-  string equipment_name = 5;         // 设备名称
-  string train_number = 6;           // 车次
-  int32 class_number = 7;            // 班次
-  string formulation_name = 8;       // 配方名称
-  int32 jump_type = 9;               // 跳转方式 0 手动跳转 1 自动跳转
-  int32 hlwc1 = 10;                  // 混料误差值1
-  int32 hlwc2 = 11;                  // 混料误差值2
-  int32 hlzq1 = 12;                  // 混料准确率1
-  int32 hlzq2 = 13;                  // 混料准确率2
-  int32 hlzql1 = 14;                 // 混料正确率1
-  int32 hlzql2 = 15;                 // 混料正确率2
-  bool is_error = 16;                // 只看超出预设值数据
-  string button_type = 17;
-  string is_use = 18;
-  PaginationModel pagination = 19;   // 分页
-}
-
-// SprinkleStatisticsRequest 准确性分析-撒料统计
-message SprinkleStatisticsRequest {
-  string start_time  = 1;            // 开始时间
-  string end_time = 2;               // 结束时间
-  string api_name = 3;               // 牧场端接口标识名称
-  int32 pasture_id = 4;              // 牧场id
-  string equipment_name = 5;         // tmr设备名称
-  string train_number = 6;           // 车次
-  int32 class_number = 7;            // 班次
-  string formulation_name = 8;       // 配方名称
-  string barn_name = 9;              // 栏舍名称
-  int32 jump_type = 10;               // 跳转方式 0 手动跳转 1 自动跳转
-  int32 slwc1 = 11;                  // 撒料误差值1
-  int32 slwc2 = 12;                  // 撒料误差值2
-  int32 slzq1 = 13;                  // 撒料准确率1
-  int32 slzq2 = 14;                  // 撒料准确率2
-  int32 slzql1 = 15;                 // 撒料正确率1
-  int32 slzql2 = 16;                 // 撒料正确率2
-  bool is_error = 17;                // 只看超出预设值数据
-  string button_type = 18;
-  string is_use = 19;
-  PaginationModel pagination = 20;   // 分页
-}
-
-// GetDataByNameRequest
-message GetDataByNameRequest {
-  string start_time  = 1;            // 开始时间
-  string end_time = 2;               // 结束时间
-  string api_name = 3;               // 牧场端接口标识名称
-  int32 pasture_id = 4;              // 牧场id
-}
-
-// ProcessAnalysisRequest 过程分析
-message ProcessAnalysisRequest {
-  string start_time  = 1;            // 开始时间
-  string end_time = 2;               // 结束时间
-  string api_name = 3;               // 牧场端接口标识名称
-  int32 pasture_id = 4;              // 牧场id
-  int32 plan_type = 5;               // 计划类型
-  repeated string tmr_name = 6;      // TMR名称
-  string error_range = 7;            // 误差筛选范围
-  string work_status = 8;            // 工作状态
-  string mix_feed_type = 9;          // 混料类别
-  int32 hlwc1 = 10;                  // 混料误差值1
-  int32 hlwc2 = 11;                  // 混料误差值2
-  int32 hlzq1 = 12;                  // 混料准确率1
-  int32 hlzq2 = 13;                  // 混料准确率2
-  int32 slwc1 = 14;                  // 撒料误差值1
-  int32 slwc2 = 15;                  // 撒料误差值2
-  int32 slzq1 = 16;                  // 撒料准确率1
-  int32 slzq2 = 17;                  // 撒料准确率2
-  PaginationModel pagination = 18;   // 分页
-}
-
-// ProcessMixedSprinkleDetailRequest
-message ProcessMixedSprinkleDetailRequest {
-  string api_name = 1;
-  int32 pasture_id = 2;
-  string pid = 3;
-  string fclass_id = 4;
-  string id = 5;
-  PaginationModel pagination = 6;   // 分页
-}
-
-message TrainNumberRequest {
-  string api_name = 1;               // 牧场端接口标识名称
-  int32 pasture_id = 2;              // 牧场id
-  string info_name = 3;
-  PaginationModel pagination = 4;   // 分页
-}
-
-message TrainNumberResponse {
-  int32 code = 1;
-  string msg = 2;
-  TrainNumberData data = 3;
-}
-
-message TrainNumberData {
-  repeated FormulaOptionEnum list = 1;
-}
-
-
-// 首页 dashboard 准确性分析
-message SearchAnalysisAccuracyRequest {
-  CattleCategoryParent.Kind cattle_parent_category_id = 1;   // 牧畜分类id 泌乳牛
-  int32 feed_formula_id = 2;    // 配方id
-  string start_date = 3;       // 开始时间
-  string end_date = 4;         // 结束时间
-  repeated int32 pasture_ids = 5;   //牧场ids
-  float top_rand_start = 6;         // 排名区间开始位
-  float top_rand_end = 7;           // 排名区间结束位
-  DashboardTopType.Kind dashboard_top_type = 8;  // 排序区间标识
-}
-
-message SearchAnalysisAccuracyResponse {
-  int32 code = 1;
-  string msg = 2;
-  AnalysisAccuracy data = 3;
-}
-
-message AnalysisAccuracy {
-  Chart chart = 1;
-  Table table = 2;
-}
-
-message Chart {
-  CommonValueRatio mixed_fodder_accurate_ratio = 4;              // 混料准确率
-  CommonValueRatio mixed_fodder_correct_ratio = 5;               // 混料正确率
-  CommonValueRatio sprinkle_fodder_accurate_ratio = 6;           // 撒料准确率
-  CommonValueRatio sprinkle_fodder_correct_ratio = 7;            // 撒料正确率
-}
-
-message Table {
-  message TableList {
-    int32 id = 1;
-    string name = 2;
-  }
-
-  repeated TableList table_list = 1;
-}
-
-message CommonValueRatio {
-  string max_value = 1;                  // 最高值
-  string middle_value = 2;               // 中位值
-  string min_value = 3;                  // 最低值
-  repeated ValueRatio data_list = 4;     // 数据集合
-  repeated string pasture_name = 5;      // 牧场名称集合
-  repeated string date_day = 6;          // 日期集合
-}
-
-message ValueRatio {
-  repeated string value_ratio = 1;
-}
-
-// 首页 dashboard 撒料时间统计分析
-message SprinkleFeedTimeRequest {
-  int32 feed_formula_id = 1;    // 配方id
-  string start_date = 2;       // 开始时间
-  string end_date = 3;         // 结束时间
-  repeated int32 pasture_ids = 4;   //牧场ids
-  int32 data_type = 5;       // 过滤的数据类型 0 不过滤 1 正常 2 异常
-}
-
-// MixedCategoryTmrName tmr名称和混料类别
-message MixedCategoryTmrName  {
-  string api_name   = 1;
-  int32 pasture_id = 2;
-  string start_time = 3;
-  string end_time = 4;
-}

+ 0 - 220
backend/operation/system.proto

@@ -1,220 +0,0 @@
-syntax = "proto3";
-package backend.operation;
-
-option go_package = ".;operationPb";
-
-import "backend/operation/enum.proto";
-import "backend/operation/pagination.proto";
-import "backend/operation/pasture.proto";
-
-message CommonOK {
-  int32 code = 1;
-  string msg = 2;
-  Success data = 3;
-}
-
-message Success {
-  bool success = 1;
-}
-
-message WxOpenId {
-  string openid = 1;
-}
-
-// 用户角色
-message AddRoleRequest {
-  uint32 id = 1;
-  string name = 2;        // 角色名称
-  string remarks = 3;     // 角色备注
-  IsShow.Kind is_show = 4;     // 是否启用
-  repeated uint32 pasture_id = 5;    // 牧场id
-  repeated uint32 menu_id = 6;       // 菜单id
-  repeated uint32 mobile_id = 7;     // 移动端id
-  string create_user = 8;          // 创建用户
-  uint32 created_at = 9;             // 创建时间
-  string created_at_format = 10;     // 创建时间格式化
-
-  repeated string pasture_list = 11;   // 负责的牧场
-  repeated string menu_list = 12; // 权限列表
-}
-
-message SearchRoleRequest {
-  string name = 3;       // 角色名称
-  PaginationModel pagination = 2;  // 分页
-}
-
-message SearchRoleResponse {
-  uint32 code = 1;
-  string msg = 2;
-  SearchRoleData data = 3;
-}
-
-message SearchRoleData {
-  int32 page = 1;
-  int32 total = 2;
-  int32 page_size = 3;
-  repeated AddRoleRequest list = 4;
-}
-
-// 角色对应权限列表
-message RolePermissionsList {
-  int32 code = 1;
-  string msg = 2;
-  RolePermissionsData data = 3;
-}
-
-message RolePermissionsData {
-  repeated uint32 mobile_list = 1;    // 移动端权限id
-  repeated uint32 pasture_list = 2;    // 牧场端列表
-  repeated uint32 menu_list = 3;      // 后端权限列表
-}
-
-// 用户token
-message SystemToken {
-  int32 code =  1;
-  string msg = 2;
-  TokenData data = 3;
-}
-
-message TokenData {
-  string token = 1;
-}
-
-// 用户登录
-message UserAuth {
-  int32 code = 1;
-  string msg = 2;
-  UserAuthData data = 3;
-}
-
-message UserAuthData {
-  string user_name = 1;   // 用户名称
-  string password = 2;    // 用户密码
-  string phone = 3;       // 用户手机号
-  repeated UserRole roles  = 4;    // 用户角色
-  string employee_name = 5;    // 员工名称
-  repeated UserPasture pastures = 6; // 用户角色牧场牧场
-}
-
-message UserRole {
-  int32 id = 1;      // 角色id
-  string name = 2;   // 角色名称
-}
-
-// 用户详情
-message UserDetails {
-  int32 code = 1;
-  string msg = 2;
-  AddSystemUser data = 3;
-}
-
-
-message AddSystemUser {
-  int32 id = 1;                    // 用户id
-  string name = 2;                 // 用户名称
-  string phone = 3;                // 用户手机号
-  repeated UserRole roles = 4;      // 角色
-  IsShow.Kind is_show = 5;         // 是否开启
-  string employee_name = 6;        // 员工姓名
-  string create_user = 7;          // 创建人
-  int32 created_at = 8;            // 创建时间
-  string created_at_format = 9;      // 创建时间格式化
-  string role_name = 10;            // 角色名称
-  repeated int32 role_ids = 11;     // 角色ids
-}
-
-// 查询用户
-message SearchUserRequest {
-  string name = 1;               // 用户名称
-  string employee_name = 2;       // 员工姓名
-  IsShow.Kind is_show = 3;        // 是否启用
-  uint32 created_start_time = 4;   // 开始时间
-  uint32 created_end_time = 5;     // 结束时间
-  PaginationModel pagination = 6; // 分页
-}
-
-message SearchUserResponse {
-    int32 code = 1;
-    string msg = 2;
-    SearchUserData data = 3;
-}
-
-message SearchUserData  {
-  int32 page = 1;
-  int32 total = 2;
-  int32 page_size = 3;
-  repeated AddSystemUser list = 4;
-}
-
-message IsShowSystemUserRequest {
-  int32 user_id = 1;  // 用户id
-  IsShow.Kind is_show = 2;   // is_show
-}
-// 系统菜单权限
-message AddMenuRequest {
-  int32 id = 1;
-  string name = 2;           // 名称
-  int32 parent_id = 3;       // 父id
-  int32 menu_type = 4;       // 菜单类型 1 菜单 2 按钮
-  string title = 5;          // 标题
-  string path = 6;           // 路径 path
-  IsShow.Kind is_show = 7;   // 是否显示
-  string component = 8;      // 组件
-  string icon = 9;           // 图标
-  int32 sort = 10;           // 排序
-  string redirect = 11;      // 重定向
-  int32 created_at = 12;     // 创建时间
-  string created_at_format = 13;      // 创建时间格式化
-  int32 level = 14;                   // 菜单等级
-  repeated AddMenuRequest children = 15;   // 子分类
-  bool affix = 16;
-  bool keepAlive = 17;
-}
-
-message IsShowSystemMenuRequest {
-  int32 menu_id = 1;  // 角色id
-  IsShow.Kind is_show = 2;   // is_show
-}
-
-// 查询菜单权限
-message SearchMenuRequest {
-  string name = 1;               // 菜单名称
-  PaginationModel pagination = 2; // 分页
-}
-
-message SearchMenuResponse {
-  int32 code = 1;
-  string msg = 2;
-  SearchMenuData data = 3;
-}
-
-message SearchMenuData {
-  int32 page = 1;
-  int32 total = 2;
-  repeated AddMenuRequest list = 3;
-}
-
-// 系统用户权限相关
-message SystemUserMenuPermissions {
-  int32 code = 1;
-  string msg = 2;
-  SystemUserMenuData data = 3;
-}
-
-message SystemUserMenuData {
-  repeated AddPastureRequest pasture_list = 1;    // 牧场列表
-  repeated AddMenuRequest menu_list = 2;          // 菜单列表
-  repeated AddMobileRequest mobile_list = 3;      // 移动端权限
-  repeated MenuButtonsPath menu_buttons_path = 4;  // 按钮级别权限path,前端需要特别处理
-}
-
-message MenuButtonsPath {
-  string path = 1;
-  int32 menu_id = 2;
-}
-
-// 移动端
-message AddMobileRequest {
-  uint32 id = 1;     // id
-  string name = 2;  // 名称
-}

+ 1 - 1
cmd/http.go

@@ -2,10 +2,10 @@ package cmd
 
 import (
 	"fmt"
+	"gitee.com/xuyiping_admin/pkg/logger/logrus"
 	"kpt-tmr-group/config"
 	"kpt-tmr-group/dep"
 	"kpt-tmr-group/http"
-	"kpt-tmr-group/pkg/logger/logrus"
 
 	"github.com/spf13/cobra"
 )

+ 1 - 1
config/app.go

@@ -2,7 +2,7 @@ package config
 
 import (
 	"crypto/rsa"
-	"kpt-tmr-group/pkg/di"
+	"gitee.com/xuyiping_admin/pkg/di"
 	"os"
 	"strings"
 	"sync"

+ 1 - 1
dep/dep.go

@@ -1,9 +1,9 @@
 package dep
 
 import (
+	"gitee.com/xuyiping_admin/pkg/di"
 	"kpt-tmr-group/config"
 	"kpt-tmr-group/module/backend"
-	"kpt-tmr-group/pkg/di"
 	"kpt-tmr-group/service/sso"
 	"kpt-tmr-group/service/wechat"
 	"kpt-tmr-group/store/kptstore"

+ 1 - 1
dep/di.go

@@ -1,6 +1,6 @@
 package dep
 
-import "kpt-tmr-group/pkg/di"
+import "gitee.com/xuyiping_admin/pkg/di"
 
 func DI(opts ...di.HubOption) *di.Hub {
 	var hubOpts []di.HubOption

+ 10 - 13
go.mod

@@ -3,7 +3,8 @@ module kpt-tmr-group
 go 1.17
 
 require (
-	github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20230822100450-307557aa568a
+	gitee.com/xuyiping_admin/pkg v0.0.0-20230822102440-0e489dd5d75a
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/getsentry/sentry-go v0.23.0
 	github.com/gin-contrib/cors v1.4.0
@@ -14,16 +15,7 @@ require (
 	github.com/go-redis/redis/v7 v7.4.1
 	github.com/golang/mock v1.4.4
 	github.com/golang/protobuf v1.5.3
-	github.com/google/go-cmp v0.5.9
-	github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
-	github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
-	github.com/huandu/xstrings v1.4.0
-	github.com/jinzhu/copier v0.3.5
-	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
-	github.com/magiconair/properties v1.8.7
 	github.com/mitchellh/mapstructure v1.5.0
-	github.com/nyaruka/phonenumbers v1.1.7
-	github.com/sirupsen/logrus v1.9.3
 	github.com/spf13/cobra v1.7.0
 	github.com/spf13/viper v1.15.0
 	github.com/stretchr/testify v1.8.4
@@ -32,15 +24,12 @@ require (
 	go.uber.org/multierr v1.8.0
 	go.uber.org/zap v1.24.0
 	golang.org/x/sync v0.2.0
-	google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf
-	google.golang.org/grpc v1.57.0
 	google.golang.org/protobuf v1.31.0
 	gorm.io/driver/mysql v1.5.1
 	gorm.io/gorm v1.25.2
 )
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20230802054950-77dee3d12065 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
 	github.com/bytedance/sonic v1.9.1 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
@@ -55,14 +44,19 @@ require (
 	github.com/go-sql-driver/mysql v1.7.0 // indirect
 	github.com/goccy/go-json v0.10.2 // indirect
 	github.com/google/uuid v1.3.0 // indirect
+	github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
+	github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
+	github.com/huandu/xstrings v1.4.0 // indirect
 	github.com/inconshreveable/mousetrap v1.1.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.5 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
 	github.com/leodido/go-urn v1.2.4 // indirect
+	github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
 	github.com/lestrrat-go/strftime v1.0.6 // indirect
+	github.com/magiconair/properties v1.8.7 // indirect
 	github.com/mattn/go-isatty v0.0.19 // indirect
 	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -77,6 +71,7 @@ require (
 	github.com/prometheus/procfs v0.10.1 // indirect
 	github.com/richardlehane/mscfb v1.0.4 // indirect
 	github.com/richardlehane/msoleps v1.0.3 // indirect
+	github.com/sirupsen/logrus v1.9.3 // indirect
 	github.com/spf13/afero v1.9.3 // indirect
 	github.com/spf13/cast v1.5.0 // indirect
 	github.com/spf13/jwalterweatherman v1.1.0 // indirect
@@ -92,6 +87,8 @@ require (
 	golang.org/x/net v0.10.0 // indirect
 	golang.org/x/sys v0.8.0 // indirect
 	golang.org/x/text v0.9.0 // indirect
+	google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect
+	google.golang.org/grpc v1.57.0 // indirect
 	gopkg.in/ini.v1 v1.67.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )

+ 4 - 9
go.sum

@@ -36,12 +36,13 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
 cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20230802054950-77dee3d12065 h1:ITJlIE5ITvh3FiOw6QOrVDgAYOtuimwMBiHM0prmVbQ=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20230802054950-77dee3d12065/go.mod h1:cxbPefIf1o+cyQwvFaM3ndaoUeaK5aWzPV/eZQGJPgE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20230822100450-307557aa568a h1:77YHuhzd5gGnNNcEahlUWNbA+QheErdLcENBFMbX8eI=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20230822100450-307557aa568a/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
+gitee.com/xuyiping_admin/pkg v0.0.0-20230822102440-0e489dd5d75a h1:+SSGto+q5BKy6r9FLFQXooTNqZs4tALceFpoo2jef8w=
+gitee.com/xuyiping_admin/pkg v0.0.0-20230822102440-0e489dd5d75a/go.mod h1:vK5K2LnhWZnvZlEY9gmT6GFdq/5Y0mtxuKLNJHFJkE4=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
-github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
 github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
 github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
 github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -164,7 +165,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
 github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
-github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
 github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@@ -202,8 +202,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
-github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
-github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
 github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
 github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
 github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@@ -254,7 +252,6 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
 github.com/nyaruka/phonenumbers v1.1.7 h1:5UUI9hE79Kk0dymSquXbMYB7IlNDNhvu2aNlJpm9et8=
-github.com/nyaruka/phonenumbers v1.1.7/go.mod h1:DC7jZd321FqUe+qWSNcHi10tyIyGNXGcNbfkPvdp1Vs=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
 github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -730,8 +727,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-kpt-tmr-group/pkg v0.0.0-20230802061948-5b07cd8c16e6 h1:K4RrKDO1SG1NOCoqNO0jnlGKmY7AfOmuqzDIw94KCTk=
-kpt-tmr-group/pkg v0.0.0-20230802061948-5b07cd8c16e6/go.mod h1:h3kdB9CyxmW6duxLLA6fJezVCHa0g5+erAQ60iv+S58=
 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

+ 4 - 4
http/debug/debug.go

@@ -1,11 +1,11 @@
 package debug
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 
 	"github.com/gin-gonic/gin"

+ 4 - 4
http/handler/dashboard/dashboard.go

@@ -1,11 +1,11 @@
 package dashboard
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 
 	"github.com/gin-gonic/gin"

+ 5 - 5
http/handler/feed/feed_formula.go

@@ -2,12 +2,12 @@ package feed
 
 import (
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"mime/multipart"
 	"net/http"
 	"path"

+ 4 - 4
http/handler/feed/feed_formula_detail.go

@@ -1,11 +1,11 @@
 package feed
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 
 	"github.com/gin-gonic/gin"

+ 3 - 3
http/handler/mobile/mobile_list.go

@@ -1,10 +1,10 @@
 package mobile
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 
 	"github.com/gin-gonic/gin"

+ 4 - 4
http/handler/pasture/cattle_forage_category.go

@@ -1,11 +1,11 @@
 package pasture
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 

+ 5 - 5
http/handler/pasture/forage_list.go

@@ -2,12 +2,12 @@ package pasture
 
 import (
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"mime/multipart"
 	"net/http"
 	"path"

+ 4 - 4
http/handler/pasture/pasture.go

@@ -1,11 +1,11 @@
 package pasture
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 
 	"github.com/gin-gonic/gin"

+ 4 - 4
http/handler/pasture/pasture_list.go

@@ -1,11 +1,11 @@
 package pasture
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 

+ 4 - 4
http/handler/statistic/analysis.go

@@ -2,11 +2,11 @@ package statistic
 
 import (
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"time"
 

+ 4 - 4
http/handler/system/menu.go

@@ -1,11 +1,11 @@
 package system
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 

+ 4 - 4
http/handler/system/role.go

@@ -1,11 +1,11 @@
 package system
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 

+ 4 - 4
http/handler/system/user.go

@@ -1,11 +1,11 @@
 package system
 
 import (
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/ginutil"
+	"gitee.com/xuyiping_admin/pkg/valid"
 	"kpt-tmr-group/http/middleware"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/ginutil"
-	"kpt-tmr-group/pkg/valid"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 

+ 1 - 1
http/middleware/cors.go

@@ -1,8 +1,8 @@
 package middleware
 
 import (
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
 	"io/ioutil"
-	"kpt-tmr-group/pkg/logger/zaplog"
 	"net/http"
 
 	"go.uber.org/zap"

+ 2 - 2
http/middleware/sentry.go

@@ -1,8 +1,8 @@
 package middleware
 
 import (
-	sentry2 "kpt-tmr-group/pkg/sentry"
-	"kpt-tmr-group/pkg/xerr"
+	sentry2 "gitee.com/xuyiping_admin/pkg/sentry"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"sync"
 
 	"github.com/getsentry/sentry-go"

+ 4 - 3
http/middleware/sso.go

@@ -2,9 +2,10 @@ package middleware
 
 import (
 	"kpt-tmr-group/config"
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/jwt"
-	commonPb "kpt-tmr-group/proto/go/backend/common"
+
+	commonPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/common"
+	"gitee.com/xuyiping_admin/pkg/apierr"
+	"gitee.com/xuyiping_admin/pkg/jwt"
 
 	"net/http"
 	"strings"

+ 1 - 1
http/util/httptt/http.go

@@ -7,7 +7,7 @@ import (
 	"net/http"
 	"testing"
 
-	"kpt-tmr-group/pkg/jsonpb"
+	"gitee.com/xuyiping_admin/pkg/jsonpb"
 
 	"github.com/golang/protobuf/proto"
 	"github.com/stretchr/testify/require"

+ 1 - 1
http/util/httptt/query_encoder.go

@@ -8,7 +8,7 @@ import (
 	"reflect"
 	"strings"
 
-	"kpt-tmr-group/pkg/xerr"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 
 	"github.com/golang/protobuf/proto"
 )

+ 1 - 1
main.go

@@ -5,8 +5,8 @@ Copyright © 2022 NAME HERE <EMAIL ADDRESS>
 package main
 
 import (
+	"gitee.com/xuyiping_admin/pkg/logger/logrus"
 	"kpt-tmr-group/cmd"
-	"kpt-tmr-group/pkg/logger/logrus"
 )
 
 func main() {

+ 1 - 1
model/analysis_accuracy.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 )
 
 type AnalysisAccuracy struct {

+ 1 - 1
model/cattle_category.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/feed_formula.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/feed_formula_detail.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/feed_formula_distribute_log.go

@@ -1,6 +1,6 @@
 package model
 
-import operationPb "kpt-tmr-group/proto/go/backend/operation"
+import operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 
 type FeedFormulaDistributeLog struct {
 	Id            int64                   `json:"id"`

+ 1 - 1
model/feed_formula_edit_record.go

@@ -1,6 +1,6 @@
 package model
 
-import operationPb "kpt-tmr-group/proto/go/backend/operation"
+import operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 
 type FeedFormulaEditRecord struct {
 	Id            int64                                      `json:"id"`

+ 1 - 1
model/forage.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/forage_category.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/formula_estimate.go

@@ -2,7 +2,7 @@ package model
 
 import (
 	"fmt"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 )
 
 type PastureCommonRequest struct {

+ 4 - 4
model/group_pasture.go

@@ -4,11 +4,11 @@ import (
 	"bytes"
 	"encoding/json"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/tool"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"io/ioutil"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/tool"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strings"
 	"time"

+ 1 - 1
model/pasture_data.go

@@ -1,6 +1,6 @@
 package model
 
-import operationPb "kpt-tmr-group/proto/go/backend/operation"
+import operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 
 type DistributeFeedFormulaRequest struct {
 	PastureId         int64                `json:"pasture_id"`

+ 1 - 1
model/system_group_pasture_permissions.go

@@ -1,6 +1,6 @@
 package model
 
-import operationPb "kpt-tmr-group/proto/go/backend/operation"
+import operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 
 type SystemGroupPasturePermissions struct {
 	Id        int64                   `json:"id,omitempty"`

+ 1 - 1
model/system_menu.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/system_menu_permissions.go

@@ -1,6 +1,6 @@
 package model
 
-import operationPb "kpt-tmr-group/proto/go/backend/operation"
+import operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 
 type SystemMenuPermissions struct {
 	Id        int64                   `json:"id,omitempty"`

+ 1 - 1
model/system_mobile.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/system_mobile_permissions.go

@@ -1,6 +1,6 @@
 package model
 
-import operationPb "kpt-tmr-group/proto/go/backend/operation"
+import operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 
 type SystemMobilePermissions struct {
 	Id        int64                   `json:"id,omitempty"`

+ 1 - 1
model/system_role.go

@@ -1,7 +1,7 @@
 package model
 
 import (
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"time"
 )
 

+ 1 - 1
model/system_user.go

@@ -2,7 +2,7 @@ package model
 
 import (
 	"fmt"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 	"strings"

+ 6 - 6
module/backend/dashboard_service.go

@@ -4,11 +4,11 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/tool"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/tool"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"sort"
 	"sync"
@@ -49,7 +49,7 @@ func (s *StoreEntry) PasturePrefAnalysisData(ctx context.Context, req *operation
 			}
 			_, err = s.PastureHttpClient(ctx, model.DashboardAccuracyUrl, int64(pId), body, response)
 			if err != nil {
-				zaplog.Error("DistributeFeedFormula",
+				zaplog.Error("PasturePrefAnalysisData",
 					zap.String("url", model.DashboardAccuracyUrl),
 					zap.Any("pasture", groupPasture), zap.Any("body", body),
 					zap.Any("err", err), zap.Any("response", response))
@@ -60,7 +60,7 @@ func (s *StoreEntry) PasturePrefAnalysisData(ctx context.Context, req *operation
 				return
 			}
 			if response.Code != http.StatusOK {
-				zaplog.Error("DistributeFeedFormula-response",
+				zaplog.Error("PasturePrefAnalysisData-response",
 					zap.String("url", model.DashboardAccuracyUrl),
 					zap.Any("pasture", groupPasture), zap.Any("body", body),
 					zap.Any("response", response), zap.Any("response", response))

+ 1 - 1
module/backend/edit_record_service.go

@@ -2,8 +2,8 @@ package backend
 
 import (
 	"context"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/xerr"
 )
 
 func (s *StoreEntry) GetEditRecordLastGroupId(ctx context.Context) (*model.FeedFormulaEditRecord, error) {

+ 17 - 8
module/backend/feed_service.go

@@ -6,11 +6,11 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"io"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 	"sync"
@@ -711,12 +711,11 @@ func (s *StoreEntry) DistributeFeedFormula(ctx context.Context, req *operationPb
 		go func(p *model.GroupPasture) {
 			defer wg.Done()
 
-			request := &model.DistributeFeedFormulaRequest{
+			request, response := &model.DistributeFeedFormulaRequest{
 				PastureId:         p.Id,
 				FeedFormula:       distributeData.FeedFormulaList,
 				FeedFormulaDetail: distributeData.FeedFormulaDetail,
-			}
-			response := &model.PastureResponse{}
+			}, &model.PastureResponse{}
 			defer func() {
 				if response.Code == http.StatusOK {
 					s.DB.Create(model.NewFeedFormulaDistributeLogList(distributeData.FeedFormulaList, p.Id, p.Name, operationPb.IsShow_OK))
@@ -727,7 +726,12 @@ func (s *StoreEntry) DistributeFeedFormula(ctx context.Context, req *operationPb
 
 			if _, err = s.PastureHttpClient(ctx, model.FeedFormulaDistributeUrl, p.Id, request, response); err != nil {
 				muError = multierr.Append(muError, err)
-				zaplog.Error("DistributeFeedFormula", zap.Any("pasture", p), zap.Any("body", distributeData.FeedFormulaList), zap.Any("err", err), zap.Any("response", response))
+				zaplog.Error("DistributeFeedFormula",
+					zap.Any("pasture", p),
+					zap.Any("body", distributeData.FeedFormulaList),
+					zap.Any("err", err),
+					zap.Any("response", response),
+				)
 				b, _ := json.Marshal(request)
 				res, _ := json.Marshal(response)
 				pastureDataLog := model.NewPastureDataLog(p.Id, PastureDataLogType["FeedFormula_Distribute"], model.FeedFormulaDistributeUrl, string(b), string(res))
@@ -772,7 +776,12 @@ func (s *StoreEntry) CancelDistributeFeedFormula(ctx context.Context, req *opera
 			response := &model.PastureResponse{}
 
 			if _, err = s.PastureHttpClient(ctx, model.FeedFormulaCancelDistributeUrl, p.Id, request, response); err != nil {
-				zaplog.Error("DistributeFeedFormula", zap.Any("pasture", p), zap.Any("body", distributeData.FeedFormulaList), zap.Any("err", err), zap.Any("response", response))
+				zaplog.Error("DistributeFeedFormula",
+					zap.String("url", model.FeedFormulaCancelDistributeUrl),
+					zap.Any("pasture", p),
+					zap.Any("body", distributeData.FeedFormulaList),
+					zap.Any("err", err),
+					zap.Any("response", response))
 				b, _ := json.Marshal(request)
 				res, _ := json.Marshal(response)
 				pastureDataLog := model.NewPastureDataLog(p.Id, PastureDataLogType["FeedFormula_Cancel_Distribute"], model.FeedFormulaCancelDistributeUrl, string(b), string(res))

+ 2 - 2
module/backend/interface.go

@@ -3,11 +3,11 @@ package backend
 import (
 	"bytes"
 	"context"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/di"
 	"io"
 	"kpt-tmr-group/config"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/di"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"kpt-tmr-group/service/wechat"
 	"kpt-tmr-group/store/kptstore"
 

+ 1 - 1
module/backend/mock/PastureService.go

@@ -9,7 +9,7 @@ import (
 	context "context"
 	io "io"
 	model "kpt-tmr-group/model"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	reflect "reflect"
 
 	gomock "github.com/golang/mock/gomock"

+ 1 - 1
module/backend/mock/PastureSyncService.go

@@ -6,7 +6,7 @@ package kptservicemock
 
 import (
 	context "context"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	reflect "reflect"
 
 	gomock "github.com/golang/mock/gomock"

+ 1 - 1
module/backend/mock/StatisticService.go

@@ -8,7 +8,7 @@ import (
 	bytes "bytes"
 	context "context"
 	model "kpt-tmr-group/model"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	reflect "reflect"
 
 	gomock "github.com/golang/mock/gomock"

+ 1 - 1
module/backend/mock/SystemService.go

@@ -6,7 +6,7 @@ package kptservicemock
 
 import (
 	context "context"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	reflect "reflect"
 
 	gomock "github.com/golang/mock/gomock"

+ 1 - 1
module/backend/mock/WxAppletService.go

@@ -6,7 +6,7 @@ package kptservicemock
 
 import (
 	context "context"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	reflect "reflect"
 
 	gomock "github.com/golang/mock/gomock"

+ 1 - 1
module/backend/mock/kptservice.go

@@ -9,7 +9,7 @@ import (
 	context "context"
 	io "io"
 	model "kpt-tmr-group/model"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
 	reflect "reflect"
 
 	gomock "github.com/golang/mock/gomock"

+ 4 - 4
module/backend/pasture_service.go

@@ -5,12 +5,12 @@ import (
 	"context"
 	"errors"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/tool"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"io"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/tool"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 	"sync"

+ 2 - 2
module/backend/pasture_sync_service.go

@@ -3,9 +3,9 @@ package backend
 import (
 	"context"
 	"errors"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"math"
 	"net/http"
 

+ 3 - 3
module/backend/statistic_service.go

@@ -6,10 +6,10 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"sort"
 	"sync"

+ 3 - 3
module/backend/system_permissions.go

@@ -2,10 +2,10 @@ package backend
 
 import (
 	"context"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"sort"
 	"strings"

+ 5 - 5
module/backend/system_service.go

@@ -4,12 +4,12 @@ import (
 	"context"
 	"errors"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/jwt"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/tool"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/jwt"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/tool"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 	"net/http"
 	"strconv"
 	"strings"

+ 3 - 3
module/backend/wx_applet_service.go

@@ -4,10 +4,10 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"gitee.com/xuyiping_admin/pkg/xerr"
 	"kpt-tmr-group/model"
-	"kpt-tmr-group/pkg/logger/zaplog"
-	"kpt-tmr-group/pkg/xerr"
-	operationPb "kpt-tmr-group/proto/go/backend/operation"
 
 	"go.uber.org/zap"
 )

+ 0 - 207
pkg/apierr/apierr.go

@@ -1,207 +0,0 @@
-package apierr
-
-import (
-	"encoding/json"
-	"kpt-tmr-group/pkg/xerr"
-	common "kpt-tmr-group/proto/go/backend/common"
-	"net/http"
-
-	"github.com/gin-gonic/gin"
-)
-
-func New(code common.Error_Code) *Error {
-	return &Error{err: &common.Error{
-		Code: code,
-		Msg:  errorMessage(code),
-	}}
-}
-
-func errorMessage(code common.Error_Code) string {
-	var errMessage string
-	if msg, ok := common.Error_Code_name[int32(code)]; ok {
-		errMessage = msg
-	} else {
-		errMessage = "INTERNAL_ERROR"
-	}
-
-	return errMessage
-}
-
-type Error struct {
-	err *common.Error
-}
-
-func (e *Error) GetCode() common.Error_Code {
-	return e.err.Code
-}
-
-func (e *Error) GetMsg() string {
-	return e.err.Msg
-}
-
-func (e *Error) GetErrors() []string {
-	return e.err.Errors
-}
-
-func (e *Error) Error() string {
-	bs, _ := json.Marshal(e.err)
-	return string(bs)
-}
-
-// Is 判断 err 和 e 是否相同
-func (e *Error) Is(err error) bool {
-	if gotErr, ok := err.(*Error); !ok {
-		return false
-	} else {
-		return e.err.Code == gotErr.err.Code
-	}
-}
-
-func (e *Error) MarshalJSON() ([]byte, error) {
-	return json.Marshal(e.err)
-}
-
-func (e *Error) UnmarshalJSON(data []byte) error {
-	var commonErr common.Error
-	if err := json.Unmarshal(data, &commonErr); err != nil {
-		return err
-	}
-
-	e.err = &commonErr
-	return nil
-}
-
-func (e *Error) WithLocaleMessage(c *gin.Context) *Error {
-	if msg := e.GetMsg(); msg != "" {
-		return e.SetMessage(msg)
-	}
-
-	return e
-}
-
-func (e *Error) SetMessage(m string) *Error {
-	e.err.Msg = m
-	return e
-}
-
-func (e *Error) SetErrors(errMessages []string) *Error {
-	e.err.Errors = errMessages
-	return e
-}
-
-// With more information
-func (e *Error) With(errs ...error) *Error {
-	for _, err := range errs {
-		e.err.Errors = append(e.err.Errors, err.Error())
-	}
-
-	return e
-}
-
-// WithContext return error with i18n message ?
-func WithContext(c *gin.Context, code common.Error_Code) *Error {
-	return New(code).WithLocaleMessage(c)
-}
-
-// AbortError 用来处理多种内部错误.
-// 在复杂业务场景中,存在一个接口返回多种业务错误码情况,通过这个函数来统一处理
-func AbortError(c *gin.Context, err error) {
-	if err == nil {
-		return
-	}
-
-	if e, ok := xerr.Cause(err).(*Error); ok {
-		// 取默认状态码
-		statusCode := DefaultErrorStatusCode(e.err.Code)
-		if !shouldIgnoreCode(statusCode) {
-			c.Error(e)
-		}
-		c.AbortWithStatusJSON(statusCode, e.WithLocaleMessage(c))
-		return
-	}
-
-	c.Error(err)
-	c.AbortWithStatusJSON(http.StatusInternalServerError, WithContext(c, common.Error_INTERNAL_ERROR).With(err))
-}
-
-// AbortStatusError 用来处理多种内部错误和定制返回的 http status code.
-// 在复杂业务场景中,存在一个接口返回多种业务错误码情况,通过这个函数来统一处理
-func AbortStatusError(c *gin.Context, httpCode int, err error) {
-	if err == nil {
-		return
-	}
-
-	if e, ok := xerr.Cause(err).(*Error); ok {
-		c.Error(e)
-		c.AbortWithStatusJSON(httpCode, WithContext(c, e.err.Code))
-		return
-	}
-
-	c.Error(err)
-	c.AbortWithStatusJSON(httpCode, WithContext(c, common.Error_INTERNAL_ERROR).With(err))
-}
-
-// DefaultErrorStatusCode 返回错误码对应的默认 http status code
-func DefaultErrorStatusCode(code common.Error_Code) int {
-	if statusCode, ok := errorStatusCode[int(code)]; ok {
-		return statusCode
-	}
-
-	return http.StatusInternalServerError
-}
-
-// 错误对应默认返回的 http status code
-var errorStatusCode = map[int]int{
-	0:     http.StatusOK,
-	10000: http.StatusUnauthorized,
-	11000: http.StatusBadRequest,
-	11001: http.StatusBadRequest,
-	11002: http.StatusBadRequest,
-	11003: http.StatusTooManyRequests,
-	11100: http.StatusBadRequest,
-	11200: http.StatusBadRequest,
-	20000: http.StatusBadRequest,
-	21000: http.StatusBadRequest,
-	22000: http.StatusBadRequest,
-	23000: http.StatusBadRequest,
-	23001: http.StatusBadRequest,
-	24000: http.StatusBadRequest,
-	24100: http.StatusBadRequest,
-	24101: http.StatusBadRequest,
-	24102: http.StatusBadRequest,
-	24103: http.StatusBadRequest,
-	24104: http.StatusBadRequest,
-	24400: http.StatusBadRequest,
-	24500: http.StatusBadRequest,
-	24501: http.StatusBadRequest,
-	24502: http.StatusBadRequest,
-	24520: http.StatusBadRequest,
-	24521: http.StatusBadRequest,
-	24522: http.StatusBadRequest,
-	24523: http.StatusBadRequest,
-	24524: http.StatusBadRequest,
-	24525: http.StatusBadRequest,
-	24526: http.StatusBadRequest,
-	24527: http.StatusBadRequest,
-	24528: http.StatusBadRequest,
-	24600: http.StatusBadRequest,
-	24601: http.StatusBadRequest,
-	24602: http.StatusBadRequest,
-	24603: http.StatusBadRequest,
-	24700: http.StatusBadRequest,
-	24701: http.StatusBadRequest,
-	24702: http.StatusBadRequest,
-	24704: http.StatusBadRequest,
-	24705: http.StatusBadRequest,
-	24706: http.StatusBadRequest,
-	24707: http.StatusBadRequest,
-	24800: http.StatusBadRequest,
-	24801: http.StatusBadRequest,
-	24802: http.StatusBadRequest,
-	24803: http.StatusBadRequest,
-	90000: http.StatusInternalServerError,
-	90100: http.StatusBadRequest,
-	90101: http.StatusBadRequest,
-	90102: http.StatusBadRequest,
-	91000: http.StatusInternalServerError,
-}

+ 0 - 761
pkg/apierr/apierr_gen.go

@@ -1,761 +0,0 @@
-package apierr
-
-import (
-	common "kpt-tmr-group/proto/go/backend/common"
-
-	"github.com/gin-gonic/gin"
-)
-
-// NewErrUnauthorized create err with default message
-func NewErrUnauthorized(err ...error) *Error {
-	return New(common.Error_UNAUTHORIZED).With(err...)
-}
-
-// ErrUnauthorized create err with locales
-func ErrUnauthorized(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_UNAUTHORIZED).With(err...)
-}
-
-// AbortUnauthorized abort with status code and log common.Error_UNAUTHORIZED to newrelic
-func AbortUnauthorized(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrUnauthorized(c, err...))
-}
-
-// AbortStatusUnauthorized abort with status code and log common.Error_UNAUTHORIZED to newrelic
-func AbortStatusUnauthorized(c *gin.Context, err ...error) {
-	AbortUnauthorized(c, 401, err...)
-}
-
-// NewErrBadRequest create err with default message
-func NewErrBadRequest(err ...error) *Error {
-	return New(common.Error_BAD_REQUEST).With(err...)
-}
-
-// ErrBadRequest create err with locales
-func ErrBadRequest(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_BAD_REQUEST).With(err...)
-}
-
-// AbortBadRequest abort with status code and log common.Error_BAD_REQUEST to newrelic
-func AbortBadRequest(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrBadRequest(c, err...))
-}
-
-// AbortStatusBadRequest abort with status code and log common.Error_BAD_REQUEST to newrelic
-func AbortStatusBadRequest(c *gin.Context, err ...error) {
-	AbortBadRequest(c, 400, err...)
-}
-
-// NewErrInvalidContentType create err with default message
-func NewErrInvalidContentType(err ...error) *Error {
-	return New(common.Error_INVALID_CONTENT_TYPE).With(err...)
-}
-
-// ErrInvalidContentType create err with locales
-func ErrInvalidContentType(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_CONTENT_TYPE).With(err...)
-}
-
-// AbortInvalidContentType abort with status code and log common.Error_INVALID_CONTENT_TYPE to newrelic
-func AbortInvalidContentType(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidContentType(c, err...))
-}
-
-// AbortStatusInvalidContentType abort with status code and log common.Error_INVALID_CONTENT_TYPE to newrelic
-func AbortStatusInvalidContentType(c *gin.Context, err ...error) {
-	AbortInvalidContentType(c, 400, err...)
-}
-
-// NewErrInvalidContentEncoding create err with default message
-func NewErrInvalidContentEncoding(err ...error) *Error {
-	return New(common.Error_INVALID_CONTENT_ENCODING).With(err...)
-}
-
-// ErrInvalidContentEncoding create err with locales
-func ErrInvalidContentEncoding(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_CONTENT_ENCODING).With(err...)
-}
-
-// AbortInvalidContentEncoding abort with status code and log common.Error_INVALID_CONTENT_ENCODING to newrelic
-func AbortInvalidContentEncoding(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidContentEncoding(c, err...))
-}
-
-// AbortStatusInvalidContentEncoding abort with status code and log common.Error_INVALID_CONTENT_ENCODING to newrelic
-func AbortStatusInvalidContentEncoding(c *gin.Context, err ...error) {
-	AbortInvalidContentEncoding(c, 400, err...)
-}
-
-// NewErrTooManyRequests create err with default message
-func NewErrTooManyRequests(err ...error) *Error {
-	return New(common.Error_TOO_MANY_REQUESTS).With(err...)
-}
-
-// ErrTooManyRequests create err with locales
-func ErrTooManyRequests(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_TOO_MANY_REQUESTS).With(err...)
-}
-
-// AbortTooManyRequests abort with status code and log common.Error_TOO_MANY_REQUESTS to newrelic
-func AbortTooManyRequests(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrTooManyRequests(c, err...))
-}
-
-// AbortStatusTooManyRequests abort with status code and log common.Error_TOO_MANY_REQUESTS to newrelic
-func AbortStatusTooManyRequests(c *gin.Context, err ...error) {
-	AbortTooManyRequests(c, 429, err...)
-}
-
-// NewErrInvalidStorageType create err with default message
-func NewErrInvalidStorageType(err ...error) *Error {
-	return New(common.Error_INVALID_STORAGE_TYPE).With(err...)
-}
-
-// ErrInvalidStorageType create err with locales
-func ErrInvalidStorageType(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_STORAGE_TYPE).With(err...)
-}
-
-// AbortInvalidStorageType abort with status code and log common.Error_INVALID_STORAGE_TYPE to newrelic
-func AbortInvalidStorageType(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidStorageType(c, err...))
-}
-
-// AbortStatusInvalidStorageType abort with status code and log common.Error_INVALID_STORAGE_TYPE to newrelic
-func AbortStatusInvalidStorageType(c *gin.Context, err ...error) {
-	AbortInvalidStorageType(c, 400, err...)
-}
-
-// NewErrInvalidDeData create err with default message
-func NewErrInvalidDeData(err ...error) *Error {
-	return New(common.Error_INVALID_DE_DATA).With(err...)
-}
-
-// ErrInvalidDeData create err with locales
-func ErrInvalidDeData(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_DE_DATA).With(err...)
-}
-
-// AbortInvalidDeData abort with status code and log common.Error_INVALID_DE_DATA to newrelic
-func AbortInvalidDeData(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidDeData(c, err...))
-}
-
-// AbortStatusInvalidDeData abort with status code and log common.Error_INVALID_DE_DATA to newrelic
-func AbortStatusInvalidDeData(c *gin.Context, err ...error) {
-	AbortInvalidDeData(c, 400, err...)
-}
-
-// NewErrCheckinRepeated create err with default message
-func NewErrCheckinRepeated(err ...error) *Error {
-	return New(common.Error_CHECKIN_REPEATED).With(err...)
-}
-
-// ErrCheckinRepeated create err with locales
-func ErrCheckinRepeated(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_CHECKIN_REPEATED).With(err...)
-}
-
-// AbortCheckinRepeated abort with status code and log common.Error_CHECKIN_REPEATED to newrelic
-func AbortCheckinRepeated(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrCheckinRepeated(c, err...))
-}
-
-// AbortStatusCheckinRepeated abort with status code and log common.Error_CHECKIN_REPEATED to newrelic
-func AbortStatusCheckinRepeated(c *gin.Context, err ...error) {
-	AbortCheckinRepeated(c, 400, err...)
-}
-
-// NewErrCourseNotFound create err with default message
-func NewErrCourseNotFound(err ...error) *Error {
-	return New(common.Error_COURSE_NOT_FOUND).With(err...)
-}
-
-// ErrCourseNotFound create err with locales
-func ErrCourseNotFound(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_COURSE_NOT_FOUND).With(err...)
-}
-
-// AbortCourseNotFound abort with status code and log common.Error_COURSE_NOT_FOUND to newrelic
-func AbortCourseNotFound(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrCourseNotFound(c, err...))
-}
-
-// AbortStatusCourseNotFound abort with status code and log common.Error_COURSE_NOT_FOUND to newrelic
-func AbortStatusCourseNotFound(c *gin.Context, err ...error) {
-	AbortCourseNotFound(c, 400, err...)
-}
-
-// NewErrCourseNotInterest create err with default message
-func NewErrCourseNotInterest(err ...error) *Error {
-	return New(common.Error_COURSE_NOT_INTEREST).With(err...)
-}
-
-// ErrCourseNotInterest create err with locales
-func ErrCourseNotInterest(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_COURSE_NOT_INTEREST).With(err...)
-}
-
-// AbortCourseNotInterest abort with status code and log common.Error_COURSE_NOT_INTEREST to newrelic
-func AbortCourseNotInterest(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrCourseNotInterest(c, err...))
-}
-
-// AbortStatusCourseNotInterest abort with status code and log common.Error_COURSE_NOT_INTEREST to newrelic
-func AbortStatusCourseNotInterest(c *gin.Context, err ...error) {
-	AbortCourseNotInterest(c, 500, err...)
-}
-
-// NewErrModuleNotFound create err with default message
-func NewErrModuleNotFound(err ...error) *Error {
-	return New(common.Error_MODULE_NOT_FOUND).With(err...)
-}
-
-// ErrModuleNotFound create err with locales
-func ErrModuleNotFound(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_MODULE_NOT_FOUND).With(err...)
-}
-
-// AbortModuleNotFound abort with status code and log common.Error_MODULE_NOT_FOUND to newrelic
-func AbortModuleNotFound(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrModuleNotFound(c, err...))
-}
-
-// AbortStatusModuleNotFound abort with status code and log common.Error_MODULE_NOT_FOUND to newrelic
-func AbortStatusModuleNotFound(c *gin.Context, err ...error) {
-	AbortModuleNotFound(c, 400, err...)
-}
-
-// NewErrUserCourseAlreadyAdded create err with default message
-func NewErrUserCourseAlreadyAdded(err ...error) *Error {
-	return New(common.Error_USER_COURSE_ALREADY_ADDED).With(err...)
-}
-
-// ErrUserCourseAlreadyAdded create err with locales
-func ErrUserCourseAlreadyAdded(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_USER_COURSE_ALREADY_ADDED).With(err...)
-}
-
-// AbortUserCourseAlreadyAdded abort with status code and log common.Error_USER_COURSE_ALREADY_ADDED to newrelic
-func AbortUserCourseAlreadyAdded(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrUserCourseAlreadyAdded(c, err...))
-}
-
-// AbortStatusUserCourseAlreadyAdded abort with status code and log common.Error_USER_COURSE_ALREADY_ADDED to newrelic
-func AbortStatusUserCourseAlreadyAdded(c *gin.Context, err ...error) {
-	AbortUserCourseAlreadyAdded(c, 400, err...)
-}
-
-// NewErrUserCourseNotFound create err with default message
-func NewErrUserCourseNotFound(err ...error) *Error {
-	return New(common.Error_USER_COURSE_NOT_FOUND).With(err...)
-}
-
-// ErrUserCourseNotFound create err with locales
-func ErrUserCourseNotFound(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_USER_COURSE_NOT_FOUND).With(err...)
-}
-
-// AbortUserCourseNotFound abort with status code and log common.Error_USER_COURSE_NOT_FOUND to newrelic
-func AbortUserCourseNotFound(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrUserCourseNotFound(c, err...))
-}
-
-// AbortStatusUserCourseNotFound abort with status code and log common.Error_USER_COURSE_NOT_FOUND to newrelic
-func AbortStatusUserCourseNotFound(c *gin.Context, err ...error) {
-	AbortUserCourseNotFound(c, 400, err...)
-}
-
-// NewErrPtLimited create err with default message
-func NewErrPtLimited(err ...error) *Error {
-	return New(common.Error_PT_LIMITED).With(err...)
-}
-
-// ErrPtLimited create err with locales
-func ErrPtLimited(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_PT_LIMITED).With(err...)
-}
-
-// AbortPtLimited abort with status code and log common.Error_PT_LIMITED to newrelic
-func AbortPtLimited(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrPtLimited(c, err...))
-}
-
-// AbortStatusPtLimited abort with status code and log common.Error_PT_LIMITED to newrelic
-func AbortStatusPtLimited(c *gin.Context, err ...error) {
-	AbortPtLimited(c, 400, err...)
-}
-
-// NewErrInvalidPrice create err with default message
-func NewErrInvalidPrice(err ...error) *Error {
-	return New(common.Error_INVALID_PRICE).With(err...)
-}
-
-// ErrInvalidPrice create err with locales
-func ErrInvalidPrice(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_PRICE).With(err...)
-}
-
-// AbortInvalidPrice abort with status code and log common.Error_INVALID_PRICE to newrelic
-func AbortInvalidPrice(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidPrice(c, err...))
-}
-
-// AbortStatusInvalidPrice abort with status code and log common.Error_INVALID_PRICE to newrelic
-func AbortStatusInvalidPrice(c *gin.Context, err ...error) {
-	AbortInvalidPrice(c, 400, err...)
-}
-
-// NewErrInvalidProductId create err with default message
-func NewErrInvalidProductId(err ...error) *Error {
-	return New(common.Error_INVALID_PRODUCT_ID).With(err...)
-}
-
-// ErrInvalidProductId create err with locales
-func ErrInvalidProductId(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_PRODUCT_ID).With(err...)
-}
-
-// AbortInvalidProductId abort with status code and log common.Error_INVALID_PRODUCT_ID to newrelic
-func AbortInvalidProductId(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidProductId(c, err...))
-}
-
-// AbortStatusInvalidProductId abort with status code and log common.Error_INVALID_PRODUCT_ID to newrelic
-func AbortStatusInvalidProductId(c *gin.Context, err ...error) {
-	AbortInvalidProductId(c, 400, err...)
-}
-
-// NewErrInvalidOrderNumber create err with default message
-func NewErrInvalidOrderNumber(err ...error) *Error {
-	return New(common.Error_INVALID_ORDER_NUMBER).With(err...)
-}
-
-// ErrInvalidOrderNumber create err with locales
-func ErrInvalidOrderNumber(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_ORDER_NUMBER).With(err...)
-}
-
-// AbortInvalidOrderNumber abort with status code and log common.Error_INVALID_ORDER_NUMBER to newrelic
-func AbortInvalidOrderNumber(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidOrderNumber(c, err...))
-}
-
-// AbortStatusInvalidOrderNumber abort with status code and log common.Error_INVALID_ORDER_NUMBER to newrelic
-func AbortStatusInvalidOrderNumber(c *gin.Context, err ...error) {
-	AbortInvalidOrderNumber(c, 400, err...)
-}
-
-// NewErrInvalidUserId create err with default message
-func NewErrInvalidUserId(err ...error) *Error {
-	return New(common.Error_INVALID_USER_ID).With(err...)
-}
-
-// ErrInvalidUserId create err with locales
-func ErrInvalidUserId(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_USER_ID).With(err...)
-}
-
-// AbortInvalidUserId abort with status code and log common.Error_INVALID_USER_ID to newrelic
-func AbortInvalidUserId(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidUserId(c, err...))
-}
-
-// AbortStatusInvalidUserId abort with status code and log common.Error_INVALID_USER_ID to newrelic
-func AbortStatusInvalidUserId(c *gin.Context, err ...error) {
-	AbortInvalidUserId(c, 400, err...)
-}
-
-// NewErrInvalidReceipt create err with default message
-func NewErrInvalidReceipt(err ...error) *Error {
-	return New(common.Error_INVALID_RECEIPT).With(err...)
-}
-
-// ErrInvalidReceipt create err with locales
-func ErrInvalidReceipt(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INVALID_RECEIPT).With(err...)
-}
-
-// AbortInvalidReceipt abort with status code and log common.Error_INVALID_RECEIPT to newrelic
-func AbortInvalidReceipt(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInvalidReceipt(c, err...))
-}
-
-// AbortStatusInvalidReceipt abort with status code and log common.Error_INVALID_RECEIPT to newrelic
-func AbortStatusInvalidReceipt(c *gin.Context, err ...error) {
-	AbortInvalidReceipt(c, 400, err...)
-}
-
-// NewErrEmptyIosReceipt create err with default message
-func NewErrEmptyIosReceipt(err ...error) *Error {
-	return New(common.Error_EMPTY_IOS_RECEIPT).With(err...)
-}
-
-// ErrEmptyIosReceipt create err with locales
-func ErrEmptyIosReceipt(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_EMPTY_IOS_RECEIPT).With(err...)
-}
-
-// AbortEmptyIosReceipt abort with status code and log common.Error_EMPTY_IOS_RECEIPT to newrelic
-func AbortEmptyIosReceipt(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrEmptyIosReceipt(c, err...))
-}
-
-// AbortStatusEmptyIosReceipt abort with status code and log common.Error_EMPTY_IOS_RECEIPT to newrelic
-func AbortStatusEmptyIosReceipt(c *gin.Context, err ...error) {
-	AbortEmptyIosReceipt(c, 500, err...)
-}
-
-// NewErrUserPlanLimitedCourseCount create err with default message
-func NewErrUserPlanLimitedCourseCount(err ...error) *Error {
-	return New(common.Error_USER_PLAN_LIMITED_COURSE_COUNT).With(err...)
-}
-
-// ErrUserPlanLimitedCourseCount create err with locales
-func ErrUserPlanLimitedCourseCount(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_USER_PLAN_LIMITED_COURSE_COUNT).With(err...)
-}
-
-// AbortUserPlanLimitedCourseCount abort with status code and log common.Error_USER_PLAN_LIMITED_COURSE_COUNT to newrelic
-func AbortUserPlanLimitedCourseCount(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrUserPlanLimitedCourseCount(c, err...))
-}
-
-// AbortStatusUserPlanLimitedCourseCount abort with status code and log common.Error_USER_PLAN_LIMITED_COURSE_COUNT to newrelic
-func AbortStatusUserPlanLimitedCourseCount(c *gin.Context, err ...error) {
-	AbortUserPlanLimitedCourseCount(c, 500, err...)
-}
-
-// NewErrInternalError create err with default message
-func NewErrInternalError(err ...error) *Error {
-	return New(common.Error_INTERNAL_ERROR).With(err...)
-}
-
-// ErrInternalError create err with locales
-func ErrInternalError(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_INTERNAL_ERROR).With(err...)
-}
-
-// AbortInternalError abort with status code and log common.Error_INTERNAL_ERROR to newrelic
-func AbortInternalError(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrInternalError(c, err...))
-}
-
-// AbortStatusInternalError abort with status code and log common.Error_INTERNAL_ERROR to newrelic
-func AbortStatusInternalError(c *gin.Context, err ...error) {
-	AbortInternalError(c, 500, err...)
-}
-
-// NewErrJsonpbError create err with default message
-func NewErrJsonpbError(err ...error) *Error {
-	return New(common.Error_JSONPB_ERROR).With(err...)
-}
-
-// ErrJsonpbError create err with locales
-func ErrJsonpbError(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_JSONPB_ERROR).With(err...)
-}
-
-// AbortJsonpbError abort with status code and log common.Error_JSONPB_ERROR to newrelic
-func AbortJsonpbError(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrJsonpbError(c, err...))
-}
-
-// AbortStatusJsonpbError abort with status code and log common.Error_JSONPB_ERROR to newrelic
-func AbortStatusJsonpbError(c *gin.Context, err ...error) {
-	AbortJsonpbError(c, 400, err...)
-}
-
-// NewErrJsonError create err with default message
-func NewErrJsonError(err ...error) *Error {
-	return New(common.Error_JSON_ERROR).With(err...)
-}
-
-// ErrJsonError create err with locales
-func ErrJsonError(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_JSON_ERROR).With(err...)
-}
-
-// AbortJsonError abort with status code and log common.Error_JSON_ERROR to newrelic
-func AbortJsonError(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrJsonError(c, err...))
-}
-
-// AbortStatusJsonError abort with status code and log common.Error_JSON_ERROR to newrelic
-func AbortStatusJsonError(c *gin.Context, err ...error) {
-	AbortJsonError(c, 400, err...)
-}
-
-// NewErrPbError create err with default message
-func NewErrPbError(err ...error) *Error {
-	return New(common.Error_PB_ERROR).With(err...)
-}
-
-// ErrPbError create err with locales
-func ErrPbError(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_PB_ERROR).With(err...)
-}
-
-// AbortPbError abort with status code and log common.Error_PB_ERROR to newrelic
-func AbortPbError(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrPbError(c, err...))
-}
-
-// AbortStatusPbError abort with status code and log common.Error_PB_ERROR to newrelic
-func AbortStatusPbError(c *gin.Context, err ...error) {
-	AbortPbError(c, 400, err...)
-}
-
-// NewErrExternalError create err with default message
-func NewErrExternalError(err ...error) *Error {
-	return New(common.Error_EXTERNAL_ERROR).With(err...)
-}
-
-// ErrExternalError create err with locales
-func ErrExternalError(c *gin.Context, err ...error) *Error {
-	return WithContext(c, common.Error_EXTERNAL_ERROR).With(err...)
-}
-
-// AbortExternalError abort with status code and log common.Error_EXTERNAL_ERROR to newrelic
-func AbortExternalError(c *gin.Context, code int, err ...error) {
-	for _, e := range err {
-		// if err is nil, gin will panic
-		if e != nil {
-			// so many 4xx error in new relic, only ignore 400/401/404 error, have fun!
-			if !shouldIgnoreCode(code) {
-				c.Error(e)
-			}
-		}
-	}
-	c.AbortWithStatusJSON(code, ErrExternalError(c, err...))
-}
-
-// AbortStatusExternalError abort with status code and log common.Error_EXTERNAL_ERROR to newrelic
-func AbortStatusExternalError(c *gin.Context, err ...error) {
-	AbortExternalError(c, 500, err...)
-}

+ 0 - 47
pkg/apierr/config.go

@@ -1,47 +0,0 @@
-package apierr
-
-import (
-	"net/http"
-	"sort"
-
-	"github.com/gin-gonic/gin"
-
-	"kpt-tmr-group/pkg/grpcutil"
-	"kpt-tmr-group/pkg/xerr"
-)
-
-var (
-	ignoreCodes = []int{400, 401, 404, 429}
-	codesSize   = int(3)
-)
-
-// IgnoreStatusCodes ignore error with status codes
-func IgnoreStatusCodes(codes ...int) {
-	sort.Ints(codes)
-
-	ignoreCodes = codes
-	codesSize = len(codes)
-}
-
-func shouldIgnoreCode(code int) bool {
-	// SearchInts using binary search, more fast
-	idx := sort.SearchInts(ignoreCodes, code)
-	return idx < codesSize && ignoreCodes[idx] == code
-}
-
-// ClassifiedAbort classify base on error type
-func ClassifiedAbort(c *gin.Context, err error) {
-	if err == nil {
-		return
-	}
-
-	if e, isc := xerr.IsCustomError(err); isc {
-		// 服务内部自定义错误
-		AbortBadRequest(c, http.StatusBadRequest, e)
-	} else if !grpcutil.FilterServerError(err) {
-		// gRPC 部分错误
-		AbortBadRequest(c, http.StatusBadRequest, err)
-	} else {
-		AbortError(c, err)
-	}
-}

+ 0 - 23
pkg/apiok/common.go

@@ -1,23 +0,0 @@
-package apiok
-
-/*type OkResponse struct {
-	Code int         `json:"code"`
-	Msg  string      `json:"msg"`
-	Data interface{} `json:"data"`
-}
-
-func CommonResponse(data interface{}) *OkResponse {
-	return &OkResponse{
-		Code: 200,
-		Msg:  "ok",
-		Data: data,
-	}
-}
-*/
-type ApiOk struct {
-	Success bool `json:"success"`
-}
-
-func NewApiOk(success bool) *ApiOk {
-	return &ApiOk{Success: success}
-}

+ 0 - 133
pkg/cleanup/entry.go

@@ -1,133 +0,0 @@
-// Package cleanup provides a single point for registering clean up functions.
-// This is similar to Finalizer, except that the clean up functions are
-// guaranteed to be called if the process terminates normally.
-//
-// Usage:
-//
-// In my_package.go
-//
-//   cleanup.Register(func(){
-//     // Arbitrary clean up function, most likely close goroutine, etc.
-//   })
-//
-// In main.go
-//
-//   func main() {
-//     flag.Parse()
-//     defer cleanup.Run()
-//   }
-package cleanup
-
-import (
-	"context"
-	"reflect"
-	"sync"
-
-	"kpt-tmr-group/pkg/logger/logrus"
-	"kpt-tmr-group/pkg/xerr"
-)
-
-// entry global cleanup entry
-var entry Entry
-
-// Register adds a function to the global cleanup queue.
-func Register(container interface{}) {
-	entry.Register(container)
-}
-
-// Run runs all the global cleanup functions registered.
-func Run() {
-	entry.Run()
-}
-
-type Entry struct {
-	mu   sync.Mutex
-	fns  []func()
-	once sync.Once
-}
-
-// Run runs all the cleanup functions registered.
-func (entry *Entry) Run() {
-	logrus.Infof("cleanup: performing %d cleanups", len(entry.fns))
-
-	entry.once.Do(func() {
-		for _, f := range entry.fns {
-			f()
-		}
-	})
-
-	logrus.Infof("cleanup: all done")
-}
-
-// Register adds a function to the cleanup queue.
-func (entry *Entry) Register(container interface{}) {
-	v := reflect.Indirect(reflect.ValueOf(container))
-	var err error
-	switch v.Kind() {
-	case reflect.Func:
-		err = entry.RegisterFunc(v.Interface())
-	case reflect.Struct:
-		err = entry.RegisterStruct(v.Interface())
-	default:
-		panic("cleanup: unsupported type")
-	}
-	if err != nil {
-		panic(err)
-	}
-}
-
-func (entry *Entry) RegisterStruct(ctor interface{}) error {
-	cValue := reflect.Indirect(reflect.ValueOf(ctor))
-	if cValue.Kind() != reflect.Struct {
-		return xerr.New("RegisterStruct receive a struct or ptr to struct")
-	}
-	for i := 0; i < cValue.NumField(); i++ {
-		field := cValue.Field(i)
-		if field.IsZero() {
-			continue
-		}
-		method := field.MethodByName("Close")
-		if !method.IsValid() {
-			method = field.MethodByName("Flush")
-		}
-		if method.IsValid() {
-			if err := entry.RegisterFunc(method.Interface()); err != nil {
-				logrus.WithError(err).WithField("fieldName", field.Type().Name()).Error("register func failed")
-			}
-		}
-	}
-	return nil
-}
-
-// RegisterFunc receive func() or func() error
-func (entry *Entry) RegisterFunc(fn interface{}) error {
-	fType := reflect.TypeOf(fn)
-	if fType.Kind() != reflect.Func {
-		return xerr.New("cleanup: unsupported type")
-	}
-	if fType.NumIn() > 0 {
-		return xerr.New("RegisterFunc receive func() or func() error")
-	}
-
-	if f, ok := fn.(func()); ok {
-		entry.register(f)
-		return nil
-	}
-	if f, ok := fn.(func() error); ok {
-		entry.register(func() {
-			if err := f(); err != nil {
-				_ = xerr.ReportError(context.Background(), err)
-			}
-		})
-		return nil
-	}
-	return xerr.New("RegisterFunc receive func() or func() error")
-}
-
-func (entry *Entry) register(fns ...func()) {
-	entry.mu.Lock()
-	defer entry.mu.Unlock()
-	for _, fn := range fns {
-		entry.fns = append(entry.fns, fn)
-	}
-}

+ 0 - 53
pkg/cleanup/entry_test.go

@@ -1,53 +0,0 @@
-package cleanup
-
-import (
-	"testing"
-)
-
-type f1 struct{}
-
-func (*f1) Close() {}
-
-type f2 struct{}
-
-func (*f2) Close() error { return nil }
-
-type f3 struct{}
-
-func (*f3) Flush() {}
-
-type f4 struct{}
-
-func (*f4) NoCloseOrFlush() {}
-
-type TestStruct struct {
-	F1 *f1
-	F2 *f2
-	F3 *f3
-	F4 *f4
-}
-
-func TestRegisterStruct(t *testing.T) {
-	var e Entry
-	s := TestStruct{
-		F1: &f1{},
-		F2: &f2{},
-		F3: &f3{},
-		F4: &f4{},
-	}
-	e.Register(s)
-}
-
-func TestCleanup(t *testing.T) {
-	var e Entry
-	i, j := 0, 0
-	func() {
-		e.Register(func() { i += 1 })
-		e.Register(func() { j += 2 })
-		e.Run()
-		e.Run() // multiple runs will be OK.
-	}()
-	if i != 1 || j != 2 {
-		t.Errorf("Run() incorrect, want i = 1, j = 2, got i = %d, j = %d", i, j)
-	}
-}

+ 0 - 19
pkg/cputil/cp.go

@@ -1,19 +0,0 @@
-package cputil
-
-import (
-	"github.com/jinzhu/copier"
-)
-
-func ShallowCopy(toValue interface{}, fromValue interface{}) error {
-	return copier.CopyWithOption(toValue, fromValue, copier.Option{
-		IgnoreEmpty: true,
-		DeepCopy:    false,
-	})
-}
-
-func DeepCopy(toValue interface{}, fromValue interface{}) error {
-	return copier.CopyWithOption(toValue, fromValue, copier.Option{
-		IgnoreEmpty: true,
-		DeepCopy:    true,
-	})
-}

+ 0 - 59
pkg/cputil/cp_test.go

@@ -1,59 +0,0 @@
-package cputil
-
-import (
-	"testing"
-
-	"github.com/google/go-cmp/cmp"
-	"github.com/stretchr/testify/require"
-)
-
-type Dummy struct {
-	A1 int
-	A2 int
-	B1 bool
-	B2 bool
-	C1 map[string]interface{}
-	D1 []int
-}
-
-func TestShallowCopy(t *testing.T) {
-	d1 := &Dummy{
-		A1: 0,
-		A2: 1,
-		B1: false,
-		B2: true,
-		C1: map[string]interface{}{
-			"a": 1,
-		},
-		D1: []int{0, 1},
-	}
-
-	d2 := &Dummy{}
-	_ = ShallowCopy(&d2, d1)
-	require.Empty(t, cmp.Diff(d1, d2))
-
-	// case: 浅拷贝会互相影响
-	d1.C1["a"] = 2
-	require.Equal(t, d2.C1["a"], d1.C1["a"])
-}
-
-func TestDeepCopy(t *testing.T) {
-	d1 := &Dummy{
-		A1: 0,
-		A2: 1,
-		B1: false,
-		B2: true,
-		C1: map[string]interface{}{
-			"a": 1,
-		},
-		D1: []int{0, 1},
-	}
-
-	d2 := &Dummy{}
-	_ = DeepCopy(&d2, d1)
-	require.Empty(t, cmp.Diff(d1, d2))
-
-	// case: 深拷贝不会互相影响
-	d1.C1["a"] = 2
-	require.NotEqual(t, d2.C1["a"], d1.C1["a"])
-}

+ 0 - 26
pkg/di/annotation.go

@@ -1,26 +0,0 @@
-package di
-
-type Annotated struct {
-	// If specified, this will be used as the name for all non-error values returned
-	// by the constructor. For more information on named values, see the documentation
-	// for the fx.Out type.
-	//
-	// A name option may not be provided if a group option is provided.
-	Name string
-
-	// If specified, this will be used as the group name for all non-error values returned
-	// by the constructor. For more information on value groups, see the package documentation.
-	//
-	// A group option may not be provided if a name option is provided.
-	//
-	// Similar to group tags, the group name may be followed by a `,flatten`
-	// option to indicate that each element in the slice returned by the
-	// constructor should be injected into the value group individually.
-	Group string
-
-	// Target is the constructor or value being annotated with fx.Annotated.
-	Target interface{}
-
-	// Close is the function being closed when container is destroy
-	Close interface{}
-}

+ 0 - 153
pkg/di/hub.go

@@ -1,153 +0,0 @@
-package di
-
-import (
-	"reflect"
-
-	"kpt-tmr-group/pkg/cleanup"
-	"kpt-tmr-group/pkg/di/xreflect"
-	"kpt-tmr-group/pkg/xerr"
-
-	"go.uber.org/dig"
-)
-
-func New(opts ...HubOption) (*Hub, error) {
-	hub := &Hub{
-		cleanup:  cleanup.Entry{},
-		provides: make([]Provided, 0),
-	}
-	for _, opt := range opts {
-		opt.Apply(hub)
-	}
-
-	hub.container = dig.New(
-		dig.DryRun(hub.validate),
-	)
-	for i, p := range hub.provides {
-		if err := hub.usingProvide(p); err != nil {
-			return nil, xerr.Errorf("error after options[%d] were applied: %v", i, err)
-		}
-	}
-
-	return hub, nil
-}
-
-// Hub is a directed acyclic graph of types and their dependencies.
-// extend dig.Container
-type Hub struct {
-	container *dig.Container
-	cleanup   cleanup.Entry
-	provides  []Provided
-	validate  bool
-}
-
-// Cleanup runs all the cleanup functions registered in the hub.
-func (hub *Hub) Cleanup() {
-	hub.cleanup.Run()
-}
-
-// Provided is a single constructor provided to di.
-type Provided struct {
-	// Constructor provided to di. This may be an di.Annotated.
-	Target interface{}
-
-	// Stack trace of where this Provided was made.
-	Stack xreflect.Stack
-
-	// IsSupply is true when the Target constructor was emitted by di.Supply.
-	IsSupply bool
-}
-
-func (hub *Hub) usingProvide(p Provided) error {
-	constructor := p.Target
-
-	if _, ok := constructor.(HubOption); ok {
-		return xerr.Errorf("di.Option should be passed to di.New directly, "+
-			"not to di.Provide: di.Provide received %v from:\n%+v",
-			constructor, p.Stack)
-	}
-
-	if ann, ok := constructor.(Annotated); ok {
-		var opts []dig.ProvideOption
-		switch {
-		case len(ann.Group) > 0 && len(ann.Name) > 0:
-			return xerr.Errorf(
-				"di.Annotated may specify only one of Name or Group: received %v from:\n%+v",
-				ann, p.Stack)
-		case len(ann.Name) > 0:
-			opts = append(opts, dig.Name(ann.Name))
-		case len(ann.Group) > 0:
-			opts = append(opts, dig.Group(ann.Group))
-
-		}
-
-		// 注册初始化函数
-		if err := hub.Provide(ann.Target, opts...); err != nil {
-			return xerr.Errorf("di.Provide(%v) from:\n%+vFailed: %v", ann, p.Stack, err)
-		}
-
-		// 注册清理函数
-		if ann.Close != nil {
-			hub.cleanup.Register(ann.Close)
-		}
-
-		return nil
-	}
-
-	if reflect.TypeOf(constructor).Kind() == reflect.Func {
-		ft := reflect.ValueOf(constructor).Type()
-
-		for i := 0; i < ft.NumOut(); i++ {
-			t := ft.Out(i)
-
-			if t == reflect.TypeOf(Annotated{}) {
-				return xerr.Errorf(
-					"di.Annotated should be passed to di.Provide directly, "+
-						"it should not be returned by the constructor: "+
-						"di.Provide received %v from:\n%+v",
-					xreflect.FuncName(constructor), p.Stack)
-			}
-		}
-	}
-
-	if err := hub.Provide(constructor); err != nil {
-		return xerr.Errorf("di.Provide(%v) from:\n%+vFailed: %v", xreflect.FuncName(constructor), p.Stack, err)
-	}
-
-	return nil
-}
-
-// Invoke runs the given function after instantiating its dependencies.
-//
-// Any arguments that the function has are treated as its dependencies. The
-// dependencies are instantiated in an unspecified order along with any
-// dependencies that they might have.
-//
-// The function may return an error to indicate failure. The error will be
-// returned to the caller as-is.
-func (hub *Hub) Invoke(function interface{}, opts ...InvokeOption) error {
-	return hub.container.Invoke(function, opts...)
-}
-
-// Provide teaches the container how to build values of one or more types and
-// expresses their dependencies.
-//
-// The first argument of Provide is a function that accepts zero or more
-// parameters and returns one or more results. The function may optionally
-// return an error to indicate that it failed to build the value. This
-// function will be treated as the constructor for all the types it returns.
-// This function will be called AT MOST ONCE when a type produced by it, or a
-// type that consumes this function's output, is requested via Invoke. If the
-// same types are requested multiple times, the previously produced value will
-// be reused.
-//
-// In addition to accepting constructors that accept dependencies as separate
-// arguments and produce results as separate return values, Provide also
-// accepts constructors that specify dependencies as dig.In structs and/or
-// specify results as dig.Out structs.
-func (hub *Hub) Provide(constructor interface{}, opts ...ProvideOption) error {
-	return hub.container.Provide(constructor, opts...)
-}
-
-func (hub *Hub) GetProvidedSlice() []Provided {
-	return hub.provides
-}

+ 0 - 187
pkg/di/hub_test.go

@@ -1,187 +0,0 @@
-package di
-
-import (
-	"strings"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-	"go.uber.org/dig"
-)
-
-func TestHub_New(t *testing.T) {
-	t.Run("basic di", func(t *testing.T) {
-		hub, err := New(module1, ValidateHub(true))
-		require.NoError(t, err)
-		require.NotNil(t, hub)
-
-		err = hub.Invoke(func(c C) {
-			assert.Equal(t, c.Number, int64(100))
-		})
-		require.NoError(t, err)
-
-		err = hub.Invoke(func(d D) {
-			assert.Equal(t, d.C.Number, int64(100))
-		})
-		require.NoError(t, err)
-
-		err = hub.Invoke(func(f1 F1) {
-			assert.Equal(t, f1.Name, "f1")
-		})
-		require.NoError(t, err)
-	})
-
-	t.Run("annotation", func(t *testing.T) {
-		k0 := &K0{}
-		hub, err := New(module2, Annotation(func(ann *Annotated) {
-			ann.Target = func() *K0 { return k0 }
-			ann.Close = k0.Close
-		}))
-		require.NoError(t, err)
-		require.NotNil(t, hub)
-
-		// invoke now
-		err = hub.Invoke(func(k1 K1) { assert.Equal(t, k1.J.Name, "j1") })
-		require.NoError(t, err)
-		err = hub.Invoke(func(k2 K2) { assert.Equal(t, k2.J.Name, "j2") })
-		require.NoError(t, err)
-
-		// cleanup and check it
-		hub.Cleanup()
-		require.True(t, k0.Closed)
-	})
-
-	t.Run("missing deps", func(t *testing.T) {
-		hub, err := New(moduleFailed, ValidateHub(false))
-		require.NoError(t, err) // won't check missing H in G, only check it after invoke
-		require.NotNil(t, hub)
-
-		err = hub.Invoke(func(g G) {})
-		assert.Error(t, err)
-		assert.True(t, strings.Contains(err.Error(), "missing dependencies"))
-	})
-}
-
-var module1 = Options(
-	Provide(func() A {
-		return A{Name: "a"}
-	}),
-	Provide(func(a A) B {
-		return B{
-			A:   a,
-			Age: 20,
-		}
-	}),
-	Provide(func(a A, b B) C {
-		return C{
-			A:      a,
-			B:      b,
-			Number: 100,
-		}
-	}),
-	Provide(NewE),
-)
-
-var module2 = Options(
-	Provide(Annotated{
-		Name: "j1",
-		Target: func() J {
-			return J{Name: "j1"}
-		},
-	}),
-	Provide(Annotated{
-		Name: "j2",
-		Target: func() J {
-			return J{Name: "j2"}
-		},
-	}),
-)
-
-var moduleFailed = Options(
-	Provide(func(g G) H {
-		return H{
-			G:    g,
-			Name: "h",
-		}
-	}),
-)
-
-type A struct {
-	Name string
-}
-
-type B struct {
-	A   A
-	Age int
-}
-
-type C struct {
-	A      A
-	B      B
-	Number int64
-}
-
-type D struct {
-	dig.In
-
-	A A
-	B B
-	C C
-}
-
-func NewE() E {
-	return E{
-		F1: F1{
-			Name: "f1",
-		},
-		F2: F2{
-			Name: "f2",
-		},
-	}
-}
-
-type E struct {
-	dig.Out
-
-	F1 F1
-	F2 F2
-}
-
-type F1 struct {
-	Name string
-}
-
-type F2 struct {
-	Name string
-}
-
-type G struct {
-	Name string
-}
-
-type H struct {
-	G    G
-	Name string
-}
-
-type J struct {
-	Name string
-}
-
-type K0 struct {
-	Closed bool
-}
-
-func (k *K0) Close() {
-	k.Closed = true
-}
-
-type K1 struct {
-	dig.In
-	J J `name:"j1"`
-}
-
-type K2 struct {
-	dig.In
-	J J `name:"j2"`
-}

+ 0 - 180
pkg/di/option.go

@@ -1,180 +0,0 @@
-package di
-
-import (
-	"fmt"
-	"strings"
-
-	"kpt-tmr-group/pkg/di/xreflect"
-
-	"go.uber.org/dig"
-)
-
-// Option configures a Hub. It's included for future functionality;
-// currently, there are no concrete implementations.
-type Option = dig.Option
-
-// A ProvideOption modifies the default behavior of Provide.
-type ProvideOption = dig.ProvideOption
-
-// An InvokeOption modifies the default behavior of Invoke. It's included for
-// future functionality; currently, there are no concrete implementations.
-type InvokeOption = dig.InvokeOption
-
-// HubOption is an option configures an Hub using the functional options paradigm
-// popularized by Rob Pike. If you're unfamiliar with this style, see
-// https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html.
-type HubOption interface {
-	fmt.Stringer
-	Apply(hub *Hub)
-}
-
-// Options converts a collection of Options into a single Option. This allows
-// packages to bundle sophisticated functionality into easy-to-use Fx modules.
-// For example, a logging package might export a simple option like this:
-//
-//  package logging
-//
-//  var Module = fx.Provide(func() *log.Logger {
-//    return log.New(os.Stdout, "", 0)
-//  })
-//
-// A shared all-in-one microservice package could then use Options to bundle
-// logging with similar metrics, tracing, and gRPC modules:
-//
-//  package server
-//
-//  var Module = fx.Options(
-//    logging.Module,
-//    metrics.Module,
-//    tracing.Module,
-//    grpc.Module,
-//  )
-//
-// Since this all-in-one module1 has a minimal API surface, it's easy to add
-// new functionality to it without breaking existing users. Individual
-// applications can take advantage of all this functionality with only one
-// line of code:
-//
-//  app := di.New(server.Module)
-//
-// Use this pattern sparingly, since it limits the user's ability to customize
-// their application.
-func Options(opts ...HubOption) HubOption {
-	return optionGroup(opts)
-}
-
-type optionGroup []HubOption
-
-func (og optionGroup) Apply(hub *Hub) {
-	for _, opt := range og {
-		opt.Apply(hub)
-	}
-}
-
-func (og optionGroup) String() string {
-	items := make([]string, len(og))
-	for i, opt := range og {
-		items[i] = fmt.Sprint(opt)
-	}
-	return fmt.Sprintf("di.Options(%s)", strings.Join(items, ", "))
-}
-
-// Annotation define annotated and apply to Provided
-// Annotation provides instantiated values for dependency injection as if
-// they had been provided using a constructor that simply returns them.
-// The most specific type of each value (as determined by reflection) is used.
-//
-//	type K0 struct {
-//		Closed bool
-//	}
-//
-//	func (k *K0) Close() {
-//		k.Closed = true
-//	}
-//
-//	k0 := &K0{}
-//	var module = Annotation(func(ann *Annotated) {
-//		ann.Target = func() *K0 { return k0 }
-//		ann.Close = k0.Close
-//	})
-//
-//	hub, err := di.New(module)
-func Annotation(f func(ann *Annotated)) HubOption {
-	annotation := &Annotated{}
-	f(annotation)
-
-	return provideOption{
-		Targets: []interface{}{*annotation},
-		Stack:   xreflect.CallerStack(1, 0),
-	}
-}
-
-// Provide registers any number of constructor functions, teaching the
-// application how to instantiate various types. The supplied constructor
-// function(s) may depend on other types available in the application, must
-// return one or more objects, and may return an error. For example:
-//
-//  // Constructs type *C, depends on *A and *B.
-//  func(*A, *B) *C
-//
-//  // Constructs type *C, depends on *A and *B, and indicates failure by
-//  // returning an error.
-//  func(*A, *B) (*C, error)
-//
-//  // Constructs types *B and *C, depends on *A, and can fail.
-//  func(*A) (*B, *C, error)
-func Provide(constructors ...interface{}) HubOption {
-	// check no nil or error
-	for _, value := range constructors {
-		switch value.(type) {
-		case nil:
-			panic("untyped nil passed to di.Provide")
-		case error:
-			panic("error value passed to di.Provide")
-		}
-	}
-
-	return provideOption{
-		Targets: constructors,
-		Stack:   xreflect.CallerStack(1, 0),
-	}
-}
-
-type provideOption struct {
-	Targets []interface{}
-	Stack   xreflect.Stack
-}
-
-func (o provideOption) Apply(hub *Hub) {
-	for _, target := range o.Targets {
-		hub.provides = append(hub.provides, Provided{
-			Target: target,
-			Stack:  o.Stack,
-		})
-	}
-}
-
-func (o provideOption) String() string {
-	items := make([]string, len(o.Targets))
-	for i, c := range o.Targets {
-		items[i] = xreflect.FuncName(c)
-	}
-	return fmt.Sprintf("fx.Provide(%s)", strings.Join(items, ", "))
-}
-
-// ValidateHub validates that supplied graph would run and is not missing any dependencies.
-func ValidateHub(v bool) HubOption {
-	return validateOption{validate: v}
-}
-
-type validateOption struct {
-	validate bool
-}
-
-func (o validateOption) Apply(hub *Hub) {
-	hub.validate = o.validate
-}
-
-func (o validateOption) String() string {
-	return fmt.Sprintf("fx.validate(%v)", o.validate)
-}

+ 0 - 157
pkg/di/xreflect/reflect.go

@@ -1,157 +0,0 @@
-// Copyright (c) 2019 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-package xreflect
-
-import (
-	"fmt"
-	"net/url"
-	"reflect"
-	"regexp"
-	"runtime"
-	"strings"
-
-	"go.uber.org/dig"
-)
-
-// Match from beginning of the line until the first `vendor/` (non-greedy)
-var vendorRe = regexp.MustCompile("^.*?/vendor/")
-
-// ReturnTypes takes a func and returns a slice of string'd types.
-func ReturnTypes(t interface{}) []string {
-	if reflect.TypeOf(t).Kind() != reflect.Func {
-		// Invalid provide, will be logged as an error.
-		return []string{}
-	}
-
-	rtypes := []string{}
-	ft := reflect.ValueOf(t).Type()
-
-	for i := 0; i < ft.NumOut(); i++ {
-		t := ft.Out(i)
-
-		traverseOuts(key{t: t}, func(s string) {
-			rtypes = append(rtypes, s)
-		})
-	}
-
-	return rtypes
-}
-
-type key struct {
-	t    reflect.Type
-	name string
-}
-
-func (k *key) String() string {
-	if k.name != "" {
-		return fmt.Sprintf("%v:%s", k.t, k.name)
-	}
-	return k.t.String()
-}
-
-func traverseOuts(k key, f func(s string)) {
-	// skip errors
-	if isErr(k.t) {
-		return
-	}
-
-	// call function on non-Out types
-	if dig.IsOut(k.t) {
-		// keep recursing down on field members in case they are ins
-		for i := 0; i < k.t.NumField(); i++ {
-			field := k.t.Field(i)
-			ft := field.Type
-
-			if field.PkgPath != "" {
-				continue // skip private fields
-			}
-
-			// keep recursing to traverse all the embedded objects
-			k := key{
-				t:    ft,
-				name: field.Tag.Get("name"),
-			}
-			traverseOuts(k, f)
-		}
-
-		return
-	}
-
-	f(k.String())
-}
-
-// sanitize makes the function name suitable for logging display. It removes
-// url-encoded elements from the `dot.git` package names and shortens the
-// vendored paths.
-func sanitize(function string) string {
-	// Use the stdlib to un-escape any package import paths which can happen
-	// in the case of the "dot-git" postfix. Seems like a bug in stdlib =/
-	if unescaped, err := url.QueryUnescape(function); err == nil {
-		function = unescaped
-	}
-
-	// strip everything prior to the vendor
-	return vendorRe.ReplaceAllString(function, "vendor/")
-}
-
-// Caller returns the formatted calling func name
-func Caller() string {
-	return CallerStack(1, 0).CallerName()
-}
-
-// FuncName returns a funcs formatted name
-func FuncName(fn interface{}) string {
-	fnV := reflect.ValueOf(fn)
-	if fnV.Kind() != reflect.Func {
-		return fmt.Sprint(fn)
-	}
-
-	function := runtime.FuncForPC(fnV.Pointer()).Name()
-	return fmt.Sprintf("%s()", sanitize(function))
-}
-
-func isErr(t reflect.Type) bool {
-	errInterface := reflect.TypeOf((*error)(nil)).Elem()
-	return t.Implements(errInterface)
-}
-
-// Ascend the call stack until we leave the di production code. This allows us
-// to avoid hard-coding a frame skip, which makes this code work well even
-// when it's wrapped.
-func shouldIgnoreFrame(f Frame) bool {
-	// Treat test files as leafs.
-	if strings.Contains(f.File, "_test.go") {
-		return false
-	}
-
-	// The unique, fully-qualified name for all functions begins with
-	// "{{importPath}}.". We'll ignore di and its subpackages.
-	s := strings.TrimPrefix(f.Function, "kpt-tmr-group/pkg/di")
-	if len(s) > 0 && s[0] == '.' || s[0] == '/' {
-		// We want to match,
-		//   kpt-tmr-group/pkg/di.Foo
-		//   kpt-tmr-group/pkg/di/something.Foo
-		// But not, kpt-tmr-group/pkg/difoo
-		return true
-	}
-
-	return false
-}

+ 0 - 143
pkg/di/xreflect/reflect_test.go

@@ -1,143 +0,0 @@
-// Copyright (c) 2019 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-package xreflect
-
-import (
-	"errors"
-	"log"
-	"sync"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"go.uber.org/dig"
-)
-
-type hollerer interface {
-	Holler()
-}
-
-type impl struct{}
-
-func (impl) Holler() {}
-
-type result struct {
-	dig.Out // referencing di introduces import cycles
-
-	mu     sync.Mutex // unexported
-	Logger *log.Logger
-}
-
-func TestReturnTypes(t *testing.T) {
-	t.Run("non-function", func(t *testing.T) {
-		assert.Empty(t, ReturnTypes(42))
-	})
-	t.Run("primitive", func(t *testing.T) {
-		fn := func() (int, string) {
-			return 0, ""
-		}
-		assert.Equal(t, []string{"int", "string"}, ReturnTypes(fn))
-	})
-	t.Run("pointer", func(t *testing.T) {
-		type s struct{}
-		fn := func() *s {
-			return &s{}
-		}
-		assert.Equal(t, []string{"*xreflect.s"}, ReturnTypes(fn))
-	})
-	t.Run("interface", func(t *testing.T) {
-		fn := func() hollerer {
-			return impl{}
-		}
-		assert.Equal(t, []string{"xreflect.hollerer"}, ReturnTypes(fn))
-	})
-	t.Run("result struct", func(t *testing.T) {
-		fn := func() result {
-			return result{}
-		}
-		assert.Equal(t, []string{"*log.Logger"}, ReturnTypes(fn))
-	})
-	t.Run("skips errors", func(t *testing.T) {
-		fn := func() (string, error) {
-			return "", errors.New("err")
-		}
-		assert.Equal(t, []string{"string"}, ReturnTypes(fn))
-	})
-}
-
-func TestCaller(t *testing.T) {
-	assert.Equal(t, "kpt-tmr-group/pkg/di/xreflect.TestCaller", Caller())
-}
-
-func someFunc() {}
-
-func TestFuncName(t *testing.T) {
-	tests := []struct {
-		desc string
-		give interface{}
-		want string
-	}{
-		{
-			desc: "function",
-			give: someFunc,
-			want: "kpt-tmr-group/pkg/di/xreflect.someFunc()",
-		},
-		{
-			desc: "not a function",
-			give: 42,
-			want: "42",
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.desc, func(t *testing.T) {
-			assert.Equal(t, tt.want, FuncName(tt.give))
-		})
-	}
-}
-
-func TestSanitizeFuncNames(t *testing.T) {
-	cases := []struct {
-		name     string
-		input    string
-		expected string
-	}{
-		{
-			"url encoding",
-			"go.uber.org/di/sample%2egit/someFunc",
-			"go.uber.org/di/sample.git/someFunc",
-		},
-		{
-			"vendor removal",
-			"go.uber.org/di/vendor/github.com/some/lib.SomeFunc",
-			"vendor/github.com/some/lib.SomeFunc",
-		},
-		{
-			"package happens to be named vendor is untouched",
-			"go.uber.org/di/foovendor/someFunc",
-			"go.uber.org/di/foovendor/someFunc",
-		},
-	}
-	for _, c := range cases {
-		t.Run(c.name, func(t *testing.T) {
-			assert.Equal(t, c.expected, sanitize(c.input))
-		})
-	}
-}

+ 0 - 149
pkg/di/xreflect/stack.go

@@ -1,149 +0,0 @@
-// Copyright (c) 2019 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-package xreflect
-
-import (
-	"fmt"
-	"io"
-	"runtime"
-	"strings"
-)
-
-// Frame holds information about a single frame in the call stack.
-type Frame struct {
-	// Unique, package path-qualified name for the function of this call
-	// frame.
-	Function string
-
-	// File and line number of our location in the frame.
-	//
-	// Note that the line number does not refer to where the function was
-	// defined but where in the function the next call was made.
-	File string
-	Line int
-}
-
-func (f Frame) String() string {
-	// This takes the following forms.
-	//  (path/to/file.go)
-	//  (path/to/file.go:42)
-	//  path/to/package.MyFunction
-	//  path/to/package.MyFunction (path/to/file.go)
-	//  path/to/package.MyFunction (path/to/file.go:42)
-
-	var sb strings.Builder
-	sb.WriteString(f.Function)
-	if len(f.File) > 0 {
-		if sb.Len() > 0 {
-			sb.WriteRune(' ')
-		}
-		fmt.Fprintf(&sb, "(%v", f.File)
-		if f.Line > 0 {
-			fmt.Fprintf(&sb, ":%d", f.Line)
-		}
-		sb.WriteRune(')')
-	}
-
-	if sb.Len() == 0 {
-		return "unknown"
-	}
-
-	return sb.String()
-}
-
-const _defaultCallersDepth = 8
-
-// Stack is a stack of call frames.
-//
-// Formatted with %v, the output is in a single-line, in the form,
-//
-//   foo/bar.Baz() (path/to/foo.go:42); bar/baz.Qux() (bar/baz/qux.go:12); ...
-//
-// Formatted with %+v, the output is in the form,
-//
-//   foo/bar.Baz()
-//   	path/to/foo.go:42
-//   bar/baz.Qux()
-//   	bar/baz/qux.go:12
-type Stack []Frame
-
-// Returns a single-line, semi-colon representation of a Stack. For a
-// multi-line representation, use %+v.
-func (fs Stack) String() string {
-	items := make([]string, len(fs))
-	for i, f := range fs {
-		items[i] = f.String()
-	}
-	return strings.Join(items, "; ")
-}
-
-// Format implements fmt.Formatter to handle "%+v".
-func (fs Stack) Format(w fmt.State, c rune) {
-	if !w.Flag('+') {
-		// Without %+v, fall back to String().
-		io.WriteString(w, fs.String())
-		return
-	}
-
-	for _, f := range fs {
-		fmt.Fprintln(w, f.Function)
-		fmt.Fprintf(w, "\t%v:%v\n", f.File, f.Line)
-	}
-}
-
-// CallerName returns the name of the first caller in this stack that isn't
-// owned by the di library.
-func (fs Stack) CallerName() string {
-	for _, f := range fs {
-		if shouldIgnoreFrame(f) {
-			continue
-		}
-		return f.Function
-	}
-	return "n/a"
-}
-
-// CallerStack returns the call stack for the calling function, up to depth frames
-// deep, skipping the provided number of frames, not including Callers itself.
-//
-// If zero, depth defaults to 8.
-func CallerStack(skip, depth int) Stack {
-	if depth <= 0 {
-		depth = _defaultCallersDepth
-	}
-
-	pcs := make([]uintptr, depth)
-
-	// +2 to skip this frame and runtime.Callers.
-	n := runtime.Callers(skip+2, pcs)
-	pcs = pcs[:n] // truncate to number of frames actually read
-
-	result := make([]Frame, 0, n)
-	frames := runtime.CallersFrames(pcs)
-	for f, more := frames.Next(); more; f, more = frames.Next() {
-		result = append(result, Frame{
-			Function: sanitize(f.Function),
-			File:     f.File,
-			Line:     f.Line,
-		})
-	}
-	return result
-}

+ 0 - 236
pkg/di/xreflect/stack_test.go

@@ -1,236 +0,0 @@
-// Copyright (c) 2019 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-package xreflect
-
-import (
-	"fmt"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-)
-
-func TestStack(t *testing.T) {
-	// NOTE:
-	// We don't assert the length of the stack because we cannot make
-	// guarantees about how many frames the test runner is allowed to
-	// introduce.
-
-	t.Run("default", func(t *testing.T) {
-		frames := CallerStack(0, 0)
-		require.NotEmpty(t, frames)
-		f := frames[0]
-		assert.Equal(t, "kpt-tmr-group/pkg/di/xreflect.TestStack.func1", f.Function)
-		assert.Contains(t, f.File, "xreflect/stack_test.go")
-		assert.NotZero(t, f.Line)
-	})
-
-	t.Run("default/deeper", func(t *testing.T) {
-		// Introduce a few frames.
-		frames := func() []Frame {
-			return func() []Frame {
-				return CallerStack(0, 0)
-			}()
-		}()
-
-		require.True(t, len(frames) > 3, "expected at least three frames")
-		for i, name := range []string{"func2.1.1", "func2.1", "func2"} {
-			f := frames[i]
-			assert.Equal(t, "kpt-tmr-group/pkg/di/xreflect.TestStack."+name, f.Function)
-			assert.Contains(t, f.File, "xreflect/stack_test.go")
-			assert.NotZero(t, f.Line)
-		}
-	})
-
-	t.Run("skip", func(t *testing.T) {
-		// Introduce a few frames and skip 2.
-		frames := func() []Frame {
-			return func() []Frame {
-				return CallerStack(2, 0)
-			}()
-		}()
-
-		require.NotEmpty(t, frames)
-		f := frames[0]
-		assert.Equal(t, "kpt-tmr-group/pkg/di/xreflect.TestStack.func3", f.Function)
-		assert.Contains(t, f.File, "xreflect/stack_test.go")
-		assert.NotZero(t, f.Line)
-	})
-}
-
-func TestStackCallerName(t *testing.T) {
-	tests := []struct {
-		desc string
-		give Stack
-		want string
-	}{
-		{desc: "empty", want: "n/a"},
-		{
-			desc: "skip di components",
-			give: Stack{
-				{
-					Function: "kpt-tmr-group/pkg/di.Foo()",
-					File:     "kpt-tmr-group/pkg/di/foo.go",
-				},
-				{
-					Function: "foo/bar.Baz()",
-					File:     "foo/bar/baz.go",
-				},
-			},
-			want: "foo/bar.Baz()",
-		},
-		{
-			desc: "skip di in wrong directory",
-			give: Stack{
-				{
-					Function: "kpt-tmr-group/pkg/di/di.Foo()",
-					File:     "di/foo.go",
-				},
-				{
-					Function: "foo/bar.Baz()",
-					File:     "foo/bar/baz.go",
-				},
-			},
-			want: "foo/bar.Baz()",
-		},
-		{
-			desc: "skip di subpackage",
-			give: Stack{
-				{
-					Function: "kpt-tmr-group/pkg/di/xreflect.Foo()",
-					File:     "di/internal/xreflect/foo.go",
-				},
-				{
-					Function: "foo/bar.Baz()",
-					File:     "foo/bar/baz.go",
-				},
-			},
-			want: "foo/bar.Baz()",
-		},
-		{
-			desc: "don't skip di tests",
-			give: Stack{
-				{
-					Function: "some/thing.Foo()",
-					File:     "kpt-tmr-group/pkg/di/foo_test.go",
-				},
-			},
-			want: "some/thing.Foo()",
-		},
-		{
-			desc: "don't skip di prefix",
-			give: Stack{
-				{
-					Function: "kpt-tmr-group/pkg/difoo.Bar()",
-					File:     "kpt-tmr-group/pkg/difoo/bar.go",
-				},
-			},
-			want: "kpt-tmr-group/pkg/difoo.Bar()",
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.desc, func(t *testing.T) {
-			assert.Equal(t, tt.want, tt.give.CallerName())
-		})
-	}
-}
-
-func TestFrameString(t *testing.T) {
-	tests := []struct {
-		desc string
-		give Frame
-		want string
-	}{
-		{
-			desc: "zero",
-			give: Frame{},
-			want: "unknown",
-		},
-		{
-			desc: "file and line",
-			give: Frame{File: "foo.go", Line: 42},
-			want: "(foo.go:42)",
-		},
-		{
-			desc: "file only",
-			give: Frame{File: "foo.go"},
-			want: "(foo.go)",
-		},
-		{
-			desc: "function only",
-			give: Frame{Function: "foo"},
-			want: "foo",
-		},
-		{
-			desc: "function and file",
-			give: Frame{Function: "foo", File: "bar.go"},
-			want: "foo (bar.go)",
-		},
-		{
-			desc: "function and line",
-			give: Frame{Function: "foo", Line: 42},
-			want: "foo", // line without file is meaningless
-		},
-		{
-			desc: "function, file, and line",
-			give: Frame{Function: "foo", File: "bar.go", Line: 42},
-			want: "foo (bar.go:42)",
-		},
-	}
-
-	for _, tt := range tests {
-		t.Run(tt.desc, func(t *testing.T) {
-			assert.Equal(t, tt.want, tt.give.String())
-		})
-	}
-}
-
-func TestStackFormat(t *testing.T) {
-	stack := Stack{
-		{
-			Function: "path/to/module.SomeFunction()",
-			File:     "path/to/file.go",
-			Line:     42,
-		},
-		{
-			Function: "path/to/another/module.AnotherFunction()",
-			File:     "path/to/another/file.go",
-			Line:     12,
-		},
-	}
-
-	t.Run("single line", func(t *testing.T) {
-		assert.Equal(t,
-			"path/to/module.SomeFunction() (path/to/file.go:42); "+
-				"path/to/another/module.AnotherFunction() (path/to/another/file.go:12)",
-			fmt.Sprintf("%v", stack))
-	})
-
-	t.Run("multi line", func(t *testing.T) {
-		assert.Equal(t, `path/to/module.SomeFunction()
-	path/to/file.go:42
-path/to/another/module.AnotherFunction()
-	path/to/another/file.go:12
-`, fmt.Sprintf("%+v", stack))
-	})
-
-}

+ 0 - 68
pkg/ginutil/bind.go

@@ -1,68 +0,0 @@
-package ginutil
-
-import (
-	"net/http"
-	"reflect"
-
-	"kpt-tmr-group/pkg/jsonpb"
-	"kpt-tmr-group/pkg/xerr"
-
-	"github.com/gin-gonic/gin"
-	"github.com/gin-gonic/gin/binding"
-	"github.com/golang/protobuf/proto"
-	"github.com/huandu/xstrings"
-)
-
-var camelQuery = &CamelQueryBinding{}
-
-// BindQuery with query params
-func BindQuery(c *gin.Context, obj interface{}) error {
-	return c.ShouldBindWith(obj, camelQuery)
-}
-
-type CamelQueryBinding struct{}
-
-func (*CamelQueryBinding) Name() string {
-	return "camel_query"
-}
-
-func (*CamelQueryBinding) Bind(req *http.Request, obj interface{}) error {
-	values := req.URL.Query()
-	if err := mapFormByTag(obj, values, "json"); err != nil {
-		return err
-	}
-	return binding.Validator.ValidateStruct(obj)
-}
-
-type camelFormSource map[string][]string
-
-// TrySet tries to set a value by request's form source (like map[string][]string)
-func (form camelFormSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (isSetted bool, err error) {
-	return setByForm(value, field, form, xstrings.FirstRuneToLower(xstrings.ToCamelCase(tagValue)), opt)
-}
-
-// BindProtoMessage with proto message from json body
-func BindProtoMessage(c *gin.Context, obj proto.Message) error {
-	return c.ShouldBindWith(obj, protoMessageBindingFromBody)
-}
-
-var protoMessageBindingFromBody = &ProtoMessageBinding{}
-
-type ProtoMessageBinding struct{}
-
-func (*ProtoMessageBinding) Name() string {
-	return "proto_message_binding"
-}
-
-func (*ProtoMessageBinding) Bind(req *http.Request, obj interface{}) error {
-	pbMessage, ok := obj.(proto.Message)
-	if !ok {
-		return xerr.New("bind obj should be proto.Message")
-	}
-
-	if err := jsonpb.Unmarshal(req.Body, pbMessage); err != nil {
-		return xerr.WithStack(err)
-	}
-
-	return binding.Validator.ValidateStruct(obj)
-}

+ 0 - 34
pkg/ginutil/bind_proto.go

@@ -1,34 +0,0 @@
-package ginutil
-
-import (
-	"net/http"
-
-	"kpt-tmr-group/pkg/jsonpb"
-	"kpt-tmr-group/pkg/xerr"
-
-	"github.com/gin-gonic/gin"
-	"github.com/golang/protobuf/proto"
-)
-
-type ProtoMessageQueryBinding struct{}
-
-func BindQueryProto(c *gin.Context, pb proto.Message) error {
-	values := c.Request.URL.Query()
-	if err := jsonpb.UnmarshalQuery(values, pb); err != nil {
-		return xerr.WithStack(err)
-	}
-	return nil
-}
-
-func BindProto(c *gin.Context, pb proto.Message) (err error) {
-	switch c.Request.Method {
-	case http.MethodGet, http.MethodDelete:
-		err = BindQueryProto(c, pb)
-	default:
-		err = BindProtoMessage(c, pb)
-	}
-	if err != nil {
-		return xerr.WithStack(err)
-	}
-	return
-}

+ 0 - 19
pkg/ginutil/json_proto_response.go

@@ -1,19 +0,0 @@
-package ginutil
-
-import (
-	"kpt-tmr-group/pkg/apierr"
-	"kpt-tmr-group/pkg/jsonpb"
-	"net/http"
-
-	"github.com/gin-gonic/gin"
-	"github.com/golang/protobuf/proto"
-)
-
-func JSONResp(c *gin.Context, pb proto.Message) {
-	bs, err := jsonpb.MarshalBytes(pb)
-	if err != nil {
-		apierr.AbortInternalError(c, http.StatusInternalServerError, err)
-		return
-	}
-	c.Data(http.StatusOK, "application/json", bs)
-}

+ 0 - 322
pkg/ginutil/setter.go

@@ -1,322 +0,0 @@
-package ginutil
-
-import (
-	"encoding/json"
-	"errors"
-	"reflect"
-	"strconv"
-	"strings"
-	"time"
-
-	"kpt-tmr-group/pkg/xerr"
-)
-
-var _ setter = camelFormSource(nil)
-
-var emptyField = reflect.StructField{}
-
-// setter tries to set value on a walking by fields of a struct
-type setter interface {
-	TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error)
-}
-
-type setOptions struct {
-	isDefaultExists bool
-	defaultValue    string
-}
-
-func mapFormByTag(ptr interface{}, form map[string][]string, tag string) error {
-	return mappingByPtr(ptr, camelFormSource(form), tag)
-}
-
-func mappingByPtr(ptr interface{}, setter setter, tag string) error {
-	_, err := mapping(reflect.ValueOf(ptr), emptyField, setter, tag)
-	return err
-}
-
-func mapping(value reflect.Value, field reflect.StructField, setter setter, tag string) (bool, error) {
-	var vKind = value.Kind()
-
-	if vKind == reflect.Ptr {
-		var isNew bool
-		vPtr := value
-		if value.IsNil() {
-			isNew = true
-			vPtr = reflect.New(value.Type().Elem())
-		}
-		isSetted, err := mapping(vPtr.Elem(), field, setter, tag)
-		if err != nil {
-			return false, err
-		}
-		if isNew && isSetted {
-			value.Set(vPtr)
-		}
-		return isSetted, nil
-	}
-
-	ok, err := tryToSetValue(value, field, setter, tag)
-	if err != nil {
-		return false, err
-	}
-	if ok {
-		return true, nil
-	}
-
-	if vKind == reflect.Struct {
-		tValue := value.Type()
-
-		var isSetted bool
-		for i := 0; i < value.NumField(); i++ {
-			if !value.Field(i).CanSet() {
-				continue
-			}
-			ok, err := mapping(value.Field(i), tValue.Field(i), setter, tag)
-			if err != nil {
-				return false, err
-			}
-			isSetted = isSetted || ok
-		}
-		return isSetted, nil
-	}
-	return false, nil
-}
-
-func tryToSetValue(value reflect.Value, field reflect.StructField, setter setter, tag string) (bool, error) {
-	var tagValue string
-	var setOpt setOptions
-
-	tagValue = field.Tag.Get(tag)
-	tagValue, opts := head(tagValue, ",")
-
-	if tagValue == "-" { // just ignoring this field
-		return false, nil
-	}
-	if tagValue == "" { // when field is "emptyField" variable
-		return false, nil
-	}
-
-	var opt string
-	for len(opts) > 0 {
-		opt, opts = head(opts, ",")
-
-		k, v := head(opt, "=")
-		switch k {
-		case "default":
-			setOpt.isDefaultExists = true
-			setOpt.defaultValue = v
-		}
-	}
-
-	return setter.TrySet(value, field, tagValue, setOpt)
-}
-
-func setByForm(value reflect.Value, field reflect.StructField, form map[string][]string, tagValue string, opt setOptions) (isSetted bool, err error) {
-	vs, ok := form[tagValue]
-	if !ok && !opt.isDefaultExists {
-		return false, nil
-	}
-
-	switch value.Kind() {
-	case reflect.Slice:
-		if !ok {
-			vs = []string{opt.defaultValue}
-		}
-		return true, setSlice(vs, value, field)
-	case reflect.Array:
-		if !ok {
-			vs = []string{opt.defaultValue}
-		}
-		if len(vs) != value.Len() {
-			return false, xerr.Errorf("%q is not valid value for %s", vs, value.Type().String())
-		}
-		return true, setArray(vs, value, field)
-	default:
-		var val string
-		if !ok {
-			val = opt.defaultValue
-		}
-
-		if len(vs) > 0 {
-			val = vs[0]
-		}
-		return true, setWithProperType(val, value, field)
-	}
-}
-
-var errUnknownType = errors.New("unknown type")
-
-func setWithProperType(val string, value reflect.Value, field reflect.StructField) error {
-	switch value.Kind() {
-	case reflect.Int:
-		return setIntField(val, 0, value)
-	case reflect.Int8:
-		return setIntField(val, 8, value)
-	case reflect.Int16:
-		return setIntField(val, 16, value)
-	case reflect.Int32:
-		return setIntField(val, 32, value)
-	case reflect.Int64:
-		switch value.Interface().(type) {
-		case time.Duration:
-			return setTimeDuration(val, value, field)
-		}
-		return setIntField(val, 64, value)
-	case reflect.Uint:
-		return setUintField(val, 0, value)
-	case reflect.Uint8:
-		return setUintField(val, 8, value)
-	case reflect.Uint16:
-		return setUintField(val, 16, value)
-	case reflect.Uint32:
-		return setUintField(val, 32, value)
-	case reflect.Uint64:
-		return setUintField(val, 64, value)
-	case reflect.Bool:
-		return setBoolField(val, value)
-	case reflect.Float32:
-		return setFloatField(val, 32, value)
-	case reflect.Float64:
-		return setFloatField(val, 64, value)
-	case reflect.String:
-		value.SetString(val)
-	case reflect.Struct:
-		switch value.Interface().(type) {
-		case time.Time:
-			return setTimeField(val, field, value)
-		}
-		return json.Unmarshal([]byte(val), value.Addr().Interface())
-	case reflect.Map:
-		return json.Unmarshal([]byte(val), value.Addr().Interface())
-	default:
-		return errUnknownType
-	}
-	return nil
-}
-
-func setIntField(val string, bitSize int, field reflect.Value) error {
-	if val == "" {
-		val = "0"
-	}
-	intVal, err := strconv.ParseInt(val, 10, bitSize)
-	if err == nil {
-		field.SetInt(intVal)
-	}
-	return xerr.WithStack(err)
-}
-
-func setUintField(val string, bitSize int, field reflect.Value) error {
-	if val == "" {
-		val = "0"
-	}
-	uintVal, err := strconv.ParseUint(val, 10, bitSize)
-	if err == nil {
-		field.SetUint(uintVal)
-	}
-	return xerr.WithStack(err)
-}
-
-func setBoolField(val string, field reflect.Value) error {
-	if val == "" {
-		val = "false"
-	}
-	boolVal, err := strconv.ParseBool(val)
-	if err == nil {
-		field.SetBool(boolVal)
-	}
-	return xerr.WithStack(err)
-}
-
-func setFloatField(val string, bitSize int, field reflect.Value) error {
-	if val == "" {
-		val = "0.0"
-	}
-	floatVal, err := strconv.ParseFloat(val, bitSize)
-	if err == nil {
-		field.SetFloat(floatVal)
-	}
-	return xerr.WithStack(err)
-}
-
-func setTimeField(val string, structField reflect.StructField, value reflect.Value) error {
-	timeFormat := structField.Tag.Get("time_format")
-	if timeFormat == "" {
-		timeFormat = time.RFC3339
-	}
-
-	if val == "" {
-		value.Set(reflect.ValueOf(time.Time{}))
-		return nil
-	}
-
-	l := time.Local
-	if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {
-		l = time.UTC
-	}
-
-	if locTag := structField.Tag.Get("time_location"); locTag != "" {
-		loc, err := time.LoadLocation(locTag)
-		if err != nil {
-			return xerr.WithStack(err)
-		}
-		l = loc
-	}
-
-	var (
-		t   time.Time
-		err error
-	)
-
-	if isTS, _ := strconv.ParseBool(structField.Tag.Get("time_ts")); isTS {
-		sec, e := strconv.ParseInt(val, 10, 64)
-		if e != nil {
-			return xerr.WithStack(e)
-		}
-		t = time.Unix(sec, 0).In(l)
-	} else {
-		t, err = time.ParseInLocation(timeFormat, val, l)
-	}
-	if err != nil {
-		return xerr.WithStack(err)
-	}
-
-	value.Set(reflect.ValueOf(t))
-	return nil
-}
-
-// TODO: should support array case. eg. myArray[]=a&myArray[]=b
-func setArray(vals []string, value reflect.Value, field reflect.StructField) error {
-	for i, s := range vals {
-		err := setWithProperType(s, value.Index(i), field)
-		if err != nil {
-			return xerr.WithStack(err)
-		}
-	}
-	return nil
-}
-
-func setSlice(vals []string, value reflect.Value, field reflect.StructField) error {
-	slice := reflect.MakeSlice(value.Type(), len(vals), len(vals))
-	err := setArray(vals, slice, field)
-	if err != nil {
-		return xerr.WithStack(err)
-	}
-	value.Set(slice)
-	return nil
-}
-
-func setTimeDuration(val string, value reflect.Value, _ reflect.StructField) error {
-	d, err := time.ParseDuration(val)
-	if err != nil {
-		return xerr.WithStack(err)
-	}
-	value.Set(reflect.ValueOf(d))
-	return nil
-}
-
-func head(str, sep string) (head string, tail string) {
-	idx := strings.Index(str, sep)
-	if idx < 0 {
-		return str, ""
-	}
-	return str[:idx], str[idx+len(sep):]
-}

+ 0 - 57
pkg/grpcutil/client_conn.go

@@ -1,57 +0,0 @@
-package grpcutil
-
-import (
-	"context"
-	"time"
-
-	"kpt-tmr-group/pkg/xerr"
-
-	grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
-	grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
-	grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-)
-
-func DialContext(ctx context.Context, target string, options ...grpc.DialOption) (*grpc.ClientConn, error) {
-	if len(options) == 0 {
-		options = DefaultDialOptions()
-	}
-
-	conn, err := grpc.DialContext(ctx, target, options...)
-	if err != nil {
-		return nil, xerr.WithStack(err)
-	}
-
-	return conn, err
-}
-
-func DefaultDialOptions() []grpc.DialOption {
-	options := DefaultAsyncDialOptions()
-	return append(options, grpc.WithBlock())
-}
-
-func DefaultAsyncDialOptions() []grpc.DialOption {
-	unaryInterceptors := []grpc.UnaryClientInterceptor{
-		grpc_retry.UnaryClientInterceptor(
-			grpc_retry.WithMax(3),
-			grpc_retry.WithCodes(codes.Aborted, codes.DeadlineExceeded),
-			grpc_retry.WithPerRetryTimeout(time.Millisecond*500),
-		),
-		grpc_prometheus.UnaryClientInterceptor,
-	}
-	streamInterceptors := []grpc.StreamClientInterceptor{
-		grpc_retry.StreamClientInterceptor(
-			grpc_retry.WithMax(3),
-			grpc_retry.WithCodes(codes.Aborted, codes.DeadlineExceeded),
-			grpc_retry.WithPerRetryTimeout(time.Millisecond*500),
-		),
-		grpc_prometheus.StreamClientInterceptor,
-	}
-
-	return []grpc.DialOption{
-		grpc.WithInsecure(),
-		grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient(unaryInterceptors...)),
-		grpc.WithStreamInterceptor(grpc_middleware.ChainStreamClient(streamInterceptors...)),
-	}
-}

+ 0 - 61
pkg/grpcutil/error.go

@@ -1,61 +0,0 @@
-package grpcutil
-
-import (
-	"errors"
-	"reflect"
-
-	"kpt-tmr-group/pkg/xerr"
-
-	spb "google.golang.org/genproto/googleapis/rpc/status"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/status"
-)
-
-// StatusError cause of grpc status error
-func StatusError(err error) (*status.Status, bool) {
-	statusErr, ok := status.FromError(xerr.Cause(err))
-	if !ok {
-		return nil, false
-	}
-
-	return statusErr, true
-}
-
-// FilterServerError 优化服务端错误上报逻辑
-func FilterServerError(err error) bool {
-	statusErr, ok := StatusError(err)
-	if !ok {
-		return true
-	}
-
-	details := statusErr.Details()
-	for _, detail := range details {
-		if _, ok := detail.(*spb.Status); ok && statusErr.Code() != codes.Canceled {
-			return false
-		}
-	}
-
-	ignoreStatus := []codes.Code{codes.InvalidArgument, codes.Unauthenticated, codes.NotFound, codes.FailedPrecondition, codes.AlreadyExists}
-	if inArray, _ := In(statusErr.Code(), ignoreStatus); inArray {
-		return false
-	}
-	return true
-}
-
-func In(obj interface{}, target interface{}) (bool, error) {
-	targetValue := reflect.ValueOf(target)
-	switch reflect.TypeOf(target).Kind() {
-	case reflect.Slice, reflect.Array:
-		for i := 0; i < targetValue.Len(); i++ {
-			if targetValue.Index(i).Interface() == obj {
-				return true, nil
-			}
-		}
-	case reflect.Map:
-		if targetValue.MapIndex(reflect.ValueOf(obj)).IsValid() {
-			return true, nil
-		}
-	}
-
-	return false, errors.New("not in array")
-}

+ 0 - 22
pkg/grpcutil/grpc_error.go

@@ -1,22 +0,0 @@
-package grpcutil
-
-import (
-	"fmt"
-
-	"kpt-tmr-group/pkg/xerr"
-
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/status"
-)
-
-func ClassifyError(err error, request interface{}) error {
-	if err == nil {
-		return nil
-	}
-	_, isCus := xerr.IsCustomError(err)
-	if isCus {
-		return status.Error(codes.InvalidArgument, xerr.WrapWithLog(fmt.Errorf("err: %v, request: %+v", err, request)).Error())
-	} else {
-		return status.Error(codes.Internal, xerr.WrapWithLog(fmt.Errorf("err: %v, request: %+v", err, request)).Error())
-	}
-}

+ 0 - 30
pkg/jsonpb/decode.go

@@ -1,30 +0,0 @@
-package jsonpb
-
-import (
-	"io"
-
-	"kpt-tmr-group/pkg/xerr"
-
-	"github.com/golang/protobuf/jsonpb"
-	"github.com/golang/protobuf/proto"
-)
-
-var unmarshaler = &jsonpb.Unmarshaler{AllowUnknownFields: true}
-
-func Unmarshal(r io.Reader, pb proto.Message) (err error) {
-	defer func() {
-		if e := recover(); e != nil {
-			err = e.(error)
-		}
-	}()
-
-	if err := unmarshaler.Unmarshal(r, pb); err != nil {
-		return xerr.WithStack(err)
-	}
-	return nil
-}
-
-// Unmarshaler jsonpb unmarshaler
-type Unmarshaler interface {
-	Unmarshal(r io.Reader, pb proto.Message) error
-}

+ 0 - 33
pkg/jsonpb/decode_test.go

@@ -1,33 +0,0 @@
-package jsonpb
-
-import (
-	"testing"
-)
-
-var bs = `{
-  "status": {
-    "code": "SUCCESS"
-  },
-  "done": true,
-  "result": {
-    "ptTimestampUsec": "1558687721507006",
-    "level": 2,
-    "fluencyLevel": 0,
-    "pronunciationLevel": 0
-  },
-  "suggestedActivityId": [],
-  "preloadContent": {
-    "activityContent": []
-  },
-  "cbParam": {
-    "previousPart": 4,
-    "warmed": false,
-    "ptSubPart": 0
-  },
-  "IsWarmup": false
-}
-`
-
-func TestUnmarshal(t *testing.T) {
-
-}

+ 0 - 52
pkg/jsonpb/encode.go

@@ -1,52 +0,0 @@
-package jsonpb
-
-import (
-	"bytes"
-	"sync"
-
-	"github.com/golang/protobuf/jsonpb"
-	"github.com/golang/protobuf/proto"
-)
-
-var marshaller = &jsonpb.Marshaler{EmitDefaults: true, OrigName: true, EnumsAsInts: true}
-
-func Marshal(pb proto.Message) (string, error) {
-	e := newEncodeState()
-	if err := marshaller.Marshal(e, pb); err != nil {
-		return "", err
-	}
-
-	s := e.String()
-	e.Reset()
-	encodeStatePool.Put(e)
-
-	return s, nil
-}
-
-func MarshalBytes(pb proto.Message) ([]byte, error) {
-	e := newEncodeState()
-	if err := marshaller.Marshal(e, pb); err != nil {
-		return nil, err
-	}
-
-	buf := append([]byte(nil), e.Bytes()...)
-	e.Reset()
-	encodeStatePool.Put(e)
-	return buf, nil
-}
-
-// An encodeState encodes proto into a bytes.Buffer.
-type encodeState struct {
-	*bytes.Buffer
-}
-
-var encodeStatePool sync.Pool
-
-func newEncodeState() *encodeState {
-	if v := encodeStatePool.Get(); v != nil {
-		e := v.(*encodeState)
-		e.Reset()
-		return e
-	}
-	return &encodeState{Buffer: bytes.NewBuffer(make([]byte, 0, 2048))}
-}

+ 0 - 37
pkg/jsonpb/encode_test.go

@@ -1,37 +0,0 @@
-package jsonpb
-
-import (
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-)
-
-var message proto.Message
-
-func BenchmarkMarshalWithPool(b *testing.B) {
-	b.ResetTimer()
-
-	for i := 0; i < b.N; i++ {
-		Marshal(message)
-	}
-}
-
-func BenchmarkMarshalBytesWithPool(b *testing.B) {
-	b.ResetTimer()
-
-	for i := 0; i < b.N; i++ {
-		Marshal(message)
-	}
-}
-
-func BenchmarkMarshalToPBString(b *testing.B) {
-	b.ResetTimer()
-
-	for i := 0; i < b.N; i++ {
-		marshalToPBString(message)
-	}
-}
-
-func marshalToPBString(pb proto.Message) (string, error) {
-	return marshaller.MarshalToString(pb)
-}

+ 0 - 108
pkg/jsonpb/query_decode.go

@@ -1,108 +0,0 @@
-package jsonpb
-
-import (
-	"net/url"
-	"reflect"
-	"strings"
-
-	"kpt-tmr-group/pkg/xerr"
-	"kpt-tmr-group/pkg/xreflect"
-
-	"github.com/golang/protobuf/proto"
-)
-
-var emptyField = reflect.StructField{}
-
-func UnmarshalQuery(values url.Values, pb proto.Message) error {
-	target := reflect.ValueOf(pb).Elem()
-	targetType := target.Type()
-	if targetType.Kind() != reflect.Struct {
-		return xerr.New("target should be struct")
-	}
-	sprops := proto.GetProperties(targetType)
-	for i := 0; i < target.NumField(); i++ {
-		ft := target.Type().Field(i)
-		if strings.HasPrefix(ft.Name, "XXX_") {
-			continue
-		}
-		getField := func(prop *proto.Properties) ([]string, bool) {
-			// Be liberal in what names we accept; both orig_name and camelName are okay.
-			camel, orig := prop.JSONName, prop.OrigName
-
-			keys := []string{camel, orig}
-			// handle condition xxx[]=1&xxx[]=2
-			if prop.Repeated {
-				keys = append(keys, camel+"[]", orig+"[]")
-			}
-			for _, key := range keys {
-				v, ok := values[key]
-				if ok {
-					return v, true
-				}
-			}
-			return nil, false
-		}
-
-		valueForField, ok := getField(sprops.Prop[i])
-		if !ok {
-			continue
-		}
-		err := setProtoByQueryValue(target.Field(i), valueForField, sprops.Prop[i])
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func setProtoByQueryValue(target reflect.Value, queryValue []string, prop *proto.Properties) (err error) {
-	if len(queryValue) == 0 {
-		if prop.HasDefault {
-			queryValue = []string{prop.Default}
-		} else {
-			return nil
-		}
-	}
-	if target.Kind() == reflect.Slice {
-		slice := reflect.MakeSlice(target.Type(), len(queryValue), len(queryValue))
-		for i, s := range queryValue {
-			err := setProtoByQueryValue(slice.Index(i), []string{s}, prop)
-			if err != nil {
-				return err
-			}
-		}
-		target.Set(slice)
-		return nil
-	}
-
-	// Handle enums, which have an underlying type of int32,
-	// and may appear as strings.
-	// The case of an enum appearing as a number is handled
-	// at the bottom of this function.
-	if prop != nil && prop.Enum != "" {
-		vmap := proto.EnumValueMap(prop.Enum)
-		if len(queryValue) == 1 {
-			// Don't need to do unquoting; valid enum names
-			// are from a limited character set.
-			s := queryValue[0]
-			n, ok := vmap[s]
-			if !ok {
-				return xerr.Errorf("unknown value %q for enum %s", s, prop.Enum)
-			}
-			return setProtoEnum(n, target, prop)
-		}
-	}
-	return xreflect.SetString(target, queryValue[0])
-}
-
-func setProtoEnum(val int32, target reflect.Value, prop *proto.Properties) error {
-	if target.Kind() == reflect.Ptr { // proto2
-		target.Set(reflect.New(target.Type().Elem()))
-		target = target.Elem()
-	}
-	if target.Kind() != reflect.Int32 {
-		return xerr.Errorf("invalid target %q for enum %s", target.Kind(), prop.Enum)
-	}
-	target.SetInt(int64(val))
-	return nil
-}

+ 0 - 9
pkg/jsonpb/query_decode_test.go

@@ -1,9 +0,0 @@
-package jsonpb
-
-import (
-	"testing"
-)
-
-func TestUnmarshalQuery(t *testing.T) {
-
-}

+ 0 - 64
pkg/jwt/jwt.go

@@ -1,64 +0,0 @@
-package jwt
-
-import (
-	"crypto/rsa"
-	"fmt"
-	"time"
-
-	"github.com/dgrijalva/jwt-go"
-)
-
-type JWTTokenGenerate struct {
-	privateKey *rsa.PrivateKey
-	issuer     string
-	nowFunc    func() time.Time
-}
-
-func NewJWTTokenGen(issuer string, privateKey *rsa.PrivateKey) *JWTTokenGenerate {
-	return &JWTTokenGenerate{
-		privateKey: privateKey,
-		issuer:     issuer,
-		nowFunc:    time.Now,
-	}
-}
-
-func (j *JWTTokenGenerate) GenerateToken(username string, expireTime int) (string, error) {
-	nowTime := j.nowFunc().Unix()
-	token := jwt.NewWithClaims(jwt.SigningMethodRS512, jwt.StandardClaims{
-		Issuer:    j.issuer,
-		IssuedAt:  nowTime,
-		ExpiresAt: nowTime + int64(expireTime),
-		Subject:   username,
-	})
-	return token.SignedString(j.privateKey)
-}
-
-// JWTTokenVerifier 校验token
-type JWTTokenVerifier struct {
-	PublicKey *rsa.PublicKey
-}
-
-func (v *JWTTokenVerifier) ParseToken(token string) (string, error) {
-	// 自定义字段许使用  jwt.MapClaims{},这里没有定义其他字段,就用jwt.StandardClaims
-	jwtToken, err := jwt.ParseWithClaims(token, &jwt.StandardClaims{}, func(token *jwt.Token) (interface{}, error) {
-		return v.PublicKey, nil
-	})
-
-	if err != nil {
-		return "", err
-	}
-	if !jwtToken.Valid {
-		return "", fmt.Errorf("token not valid")
-	}
-	// 判断类型
-	clm, ok := jwtToken.Claims.(*jwt.StandardClaims)
-	if !ok {
-		return "", fmt.Errorf("token claim is not StandardClaims")
-	}
-
-	if err = clm.Valid(); err != nil {
-		return "", fmt.Errorf("claim not valid: %v", err)
-	}
-
-	return clm.Subject, nil
-}

+ 0 - 87
pkg/jwt/jwt_test.go

@@ -1,87 +0,0 @@
-package jwt
-
-import (
-	"testing"
-	"time"
-
-	"github.com/dgrijalva/jwt-go"
-)
-
-const privateKey = `-----BEGIN RSA PRIVATE KEY-----
-MIIEpQIBAAKCAQEA1aC2ROAGNjpmpevOlg/NTVtgd8fdve3cM1J69uS6UHoZJWR2
-pmIzOr5EQkQjr0ldnS4zP9feHPTeGebcvekqAzrGwEgKTMe5Scu64f+y77l1p5RV
-FI2WLZhCw1zaYI3GiJMzYx5YeMRT2aKizIe2ORIooXdypx+xY8E4vTERsAr+w1Zb
-U2P+HSc65u7FYxjNx5y4m4lsE4oRHcaNK9DxtdccRQmugVRHINdZFtcNmtArZK2p
-sexpdmkRDL3tJtQD3O1GcLR7JEMQR1UGrjvvd/ZQmQIVgz+D9R3Nd/B8mSHFwV3z
-Mt3I1y7Pd1ZMYve06iTzqxBBDs4ot60BQj85awIDAQABAoIBAQDCZis3Zf2BH4gF
-eR5XZC3ZNUwF9DUO/wMhGO+Y+O+rCFEVu+RU6Ivh6v7GpqcqfcLYpBAzCseu5g2u
-2G0LzMBUjAoNNAFbeWxdgS2hN0Sn7cbpJox91ZJSD3rBuR9oOdvusLVUf2rXCyGa
-rOsk4GKscJ/Uv5PwDWEpe82cLKkB3nW9iXDUNv6+QQyLf9Rfikxzzcm9PW3qOCBE
-FFUGgFiC4vXL7mjodwQ4uxS8Krpn1poyBDkHGOv5yMbsOouaR6ShsJHPXSeeTfu5
-y8THhRJDzN2L39ecKdLwv1fKcQgLDqT69TwOJ//78k777yy3tDhU+0S/nDQQdEXF
-Hx5s7DPxAoGBAPFqJyLpRj93HiyS5LCQv93thQ7tc+fnMCBembVh5ErTTfQPREKT
-B6+42UWWch8xjcL1JQKcyBbgGeA5kLzMKmi+JEtHXpoqznkkJLBLXmuNvmwbXB3x
-uuAj904fOdntDoMsoExIt+GA0sGyx825TxMNoSiC7lMnQUtS/2JTPlE9AoGBAOKI
-yuJmzZb/QMC7x83/PqhqJCxd9myxxc1KEBYqLM3hwb0dhG22ep84QxyLf0ScrhUf
-d5KGLIZ/lwCW3kZsSE6GzlK9GTzhbWeNEBSk8hhDITI+P+9ca+j1jNRzrQA3Ilx1
-U7CiuDPHkgh4QFU8Vxlg35zad6UH9Sojazd/8Y/HAoGBAJ67UF5JCXJjTQi70Pgz
-RKSULr/A60vYm7E84k37vpJgW0oU26n2aMBmhx2VLRZLi81bSGluUrWPxhPDZeJt
-T5ktJEoG9DHj4XyPgjwUYlHPkhwc5TWfImOL4miQaYZbswYWypM94QG5pVnMxkkD
-BfYeKQ+s/yzXi7wOJ3MsDrZ1AoGBAN/b4/nlM0cDCP8s0Z7cnBObiBGb7ReueVSL
-2ue8V7hAXs6+q44rpHNRCujbZTHtTw4qoWPXWYqz7Qm1DQQ0nyOSjbMvkRAbiJyq
-xnhQI7kcJWLcJxwnja+Rb9DGWvB6i2covkIwGq14ivP5uUFBtqSqmW8MaO1Ztskk
-ZSBcO98jAoGAbHMD0WmQqnKpVHbchOfldluzzWkWZMBQlX23Fr7iHfzXiikjgCqK
-6HtRq1m6AGIZsbM+Dd53knurbTo49GfGjneN0ZtCFbiBOwFx0OX69UZcxmd+3Cqz
-14QDSlFpfXTbugpZFYC9KTakY7nDgsj1Ei2WjTE0gVSlUtuiw1XykCM=
------END RSA PRIVATE KEY-----`
-
-const publicKey = `-----BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAokQEiPqzrL22jrKqWN3a
-9XXYtXLhJOolmYoPRfBpWFr5ml/vcEsMMPmVc9EUhDSXyo2tTgiCBhqyLZ+C/9ob
-JJv92W4sPaPjeVHhvpFdC+a0RDQyb9X8s5xuUBVCyh7UlAs2dOHQ3kqAhhybATHl
-OvOksc8GFp9hxQZtqeVhmjMKjdJYMcIi8HLL3v/CvZO43ClohSRVB7mxNYm4ddTg
-c1jFmtBAUuu3ha7qm8CXQFAEYwf89PkjfhKXaALAVS09lpy8Qx3rCGjeuFbKHtVe
-dy/CZmjq3xHrJVNcKwaRFCXUroyuWjFlITyQCHjugh+6MiDnz3oP/4Y3rXaMag+E
-9QIDAQAB
------END PUBLIC KEY-----`
-
-var (
-	userName = "1234567890"
-)
-
-func TestJWTTokenGenerate_GenerateToken(t *testing.T) {
-	key, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(privateKey))
-	if err != nil {
-		t.Fatalf("cannot parse private key: %v", err)
-	}
-	g := NewJWTTokenGen("kpt-tmr-group", key)
-	g.nowFunc = func() time.Time {
-		return time.Now()
-	}
-	token, err := g.GenerateToken(userName, 7200)
-	if err != nil {
-		t.Fatalf("cannot generate token: %v", err)
-	}
-	want := `eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTYyNDYyMjIsImlhdCI6MTUxNjIzOTAyMiwiaXNzIjoia3B0LXRtci1ncm91cCIsInN1YiI6IjEyMzQ1Njc4OTAtMTIzIn0.fNKcmzjsghdCVn0ZhPHt3mg_I22IZvTQyMaN8xt9GHoZdUpml1sqZ24-mamCaIK1T-pP0USqc69ZkeUBjOz1hi-p0u3Z8u8J8uaaTh0RD7cYxhT6ey5-KzctiuiSutFH8G5Y3pZ3ffRO-b_8hKpTICFET9-3_4pWgtQ4_M76JnLZEm_0-3e4MA3GRba0S6ntZ19TiOeNkF30LQjQ3jCSp3xQb-NoDRdlQKWoYDAQI33RxAjtR5ZsLwee278qbzWjwtd_GyqJJuaokfFsc0JZXFSIOffK1S6qHijSsK85U6PciX05M6NkE9LMyAi990Q6iLk4NUrVE5gmEXA9MeEm0w`
-	if want != token {
-		t.Fatalf("wrong token generated. got: %q", token)
-	}
-}
-
-func TestJWTTokenVerifier_ParseToken(t *testing.T) {
-	/*publicKeyFromPEM, err := jwt.ParseRSAPublicKeyFromPEM([]byte(publicKey))
-	if err != nil {
-		t.Fatalf("cannot parse public key: %v", err)
-	}
-	v := &JWTTokenVerifier{PublicKey: publicKeyFromPEM}
-
-	token := `eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODk4Mjc3OTMsImlhdCI6MTY4OTgyMDU5MywiaXNzIjoia3B0LXRtci1ncm91cCIsInN1YiI6ImR1YW54aWFvZHVhbi1lMTBhZGMzOTQ5YmE1OWFiYmU1NmUwNTdmMjBmODgzZSJ9.cdtoNMAU5WEO-OTqHS9EQXvRBhanbB_B591LBxDeFkOe1QM7m1lZpLpV-BniK785ZMNmfjqTfSpXT2N2E53mjZn1MTmRhi2tsBhrlvm6VpvQES8_TSL8bOUhDOYjhnFYB_qpua_ykrmm1DAf8wDWBapx8gYRN8WmbeAxY6Q8bnU9CsBM_jeEzr-CDP73DuFZDX0cpf_AFYBYL7DNU_ju6ufP4HwGSfuGJXcTXqfQh5eUoAZuG_YgSC2DPoKPtKl1QD_oy1k-g6StkKWjGe8pfmx4FyqfTTV3bo-Uthr5RQ0CjLKseOnwuHt6J5GOcpttgA3GnSUxETUq5qMOenWnDA`
-	userNameVerifier, err := v.ParseToken(token)
-	if err != nil {
-		t.Fatalf("Verifier token : %v", err)
-	}
-	want := "duanxiaoduan"
-	if want != userNameVerifier {
-		t.Fatalf("token err")
-	}*/
-}

+ 0 - 204
pkg/logger/logrus/log.go

@@ -1,204 +0,0 @@
-package logrus
-
-import (
-	"fmt"
-	"kpt-tmr-group/pkg/tool"
-	"path"
-	"runtime"
-	"time"
-
-	rotatelogs "github.com/lestrrat-go/file-rotatelogs"
-	"github.com/sirupsen/logrus"
-)
-
-var (
-	logPath     = "./logger"
-	logFileName = fmt.Sprintf("/logrus-%s.log", time.Now().Format(tool.DateTime))
-)
-
-func init() {
-	// Log as JSON instead of the default ASCII formatter.
-	logrus.SetFormatter(&logrus.JSONFormatter{
-		CallerPrettyfier: func(f *runtime.Frame) (string, string) {
-			filename := path.Base(f.File)
-			return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line)
-		},
-	})
-
-	// Output to stdout instead of the default stderr
-	// Can be any io.Writer, see below for File example
-	writer, _ := rotatelogs.New(
-		fmt.Sprintf("%s%s", logPath, logFileName),
-		// rotatelogs.WithLinkName(logPath),
-		rotatelogs.WithMaxAge(time.Duration(7*24)*time.Hour),     // 备份7天的日志
-		rotatelogs.WithRotationTime(time.Duration(24)*time.Hour), // 24小时切割一次日志
-	)
-	logrus.SetOutput(writer) // logrus 设置日志的输出方式
-	// Only log the warning severity or above.
-	logrus.SetLevel(DebugLevel)
-}
-
-// These are the different logging levels. You can set the logging level to log
-// on your instance of logger, obtained with `logrus.New()`.
-const (
-	// PanicLevel level, highest level of severity. Logs and then calls panic with the
-	// message passed to Debug, Info, ...
-	PanicLevel Level = iota
-	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
-	// logging level is set to Panic.
-	FatalLevel
-	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
-	// Commonly used for hooks to send errors to an error tracking service.
-	ErrorLevel
-	// WarnLevel level. Non-critical entries that deserve eyes.
-	WarnLevel
-	// InfoLevel level. General operational entries about what's going on inside the
-	// application.
-	InfoLevel
-	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
-	DebugLevel
-	// TraceLevel level. Designates finer-grained informational events than the Debug.
-	TraceLevel
-)
-
-// Entry is the final or intermediate Logrus logging entry. It contains all
-// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
-// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
-// passed around as much as you wish to avoid field duplication.
-type Entry = logrus.Entry
-
-// Fields type, used to pass to `WithFields`.
-type Fields = logrus.Fields
-
-// FieldMap allows customization of the key names for default fields.
-type FieldMap = logrus.FieldMap
-
-// Level type
-type Level = logrus.Level
-
-// Logger type
-type Logger = logrus.Logger
-
-// JSONFormatter formats logs into parsable json
-type JSONFormatter struct {
-	logrus.JSONFormatter
-}
-
-// TextFormatter formats logs into text
-type TextFormatter struct {
-	logrus.TextFormatter
-}
-
-// Formatter
-// The Formatter interface is used to implement a custom Formatter. It takes an
-// `Entry`. It exposes all the fields, including the default ones:
-//
-// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
-// * `entry.Data["time"]`. The timestamp.
-// * `entry.Data["level"]. The level the entry was logged at.
-//
-// Any additional fields added with `WithField` or `WithFields` are also in
-// `entry.Data`. Format is expected to return an array of bytes which are then
-// logged to `logger.Out`.
-
-// SetLevel ...
-func SetLevel(level Level) {
-	logrus.SetLevel(level)
-}
-
-// NewWithFields returns a logrus Entry with fields
-func NewWithFields(fields Fields) *Entry {
-	return logrus.WithFields(fields)
-}
-
-// NewEntry return an entry is the final or intermediate Logrus logging entry
-func NewEntry(logger *Logger) *Entry {
-	return logrus.NewEntry(logger)
-}
-
-// Exported from logrus
-var (
-	// Creates a new logger. Configuration should be set by changing `Formatter`,
-	// `Out` and `Hooks` directly on the default logger instance. You can also just
-	// instantiate your own:
-	//
-	//    var log = &Logger{
-	//      Out: os.Stderr,
-	//      Formatter: new(JSONFormatter),
-	//      Level: logrus.DebugLevel,
-	//    }
-	//
-	// It's recommended to make this a global instance called `log`.
-	New = logrus.New
-	// StandardLogger default logger
-	StandardLogger = logrus.StandardLogger
-	// SetOutput sets the standard logger output.
-	SetOutput = logrus.SetOutput
-	// SetFormatter sets the standard logger formatter.
-	SetFormatter = logrus.SetFormatter
-	// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
-	WithError = logrus.WithError
-	// WithField creates an entry from the standard logger and adds a field to
-	// it. If you want multiple fields, use `WithFields`.
-	//
-	// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
-	// or Panic on the Entry it returns.
-	WithField = logrus.WithField
-	// WithFields creates an entry from the standard logger and adds multiple
-	// fields to it. This is simply a helper for `WithField`, invoking it
-	// once for each field.
-	//
-	// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
-	// or Panic on the Entry it returns.
-	WithFields = logrus.WithFields
-
-	// Debug logs a message at level Debug on the standard logger.
-	Debug = logrus.Debug
-	// Print logs a message at level Info on the standard logger.
-	Print = logrus.Print
-	// Info logs a message at level Info on the standard logger.
-	Info = logrus.Info
-	// Warn logs a message at level Warn on the standard logger.
-	Warn = logrus.Warn
-	// Warning logs a message at level Warn on the standard logger.
-	Warning = logrus.Warning
-	// Error logs a message at level Error on the standard logger.
-	Error = logrus.Error
-	// Panic logs a message at level Panic on the standard logger.
-	Panic = logrus.Panic
-	// Fatal logs a message at level Fatal on the standard logger.
-	Fatal = logrus.Fatal
-
-	// Debugf logs a message at level Debug on the standard logger.
-	Debugf = logrus.Debugf
-	// Printf logs a message at level Info on the standard logger.
-	Printf = logrus.Printf
-	// Infof logs a message at level Info on the standard logger.
-	Infof = logrus.Infof
-	// Warnf logs a message at level Warn on the standard logger.
-	Warnf = logrus.Warnf
-	// Warningf logs a message at level Warn on the standard logger.
-	Warningf = logrus.Warningf
-	// Errorf logs a message at level Error on the standard logger.
-	Errorf = logrus.Errorf
-	// Panicf logs a message at level Panic on the standard logger.
-	Panicf = logrus.Panicf
-	// Fatalf logs a message at level Fatal on the standard logger.
-	Fatalf = logrus.Fatalf
-	// Debugln logs a message at level Debug on the standard logger.
-	Debugln = logrus.Debugln
-	// Println logs a message at level Info on the standard logger.
-	Println = logrus.Println
-	// Infoln logs a message at level Info on the standard logger.
-	Infoln = logrus.Infoln
-	// Warnln logs a message at level Warn on the standard logger.
-	Warnln = logrus.Warnln
-	// Warningln logs a message at level Warn on the standard logger.
-	Warningln = logrus.Warningln
-	// Errorln logs a message at level Error on the standard logger.
-	Errorln = logrus.Errorln
-	// Panicln logs a message at level Panic on the standard logger.
-	Panicln = logrus.Panicln
-	// Fatalln logs a message at level Fatal on the standard logger.
-	Fatalln = logrus.Fatalln
-)

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio