Skip to content

Commit ee984f7

Browse files
author
smgano
committed
fmt
1 parent 056cca2 commit ee984f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+502
-427
lines changed

bfg-1.14.0.jar

-13.8 MB
Binary file not shown.

cmd/gen/main.go

+23-22
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package main
22

33
import (
44
"fmt"
5-
"gorm.io/driver/mysql"
6-
"gorm.io/gen"
7-
"gorm.io/gorm"
85
"log"
96
"strings"
107
"unicode"
8+
9+
"gorm.io/driver/mysql"
10+
"gorm.io/gen"
11+
"gorm.io/gorm"
1112
)
1213

1314
// DBType database type
@@ -23,22 +24,22 @@ const (
2324
)
2425

2526
const (
26-
//defaultQueryPath 模型文件存放目录
27+
// defaultQueryPath 模型文件存放目录
2728
defaultQueryPath = "./dao/query"
2829
)
2930

3031
const Dsn = "root:passw0rd@tcp(127.0.0.1:3306)/db_goods_center?charset=utf8mb4&parseTime=True&loc=Local"
3132

32-
//const Dsn = "root:abcd1234@tcp(192.168.28.75:3306)/db_token?charset=utf8mb4&parseTime=True&loc=Local"
33+
// const Dsn = "root:abcd1234@tcp(192.168.28.75:3306)/db_token?charset=utf8mb4&parseTime=True&loc=Local"
3334

