Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
ff05e127bd
4
go.mod
4
go.mod
|
@ -8,10 +8,14 @@ require (
|
|||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/zeromicro/go-zero v1.5.2
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
|
||||
gorm.io/driver/mysql v1.5.1
|
||||
gorm.io/gorm v1.25.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/474420502/requests v1.30.0
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/tidwall/gjson v1.12.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
|
|
8
go.sum
8
go.sum
|
@ -165,6 +165,10 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
||||
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=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
|
@ -530,6 +534,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw=
|
||||
gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o=
|
||||
gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64=
|
||||
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
|
|
@ -2,20 +2,21 @@ package svc
|
|||
|
||||
import (
|
||||
{{.configImport}}
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"fusenapi/initalize"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config {{.config}}
|
||||
{{.middleware}}
|
||||
MysqlConn sqlx.SqlConn
|
||||
MysqlConn *gorm.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c {{.config}}) *ServiceContext {
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: sqlx.NewMysql(c.SourceMysql),
|
||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||
{{.middlewareAssignment}}
|
||||
}
|
||||
}
|
||||
|
|
44
initalize/mysql.go
Normal file
44
initalize/mysql.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package initalize
|
||||
|
||||
import (
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
|
||||
// 初始化mysql
|
||||
func InitMysql(sourceMysql string) *gorm.DB {
|
||||
dsn := sourceMysql + "?" + "charset=utf8mb4&parseTime=true"
|
||||
db, err := gorm.Open(mysql.New(mysql.Config{
|
||||
DSN: dsn, // DSN data source name
|
||||
DefaultStringSize: 255, // string 类型字段的默认长度
|
||||
DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
|
||||
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
|
||||
DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
|
||||
SkipInitializeWithVersion: true, // 根据当前 MySQL 版本自动配置
|
||||
}), &gorm.Config{
|
||||
NamingStrategy: schema.NamingStrategy{
|
||||
TablePrefix: "", // 表名前缀
|
||||
SingularTable: true, // 使用单数表名
|
||||
},
|
||||
SkipDefaultTransaction: true,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// SetMaxIdleConns 设置空闲连接池中连接的最大数量
|
||||
sqlDB.SetMaxIdleConns(10)
|
||||
|
||||
// SetMaxOpenConns 设置打开数据库连接的最大数量。
|
||||
sqlDB.SetMaxOpenConns(50)
|
||||
|
||||
// SetConnMaxLifetime 设置了连接可复用的最大时间。
|
||||
sqlDB.SetConnMaxLifetime(time.Minute * 20)
|
||||
return db
|
||||
}
|
18
model/gorm/fsaddressmodel.go
Executable file
18
model/gorm/fsaddressmodel.go
Executable file
|
@ -0,0 +1,18 @@
|
|||
package gorm
|
||||
|
||||
type FsAddress struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID
|
||||
Name *string `gorm:"default:''" json:"name"` // 地址名称
|
||||
FirstName *string `gorm:"default:''" json:"first_name"` // FirstName
|
||||
LastName *string `gorm:"default:''" json:"last_name"` // LastName
|
||||
Mobile *string `gorm:"default:''" json:"mobile"` // 手机号码
|
||||
Street *string `gorm:"default:''" json:"street"` // 街道
|
||||
Suite *string `gorm:"default:''" json:"suite"` // 房号
|
||||
City *string `gorm:"default:''" json:"city"` // 城市
|
||||
State *string `gorm:"default:''" json:"state"` // 州名
|
||||
Country *string `gorm:"default:''" json:"country"` // 国家
|
||||
ZipCode *string `gorm:"default:''" json:"zip_code"` // 邮编
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 1正常 0异常
|
||||
IsDefault *int64 `gorm:"default:0" json:"is_default"` // 1默认地址,0非默认地址
|
||||
}
|
12
model/gorm/fscanteenproductmodel.go
Executable file
12
model/gorm/fscanteenproductmodel.go
Executable file
|
@ -0,0 +1,12 @@
|
|||
package gorm
|
||||
|
||||
type FsCanteenProduct struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
CanteenType *int64 `gorm:"default:0" json:"canteen_type"` // 餐厅类别id
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品id
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸id
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1启用0停用
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Sid *string `gorm:"default:''" json:"sid"` // 前端带入的id
|
||||
}
|
9
model/gorm/fscanteentypemodel.go
Executable file
9
model/gorm/fscanteentypemodel.go
Executable file
|
@ -0,0 +1,9 @@
|
|||
package gorm
|
||||
|
||||
type FsCanteenType struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Name *string `gorm:"default:''" json:"name"` // 餐厅名字
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1启用0停用
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
}
|
14
model/gorm/fsfaqmodel.go
Executable file
14
model/gorm/fsfaqmodel.go
Executable file
|
@ -0,0 +1,14 @@
|
|||
package gorm
|
||||
|
||||
import "database/sql"
|
||||
|
||||
type FsFaq struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
TagId *int64 `gorm:"default:0" json:"tag_id"` // 分类ID
|
||||
TagName *string `gorm:"default:''" json:"tag_name"` // 分类名称
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Content *string `gorm:"default:''" json:"content"` // 内容
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态(0:禁用,1:启用)
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Ctime *sql.NullInt64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
}
|
9
model/gorm/fsfontmodel.go
Executable file
9
model/gorm/fsfontmodel.go
Executable file
|
@ -0,0 +1,9 @@
|
|||
package gorm
|
||||
|
||||
type FsFont struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // id
|
||||
Title *string `gorm:"default:''" json:"title"` // 字体名字
|
||||
LinuxFontname *string `gorm:"default:''" json:"linux_fontname"` // linux对应字体名
|
||||
FilePath *string `gorm:"default:''" json:"file_path"` // 字体文件路径
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
}
|
33
model/gorm/fsproductmodel.go
Executable file
33
model/gorm/fsproductmodel.go
Executable file
|
@ -0,0 +1,33 @@
|
|||
package gorm
|
||||
|
||||
type FsProduct struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Sn *string `gorm:"default:''" json:"sn"` // 商品编号 P98f087j
|
||||
Type *int64 `gorm:"default:0" json:"type"` // 分类ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 名称
|
||||
TitleCn *string `gorm:"default:''" json:"title_cn"` // 中文名称
|
||||
Cover *string `gorm:"default:''" json:"cover"` // 封面图
|
||||
Imgs *string `gorm:"default:''" json:"imgs"` // 一个或多个介绍图或视频
|
||||
Keywords *string `gorm:"default:''" json:"keywords"` // 关键字
|
||||
Intro *string `gorm:"default:''" json:"intro"` // 简要描述
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
SelledNum *int64 `gorm:"default:0" json:"selled_num"` // 已卖数量
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
View *int64 `gorm:"default:0" json:"view"` // 浏览量
|
||||
SizeIds *string `gorm:"default:''" json:"size_ids"` // 尺寸 1,2,3,4
|
||||
MaterialIds *string `gorm:"default:''" json:"material_ids"` // 材质 1,2,3
|
||||
TagIds *string `gorm:"default:''" json:"tag_ids"` // 标签 逗号间隔
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 弃用
|
||||
ProduceDays *int64 `gorm:"default:0" json:"produce_days"` // 生产天数
|
||||
DeliveryDays *int64 `gorm:"default:0" json:"delivery_days"` // 运送天数
|
||||
CoverImg *string `gorm:"default:''" json:"cover_img"` // 背景图
|
||||
IsShelf *int64 `gorm:"default:1" json:"is_shelf"` // 是否上架
|
||||
IsRecommend *int64 `gorm:"default:1" json:"is_recommend"` // 是否推荐
|
||||
IsHot *int64 `gorm:"default:1" json:"is_hot"` // 是否热销
|
||||
IsProtection *int64 `gorm:"default:1" json:"is_protection"` // 是否环保
|
||||
IsMicrowave *int64 `gorm:"default:1" json:"is_microwave"` // 是否可微波炉
|
||||
IsDel *int64 `gorm:"default:0" json:"is_del"` // 是否删除
|
||||
RecommendProduct *string `gorm:"default:''" json:"recommend_product"` // 推荐产品id例如: 1,3,4,5
|
||||
RecommendProductSort *string `gorm:"default:''" json:"recommend_product_sort"` // 推荐排序例如:1324
|
||||
SceneIds *string `gorm:"default:''" json:"scene_ids"` // 关联的场景id
|
||||
}
|
9
model/gorm/fsproductmodel3dlightmodel.go
Executable file
9
model/gorm/fsproductmodel3dlightmodel.go
Executable file
|
@ -0,0 +1,9 @@
|
|||
package gorm
|
||||
|
||||
type FsProductModel3dLight struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Name *string `gorm:"default:''" json:"name"` // 灯光名称
|
||||
Info *string `gorm:"default:''" json:"info"` // 灯光数据(json格式)
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态值(1:显示,0:删除)
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 创建时间
|
||||
}
|
22
model/gorm/fsproductmodel3dmodel.go
Executable file
22
model/gorm/fsproductmodel3dmodel.go
Executable file
|
@ -0,0 +1,22 @@
|
|||
package gorm
|
||||
|
||||
type FsProductModel3d struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
Tag *int64 `gorm:"default:1" json:"tag"` // 类别(1:模型,2:配件,3:场景)
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Name *string `gorm:"default:''" json:"name"` // 详情页展示名称
|
||||
ModelInfo *string `gorm:"default:''" json:"model_info"` // 模型详情
|
||||
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
Light *int64 `gorm:"default:0" json:"light"` // 灯光组
|
||||
LightList *string `gorm:"default:''" json:"light_list"` // 灯光备选项
|
||||
PartId *int64 `gorm:"default:0" json:"part_id"` // 配件选项id(配件就是模型的id)
|
||||
PartList *string `gorm:"default:''" json:"part_list"` // 配件备选项
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1显示 0删除
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
OptionTemplate *int64 `gorm:"default:0" json:"option_template"` // 配件绑定的公共模板
|
||||
Price *int64 `gorm:"default:0" json:"price"` // 仅配件用,配件的价格, 单位:美分
|
||||
Sku *string `gorm:"default:''" json:"sku"` // sku
|
||||
}
|
17
model/gorm/fsproductpricemodel.go
Executable file
17
model/gorm/fsproductpricemodel.go
Executable file
|
@ -0,0 +1,17 @@
|
|||
package gorm
|
||||
|
||||
type FsProductPrice struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
Sn *string `gorm:"default:''" json:"sn"` // 唯一编码
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题描述
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
|
||||
EachBoxNum *int64 `gorm:"default:0" json:"each_box_num"` // 每一箱的个数
|
||||
EachBoxWeight *float64 `gorm:"default:0" json:"each_box_weight"` // 每一箱的重量 单位KG
|
||||
MinBuyNum *int64 `gorm:"default:0" json:"min_buy_num"` // 最少购买量
|
||||
StepNum *string `gorm:"default:''" json:"step_num"` // 数量阶梯 eg:10,20,30
|
||||
StepPrice *string `gorm:"default:''" json:"step_price"` // 价格阶梯 eg:100,50,25
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 是否可用
|
||||
IsDefault *int64 `gorm:"default:0" json:"is_default"` // 是否默认
|
||||
}
|
14
model/gorm/fsproductsizemodel.go
Executable file
14
model/gorm/fsproductsizemodel.go
Executable file
|
@ -0,0 +1,14 @@
|
|||
package gorm
|
||||
|
||||
type FsProductSize struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题 10*10*20
|
||||
Cover *string `gorm:"default:''" json:"cover"` // 封面图
|
||||
CoverImg *string `gorm:"default:''" json:"cover_img"` // 背景图
|
||||
Capacity *string `gorm:"default:''" json:"capacity"` // 自己填的尺寸名称
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态位 1显示 0删除
|
||||
Sort *int64 `gorm:"default:50" json:"sort"` // 排序
|
||||
Remark *string `gorm:"default:''" json:"remark"` // 备注信息
|
||||
PartsCanDeleted *int64 `gorm:"default:1" json:"parts_can_deleted"` // 配件是否可移除 1是0否
|
||||
}
|
8
model/gorm/fsproducttemplatetagsmodel.go
Executable file
8
model/gorm/fsproducttemplatetagsmodel.go
Executable file
|
@ -0,0 +1,8 @@
|
|||
package gorm
|
||||
|
||||
type FsProductTemplateTags struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1:可用 0不可用
|
||||
CreateAt *int64 `gorm:"default:0" json:"create_at"` // 创建时间
|
||||
}
|
20
model/gorm/fsproducttemplatev2model.go
Executable file
20
model/gorm/fsproducttemplatev2model.go
Executable file
|
@ -0,0 +1,20 @@
|
|||
package gorm
|
||||
|
||||
type FsProductTemplateV2 struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"`
|
||||
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
|
||||
ModelId *int64 `gorm:"default:0" json:"model_id"` // 模型ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 模板(sku),预留字段
|
||||
Name *string `gorm:"default:''" json:"name"` // 名称
|
||||
CoverImg *string `gorm:"default:''" json:"cover_img"` // 模板背景图
|
||||
TemplateInfo *string `gorm:"default:''" json:"template_info"` // 模板详情
|
||||
MaterialImg *string `gorm:"default:''" json:"material_img"` // 合成好的贴图
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
|
||||
LogoWidth *int64 `gorm:"default:0" json:"logo_width"` // logo图最大宽度
|
||||
LogoHeight *int64 `gorm:"default:0" json:"logo_height"` // logo图最大高度
|
||||
IsPublic *int64 `gorm:"default:0" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态1正常 2异常
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Tag *string `gorm:"default:''" json:"tag"` // 标签(用户自填)
|
||||
IsDel *int64 `gorm:"default:0" json:"is_del"` // 是否删除 1删除
|
||||
}
|
16
model/gorm/fsqrcodesetmodel.go
Executable file
16
model/gorm/fsqrcodesetmodel.go
Executable file
|
@ -0,0 +1,16 @@
|
|||
package gorm
|
||||
|
||||
type FsQrcodeSet struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // id
|
||||
Name *string `gorm:"default:''" json:"name"` // 二维码组件名称
|
||||
Size *int64 `gorm:"default:0" json:"size"` // 二维码内容尺寸
|
||||
IndexX *int64 `gorm:"default:0" json:"index_x"` // x偏移量
|
||||
IndexY *int64 `gorm:"default:0" json:"index_y"` // y偏移量
|
||||
SvgWebsite *string `gorm:"default:''" json:"svg_website"` // website d数据
|
||||
SvgInstagram *string `gorm:"default:''" json:"svg_instagram"` // svg instagram d数据
|
||||
SvgFacebook *string `gorm:"default:''" json:"svg_facebook"` // svg facebook d数据
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1正常 1删除
|
||||
AdminId *int64 `gorm:"default:0" json:"admin_id"` // 操作人
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Utime *int64 `gorm:"default:0" json:"utime"` // 更新时间
|
||||
}
|
9
model/gorm/fsstandardlogomodel.go
Executable file
9
model/gorm/fsstandardlogomodel.go
Executable file
|
@ -0,0 +1,9 @@
|
|||
package gorm
|
||||
|
||||
type FsStandardLogo struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Name *string `gorm:"default:''" json:"name"` // logo名称
|
||||
Image *string `gorm:"default:''" json:"image"` // 图片地址
|
||||
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1正常 0删除
|
||||
}
|
15
model/gorm/fstagsmodel.go
Executable file
15
model/gorm/fstagsmodel.go
Executable file
|
@ -0,0 +1,15 @@
|
|||
package gorm
|
||||
|
||||
type FsTags struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
Title *string `gorm:"default:''" json:"title"` // 标题
|
||||
Level *int64 `gorm:"default:0" json:"level"` // 层级、分类 1 => 二维码分类
|
||||
ClickNum *int64 `gorm:"default:0" json:"click_num"` // 点击次数
|
||||
Sort *int64 `gorm:"default:0" json:"sort"` // 排序(从大到小)
|
||||
CreateAt *int64 `gorm:"default:0" json:"create_at"` // 创建时间
|
||||
Icon *string `gorm:"default:''" json:"icon"` // 标签图标
|
||||
Status *int64 `gorm:"default:1" json:"status"` // 状态 1:可用
|
||||
Description *string `gorm:"default:''" json:"description"` // 介绍 Seo
|
||||
RecommendProduct *string `gorm:"default:''" json:"recommend_product"` // 推荐产品id例如: 1,3,4,5
|
||||
RecommendProductSort *string `gorm:"default:''" json:"recommend_product_sort"` // 推荐排序例如:1324
|
||||
}
|
30
model/gorm/fsusermodel.go
Executable file
30
model/gorm/fsusermodel.go
Executable file
|
@ -0,0 +1,30 @@
|
|||
package gorm
|
||||
|
||||
type FsUser struct {
|
||||
Id int64 `gorm:"primary_key" json:"id"` // ID
|
||||
FaceId int64 `gorm:"default:0" json:"face_id"` // facebook的userid
|
||||
Sub int64 `gorm:"default:0" json:"sub"` // google的sub
|
||||
FirstName string `gorm:"default:''" json:"first_name"` // FirstName
|
||||
LastName string `gorm:"default:''" json:"last_name"` // LastName
|
||||
Username string `gorm:"default:''" json:"username"` // 用户名
|
||||
Company string `gorm:"default:''" json:"company"` // 公司名称
|
||||
Mobile string `gorm:"default:''" json:"mobile" ` // 手机号码
|
||||
AuthKey string `gorm:"default:''" json:"auth_key"`
|
||||
PasswordHash string `gorm:"default:''" json:"password_hash"`
|
||||
VerificationToken string `gorm:"default:''" json:"verification_token"`
|
||||
PasswordResetToken string `gorm:"default:''" json:"password_reset_token"`
|
||||
Email string `gorm:"default:''" json:"email"` // 邮箱
|
||||
Type int64 `gorm:"default:1" json:"type"` // 1普通餐厅 2连锁餐厅
|
||||
Status int64 `gorm:"default:1" json:"status"` // 1正常 0不正常
|
||||
IsDel int64 `gorm:"default:0" json:"is_del"` // 是否删除 1删除
|
||||
CreatedAt int64 `gorm:"default:0" json:"created_at"` // 添加时间
|
||||
UpdatedAt int64 `gorm:"default:0" json:"updated_at"` // 更新时间
|
||||
IsOrderStatusEmail int64 `gorm:"default:0" json:"is_order_status_email"` // 订单状态改变时是否接收邮件
|
||||
IsEmailAdvertisement int64 `gorm:"default:0" json:"is_email_advertisement"` // 是否接收邮件广告
|
||||
IsOrderStatusPhone int64 `gorm:"default:0" json:"is_order_status_phone"` // 订单状态改变是是否接收电话
|
||||
IsPhoneAdvertisement int64 `gorm:"default:0" json:"is_phone_advertisement"` // 是否接收短信广告
|
||||
IsOpenRender int64 `gorm:"default:0" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭)
|
||||
IsThousandFace int64 `gorm:"default:0" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在)
|
||||
IsLowRendering int64 `gorm:"default:0" json:"is_low_rendering"` // 是否开启低渲染模型渲染
|
||||
IsRemoveBg int64 `gorm:"default:1" json:"is_remove_bg"` // 用户上传logo是否去除背景
|
||||
}
|
|
@ -23,6 +23,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Handler: SaveCanteenTypeProductHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
//rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/server/canteen/internal/config"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
|
||||
MysqlConn sqlx.SqlConn
|
||||
MysqlConn *gorm.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: sqlx.NewMysql(c.SourceMysql),
|
||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/upload/qrcode",
|
||||
Handler: UploadQrcodeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/upload/up-logo",
|
||||
Handler: UploadLogoHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
)
|
||||
|
|
37
server/data-transfer/internal/handler/uploadlogohandler.go
Normal file
37
server/data-transfer/internal/handler/uploadlogohandler.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"fusenapi/server/data-transfer/internal/logic"
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
"fusenapi/server/data-transfer/internal/types"
|
||||
)
|
||||
|
||||
func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.UploadLogoReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.OkJsonCtx(r.Context(), w, &types.Response{
|
||||
Code: 510,
|
||||
Message: "parameter error",
|
||||
})
|
||||
logx.Info(err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewUploadLogoLogic(r.Context(), svcCtx)
|
||||
resp := l.UploadLogo(&req)
|
||||
if resp != nil {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
} else {
|
||||
err := errors.New("server logic is error, resp must not be nil")
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
logx.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
31
server/data-transfer/internal/logic/uploadlogologic.go
Normal file
31
server/data-transfer/internal/logic/uploadlogologic.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
"fusenapi/server/data-transfer/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UploadLogoLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUploadLogoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogoLogic {
|
||||
return &UploadLogoLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq) (resp *types.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
|
@ -1,19 +1,20 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
config2 "fusenapi/server/data-transfer/internal/config"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/server/data-transfer/internal/config"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config2.Config
|
||||
Config config.Config
|
||||
|
||||
MysqlConn sqlx.SqlConn
|
||||
MysqlConn *gorm.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c config2.Config) *ServiceContext {
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: sqlx.NewMysql(c.SourceMysql),
|
||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,19 @@ type UploadQrcodeRsp struct {
|
|||
Data string `json:"d"`
|
||||
}
|
||||
|
||||
type UploadLogoReq struct {
|
||||
SkuId int64 `json:"skuId"`
|
||||
IsRemoveBg bool `json:"is_remove_bg"`
|
||||
Proportion int64 `json:"proportion"`
|
||||
}
|
||||
|
||||
type UploadLogoRsp struct {
|
||||
NobgUrl string `json:"nobg_url"`
|
||||
ThumbnailUrl string `json:"thumbnail_url"`
|
||||
IsmaxProportion bool `json:"ismax_proportion"`
|
||||
ImgColor []string `json:"img_color"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/server/product/internal/config"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
MysqlConn sqlx.SqlConn
|
||||
Config config.Config
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: sqlx.NewMysql(c.DataSource),
|
||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ service data-transfer {
|
|||
//生成二维码
|
||||
@handler UploadQrcodeHandler
|
||||
post /upload/qrcode (UploadQrcodeReq) returns (response);
|
||||
//上传logo
|
||||
@handler UploadLogoHandler
|
||||
post /upload/up-logo (UploadLogoReq) returns (response);
|
||||
}
|
||||
|
||||
//获取标准logo列表
|
||||
|
@ -43,4 +46,17 @@ type UploadQrcodeReq {
|
|||
type UploadQrcodeRsp {
|
||||
Link string `json:"link"`
|
||||
Data string `json:"d"`
|
||||
}
|
||||
|
||||
//上传logo
|
||||
type UploadLogoReq {
|
||||
SkuId int64 `json:"skuId"`
|
||||
IsRemoveBg bool `json:"is_remove_bg"`
|
||||
Proportion int64 `json:"proportion"`
|
||||
}
|
||||
type UploadLogoRsp {
|
||||
NobgUrl string `json:"nobg_url"`
|
||||
ThumbnailUrl string `json:"thumbnail_url"`
|
||||
IsmaxProportion bool `json:"ismax_proportion"`
|
||||
ImgColor []string `json:"img_color"`
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package sql_placeholder
|
||||
|
||||
import "strings"
|
||||
|
||||
// 获取对应长度占位符号
|
||||
func GetSqlPlaceholder(l uint) string {
|
||||
s := make([]string, 0, int(l))
|
||||
for i := 0; i < int(l); i++ {
|
||||
s = append(s, "?")
|
||||
}
|
||||
return strings.Join(s, ",")
|
||||
}
|
Loading…
Reference in New Issue
Block a user