3435
func main() {
35-
//mysql
36+
// mysql
3637
db, err := gorm.Open(mysql.Open(Dsn))
3738

3839
// clickhouse
39-
//db, err := gorm.Open(clickhouse.Open(Dsn))
40+
// db, err := gorm.Open(clickhouse.Open(Dsn))
4041
// postgres
41-
//db, err := gorm.Open(postgres.Open(Dsn))
42+
// db, err := gorm.Open(postgres.Open(Dsn))
4243

4344
if err != nil {
4445
log.Fatalln("connect db server fail:", err)
@@ -47,42 +48,42 @@ func main() {
4748
g := gen.NewGenerator(gen.Config{
4849
OutPath: defaultQueryPath,
4950
// 默认为:gen.go
50-
//OutFile: "genb.go",
51-
//ModelPkgPath 生成模型的包名
51+
// OutFile: "genb.go",
52+
// ModelPkgPath 生成模型的包名
5253
ModelPkgPath: "model",
53-
//生成单元测试。
54-
//WithUnitTest: true,
55-
//FieldNullable 字段可为空时使用指针生成
54+
// 生成单元测试。
55+
// WithUnitTest: true,
56+
// FieldNullable 字段可为空时使用指针生成
5657
FieldNullable: true,
57-
//字段有默认值时使用指针生成
58-
//FieldCoverable: true,
59-
//FieldWithIndexTag 使用GROM索引标记生成字段
58+
// 字段有默认值时使用指针生成
59+
// FieldCoverable: true,
60+
// FieldWithIndexTag 使用GROM索引标记生成字段
6061
FieldWithIndexTag: true,
61-
//FieldWithTypeTag 使用gorm列类型标记生成字段
62+
// FieldWithTypeTag 使用gorm列类型标记生成字段
6263
FieldWithTypeTag: true,
63-
//基于数据表定义的数据类型,生成对应的数据类型
64+
// 基于数据表定义的数据类型,生成对应的数据类型
6465
FieldSignable: true,
6566
})
6667

6768
g.UseDB(db)
6869

6970
g.WithJSONTagNameStrategy(
70-
ToLowerCamelCase, //表字段 json tag 驼峰, 默认是下划线分割
71+
ToLowerCamelCase, // 表字段 json tag 驼峰, 默认是下划线分割
7172
)
7273
// 部分表
7374
tables := []string{
7475
"apple_config",
7576
"apple_product_price",
7677
"user_score",
77-
//"gp_product_price",
78+
// "gp_product_price",
7879
}
79-
//tables := []string{} //全部表
80+
// tables := []string{} //全部表
8081
models, err := genModels(g, db, tables)
8182
if err != nil {
8283
log.Fatalln("get tables info fail:", err)
8384
}
8485

85-
//false 指生成model,不生成query文件; true 全都生成
86+
// false 指生成model,不生成query文件; true 全都生成
8687
onlyModel := true
8788
if onlyModel {
8889
g.ApplyBasic(models...)

config/config.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package config
33
import (
44
"context"
55
"fmt"
6+
"os"
7+
"path/filepath"
8+
69
"github.com/fsnotify/fsnotify"
710
"github.com/google/uuid"
811
"github.com/spf13/viper"
@@ -11,8 +14,6 @@ import (
1114
"github.com/yituoshiniao/kit/xrds"
1215
"github.com/yituoshiniao/kit/xtask"
1316
"github.com/yituoshiniao/kit/xtrace"
14-
"os"
15-
"path/filepath"
1617
)
1718

1819
type LoggerConfig struct {
@@ -40,13 +41,13 @@ type MonitorConfig struct {
4041
}
4142

4243
type XTraceConfig struct {
43-
//#上报配置类型
44+
// #上报配置类型
4445
SamplerType string
45-
//#常量配置
46+
// #常量配置
4647
SamplerParam float64
47-
//#数据服务器地址
48+
// #数据服务器地址
4849
ReporterLocalAgentHostPort string
49-
//服务名
50+
// 服务名
5051
ServerName string
5152
}
5253

@@ -86,7 +87,7 @@ type Config struct {
8687
type Database struct {
8788
GoodsCenter v1.Config `yaml:"goodsCenter"`
8889
Camexam v1.Config `yaml:"camexam"`
89-
//解决viper读取yaml配置存在下划线时无法映射 添加tag: mapstructure
90+
// 解决viper读取yaml配置存在下划线时无法映射 添加tag: mapstructure
9091
DbToken v1.Config `yaml:"db_token" mapstructure:"db_token"`
9192
}
9293

@@ -111,11 +112,11 @@ var (
111112
func ParseConfig(envPath string) Config {
112113
pwd, _ := os.Getwd()
113114
dirName := filepath.Base(pwd)
114-
//read config
115+
// read config
115116
viper.SetConfigFile("./env.yaml") // 指定配置文件路径
116117
viper.SetConfigName("env") // 配置文件名称(无扩展名)
117118

118-
//多环境变量
119+
// 多环境变量
119120
if envPath != "" {
120121
viper.SetConfigFile("./env_" + envPath + ".yaml") // 指定配置文件路径
121122
viper.SetConfigName("env_" + envPath) // 配置文件名称(无扩展名)
@@ -127,7 +128,7 @@ func ParseConfig(envPath string) Config {
127128
err := viper.ReadInConfig() // 读取配置数据
128129
if err != nil {
129130
panic(fmt.Sprintf("Fatal error config file: %s", err))
130-
//log.Fatalf("Fatal error config file: %s", err)
131+
// log.Fatalf("Fatal error config file: %s", err)
131132
}
132133

133134
dynamicReloadConfig(context.Background()) // 动态加载配置
@@ -137,7 +138,7 @@ func ParseConfig(envPath string) Config {
137138
if err != nil {
138139
// 处理读取配置文件的错误
139140
panic(fmt.Sprintf("Unmarshal error config file: %s", err))
140-
//log.Fatal(ctx, err)
141+
// log.Fatal(ctx, err)
141142
}
142143
GlobalConfig = cfg
143144
return cfg
@@ -158,7 +159,7 @@ func dynamicReloadConfig(ctx context.Context) {
158159
var tmpCfg Config
159160
if err := viper.Unmarshal(&tmpCfg); err != nil {
160161
xlog.S(ctx).Errorw("加载配置错误", "err", err, "uuid", uuid)
161-
//panic(fmt.Errorf("配置重载失败:%s\n", err))
162+
// panic(fmt.Errorf("配置重载失败:%s\n", err))
162163
return
163164
}
164165
GlobalConfig = tmpCfg

inject/provider.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package inject
22

33
import (
44
"context"
5+
56
"github.com/opentracing/opentracing-go"
67
config2 "github.com/uber/jaeger-client-go/config"
7-
"github.com/yituoshiniao/gin-api-http/config"
88
"github.com/yituoshiniao/kit/xlog"
99
"github.com/yituoshiniao/kit/xtrace"
1010
"go.uber.org/zap"
11+
12+
"github.com/yituoshiniao/gin-api-http/config"
1113
)
1214

1315
// ProvideLogger Log提供者

inject/wire.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package inject
55

66
import (
77
"github.com/google/wire"
8+
89
"github.com/yituoshiniao/gin-api-http/config"
910
"github.com/yituoshiniao/gin-api-http/internal/api"
1011
"github.com/yituoshiniao/gin-api-http/internal/api/cron"
@@ -22,7 +23,7 @@ func InitApp() (healthy *app2.App, cleanup func(), err error) {
2223
wire.Build(
2324
config.ParseConfig,
2425
ProvideLogger,
25-
ProvideTracer, //保证生成的 tracer 在文件wire_gen.go中的最前面
26+
ProvideTracer, // 保证生成的 tracer 在文件wire_gen.go中的最前面
2627
conn.WireSet,
2728
app2.WireSet,
2829
router.WireSet,

internal/api/cron/enter.go

+2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package cron
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/pkg/errors"
8+
79
"github.com/yituoshiniao/gin-api-http/internal/metrics"
810
)
911

internal/api/cron/test_srv.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cron
22

33
import (
44
"context"
5+
56
"github.com/yituoshiniao/kit/xlog"
67
)
78

internal/api/dto/apple_dto.go

+45-44
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dto
22

33
import (
44
"github.com/allegro/bigcache"
5+
56
"github.com/yituoshiniao/gin-api-http/internal/api/http"
67
)
78

@@ -26,7 +27,7 @@ type StatusLocalCacheTaskResponse struct {
2627
}
2728

2829
type ProductTerritoryPriceRequest struct {
29-
ProductId string `form:"productId" binding:"required"` //产品id
30+
ProductId string `form:"productId" binding:"required"` // 产品id
3031
Territory string `form:"territory" binding:"required,min=2,max=3"` // 国家地区编码 三位,参数最小长度2,最大长度3
3132
Channel string `form:"channel" binding:"required"` // 渠道 如 camexam(蜜蜂试卷)
3233
Timestamp int64 `form:"timestamp" binding:"required"` // 传递时间戳
@@ -35,87 +36,87 @@ type ProductTerritoryPriceRequest struct {
3536
}
3637

3738
type ProductTerritoryPriceInternalRequest struct {
38-
ProductId string `form:"productId" binding:"required"` //产品id
39+
ProductId string `form:"productId" binding:"required"` // 产品id
3940
// Territory string `form:"territory" binding:"required,min=2,max=3"` // 国家地区编码 三位,参数最小长度2,最大长度3
4041
Channel string `form:"channel,default=cs"` // 渠道 如 camexam(蜜蜂试卷)
4142
Vector string `form:"vector"`
4243
}
4344

4445
type AppleTokenRequest struct {
45-
ProductId string `form:"productId" binding:"required"` //产品id
46+
ProductId string `form:"productId" binding:"required"` // 产品id
4647
Territory string `form:"territory" binding:"required"` // 国家地区编码 三位
4748
Channel string `form:"channel" binding:"required"` // 渠道 如 camexam(蜜蜂试卷)
4849
Timestamp int64 `form:"timestamp"` // 传递时间戳
4950
}
5051

5152
type AppleTokenResponse struct {
52-
Params map[string]string `json:"params"` //请求参数
53-
Token string `json:"token"` //生成token
53+
Params map[string]string `json:"params"` // 请求参数
54+
Token string `json:"token"` // 生成token
5455
}
5556

5657
type ProductTerritoryPriceResponse struct {
5758
Number int64 `json:"number,string"` // int64 javascript前段精度问题,转字符串返回
58-
ProductId string `json:"productId"` //产品id
59-
Name string `json:"name"` //产品名
60-
CustomerPrice float64 `json:"customerPrice"` //价格
61-
FirstPrice float64 `json:"firstPrice"` //首单优惠价格
62-
Territory string `json:"territory"` //地区编码
63-
Currency string `json:"currency"` //货币
59+
ProductId string `json:"productId"` // 产品id
60+
Name string `json:"name"` // 产品名
61+
CustomerPrice float64 `json:"customerPrice"` // 价格
62+
FirstPrice float64 `json:"firstPrice"` // 首单优惠价格
63+
Territory string `json:"territory"` // 地区编码
64+
Currency string `json:"currency"` // 货币
6465
ManualPricesId string `json:"manualPricesId"`
6566
SubscriptionsPricePointsId string `json:"subscriptionsPricePointsId"`
66-
Channel string `json:"channel"` //渠道
67+
Channel string `json:"channel"` // 渠道
6768
Type int8 `json:"type"` // 订阅类型
68-
SubscriptionPeriod string `json:"subscriptionPeriod"` //订阅周期
69+
SubscriptionPeriod string `json:"subscriptionPeriod"` // 订阅周期
6970
InAppPurchaseType string `json:"InAppPurchaseType"`
70-
FamilySharable int8 `json:"familySharable"` //是否家庭共享
71-
AvailableInAllTerritories int8 `json:"availableInAllTerritories"` //是否适用于所有地区
72-
Price string `json:"price"` //原价
73-
PriceMonthly string `json:"priceMonthly"` //原价折月价
74-
PriceYear string `json:"priceYear"` //原价折年价
75-
OfferPrice string `json:"offerPrice"` //优惠价
76-
OfferPriceMonthly string `json:"offerPriceMonthly"` //优惠折月价
77-
OfferPriceYear string `json:"offerPriceYear"` //优惠折年价
78-
TerritoryName string `json:"territoryName"` //国家名称
71+
FamilySharable int8 `json:"familySharable"` // 是否家庭共享
72+
AvailableInAllTerritories int8 `json:"availableInAllTerritories"` // 是否适用于所有地区
73+
Price string `json:"price"` // 原价
74+
PriceMonthly string `json:"priceMonthly"` // 原价折月价
75+
PriceYear string `json:"priceYear"` // 原价折年价
76+
OfferPrice string `json:"offerPrice"` // 优惠价
77+
OfferPriceMonthly string `json:"offerPriceMonthly"` // 优惠折月价
78+
OfferPriceYear string `json:"offerPriceYear"` // 优惠折年价
79+
TerritoryName string `json:"territoryName"` // 国家名称
7980
PriceNumMap map[string]string `json:"priceNumMap"`
8081
MonthPriceMap map[string]string `json:"monthPriceMap"`
8182
YearPriceMap map[string]string `json:"yearPriceMap"`
8283
OfferMonthPriceMap map[string]string `json:"offerMonthPriceMap"`
8384
OfferYearPriceMap map[string]string `json:"offerYearPriceMap"`
8485
}
8586
type ExtendSubscriptionRenewalDateRequest struct {
86-
ExtendByDays string `form:"extendByDays" binding:"required,min=1,max=90"` //延长订阅续天数 最大90天
87-
//ExtendReasonCode延迟原因;
88-
//0、未申报;没有提供信息。
89-
//1、延长续订日期是为了让客户满意。
90-
//2、续订日期延期是出于其他原因。
91-
//3、续订日期延期是由于服务问题或中断。
92-
ExtendReasonCode string `form:"extendReasonCode" binding:"required"` //延迟原因
93-
OriginalTransactionId string `form:"originalTransactionId" binding:"required"` //订单id
94-
Channel string `form:"channel" binding:"required"` //渠道 cs || 蜜蜂等
95-
Sign string `form:"sign" binding:"required"` //签名
87+
ExtendByDays string `form:"extendByDays" binding:"required,min=1,max=90"` // 延长订阅续天数 最大90天
88+
// ExtendReasonCode延迟原因;
89+
// 0、未申报;没有提供信息。
90+
// 1、延长续订日期是为了让客户满意。
91+
// 2、续订日期延期是出于其他原因。
92+
// 3、续订日期延期是由于服务问题或中断。
93+
ExtendReasonCode string `form:"extendReasonCode" binding:"required"` // 延迟原因
94+
OriginalTransactionId string `form:"originalTransactionId" binding:"required"` // 订单id
95+
Channel string `form:"channel" binding:"required"` // 渠道 cs || 蜜蜂等
96+
Sign string `form:"sign" binding:"required"` // 签名
9697
}
9798

9899
type OfferSignRequest struct {
99100
// 购买项id example:com.premiums.oneyear.autorenewable.free.limited2
100-
ProductID string `form:"productId" binding:"required"` //产品id
101-
//offerID example:firstyear178
101+
ProductID string `form:"productId" binding:"required"` // 产品id
102+
// offerID example:firstyear178
102103
OfferID string `form:"offerId" binding:"required"`
103-
//Channel 渠道 example: cs
104+
// Channel 渠道 example: cs
104105
Channel string `form:"channel" binding:"required"`
105-
//ApplicationUsername
106+
// ApplicationUsername
106107
ApplicationUsername string `form:"applicationUsername" binding:"required"`
107108
}
108109

109110
type OfferSignResponse struct {
110111
http.ResponseData
111112
}
112113
type ProductTerritoryPriceInternalResponse struct {
113-
ProductId string `json:"productId"` //产品id
114-
Price string `json:"price"` //原价
115-
PriceMonthly string `json:"priceMonthly"` //原价折月价
116-
OfferPrice string `json:"offerPrice"` //优惠价
117-
OfferPriceMonthly string `json:"offerPriceMonthly"` //优惠折月价
118-
TerritoryName string `json:"territoryName"` //国家名称
119-
PriceYear string `json:"priceYear"` //原价折年价
120-
OfferPriceYear string `json:"offerPriceYear"` //优惠折年价
114+
ProductId string `json:"productId"` // 产品id
115+
Price string `json:"price"` // 原价
116+
PriceMonthly string `json:"priceMonthly"` // 原价折月价
117+
OfferPrice string `json:"offerPrice"` // 优惠价
118+
OfferPriceMonthly string `json:"offerPriceMonthly"` // 优惠折月价
119+
TerritoryName string `json:"territoryName"` // 国家名称
120+
PriceYear string `json:"priceYear"` // 原价折年价
121+
OfferPriceYear string `json:"offerPriceYear"` // 优惠折年价
121122
}

0 commit comments

Comments
 (0)