Merge branch 'develop' into feature/auth
This commit is contained in:
commit
d35ffd793a
@ -2,4 +2,5 @@ package constants
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
BLMServiceUrlLogoCombine string = "/LogoCombine"
|
BLMServiceUrlLogoCombine string = "/LogoCombine"
|
||||||
|
BLMServiceUrlLogoRemovebg string = "/removebg"
|
||||||
)
|
)
|
||||||
|
@ -12,8 +12,6 @@ const (
|
|||||||
WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT"
|
WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT"
|
||||||
//请求恢复为上次连接的标识错误
|
//请求恢复为上次连接的标识错误
|
||||||
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR"
|
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR"
|
||||||
//渲染前数据组装
|
|
||||||
WEBSOCKET_RENDER_IMAGE_ASSEMBLE = "WEBSOCKET_RENDER_IMAGE_ASSEMBLE"
|
|
||||||
//图片渲染
|
//图片渲染
|
||||||
WEBSOCKET_RENDER_IMAGE = "WEBSOCKET_RENDER_IMAGE"
|
WEBSOCKET_RENDER_IMAGE = "WEBSOCKET_RENDER_IMAGE"
|
||||||
//数据格式错误
|
//数据格式错误
|
||||||
|
@ -9,10 +9,10 @@ type FsAuthItem struct {
|
|||||||
Name string `gorm:"primary_key;default:'';" json:"name"` // 角色或权限名称
|
Name string `gorm:"primary_key;default:'';" json:"name"` // 角色或权限名称
|
||||||
Type *int64 `gorm:"index;default:0;" json:"type"` // 权限类型:1 表示角色,2 表示权限
|
Type *int64 `gorm:"index;default:0;" json:"type"` // 权限类型:1 表示角色,2 表示权限
|
||||||
Description *string `gorm:"default:'';" json:"description"` // 角色或权限描述
|
Description *string `gorm:"default:'';" json:"description"` // 角色或权限描述
|
||||||
RuleName *string `gorm:"index;default:'';" json:"rule_name"` //
|
RuleName *string `gorm:"index;default:'';" json:"rule_name"` // 规则名称
|
||||||
Data *[]byte `gorm:"default:'';" json:"data"` // 角色或权限的额外数据
|
Data *[]byte `gorm:"default:'';" json:"data"` // 角色或权限的额外数据
|
||||||
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` //
|
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
|
||||||
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` //
|
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间
|
||||||
// FsAuthItemIbfk1 foreign `gorm:"" json:"fs_auth_item_ibfk_1"`//
|
// FsAuthItemIbfk1 foreign `gorm:"" json:"fs_auth_item_ibfk_1"`//
|
||||||
}
|
}
|
||||||
type FsAuthItemModel struct {
|
type FsAuthItemModel struct {
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
type FsAuthRule struct {
|
type FsAuthRule struct {
|
||||||
Name string `gorm:"primary_key;default:'';" json:"name"` // 规则名称
|
Name string `gorm:"primary_key;default:'';" json:"name"` // 规则名称
|
||||||
Data *[]byte `gorm:"default:'';" json:"data"` // 规则的额外数据
|
Data *[]byte `gorm:"default:'';" json:"data"` // 规则的额外数据
|
||||||
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` //
|
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
|
||||||
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` //
|
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间
|
||||||
}
|
}
|
||||||
type FsAuthRuleModel struct {
|
type FsAuthRuleModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -14,6 +14,8 @@ type FsCanteenProduct struct {
|
|||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Sid *string `gorm:"default:'';" json:"sid"` // 前端带入的id
|
Sid *string `gorm:"default:'';" json:"sid"` // 前端带入的id
|
||||||
|
ShowSizeTips *int64 `gorm:"default:0;" json:"show_size_tips"` // 是否显示提示
|
||||||
|
ShowSizeList *int64 `gorm:"default:0;" json:"show_size_list"` // 是否显示规格列表
|
||||||
}
|
}
|
||||||
type FsCanteenProductModel struct {
|
type FsCanteenProductModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
// fs_cart 购物车
|
// fs_cart 购物车
|
||||||
type FsCart struct {
|
type FsCart struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模板ID
|
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模板ID
|
||||||
PriceId *int64 `gorm:"index;default:0;" json:"price_id"` // 价格ID
|
PriceId *int64 `gorm:"index;default:0;" json:"price_id"` // 价格ID
|
||||||
@ -17,7 +17,7 @@ type FsCart struct {
|
|||||||
BuyNum *int64 `gorm:"default:0;" json:"buy_num"` // 购买数量
|
BuyNum *int64 `gorm:"default:0;" json:"buy_num"` // 购买数量
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` // 截图
|
Cover *string `gorm:"default:'';" json:"cover"` // 截图
|
||||||
DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID
|
DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位
|
||||||
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
|
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
|
||||||
IsCheck *int64 `gorm:"default:0;" json:"is_check"` // 是否选中状态(0:未选中,1:选中)
|
IsCheck *int64 `gorm:"default:0;" json:"is_check"` // 是否选中状态(0:未选中,1:选中)
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
type FsCloudRenderLog struct {
|
type FsCloudRenderLog struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||||
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id
|
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id
|
||||||
GuestId *int64 `gorm:"default:0;" json:"guest_id"` // 游客id
|
|
||||||
PostData *string `gorm:"default:'';" json:"post_data"` //
|
PostData *string `gorm:"default:'';" json:"post_data"` //
|
||||||
PostUrl *string `gorm:"default:'';" json:"post_url"` //
|
PostUrl *string `gorm:"default:'';" json:"post_url"` //
|
||||||
Title *string `gorm:"index;default:'';" json:"title"` //
|
Title *string `gorm:"index;default:'';" json:"title"` //
|
||||||
|
@ -11,8 +11,8 @@ type FsContact struct {
|
|||||||
Email *string `gorm:"index;default:'';" json:"email"` // 邮箱
|
Email *string `gorm:"index;default:'';" json:"email"` // 邮箱
|
||||||
Subject *int64 `gorm:"default:0;" json:"subject"` // 主题
|
Subject *int64 `gorm:"default:0;" json:"subject"` // 主题
|
||||||
Message *string `gorm:"default:'';" json:"message"` // 消息
|
Message *string `gorm:"default:'';" json:"message"` // 消息
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` //
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否已处理
|
||||||
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
|
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
|
||||||
}
|
}
|
||||||
type FsContactModel struct {
|
type FsContactModel struct {
|
||||||
|
@ -12,10 +12,10 @@ type FsContactService struct {
|
|||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
||||||
Name *string `gorm:"default:'';" json:"name"` // 联系人姓名
|
Name *string `gorm:"default:'';" json:"name"` // 联系人姓名
|
||||||
Email *string `gorm:"index;default:'';" json:"email"` // 联系人邮箱
|
Email *string `gorm:"index;default:'';" json:"email"` // 联系人邮箱
|
||||||
Phone *string `gorm:"default:'';" json:"phone"` //
|
Phone *string `gorm:"default:'';" json:"phone"` // 联系人电话
|
||||||
Remark *string `gorm:"default:'';" json:"remark"` // 备注内容
|
Remark *string `gorm:"default:'';" json:"remark"` // 备注内容
|
||||||
IsHandle *int64 `gorm:"default:0;" json:"is_handle"` // 是否被处理(0:未处理,1:已处理)
|
IsHandle *int64 `gorm:"default:0;" json:"is_handle"` // 是否被处理(0:未处理,1:已处理)
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||||
HandleRemark *string `gorm:"default:'';" json:"handle_remark"` // 处理备注
|
HandleRemark *string `gorm:"default:'';" json:"handle_remark"` // 处理备注
|
||||||
HandleUid *int64 `gorm:"default:0;" json:"handle_uid"` // 处理人
|
HandleUid *int64 `gorm:"default:0;" json:"handle_uid"` // 处理人
|
||||||
HandleTime *int64 `gorm:"default:0;" json:"handle_time"` // 处理时间
|
HandleTime *int64 `gorm:"default:0;" json:"handle_time"` // 处理时间
|
||||||
|
@ -10,10 +10,10 @@ type FsEmailTemplate struct {
|
|||||||
Type *int64 `gorm:"default:0;" json:"type"` // 模板类型
|
Type *int64 `gorm:"default:0;" json:"type"` // 模板类型
|
||||||
Name *string `gorm:"default:'';" json:"name"` // 模板名称
|
Name *string `gorm:"default:'';" json:"name"` // 模板名称
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 模板标题
|
Title *string `gorm:"default:'';" json:"title"` // 模板标题
|
||||||
ReplaceFields *string `gorm:"default:'';" json:"replace_fields"` //
|
ReplaceFields *string `gorm:"default:'';" json:"replace_fields"` // 需要替换的字段
|
||||||
Content *string `gorm:"default:'';" json:"content"` // 模板内容
|
Content *string `gorm:"default:'';" json:"content"` // 模板内容
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态值(0:禁用,1:启用)
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态值(0:禁用,1:启用)
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
type FsEmailTemplateModel struct {
|
type FsEmailTemplateModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -13,7 +13,7 @@ type FsFaq struct {
|
|||||||
Content *string `gorm:"default:'';" json:"content"` // 内容
|
Content *string `gorm:"default:'';" json:"content"` // 内容
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态(0:禁用,1:启用)
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态(0:禁用,1:启用)
|
||||||
Sort *int64 `gorm:"default:1;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:1;" json:"sort"` // 排序
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
type FsFaqModel struct {
|
type FsFaqModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -10,12 +10,12 @@ type FsGerent struct {
|
|||||||
Username *string `gorm:"unique_key;default:'';" json:"username"` // 用户名
|
Username *string `gorm:"unique_key;default:'';" json:"username"` // 用户名
|
||||||
AuthKey *string `gorm:"default:'';" json:"auth_key"` // token
|
AuthKey *string `gorm:"default:'';" json:"auth_key"` // token
|
||||||
PasswordHash *string `gorm:"default:'';" json:"password_hash"` // 加密密码
|
PasswordHash *string `gorm:"default:'';" json:"password_hash"` // 加密密码
|
||||||
PasswordResetToken *string `gorm:"unique_key;default:'';" json:"password_reset_token"` //
|
PasswordResetToken *string `gorm:"unique_key;default:'';" json:"password_reset_token"` // 加密密码token
|
||||||
Email *string `gorm:"unique_key;default:'';" json:"email"` // 邮箱
|
Email *string `gorm:"unique_key;default:'';" json:"email"` // 邮箱
|
||||||
Status *int64 `gorm:"default:10;" json:"status"` // 状态
|
Status *int64 `gorm:"default:10;" json:"status"` // 状态
|
||||||
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
|
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
|
||||||
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间
|
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间
|
||||||
Icon *string `gorm:"default:'';" json:"icon"` //
|
Icon *string `gorm:"default:'';" json:"icon"` // 标签图标
|
||||||
DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门id
|
DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门id
|
||||||
}
|
}
|
||||||
type FsGerentModel struct {
|
type FsGerentModel struct {
|
||||||
|
30
model/gmodel/fs_logo_cartoon_gen.go
Normal file
30
model/gmodel/fs_logo_cartoon_gen.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_logo_cartoon logo底图表
|
||||||
|
type FsLogoCartoon struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||||
|
CategoryId *int64 `gorm:"default:0;" json:"category_id"` // 分类
|
||||||
|
Name *string `gorm:"default:'';" json:"name"` //
|
||||||
|
Url *string `gorm:"default:'';" json:"url"` //
|
||||||
|
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除
|
||||||
|
CreateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"create_time"` //
|
||||||
|
UpdateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"update_time"` //
|
||||||
|
DeleteTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"delete_time"` //
|
||||||
|
CreateUid *int64 `gorm:"default:0;" json:"create_uid"` // 创建人
|
||||||
|
UpdateUid *int64 `gorm:"default:0;" json:"update_uid"` // 更新人
|
||||||
|
DeleteUid *int64 `gorm:"default:0;" json:"delete_uid"` // 删除人
|
||||||
|
ResourceId *string `gorm:"default:'';" json:"resource_id"` //
|
||||||
|
}
|
||||||
|
type FsLogoCartoonModel struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsLogoCartoonModel(db *gorm.DB) *FsLogoCartoonModel {
|
||||||
|
return &FsLogoCartoonModel{db: db, name: "fs_logo_cartoon"}
|
||||||
|
}
|
2
model/gmodel/fs_logo_cartoon_logic.go
Normal file
2
model/gmodel/fs_logo_cartoon_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
@ -11,7 +11,7 @@ type FsMerchantCategory struct {
|
|||||||
EnName *string `gorm:"default:'';" json:"en_name"` // 英文名
|
EnName *string `gorm:"default:'';" json:"en_name"` // 英文名
|
||||||
Icon *string `gorm:"default:'';" json:"icon"` // 图标
|
Icon *string `gorm:"default:'';" json:"icon"` // 图标
|
||||||
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品
|
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品
|
||||||
Sort *int64 `gorm:"default:128;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ type FsOrderDetail struct {
|
|||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 唯一编码
|
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 唯一编码
|
||||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID
|
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID
|
||||||
UserId *int64 `gorm:"default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID
|
||||||
FactoryId *int64 `gorm:"default:0;" json:"factory_id"` // 工厂ID
|
FactoryId *int64 `gorm:"default:0;" json:"factory_id"` // 工厂ID
|
||||||
OrderDetailTemplateId *int64 `gorm:"default:0;" json:"order_detail_template_id"` // 详情templateID
|
OrderDetailTemplateId *int64 `gorm:"default:0;" json:"order_detail_template_id"` // 详情templateID
|
||||||
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID
|
||||||
|
@ -16,7 +16,7 @@ type FsOrderDetailTemplate struct {
|
|||||||
EachBoxNum *int64 `gorm:"default:0;" json:"each_box_num"` // 每一箱的个数
|
EachBoxNum *int64 `gorm:"default:0;" json:"each_box_num"` // 每一箱的个数
|
||||||
EachBoxWeight *float64 `gorm:"default:0.00;" json:"each_box_weight"` // 每一箱的重量 单位KG
|
EachBoxWeight *float64 `gorm:"default:0.00;" json:"each_box_weight"` // 每一箱的重量 单位KG
|
||||||
DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID
|
DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
type FsOrderDetailTemplateModel struct {
|
type FsOrderDetailTemplateModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -9,17 +9,17 @@ import (
|
|||||||
type FsOrder struct {
|
type FsOrder struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
|
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` //
|
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // 销售员ID 0:自主下单
|
||||||
TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价
|
TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价
|
||||||
PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额
|
PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额
|
||||||
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip
|
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Utime *int64 `gorm:"default:0;" json:"utime"` //
|
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
||||||
Ptime *int64 `gorm:"default:0;" json:"ptime"` //
|
Ptime *int64 `gorm:"default:0;" json:"ptime"` // 最后一次 支付时间(可能多次支付)
|
||||||
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址ID或者云仓ID
|
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址ID或者云仓ID
|
||||||
DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 配送方式 1:直接发货到收获地址 2:云仓
|
DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 配送方式 1:直接发货到收获地址 2:云仓
|
||||||
CustomerMark *string `gorm:"default:'';" json:"customer_mark"` //
|
CustomerMark *string `gorm:"default:'';" json:"customer_mark"` // 客户备注
|
||||||
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
|
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
|
||||||
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 详细地址信息JSON
|
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 详细地址信息JSON
|
||||||
IsSup *int64 `gorm:"default:0;" json:"is_sup"` // 0不是补货 1是补货
|
IsSup *int64 `gorm:"default:0;" json:"is_sup"` // 0不是补货 1是补货
|
||||||
@ -37,8 +37,8 @@ type FsOrder struct {
|
|||||||
IsRefunding *int64 `gorm:"default:0;" json:"is_refunding"` // 是否退款中(0:否,1:是)
|
IsRefunding *int64 `gorm:"default:0;" json:"is_refunding"` // 是否退款中(0:否,1:是)
|
||||||
IsRefunded *int64 `gorm:"default:0;" json:"is_refunded"` // 是否退款完成(0:否,1:是)
|
IsRefunded *int64 `gorm:"default:0;" json:"is_refunded"` // 是否退款完成(0:否,1:是)
|
||||||
IsDeleted *int64 `gorm:"default:0;" json:"is_deleted"` // 是否删除(0:否,1:是)
|
IsDeleted *int64 `gorm:"default:0;" json:"is_deleted"` // 是否删除(0:否,1:是)
|
||||||
RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` //
|
RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` // 取消订单原因ID
|
||||||
RefundReason *string `gorm:"default:'';" json:"refund_reason"` //
|
RefundReason *string `gorm:"default:'';" json:"refund_reason"` // 取消订单原因
|
||||||
TsTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ts_time"` //
|
TsTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ts_time"` //
|
||||||
IsSure *int64 `gorm:"default:0;" json:"is_sure"` // 是否确认订单 1确认0未确认
|
IsSure *int64 `gorm:"default:0;" json:"is_sure"` // 是否确认订单 1确认0未确认
|
||||||
DeliverSn *string `gorm:"default:'';" json:"deliver_sn"` // 发货单号
|
DeliverSn *string `gorm:"default:'';" json:"deliver_sn"` // 发货单号
|
||||||
|
@ -8,18 +8,19 @@ import (
|
|||||||
type FsProductDesignGather struct {
|
type FsProductDesignGather struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"index;default:'';" json:"sn"` // 唯一标识
|
Sn *string `gorm:"index;default:'';" json:"sn"` // 唯一标识
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
|
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
|
||||||
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
|
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
|
||||||
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
|
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
|
||||||
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
|
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` //
|
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||||
Info *string `gorm:"default:'';" json:"info"` // 保留的设计信息
|
Info *string `gorm:"default:'';" json:"info"` // 保留的设计信息
|
||||||
Utime *int64 `gorm:"default:0;" json:"utime"` //
|
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` // 状态位(1:显示,0:删除)
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态位(1:显示,0:删除)
|
||||||
ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip
|
ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip
|
||||||
ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识
|
ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识
|
||||||
|
InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版
|
||||||
}
|
}
|
||||||
type FsProductDesignGatherModel struct {
|
type FsProductDesignGatherModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -23,6 +23,7 @@ type FsProductDesign struct {
|
|||||||
IsPay *int64 `gorm:"default:0;" json:"is_pay"` // 是否已有支付 0 未 1 有
|
IsPay *int64 `gorm:"default:0;" json:"is_pay"` // 是否已有支付 0 未 1 有
|
||||||
LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选项
|
LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选项
|
||||||
PageGuid *string `gorm:"default:'';" json:"page_guid"` // 页面识别id
|
PageGuid *string `gorm:"default:'';" json:"page_guid"` // 页面识别id
|
||||||
|
InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版用
|
||||||
}
|
}
|
||||||
type FsProductDesignModel struct {
|
type FsProductDesignModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -17,11 +17,11 @@ type FsProduct struct {
|
|||||||
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
|
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
|
||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
|
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
View *int64 `gorm:"default:0;" json:"view"` // 浏览量
|
View *int64 `gorm:"default:0;" json:"view"` // 浏览量
|
||||||
SizeIds *string `gorm:"default:'';" json:"size_ids"` //
|
SizeIds *string `gorm:"default:'';" json:"size_ids"` // 尺寸 1,2,3,4
|
||||||
MaterialIds *string `gorm:"default:'';" json:"material_ids"` // 材质 1,2,3
|
MaterialIds *string `gorm:"default:'';" json:"material_ids"` // 材质 1,2,3
|
||||||
TagIds *string `gorm:"default:'';" json:"tag_ids"` //
|
TagIds *string `gorm:"default:'';" json:"tag_ids"` // 标签 逗号间隔
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用
|
||||||
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
|
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
|
||||||
DeliveryDays *int64 `gorm:"default:0;" json:"delivery_days"` // 运送天数
|
DeliveryDays *int64 `gorm:"default:0;" json:"delivery_days"` // 运送天数
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
type FsProductModel3d struct {
|
type FsProductModel3d struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
IsPopular *int64 `gorm:"default:0;" json:"is_popular"` // 是否热门 0否 1是
|
|
||||||
Tag *int64 `gorm:"default:1;" json:"tag"` // 类别(1:模型,2:配件,3:场景)
|
Tag *int64 `gorm:"default:1;" json:"tag"` // 类别(1:模型,2:配件,3:场景)
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 标题
|
Title *string `gorm:"default:'';" json:"title"` // 标题
|
||||||
Name *string `gorm:"default:'';" json:"name"` // 详情页展示名称
|
Name *string `gorm:"default:'';" json:"name"` // 详情页展示名称
|
||||||
@ -25,6 +24,7 @@ type FsProductModel3d struct {
|
|||||||
OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板
|
OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板
|
||||||
Price *int64 `gorm:"default:0;" json:"price"` // 仅配件用,配件的价格, 单位:美分
|
Price *int64 `gorm:"default:0;" json:"price"` // 仅配件用,配件的价格, 单位:美分
|
||||||
Sku *string `gorm:"default:'';" json:"sku"` // sku
|
Sku *string `gorm:"default:'';" json:"sku"` // sku
|
||||||
|
IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门
|
||||||
}
|
}
|
||||||
type FsProductModel3dModel struct {
|
type FsProductModel3dModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -10,7 +10,7 @@ type FsProductModel3dLight struct {
|
|||||||
Name *string `gorm:"default:'';" json:"name"` // 灯光名称
|
Name *string `gorm:"default:'';" json:"name"` // 灯光名称
|
||||||
Info *string `gorm:"default:'';" json:"info"` // 灯光数据(json格式)
|
Info *string `gorm:"default:'';" json:"info"` // 灯光数据(json格式)
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` // 状态值(1:显示,0:删除)
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态值(1:显示,0:删除)
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||||
}
|
}
|
||||||
type FsProductModel3dLightModel struct {
|
type FsProductModel3dLightModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -8,19 +8,20 @@ import (
|
|||||||
type FsProductRenderDesign struct {
|
type FsProductRenderDesign struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"index;default:'';" json:"sn"` // 唯一标识
|
Sn *string `gorm:"index;default:'';" json:"sn"` // 唯一标识
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
|
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
|
||||||
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
|
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
|
||||||
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
|
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
|
||||||
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
|
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` //
|
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||||
Info *string `gorm:"default:'';" json:"info"` // 保留的设计信息
|
Info *string `gorm:"default:'';" json:"info"` // 保留的设计信息
|
||||||
Utime *int64 `gorm:"default:0;" json:"utime"` //
|
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` // 状态位(1:显示,0:删除)
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态位(1:显示,0:删除)
|
||||||
ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip
|
ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip
|
||||||
ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识
|
ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识
|
||||||
LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选颜色
|
LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选颜色
|
||||||
|
InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版用
|
||||||
}
|
}
|
||||||
type FsProductRenderDesignModel struct {
|
type FsProductRenderDesignModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -8,15 +8,15 @@ import (
|
|||||||
type FsProductSize struct {
|
type FsProductSize struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
IsPopular *int64 `gorm:"default:0;" json:"is_popular"` // 是否受欢迎 0否1是
|
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 标题 10*10*20
|
Title *string `gorm:"default:'';" json:"title"` // 标题 10*10*20
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` //
|
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
||||||
CoverImg *string `gorm:"default:'';" json:"cover_img"` //
|
CoverImg *string `gorm:"default:'';" json:"cover_img"` // 背景图
|
||||||
Capacity *string `gorm:"default:'';" json:"capacity"` // 自己填的尺寸名称
|
Capacity *string `gorm:"default:'';" json:"capacity"` // 自己填的尺寸名称
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除
|
||||||
Sort *int64 `gorm:"default:50;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:50;" json:"sort"` // 排序
|
||||||
Remark *string `gorm:"default:'';" json:"remark"` //
|
Remark *string `gorm:"default:'';" json:"remark"` // 备注信息
|
||||||
PartsCanDeleted *int64 `gorm:"default:1;" json:"parts_can_deleted"` // 配件是否可移除 1是0否
|
PartsCanDeleted *int64 `gorm:"default:1;" json:"parts_can_deleted"` // 配件是否可移除 1是0否
|
||||||
|
IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门
|
||||||
}
|
}
|
||||||
type FsProductSizeModel struct {
|
type FsProductSizeModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
35
model/gmodel/fs_product_template_element_0826_gen.go
Normal file
35
model/gmodel/fs_product_template_element_0826_gen.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_product_template_element_0826
|
||||||
|
type FsProductTemplateElement0826 struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
|
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||||
|
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
||||||
|
Main *string `gorm:"default:'';" json:"main"` //
|
||||||
|
Second *string `gorm:"default:'';" json:"second"` //
|
||||||
|
Base *string `gorm:"default:'';" json:"base"` //
|
||||||
|
Paper *string `gorm:"default:'';" json:"paper"` //
|
||||||
|
Spoon *string `gorm:"default:'';" json:"spoon"` //
|
||||||
|
Fork *string `gorm:"default:'';" json:"fork"` //
|
||||||
|
Toothpick *string `gorm:"default:'';" json:"toothpick"` //
|
||||||
|
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` //
|
||||||
|
Shadow *string `gorm:"default:'';" json:"shadow"` //
|
||||||
|
Cover *string `gorm:"default:'';" json:"cover"` //
|
||||||
|
Cover1 *string `gorm:"default:'';" json:"cover1"` //
|
||||||
|
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||||
|
Light *int64 `gorm:"default:0;" json:"light"` //
|
||||||
|
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
||||||
|
Scale *string `gorm:"default:'';" json:"scale"` //
|
||||||
|
}
|
||||||
|
type FsProductTemplateElement0826Model struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsProductTemplateElement0826Model(db *gorm.DB) *FsProductTemplateElement0826Model {
|
||||||
|
return &FsProductTemplateElement0826Model{db: db, name: "fs_product_template_element_0826"}
|
||||||
|
}
|
2
model/gmodel/fs_product_template_element_0826_logic.go
Normal file
2
model/gmodel/fs_product_template_element_0826_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
25
model/gmodel/fs_product_template_element_22_gen.go
Normal file
25
model/gmodel/fs_product_template_element_22_gen.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_product_template_element_22
|
||||||
|
type FsProductTemplateElement22 struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
|
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||||
|
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
||||||
|
Model *string `gorm:"default:'';" json:"model"` //
|
||||||
|
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||||
|
Light *int64 `gorm:"default:0;" json:"light"` //
|
||||||
|
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
||||||
|
Scale *string `gorm:"default:'';" json:"scale"` //
|
||||||
|
}
|
||||||
|
type FsProductTemplateElement22Model struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsProductTemplateElement22Model(db *gorm.DB) *FsProductTemplateElement22Model {
|
||||||
|
return &FsProductTemplateElement22Model{db: db, name: "fs_product_template_element_22"}
|
||||||
|
}
|
2
model/gmodel/fs_product_template_element_22_logic.go
Normal file
2
model/gmodel/fs_product_template_element_22_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
37
model/gmodel/fs_product_template_element_backup1018_gen.go
Normal file
37
model/gmodel/fs_product_template_element_backup1018_gen.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_product_template_element_backup1018
|
||||||
|
type FsProductTemplateElementBackup1018 struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
|
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||||
|
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
||||||
|
Main *string `gorm:"default:'';" json:"main"` //
|
||||||
|
Second *string `gorm:"default:'';" json:"second"` //
|
||||||
|
Base *string `gorm:"default:'';" json:"base"` //
|
||||||
|
Paper *string `gorm:"default:'';" json:"paper"` //
|
||||||
|
Spoon *string `gorm:"default:'';" json:"spoon"` //
|
||||||
|
Fork *string `gorm:"default:'';" json:"fork"` //
|
||||||
|
Toothpick *string `gorm:"default:'';" json:"toothpick"` //
|
||||||
|
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` //
|
||||||
|
Shadow *string `gorm:"default:'';" json:"shadow"` //
|
||||||
|
Cover *string `gorm:"default:'';" json:"cover"` //
|
||||||
|
Cover1 *string `gorm:"default:'';" json:"cover1"` //
|
||||||
|
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||||
|
Light *int64 `gorm:"default:0;" json:"light"` //
|
||||||
|
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
||||||
|
Scale *string `gorm:"default:'';" json:"scale"` //
|
||||||
|
ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据
|
||||||
|
Refletion *int64 `gorm:"default:0;" json:"refletion"` // 反射探头
|
||||||
|
}
|
||||||
|
type FsProductTemplateElementBackup1018Model struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsProductTemplateElementBackup1018Model(db *gorm.DB) *FsProductTemplateElementBackup1018Model {
|
||||||
|
return &FsProductTemplateElementBackup1018Model{db: db, name: "fs_product_template_element_backup1018"}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
@ -8,22 +8,22 @@ import (
|
|||||||
type FsProductTemplateElement struct {
|
type FsProductTemplateElement struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||||
ModelId *int64 `gorm:"index;default:0;" json:"model_id"` // 模型id
|
ModelId *int64 `gorm:"index;default:0;" json:"model_id"` // 产品模型id
|
||||||
Main *string `gorm:"default:'';" json:"main"` //
|
Main *string `gorm:"default:'';" json:"main"` // 废弃
|
||||||
Second *string `gorm:"default:'';" json:"second"` //
|
Second *string `gorm:"default:'';" json:"second"` // 废弃
|
||||||
Base *string `gorm:"default:'';" json:"base"` //
|
Base *string `gorm:"default:'';" json:"base"` // base
|
||||||
Paper *string `gorm:"default:'';" json:"paper"` //
|
Paper *string `gorm:"default:'';" json:"paper"` // 废弃
|
||||||
Spoon *string `gorm:"default:'';" json:"spoon"` //
|
Spoon *string `gorm:"default:'';" json:"spoon"` // 废弃
|
||||||
Fork *string `gorm:"default:'';" json:"fork"` //
|
Fork *string `gorm:"default:'';" json:"fork"` // 废弃
|
||||||
Toothpick *string `gorm:"default:'';" json:"toothpick"` //
|
Toothpick *string `gorm:"default:'';" json:"toothpick"` // 废弃
|
||||||
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` //
|
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // 废弃
|
||||||
Shadow *string `gorm:"default:'';" json:"shadow"` //
|
Shadow *string `gorm:"default:'';" json:"shadow"` // shadow
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` //
|
Cover *string `gorm:"default:'';" json:"cover"` // 废弃
|
||||||
Cover1 *string `gorm:"default:'';" json:"cover1"` //
|
Cover1 *string `gorm:"default:'';" json:"cover1"` // 废弃
|
||||||
Mode *string `gorm:"default:'';" json:"mode"` //
|
Mode *string `gorm:"default:'';" json:"mode"` // 材质类型
|
||||||
Light *int64 `gorm:"default:0;" json:"light"` //
|
Light *int64 `gorm:"default:0;" json:"light"` // 灯光组
|
||||||
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
Rotation *string `gorm:"default:'';" json:"rotation"` // 旋转
|
||||||
Scale *string `gorm:"default:'';" json:"scale"` //
|
Scale *string `gorm:"default:'';" json:"scale"` // 缩放
|
||||||
ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据
|
ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据
|
||||||
Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组
|
Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组
|
||||||
}
|
}
|
||||||
|
35
model/gmodel/fs_product_template_element_kongde_gen.go
Normal file
35
model/gmodel/fs_product_template_element_kongde_gen.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_product_template_element_kongde
|
||||||
|
type FsProductTemplateElementKongde struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
|
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
||||||
|
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
||||||
|
Main *string `gorm:"default:'';" json:"main"` //
|
||||||
|
Second *string `gorm:"default:'';" json:"second"` //
|
||||||
|
Base *string `gorm:"default:'';" json:"base"` //
|
||||||
|
Paper *string `gorm:"default:'';" json:"paper"` //
|
||||||
|
Spoon *string `gorm:"default:'';" json:"spoon"` //
|
||||||
|
Fork *string `gorm:"default:'';" json:"fork"` //
|
||||||
|
Toothpick *string `gorm:"default:'';" json:"toothpick"` //
|
||||||
|
Chopsticks *string `gorm:"default:'';" json:"chopsticks"` //
|
||||||
|
Shadow *string `gorm:"default:'';" json:"shadow"` //
|
||||||
|
Cover *string `gorm:"default:'';" json:"cover"` //
|
||||||
|
Cover1 *string `gorm:"default:'';" json:"cover1"` //
|
||||||
|
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||||
|
Light *int64 `gorm:"default:0;" json:"light"` //
|
||||||
|
Rotation *string `gorm:"default:'';" json:"rotation"` //
|
||||||
|
Scale *string `gorm:"default:'';" json:"scale"` //
|
||||||
|
}
|
||||||
|
type FsProductTemplateElementKongdeModel struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsProductTemplateElementKongdeModel(db *gorm.DB) *FsProductTemplateElementKongdeModel {
|
||||||
|
return &FsProductTemplateElementKongdeModel{db: db, name: "fs_product_template_element_kongde"}
|
||||||
|
}
|
2
model/gmodel/fs_product_template_element_kongde_logic.go
Normal file
2
model/gmodel/fs_product_template_element_kongde_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
@ -8,7 +8,7 @@ import (
|
|||||||
type FsProductTemplateTags struct {
|
type FsProductTemplateTags struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||||
TemplateTag *string `gorm:"unique_key;default:'';" json:"template_tag"` // 标题
|
TemplateTag *string `gorm:"unique_key;default:'';" json:"template_tag"` // 标题
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
Cover *string `gorm:"default:'';" json:"cover"` // 缩略图
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用
|
||||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||||
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息
|
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息
|
||||||
|
@ -9,21 +9,21 @@ type FsProductTemplateV2 struct {
|
|||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID
|
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID
|
||||||
Title *string `gorm:"default:'';" json:"title"` //
|
Title *string `gorm:"default:'';" json:"title"` // 模板(sku),预留字段
|
||||||
Name *string `gorm:"default:'';" json:"name"` //
|
Name *string `gorm:"default:'';" json:"name"` // 名称
|
||||||
CoverImg *string `gorm:"default:'';" json:"cover_img"` //
|
CoverImg *string `gorm:"default:'';" json:"cover_img"` // 模板背景图
|
||||||
TemplateInfo *string `gorm:"default:'';" json:"template_info"` //
|
TemplateInfo *string `gorm:"default:'';" json:"template_info"` // 模板详情
|
||||||
MaterialImg *string `gorm:"default:'';" json:"material_img"` //
|
MaterialImg *string `gorm:"default:'';" json:"material_img"` // 合成好的贴图
|
||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
|
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
|
||||||
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
|
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
|
||||||
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
TemplateTag *string `gorm:"default:'';" json:"template_tag"` // 标签(用户自填)
|
||||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
|
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息
|
||||||
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
|
Version *int64 `gorm:"default:0;" json:"version"` // 默认1
|
||||||
}
|
}
|
||||||
type FsProductTemplateV2Model struct {
|
type FsProductTemplateV2Model struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -4,11 +4,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, sort string, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||||
if len(productIds) == 0 {
|
if len(productIds) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1)
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1)
|
||||||
|
if sort != "" {
|
||||||
|
db = db.Order(sort)
|
||||||
|
}
|
||||||
if len(fields) != 0 {
|
if len(fields) != 0 {
|
||||||
db = db.Select(fields[0])
|
db = db.Select(fields[0])
|
||||||
}
|
}
|
||||||
@ -38,7 +41,7 @@ func (t *FsProductTemplateV2Model) FindAllByIdsWithoutStatus(ctx context.Context
|
|||||||
}
|
}
|
||||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp *FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp *FsProductTemplateV2, err error) {
|
||||||
|
|
||||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Find(&resp).Error
|
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Take(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
func (t *FsProductTemplateV2Model) FindByParam(ctx context.Context, id int64, modelId int64, fields ...string) (resp *FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) FindByParam(ctx context.Context, id int64, modelId int64, fields ...string) (resp *FsProductTemplateV2, err error) {
|
||||||
@ -118,7 +121,7 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont
|
|||||||
Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag).
|
Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag).
|
||||||
Where("t.status = ? and t.is_del = ?", 1, 0).
|
Where("t.status = ? and t.is_del = ?", 1, 0).
|
||||||
Where("s.status = ?", 1).
|
Where("s.status = ?", 1).
|
||||||
Order("s.sort ASC").
|
Order("t.sort ASC,s.sort ASC").
|
||||||
Take(&resp).Error
|
Take(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
@ -150,3 +153,17 @@ func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Co
|
|||||||
err = db.Find(&resp).Error
|
err = db.Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
func (t *FsProductTemplateV2Model) FindAllByProductIdsTemplateTag(ctx context.Context, productIds []int64, templateTag string, sort string, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||||
|
if len(productIds) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `template_tag` = ? and `is_del` = ? and `status` = ?", productIds, templateTag, 0, 1)
|
||||||
|
if sort != "" {
|
||||||
|
db = db.Order(sort)
|
||||||
|
}
|
||||||
|
if len(fields) != 0 {
|
||||||
|
db = db.Select(fields[0])
|
||||||
|
}
|
||||||
|
err = db.Find(&resp).Error
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
@ -11,8 +11,8 @@ type FsQrcodeLog struct {
|
|||||||
QrcodeId *int64 `gorm:"default:0;" json:"qrcode_id"` // 二维码ID
|
QrcodeId *int64 `gorm:"default:0;" json:"qrcode_id"` // 二维码ID
|
||||||
TagId *int64 `gorm:"default:0;" json:"tag_id"` // 分组ID
|
TagId *int64 `gorm:"default:0;" json:"tag_id"` // 分组ID
|
||||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
|
||||||
Platform *string `gorm:"default:'';" json:"platform"` //
|
Platform *string `gorm:"default:'';" json:"platform"` // 系统信息
|
||||||
UserAgent *string `gorm:"default:'';" json:"user_agent"` //
|
UserAgent *string `gorm:"default:'';" json:"user_agent"` // 浏览器
|
||||||
}
|
}
|
||||||
type FsQrcodeLogModel struct {
|
type FsQrcodeLogModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -19,7 +19,6 @@ type FsQuotation struct {
|
|||||||
DesignId *int64 `gorm:"default:0;" json:"design_id"` // 设计人员
|
DesignId *int64 `gorm:"default:0;" json:"design_id"` // 设计人员
|
||||||
QuotationId *int64 `gorm:"default:0;" json:"quotation_id"` // 报价人员
|
QuotationId *int64 `gorm:"default:0;" json:"quotation_id"` // 报价人员
|
||||||
IsMark *int64 `gorm:"default:0;" json:"is_mark"` // 星标
|
IsMark *int64 `gorm:"default:0;" json:"is_mark"` // 星标
|
||||||
Qid *int64 `gorm:"default:0;" json:"qid"` //
|
|
||||||
}
|
}
|
||||||
type FsQuotationModel struct {
|
type FsQuotationModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
23
model/gmodel/fs_quotation_price_gen.go
Normal file
23
model/gmodel/fs_quotation_price_gen.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_quotation_price 报价单价格表
|
||||||
|
type FsQuotationPrice struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Id
|
||||||
|
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
|
||||||
|
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id
|
||||||
|
PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格数据
|
||||||
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态 1启用0废弃
|
||||||
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
|
}
|
||||||
|
type FsQuotationPriceModel struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsQuotationPriceModel(db *gorm.DB) *FsQuotationPriceModel {
|
||||||
|
return &FsQuotationPriceModel{db: db, name: "fs_quotation_price"}
|
||||||
|
}
|
2
model/gmodel/fs_quotation_price_logic.go
Normal file
2
model/gmodel/fs_quotation_price_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
@ -20,6 +20,9 @@ type FsQuotationProduct struct {
|
|||||||
PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格信息
|
PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格信息
|
||||||
Remark *string `gorm:"default:'';" json:"remark"` // 备注
|
Remark *string `gorm:"default:'';" json:"remark"` // 备注
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 产品数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 产品数量
|
||||||
|
ShowSizeTips *int64 `gorm:"default:0;" json:"show_size_tips"` // 是否显示提示
|
||||||
|
ShowSizeList *int64 `gorm:"default:0;" json:"show_size_list"` // 是否显示规格列表
|
||||||
|
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
|
||||||
}
|
}
|
||||||
type FsQuotationProductModel struct {
|
type FsQuotationProductModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
22
model/gmodel/fs_quotation_size_layout_gen.go
Normal file
22
model/gmodel/fs_quotation_size_layout_gen.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package gmodel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// fs_quotation_size_layout 产品尺寸排版表
|
||||||
|
type FsQuotationSizeLayout struct {
|
||||||
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
|
ProductId *int64 `gorm:"unique_key;default:0;" json:"product_id"` // 产品id
|
||||||
|
SizeHtml *string `gorm:"default:'';" json:"size_html"` // 尺寸排版html
|
||||||
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态
|
||||||
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
|
}
|
||||||
|
type FsQuotationSizeLayoutModel struct {
|
||||||
|
db *gorm.DB
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFsQuotationSizeLayoutModel(db *gorm.DB) *FsQuotationSizeLayoutModel {
|
||||||
|
return &FsQuotationSizeLayoutModel{db: db, name: "fs_quotation_size_layout"}
|
||||||
|
}
|
2
model/gmodel/fs_quotation_size_layout_logic.go
Normal file
2
model/gmodel/fs_quotation_size_layout_logic.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
package gmodel
|
||||||
|
// TODO: 使用model的属性做你想做的
|
@ -13,7 +13,7 @@ type FsResource struct {
|
|||||||
ResourceType *string `gorm:"index;default:'';" json:"resource_type"` // 资源类型
|
ResourceType *string `gorm:"index;default:'';" json:"resource_type"` // 资源类型
|
||||||
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
|
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
|
||||||
Version *string `gorm:"index;default:'0';" json:"version"` // 版本信息
|
Version *string `gorm:"index;default:'0';" json:"version"` // 版本信息
|
||||||
UploadedAt *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"uploaded_at"` // 上传时间
|
UploadedAt *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"uploaded_at"` //
|
||||||
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
||||||
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
|
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
|
||||||
ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内
|
ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内
|
||||||
|
@ -13,10 +13,10 @@ type FsTrade struct {
|
|||||||
TradeSn *string `gorm:"unique_key;default:'';" json:"trade_sn"` // 三方交易号
|
TradeSn *string `gorm:"unique_key;default:'';" json:"trade_sn"` // 三方交易号
|
||||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID
|
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID
|
||||||
Amount *int64 `gorm:"default:0;" json:"amount"` // 支付金额
|
Amount *int64 `gorm:"default:0;" json:"amount"` // 支付金额
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Utime *int64 `gorm:"default:0;" json:"utime"` //
|
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
||||||
Desc *string `gorm:"default:'';" json:"desc"` //
|
Desc *string `gorm:"default:'';" json:"desc"` // 简要描述
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` //
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否支付成功
|
||||||
}
|
}
|
||||||
type FsTradeModel struct {
|
type FsTradeModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
// fs_user_design 废弃表
|
// fs_user_design 废弃表
|
||||||
type FsUserDesign struct {
|
type FsUserDesign struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
|
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
|
||||||
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
|
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
|
||||||
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
|
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
|
||||||
Info *string `gorm:"default:'';" json:"info"` // 其他设计信息
|
Info *string `gorm:"default:'';" json:"info"` // 其他设计信息
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
type FsUserDesignModel struct {
|
type FsUserDesignModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -9,11 +9,11 @@ type FsUser struct {
|
|||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||||
FaceId *int64 `gorm:"default:0;" json:"face_id"` // facebook的userid
|
FaceId *int64 `gorm:"default:0;" json:"face_id"` // facebook的userid
|
||||||
GoogleId *int64 `gorm:"default:0;" json:"google_id"` // google的sub
|
GoogleId *int64 `gorm:"default:0;" json:"google_id"` // google的sub
|
||||||
FirstName *string `gorm:"default:'';" json:"first_name"` //
|
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
|
||||||
LastName *string `gorm:"default:'';" json:"last_name"` //
|
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
|
||||||
Username *string `gorm:"unique_key;default:'';" json:"username"` //
|
Username *string `gorm:"unique_key;default:'';" json:"username"` //
|
||||||
Company *string `gorm:"default:'';" json:"company"` //
|
Company *string `gorm:"default:'';" json:"company"` // 公司名称
|
||||||
Mobile *string `gorm:"default:'';" json:"mobile"` //
|
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
|
||||||
AuthKey *string `gorm:"default:'';" json:"auth_key"` //
|
AuthKey *string `gorm:"default:'';" json:"auth_key"` //
|
||||||
PasswordHash *string `gorm:"default:'';" json:"password_hash"` //
|
PasswordHash *string `gorm:"default:'';" json:"password_hash"` //
|
||||||
VerificationToken *string `gorm:"default:'';" json:"verification_token"` //
|
VerificationToken *string `gorm:"default:'';" json:"verification_token"` //
|
||||||
@ -30,7 +30,7 @@ type FsUser struct {
|
|||||||
IsPhoneAdvertisement *int64 `gorm:"default:0;" json:"is_phone_advertisement"` // 是否接收短信广告
|
IsPhoneAdvertisement *int64 `gorm:"default:0;" json:"is_phone_advertisement"` // 是否接收短信广告
|
||||||
IsOpenRender *int64 `gorm:"default:0;" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭)
|
IsOpenRender *int64 `gorm:"default:0;" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭)
|
||||||
IsThousandFace *int64 `gorm:"default:0;" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在)
|
IsThousandFace *int64 `gorm:"default:0;" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在)
|
||||||
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` // 是否开启低渲染模型渲染
|
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` //
|
||||||
IsRemoveBg *int64 `gorm:"default:1;" json:"is_remove_bg"` // 用户上传logo是否去除背景
|
IsRemoveBg *int64 `gorm:"default:1;" json:"is_remove_bg"` // 用户上传logo是否去除背景
|
||||||
}
|
}
|
||||||
type FsUserModel struct {
|
type FsUserModel struct {
|
||||||
|
@ -58,9 +58,6 @@ func (m *FsUserMaterialModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
|||||||
|
|
||||||
// 获取最新记录
|
// 获取最新记录
|
||||||
func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, guestId int64) (resp FsUserMaterial, err error) {
|
func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, guestId int64) (resp FsUserMaterial, err error) {
|
||||||
if userId == 0 && guestId == 0 {
|
|
||||||
return FsUserMaterial{}, nil
|
|
||||||
}
|
|
||||||
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).
|
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).
|
||||||
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).
|
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).
|
||||||
Order("id DESC")
|
Order("id DESC")
|
||||||
|
@ -43,6 +43,7 @@ type AllModelsGen struct {
|
|||||||
FsGerent *FsGerentModel // fs_gerent 管理员表
|
FsGerent *FsGerentModel // fs_gerent 管理员表
|
||||||
FsGuest *FsGuestModel // fs_guest 游客表
|
FsGuest *FsGuestModel // fs_guest 游客表
|
||||||
FsLog *FsLogModel // fs_log 日志表
|
FsLog *FsLogModel // fs_log 日志表
|
||||||
|
FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表
|
||||||
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
|
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
|
||||||
FsMenu *FsMenuModel // fs_menu 后台菜单
|
FsMenu *FsMenuModel // fs_menu 后台菜单
|
||||||
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
||||||
@ -69,6 +70,10 @@ type AllModelsGen struct {
|
|||||||
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
|
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
|
||||||
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
|
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
|
||||||
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
|
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
|
||||||
|
FsProductTemplateElement0826 *FsProductTemplateElement0826Model // fs_product_template_element_0826
|
||||||
|
FsProductTemplateElement22 *FsProductTemplateElement22Model // fs_product_template_element_22
|
||||||
|
FsProductTemplateElementBackup1018 *FsProductTemplateElementBackup1018Model // fs_product_template_element_backup1018
|
||||||
|
FsProductTemplateElementKongde *FsProductTemplateElementKongdeModel // fs_product_template_element_kongde
|
||||||
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
|
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
|
||||||
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
|
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
|
||||||
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
|
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
|
||||||
@ -77,9 +82,11 @@ type AllModelsGen struct {
|
|||||||
FsQrcodeSet *FsQrcodeSetModel // fs_qrcode_set 二维码边框配置表
|
FsQrcodeSet *FsQrcodeSetModel // fs_qrcode_set 二维码边框配置表
|
||||||
FsQrcodeUser *FsQrcodeUserModel // fs_qrcode_user 二维码-用户名表
|
FsQrcodeUser *FsQrcodeUserModel // fs_qrcode_user 二维码-用户名表
|
||||||
FsQuotation *FsQuotationModel // fs_quotation 报价单信息表
|
FsQuotation *FsQuotationModel // fs_quotation 报价单信息表
|
||||||
|
FsQuotationPrice *FsQuotationPriceModel // fs_quotation_price 报价单价格表
|
||||||
FsQuotationProduct *FsQuotationProductModel // fs_quotation_product 报价单产品表
|
FsQuotationProduct *FsQuotationProductModel // fs_quotation_product 报价单产品表
|
||||||
FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板
|
FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板
|
||||||
FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表
|
FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表
|
||||||
|
FsQuotationSizeLayout *FsQuotationSizeLayoutModel // fs_quotation_size_layout 产品尺寸排版表
|
||||||
FsRefundReason *FsRefundReasonModel // fs_refund_reason
|
FsRefundReason *FsRefundReasonModel // fs_refund_reason
|
||||||
FsResource *FsResourceModel // fs_resource 资源表
|
FsResource *FsResourceModel // fs_resource 资源表
|
||||||
FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo
|
FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo
|
||||||
@ -138,6 +145,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsGerent: NewFsGerentModel(gdb),
|
FsGerent: NewFsGerentModel(gdb),
|
||||||
FsGuest: NewFsGuestModel(gdb),
|
FsGuest: NewFsGuestModel(gdb),
|
||||||
FsLog: NewFsLogModel(gdb),
|
FsLog: NewFsLogModel(gdb),
|
||||||
|
FsLogoCartoon: NewFsLogoCartoonModel(gdb),
|
||||||
FsMapLibrary: NewFsMapLibraryModel(gdb),
|
FsMapLibrary: NewFsMapLibraryModel(gdb),
|
||||||
FsMenu: NewFsMenuModel(gdb),
|
FsMenu: NewFsMenuModel(gdb),
|
||||||
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
||||||
@ -164,6 +172,10 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsProductTemplate: NewFsProductTemplateModel(gdb),
|
FsProductTemplate: NewFsProductTemplateModel(gdb),
|
||||||
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
|
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
|
||||||
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
|
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
|
||||||
|
FsProductTemplateElement0826: NewFsProductTemplateElement0826Model(gdb),
|
||||||
|
FsProductTemplateElement22: NewFsProductTemplateElement22Model(gdb),
|
||||||
|
FsProductTemplateElementBackup1018: NewFsProductTemplateElementBackup1018Model(gdb),
|
||||||
|
FsProductTemplateElementKongde: NewFsProductTemplateElementKongdeModel(gdb),
|
||||||
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
|
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
|
||||||
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
|
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
|
||||||
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
|
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
|
||||||
@ -172,9 +184,11 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsQrcodeSet: NewFsQrcodeSetModel(gdb),
|
FsQrcodeSet: NewFsQrcodeSetModel(gdb),
|
||||||
FsQrcodeUser: NewFsQrcodeUserModel(gdb),
|
FsQrcodeUser: NewFsQrcodeUserModel(gdb),
|
||||||
FsQuotation: NewFsQuotationModel(gdb),
|
FsQuotation: NewFsQuotationModel(gdb),
|
||||||
|
FsQuotationPrice: NewFsQuotationPriceModel(gdb),
|
||||||
FsQuotationProduct: NewFsQuotationProductModel(gdb),
|
FsQuotationProduct: NewFsQuotationProductModel(gdb),
|
||||||
FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb),
|
FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb),
|
||||||
FsQuotationSaler: NewFsQuotationSalerModel(gdb),
|
FsQuotationSaler: NewFsQuotationSalerModel(gdb),
|
||||||
|
FsQuotationSizeLayout: NewFsQuotationSizeLayoutModel(gdb),
|
||||||
FsRefundReason: NewFsRefundReasonModel(gdb),
|
FsRefundReason: NewFsRefundReasonModel(gdb),
|
||||||
FsResource: NewFsResourceModel(gdb),
|
FsResource: NewFsResourceModel(gdb),
|
||||||
FsStandardLogo: NewFsStandardLogoModel(gdb),
|
FsStandardLogo: NewFsStandardLogoModel(gdb),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -41,6 +42,8 @@ func SetCors(w http.ResponseWriter, r *http.Request) {
|
|||||||
var pathdict sync.Map = sync.Map{}
|
var pathdict sync.Map = sync.Map{}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
log.SetFlags(log.Llongfile)
|
||||||
|
|
||||||
// 将静态资源路径存储到pathdict
|
// 将静态资源路径存储到pathdict
|
||||||
pathdict.Store("/css", true)
|
pathdict.Store("/css", true)
|
||||||
pathdict.Store("/fonts", true)
|
pathdict.Store("/fonts", true)
|
||||||
@ -81,6 +84,12 @@ func main() {
|
|||||||
fs := http.FileServer(http.Dir(vueBuild))
|
fs := http.FileServer(http.Dir(vueBuild))
|
||||||
indexHtmlPath := vueBuild + "/index.html"
|
indexHtmlPath := vueBuild + "/index.html"
|
||||||
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
err := r.ParseMultipartForm(100 << 20)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(r.URL.Path, "/api/") {
|
if strings.HasPrefix(r.URL.Path, "/api/") {
|
||||||
// 对/api开头的请求进行反向代理
|
// 对/api开头的请求进行反向代理
|
||||||
proxy := httputil.NewSingleHostReverseProxy(apiURL)
|
proxy := httputil.NewSingleHostReverseProxy(apiURL)
|
||||||
@ -108,7 +117,34 @@ func main() {
|
|||||||
|
|
||||||
ServerAddress := ":9900"
|
ServerAddress := ":9900"
|
||||||
log.Println("listen on ", ServerAddress)
|
log.Println("listen on ", ServerAddress)
|
||||||
log.Fatal(http.ListenAndServe(ServerAddress, mux))
|
|
||||||
|
keydata, err := os.ReadFile("/opt/server.fusen.3718.cn.key")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pemdata, err := os.ReadFile("/opt/server.fusen.3718.cn.pem")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cert, err := tls.X509KeyPair(pemdata, keydata)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tlscfg := &tls.Config{
|
||||||
|
Certificates: []tls.Certificate{cert},
|
||||||
|
MinVersion: tls.VersionTLS12,
|
||||||
|
MaxVersion: tls.VersionTLS13,
|
||||||
|
}
|
||||||
|
serv := http.Server{
|
||||||
|
Addr: ServerAddress,
|
||||||
|
Handler: mux,
|
||||||
|
TLSConfig: tlscfg,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Fatal(serv.ListenAndServeTLS("", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 后端服务的类型
|
// 后端服务的类型
|
||||||
@ -132,14 +168,14 @@ func NewBackend(mux *http.ServeMux, httpAddress string, muxPaths ...string) *Bac
|
|||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
DialContext: (&net.Dialer{
|
DialContext: (&net.Dialer{
|
||||||
Timeout: 60 * time.Second,
|
Timeout: 300 * time.Second,
|
||||||
KeepAlive: 60 * time.Second,
|
KeepAlive: 60 * time.Second,
|
||||||
}).DialContext,
|
}).DialContext,
|
||||||
ForceAttemptHTTP2: true,
|
ForceAttemptHTTP2: true,
|
||||||
MaxIdleConns: 100,
|
MaxIdleConns: 100,
|
||||||
MaxIdleConnsPerHost: 100,
|
MaxIdleConnsPerHost: 100,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 300 * time.Second,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 300 * time.Second,
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us
|
|||||||
partIds = append(partIds, *v.PartId)
|
partIds = append(partIds, *v.PartId)
|
||||||
}
|
}
|
||||||
//获取配件数据
|
//获取配件数据
|
||||||
fittingList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, partIds, "is_popular DESC,price ASC")
|
fittingList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, partIds, "is_hot DESC,price ASC")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get part list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get part list")
|
||||||
@ -110,7 +110,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us
|
|||||||
Title: *fitting.Title,
|
Title: *fitting.Title,
|
||||||
Price: *fitting.Price,
|
Price: *fitting.Price,
|
||||||
ModelInfo: modelInfo,
|
ModelInfo: modelInfo,
|
||||||
IsPopular: *fitting.IsPopular > 0,
|
IsPopular: *fitting.IsHot > 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
||||||
|
@ -99,7 +99,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
|||||||
}
|
}
|
||||||
//获取模板
|
//获取模板
|
||||||
productTemplateModel := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
productTemplateModel := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||||
productTemplatesV2, err := productTemplateModel.FindAllByProductIds(l.ctx, productIds)
|
productTemplatesV2, err := productTemplateModel.FindAllByProductIds(l.ctx, productIds, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")
|
||||||
|
@ -48,7 +48,7 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
|||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
|
||||||
}
|
}
|
||||||
//获取产品尺寸列表(需要正序排序)
|
//获取产品尺寸列表(需要正序排序)
|
||||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "is_popular DESC,sort ASC")
|
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "is_hot DESC,sort ASC")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list")
|
||||||
@ -118,7 +118,7 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
|||||||
Cover: *sizeInfo.Cover,
|
Cover: *sizeInfo.Cover,
|
||||||
PartsCanDeleted: *sizeInfo.PartsCanDeleted > 0,
|
PartsCanDeleted: *sizeInfo.PartsCanDeleted > 0,
|
||||||
ModelId: modelList[modelIndex].Id,
|
ModelId: modelList[modelIndex].Id,
|
||||||
IsPopular: *sizeInfo.IsPopular > 0,
|
IsPopular: *sizeInfo.IsHot > 0,
|
||||||
MinPrice: float64(minPrice) / 100,
|
MinPrice: float64(minPrice) / 100,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info")
|
||||||
}
|
}
|
||||||
|
//前台用的分类是1
|
||||||
if *tagData.Category != 1 {
|
if *tagData.Category != 1 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag")
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方)
|
productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方)
|
||||||
productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方)
|
productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方)
|
||||||
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
||||||
mapProductTemplate = make(map[int64]struct{}) //产品模板map
|
mapProductTemplate = make(map[int64]int64) //产品模板map
|
||||||
)
|
)
|
||||||
//携带产品
|
//携带产品
|
||||||
if req.WithProduct {
|
if req.WithProduct {
|
||||||
@ -169,14 +170,22 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
|
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取模板(只是获取产品product_id)
|
//获取模板(只是获取产品product_id,id)
|
||||||
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "product_id")
|
if req.TemplateTag != "" { //指定模板tag
|
||||||
|
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIdsTemplateTag(l.ctx, productIds, req.TemplateTag, "sort ASC", "product_id,id")
|
||||||
|
} else { //没指定模板tag
|
||||||
|
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id,id")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product templates")
|
||||||
}
|
}
|
||||||
|
//只存第一个
|
||||||
for _, v := range productTemplatesV2 {
|
for _, v := range productTemplatesV2 {
|
||||||
mapProductTemplate[*v.ProductId] = struct{}{}
|
if _, ok := mapProductTemplate[*v.ProductId]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mapProductTemplate[*v.ProductId] = v.Id
|
||||||
}
|
}
|
||||||
//获取产品尺寸数量
|
//获取产品尺寸数量
|
||||||
productSizeCountList, err = l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1)
|
productSizeCountList, err = l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1)
|
||||||
@ -209,9 +218,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
|
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
|
||||||
}
|
}
|
||||||
|
//组装等级从属关系
|
||||||
|
rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel)
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
|
||||||
TotalCategoryProduct: len(productList),
|
TotalCategoryProduct: TotalCategoryProduct,
|
||||||
TagList: l.organizationLevelRelation(minLevel, mapTagLevel), //组装等级从属关系
|
TagList: rspTagList,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +234,7 @@ type dealWithTagMenuDataReq struct {
|
|||||||
MapTagProp map[int64][]types.CoverDefaultItem
|
MapTagProp map[int64][]types.CoverDefaultItem
|
||||||
ProductTagPropList []gmodel.FsProductTagProp
|
ProductTagPropList []gmodel.FsProductTagProp
|
||||||
MapProductMinPrice map[int64]int64
|
MapProductMinPrice map[int64]int64
|
||||||
MapProductTemplate map[int64]struct{}
|
MapProductTemplate map[int64]int64
|
||||||
MapProductSizeCount map[int64]int64
|
MapProductSizeCount map[int64]int64
|
||||||
MapTagLevel map[string]*types.TagItem
|
MapTagLevel map[string]*types.TagItem
|
||||||
MapProductHaveOptionFitting map[int64]struct{}
|
MapProductHaveOptionFitting map[int64]struct{}
|
||||||
@ -274,7 +285,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 组织等级从属关系
|
// 组织等级从属关系
|
||||||
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) []types.TagItem {
|
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) (rspTagList []types.TagItem, productCount int) {
|
||||||
mapTop := make(map[string]struct{})
|
mapTop := make(map[string]struct{})
|
||||||
//设置归属关系
|
//设置归属关系
|
||||||
for prefix, tagItem := range mapTagLevel {
|
for prefix, tagItem := range mapTagLevel {
|
||||||
@ -316,22 +327,23 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
|
|||||||
if len(mapTagLevel[prefix].TagProductList) == 0 {
|
if len(mapTagLevel[prefix].TagProductList) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
productCount += len(mapTagLevel[prefix].TagProductList)
|
||||||
rspList = append(rspList, *mapTagLevel[prefix])
|
rspList = append(rspList, *mapTagLevel[prefix])
|
||||||
}
|
}
|
||||||
//排序
|
//排序
|
||||||
sort.SliceStable(rspList, func(i, j int) bool {
|
sort.SliceStable(rspList, func(i, j int) bool {
|
||||||
return rspList[i].Sort < rspList[j].Sort
|
return rspList[i].Sort < rspList[j].Sort
|
||||||
})
|
})
|
||||||
return rspList
|
return rspList, productCount
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取对应tag的产品列表
|
// 获取某个tag的直属产品
|
||||||
type getTagProductsReq struct {
|
type getTagProductsReq struct {
|
||||||
TagId int64
|
TagId int64
|
||||||
ProductList []gmodel.FsProduct
|
ProductList []gmodel.FsProduct
|
||||||
MapTagProp map[int64][]types.CoverDefaultItem
|
MapTagProp map[int64][]types.CoverDefaultItem
|
||||||
MapProductMinPrice map[int64]int64
|
MapProductMinPrice map[int64]int64
|
||||||
MapProductTemplate map[int64]struct{}
|
MapProductTemplate map[int64]int64
|
||||||
MapProductSizeCount map[int64]int64
|
MapProductSizeCount map[int64]int64
|
||||||
MapProductHaveOptionFitting map[int64]struct{}
|
MapProductHaveOptionFitting map[int64]struct{}
|
||||||
Size uint32
|
Size uint32
|
||||||
@ -347,7 +359,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
|
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
|
||||||
_, tmpOk := req.MapProductTemplate[productInfo.Id]
|
templateId, tmpOk := req.MapProductTemplate[productInfo.Id]
|
||||||
//无最小价格则不显示 || 没有模板也不显示
|
//无最小价格则不显示 || 没有模板也不显示
|
||||||
if !ok || !tmpOk {
|
if !ok || !tmpOk {
|
||||||
continue
|
continue
|
||||||
@ -367,6 +379,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
|||||||
Title: *productInfo.Title,
|
Title: *productInfo.Title,
|
||||||
SizeNum: uint32(sizeNum),
|
SizeNum: uint32(sizeNum),
|
||||||
CoverDefault: []types.CoverDefaultItem{},
|
CoverDefault: []types.CoverDefaultItem{},
|
||||||
|
DefaultTemplateId: templateId,
|
||||||
MinPrice: minPrice,
|
MinPrice: minPrice,
|
||||||
HaveOptionalFitting: haveOptionalFitting,
|
HaveOptionalFitting: haveOptionalFitting,
|
||||||
Recommended: *productInfo.IsRecommend > 0,
|
Recommended: *productInfo.IsRecommend > 0,
|
||||||
|
@ -37,8 +37,8 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||||||
if req.Pid == "" {
|
if req.Pid == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty")
|
||||||
}
|
}
|
||||||
if req.ProductTemplateTagId <= 0 {
|
if req.TemplateTag == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag")
|
||||||
}
|
}
|
||||||
//获取产品信息(只获取id)
|
//获取产品信息(只获取id)
|
||||||
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
|
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
|
||||||
@ -67,15 +67,6 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||||||
} else { //指定物料
|
} else { //指定物料
|
||||||
sizeIds = append(sizeIds, req.ProductSizeId)
|
sizeIds = append(sizeIds, req.ProductSizeId)
|
||||||
}
|
}
|
||||||
//获取templatetag信息
|
|
||||||
templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOne(l.ctx, req.ProductTemplateTagId)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag is not exists")
|
|
||||||
}
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get template tag")
|
|
||||||
}
|
|
||||||
//根据尺寸id获取模型
|
//根据尺寸id获取模型
|
||||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
|
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -92,7 +83,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||||||
mapModel[v.Id] = k
|
mapModel[v.Id] = k
|
||||||
}
|
}
|
||||||
//查询模型ids下对应tag标签的模板
|
//查询模型ids下对应tag标签的模板
|
||||||
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, *templateTagInfo.TemplateTag, "")
|
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, req.TemplateTag, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
|
||||||
@ -113,17 +104,42 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, fmt.Sprintf("failed to parse json product template info(may be old data):%d", templateInfo.Id))
|
return resp.SetStatusWithMessage(basic.CodeJsonErr, fmt.Sprintf("failed to parse json product template info(may be old data):%d", templateInfo.Id))
|
||||||
}
|
}
|
||||||
//后台隐藏/显示信息
|
//后台隐藏/显示信息(现在下面是写死了)
|
||||||
var switchInfo interface{}
|
/*var switchInfo interface{}
|
||||||
if templateInfo.SwitchInfo != nil && *templateInfo.SwitchInfo != "" {
|
if templateInfo.SwitchInfo != nil && *templateInfo.SwitchInfo != "" {
|
||||||
_ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo)
|
_ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo)
|
||||||
}
|
}*/
|
||||||
modelInfo := modelList[modelIndex]
|
modelInfo := modelList[modelIndex]
|
||||||
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
|
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
|
||||||
rsp[mapKey] = map[string]interface{}{
|
rsp[mapKey] = map[string]interface{}{
|
||||||
"id": templateInfo.Id,
|
"id": templateInfo.Id,
|
||||||
"material": *templateInfo.MaterialImg,
|
"material": *templateInfo.MaterialImg,
|
||||||
"material_data": switchInfo,
|
//写死的数据
|
||||||
|
"material_data": map[string]interface{}{
|
||||||
|
"QRcode": map[string]interface{}{
|
||||||
|
"if_show": true,
|
||||||
|
"text": "1111",
|
||||||
|
"default_value": "11111",
|
||||||
|
},
|
||||||
|
"Website": map[string]interface{}{
|
||||||
|
"if_show": true,
|
||||||
|
"text": "2222",
|
||||||
|
"default_value": "2222",
|
||||||
|
},
|
||||||
|
"Address": map[string]interface{}{
|
||||||
|
"if_show": true,
|
||||||
|
"text": "address",
|
||||||
|
"default_value": "address",
|
||||||
|
},
|
||||||
|
"Phone": map[string]interface{}{
|
||||||
|
"if_show": true,
|
||||||
|
"text": "phone",
|
||||||
|
"default_value": "默认phone",
|
||||||
|
},
|
||||||
|
"Logo": map[string]interface{}{
|
||||||
|
"material": "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp)
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp)
|
||||||
|
@ -130,7 +130,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取模板(只是获取产品product_id)
|
//获取模板(只是获取产品product_id)
|
||||||
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "product_id")
|
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "", "product_id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")
|
||||||
|
@ -249,6 +249,7 @@ type GetRecommandProductListRsp struct {
|
|||||||
type GetTagProductListReq struct {
|
type GetTagProductListReq struct {
|
||||||
Cid int64 `form:"cid,optional"` //分类id
|
Cid int64 `form:"cid,optional"` //分类id
|
||||||
Size uint32 `form:"size,optional"` //尺寸
|
Size uint32 `form:"size,optional"` //尺寸
|
||||||
|
TemplateTag string `form:"template_tag,optional"` //模板标签
|
||||||
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +276,7 @@ type TagProduct struct {
|
|||||||
SizeNum uint32 `json:"size_num"`
|
SizeNum uint32 `json:"size_num"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
|
DefaultTemplateId int64 `json:"default_template_id"`
|
||||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
Recommended bool `json:"recommended"`
|
Recommended bool `json:"recommended"`
|
||||||
}
|
}
|
||||||
@ -342,7 +344,7 @@ type GetSizeByPidRsp struct {
|
|||||||
type GetTemplateByPidReq struct {
|
type GetTemplateByPidReq struct {
|
||||||
Pid string `form:"pid"`
|
Pid string `form:"pid"`
|
||||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
ProductSizeId int64 `form:"product_size_id,optional"`
|
||||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
TemplateTag string `form:"template_tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetFittingByPidReq struct {
|
type GetFittingByPidReq struct {
|
||||||
|
@ -2,7 +2,7 @@ Name: resource
|
|||||||
Host: 0.0.0.0
|
Host: 0.0.0.0
|
||||||
Port: 9916
|
Port: 9916
|
||||||
ReplicaId: 60
|
ReplicaId: 60
|
||||||
Timeout: 15000 #服务超时时间(毫秒)
|
Timeout: 150000 #服务超时时间(毫秒)
|
||||||
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
|
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
|
||||||
Auth:
|
Auth:
|
||||||
AccessSecret: fusen2023
|
AccessSecret: fusen2023
|
||||||
|
35
server/resource/internal/handler/logoremovebghandler.go
Normal file
35
server/resource/internal/handler/logoremovebghandler.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/resource/internal/logic"
|
||||||
|
"fusenapi/server/resource/internal/svc"
|
||||||
|
"fusenapi/server/resource/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LogoRemovebgHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.LogoRemovebgReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewLogoRemovebgLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.LogoRemovebg(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/resource/logo-combine",
|
Path: "/api/resource/logo-combine",
|
||||||
Handler: LogoCombineHandler(serverCtx),
|
Handler: LogoCombineHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/resource/logo-removebg",
|
||||||
|
Handler: LogoRemovebgHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/api/resource/info",
|
Path: "/api/resource/info",
|
||||||
|
61
server/resource/internal/logic/logoremovebglogic.go
Normal file
61
server/resource/internal/logic/logoremovebglogic.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/service/repositories"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/resource/internal/svc"
|
||||||
|
"fusenapi/server/resource/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogoRemovebgLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLogoRemovebgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoRemovebgLogic {
|
||||||
|
return &LogoRemovebgLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *LogoRemovebgLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *LogoRemovebgLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *LogoRemovebgLogic) LogoRemovebg(req *types.LogoRemovebgReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
|
// userinfo 传入值时, 一定不为null
|
||||||
|
res, err := l.svcCtx.Repositories.ImageHandle.LogoStandard(l.ctx, &repositories.LogoStandardReq{
|
||||||
|
IsRemoveBg: req.IsRemoveBg,
|
||||||
|
LogoFile: req.LogoFile,
|
||||||
|
Width: req.Width,
|
||||||
|
Height: req.Height,
|
||||||
|
Proportion: req.Proportion,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return resp.SetStatus(basic.CodeServiceErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回成功的响应和上传URL
|
||||||
|
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
|
||||||
|
"resource_id": res.ResourceId,
|
||||||
|
"resource_url": res.ResourceUrl,
|
||||||
|
"ismax_proportion": res.IsmaxProportion,
|
||||||
|
"img_color": res.ImgColor,
|
||||||
|
})
|
||||||
|
}
|
@ -5,6 +5,14 @@ import (
|
|||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type LogoRemovebgReq struct {
|
||||||
|
IsRemoveBg string `form:"is_remove_bg"`
|
||||||
|
LogoFile string `form:"logo_file"`
|
||||||
|
Width string `form:"width"`
|
||||||
|
Height string `form:"height"`
|
||||||
|
Proportion int64 `form:"proportion"`
|
||||||
|
}
|
||||||
|
|
||||||
type ResourceInfoReq struct {
|
type ResourceInfoReq struct {
|
||||||
ResourceId string `form:"resource_id,optional"` // 资源ID
|
ResourceId string `form:"resource_id,optional"` // 资源ID
|
||||||
ResourceKey string `form:"resource_key,optional"` // 资源唯一标识
|
ResourceKey string `form:"resource_key,optional"` // 资源唯一标识
|
||||||
|
@ -2,7 +2,8 @@ Name: upload
|
|||||||
Host: localhost
|
Host: localhost
|
||||||
Port: 9912
|
Port: 9912
|
||||||
ReplicaId: 70
|
ReplicaId: 70
|
||||||
Timeout: 15000 #服务超时时间
|
Timeout: 150000 #服务超时时间
|
||||||
|
MaxBytes: 104857600 #传输字节大小
|
||||||
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
|
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
|
||||||
Env: "test"
|
Env: "test"
|
||||||
Auth:
|
Auth:
|
||||||
|
@ -57,6 +57,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/upload/upload-file-base",
|
Path: "/api/upload/upload-file-base",
|
||||||
Handler: UploadFileBaseHandler(serverCtx),
|
Handler: UploadFileBaseHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/upload/up-standard-logo",
|
||||||
|
Handler: UploadLogoStandardHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
35
server/upload/internal/handler/uploadlogostandardhandler.go
Normal file
35
server/upload/internal/handler/uploadlogostandardhandler.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/upload/internal/logic"
|
||||||
|
"fusenapi/server/upload/internal/svc"
|
||||||
|
"fusenapi/server/upload/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UploadLogoStandardHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.UploadLogoStandardReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewUploadLogoStandardLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.UploadLogoStandard(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
@ -95,6 +96,12 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||||||
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image")
|
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 限制上传文件大小 50k
|
||||||
|
// maxSize := 100 * 1024
|
||||||
|
// if fileHeader.Size > int64(maxSize) {
|
||||||
|
// return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,The file size exceeds the maximum limit of 100k")
|
||||||
|
// }
|
||||||
|
|
||||||
// 读取数据流
|
// 读取数据流
|
||||||
ioData, err := io.ReadAll(fileObject)
|
ioData, err := io.ReadAll(fileObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -124,6 +131,8 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||||||
return resp.SetStatus(basic.CodeFileUploadErr, "upload file failed")
|
return resp.SetStatus(basic.CodeFileUploadErr, "upload file failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logx.Infof("上传logo请求算法--开始时间:%v", time.Now())
|
||||||
|
|
||||||
var logoWidth int64
|
var logoWidth int64
|
||||||
var logoHeight int64
|
var logoHeight int64
|
||||||
// 查看sku是否存在
|
// 查看sku是否存在
|
||||||
@ -146,35 +155,39 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||||||
}
|
}
|
||||||
var resultStr string
|
var resultStr string
|
||||||
|
|
||||||
var postMap = make(map[string]interface{}, 1)
|
var postMap = make(map[string]string, 1)
|
||||||
postMap["logo_url"] = uploadRes.ResourceUrl
|
postMap["logo_url"] = uploadRes.ResourceUrl
|
||||||
postMapB, _ := json.Marshal(postMap)
|
postMapB, _ := json.Marshal(postMap)
|
||||||
|
fmt.Println(string(postMapB))
|
||||||
|
|
||||||
var headerData = make(map[string]string, 1)
|
var headerData = make(map[string]string, 1)
|
||||||
headerData["Content-Type"] = "application/json"
|
headerData["Content-Type"] = "application/json"
|
||||||
result, err := curl.ApiCall(l.svcCtx.Config.BLMService.ImageProcess.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20)
|
result, err := curl.ApiCall(l.svcCtx.Config.BLMService.ImageProcess.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Minute*5)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
|
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 01")
|
||||||
}
|
}
|
||||||
defer result.Body.Close()
|
defer result.Body.Close()
|
||||||
b, err := io.ReadAll(result.Body)
|
b, err := io.ReadAll(result.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
|
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 02")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logx.Infof("上传logo请求算法--结束时间:%v", time.Now())
|
||||||
|
logx.Infof("上传logo请求算法--返回结果:%v", string(b))
|
||||||
|
|
||||||
if string(b) == "Internal Server Error" {
|
if string(b) == "Internal Server Error" {
|
||||||
err = errors.New("BLMService fail Internal Server Error")
|
err = errors.New("BLMService fail Internal Server Error")
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
|
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 03")
|
||||||
} else {
|
} else {
|
||||||
var resData map[string]interface{}
|
var resData map[string]interface{}
|
||||||
err = json.Unmarshal(b, &resData)
|
err = json.Unmarshal(b, &resData)
|
||||||
if err != nil || resData == nil {
|
if err != nil || resData == nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
|
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 04")
|
||||||
}
|
}
|
||||||
|
|
||||||
if resData != nil {
|
if resData != nil {
|
||||||
@ -182,11 +195,11 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||||||
resultStr = resData["data"].(string)
|
resultStr = resData["data"].(string)
|
||||||
} else {
|
} else {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail")
|
return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail 05")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
|
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 06")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
server/upload/internal/logic/uploadlogostandardlogic.go
Normal file
43
server/upload/internal/logic/uploadlogostandardlogic.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/upload/internal/svc"
|
||||||
|
"fusenapi/server/upload/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UploadLogoStandardLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadLogoStandardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogoStandardLogic {
|
||||||
|
return &UploadLogoStandardLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *UploadLogoStandardLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *UploadLogoStandardLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *UploadLogoStandardLogic) UploadLogoStandard(req *types.UploadLogoStandardReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
}
|
@ -5,6 +5,14 @@ import (
|
|||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type UploadLogoStandardReq struct {
|
||||||
|
IsRemoveBg string `form:"is_remove_bg"`
|
||||||
|
LogoFile string `form:"logo_file"`
|
||||||
|
Width string `form:"width"`
|
||||||
|
Height string `form:"height"`
|
||||||
|
Proportion int64 `form:"proportion"`
|
||||||
|
}
|
||||||
|
|
||||||
type UploadFileBaseReq struct {
|
type UploadFileBaseReq struct {
|
||||||
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
||||||
FileKey string `form:"file_key"` // 上传唯一标识信息
|
FileKey string `form:"file_key"` // 上传唯一标识信息
|
||||||
|
@ -3,7 +3,6 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/id_generator"
|
"fusenapi/utils/id_generator"
|
||||||
@ -81,7 +80,13 @@ type wsConnectItem struct {
|
|||||||
renderProperty renderProperty //扩展云渲染属性
|
renderProperty renderProperty //扩展云渲染属性
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 请求建立连接,升级websocket协议
|
||||||
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
|
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
|
||||||
|
//把子协议携带的token设置到标准token头信息中
|
||||||
|
token := r.Header.Get("Sec-Websocket-Protocol")
|
||||||
|
r.Header.Set("Authorization", "Bearer "+token)
|
||||||
|
//设置Sec-Websocket-Protocol
|
||||||
|
upgrade.Subprotocols = []string{token}
|
||||||
//升级websocket
|
//升级websocket
|
||||||
conn, err := upgrade.Upgrade(w, r, nil)
|
conn, err := upgrade.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -90,29 +95,18 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
//鉴权不成功后断开
|
//鉴权不成功后断开
|
||||||
/*var (
|
var (
|
||||||
userInfo *auth.UserInfo
|
userInfo *auth.UserInfo
|
||||||
isAuth bool
|
isAuth bool
|
||||||
)
|
)
|
||||||
isAuth, userInfo = l.checkAuth(r)
|
isAuth, userInfo = l.checkAuth(r)
|
||||||
if !isAuth {
|
if !isAuth {
|
||||||
time.Sleep(time.Second * 1) //兼容下火狐
|
//未授权响应消息
|
||||||
rsp := websocket_data.DataTransferData{
|
l.unAuthResponse(conn)
|
||||||
T: constants.WEBSOCKET_UNAUTH,
|
|
||||||
D: nil,
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(rsp)
|
|
||||||
//先发一条正常信息
|
|
||||||
_ = conn.WriteMessage(websocket.TextMessage, b)
|
|
||||||
//发送关闭信息
|
|
||||||
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
|
||||||
return
|
return
|
||||||
}*/
|
}
|
||||||
//测试的目前写死 39
|
|
||||||
var userInfo auth.UserInfo
|
|
||||||
userInfo.UserId = 39
|
|
||||||
//设置连接
|
//设置连接
|
||||||
ws := l.setConnPool(conn, userInfo)
|
ws := l.setConnPool(conn, *userInfo)
|
||||||
defer ws.close()
|
defer ws.close()
|
||||||
//循环读客户端信息
|
//循环读客户端信息
|
||||||
go ws.readLoop()
|
go ws.readLoop()
|
||||||
@ -144,7 +138,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
|
|||||||
userId: userInfo.UserId,
|
userId: userInfo.UserId,
|
||||||
guestId: userInfo.GuestId,
|
guestId: userInfo.GuestId,
|
||||||
renderProperty: renderProperty{
|
renderProperty: renderProperty{
|
||||||
renderImageTask: make(map[string]string),
|
renderImageTask: make(map[string]*renderTask),
|
||||||
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100),
|
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100),
|
||||||
renderChan: make(chan []byte, 100),
|
renderChan: make(chan []byte, 100),
|
||||||
},
|
},
|
||||||
@ -153,7 +147,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
|
|||||||
mapConnPool.Store(uniqueId, ws)
|
mapConnPool.Store(uniqueId, ws)
|
||||||
go func() {
|
go func() {
|
||||||
//把连接成功消息发回去
|
//把连接成功消息发回去
|
||||||
time.Sleep(time.Second * 1) //兼容下火狐
|
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
||||||
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId))
|
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId))
|
||||||
}()
|
}()
|
||||||
return ws
|
return ws
|
||||||
@ -162,24 +156,20 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
|
|||||||
// 获取唯一id
|
// 获取唯一id
|
||||||
func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string {
|
func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string {
|
||||||
//后面拼接上用户id
|
//后面拼接上用户id
|
||||||
uniqueId := uuid.New().String() + getUserPart(userInfo.UserId, userInfo.GuestId)
|
uniqueId := uuid.New().String() + getUserJoinPart(userInfo.UserId, userInfo.GuestId)
|
||||||
if _, ok := mapConnPool.Load(uniqueId); ok {
|
if _, ok := mapConnPool.Load(uniqueId); ok {
|
||||||
uniqueId = l.getUniqueId(userInfo)
|
uniqueId = l.getUniqueId(userInfo)
|
||||||
}
|
}
|
||||||
return uniqueId
|
return uniqueId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户拼接部分
|
|
||||||
func getUserPart(userId, guestId int64) string {
|
|
||||||
return fmt.Sprintf("_%d_%d", userId, guestId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 鉴权
|
// 鉴权
|
||||||
func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *auth.UserInfo) {
|
func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *auth.UserInfo) {
|
||||||
// 解析JWT token,并对空用户进行判断
|
// 解析JWT token,并对空用户进行判断
|
||||||
claims, err := l.svcCtx.ParseJwtToken(r)
|
claims, err := l.svcCtx.ParseJwtToken(r)
|
||||||
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
|
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if claims != nil {
|
if claims != nil {
|
||||||
@ -187,6 +177,7 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a
|
|||||||
userInfo, err = auth.GetUserInfoFormMapClaims(claims)
|
userInfo, err = auth.GetUserInfoFormMapClaims(claims)
|
||||||
// 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
|
// 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
//不是登录用户也不是游客
|
//不是登录用户也不是游客
|
||||||
@ -198,6 +189,22 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 鉴权失败通知
|
||||||
|
func (l *DataTransferLogic) unAuthResponse(conn *websocket.Conn) {
|
||||||
|
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
|
||||||
|
rsp := websocket_data.DataTransferData{
|
||||||
|
T: constants.WEBSOCKET_UNAUTH,
|
||||||
|
D: nil,
|
||||||
|
}
|
||||||
|
b, _ := json.Marshal(rsp)
|
||||||
|
//先发一条正常信息
|
||||||
|
_ = conn.WriteMessage(websocket.TextMessage, b)
|
||||||
|
//发送关闭信息
|
||||||
|
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
||||||
|
//关闭连接
|
||||||
|
conn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// 心跳
|
// 心跳
|
||||||
func (w *wsConnectItem) heartbeat() {
|
func (w *wsConnectItem) heartbeat() {
|
||||||
tick := time.Tick(time.Second * 5)
|
tick := time.Tick(time.Second * 5)
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fusenapi/constants"
|
"context"
|
||||||
|
"fusenapi/server/websocket/internal/svc"
|
||||||
|
"fusenapi/server/websocket/internal/types"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/file"
|
"fusenapi/utils/file"
|
||||||
"fusenapi/utils/websocket_data"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/websocket/internal/svc"
|
|
||||||
"fusenapi/server/websocket/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,14 +37,17 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend
|
|||||||
|
|
||||||
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
if req.TaskId == "" {
|
if req.TaskId == "" {
|
||||||
|
logx.Error("渲染回调参数错误:invalid param task_id")
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
||||||
}
|
}
|
||||||
if req.Image == "" {
|
if req.Image == "" {
|
||||||
|
logx.Error("渲染回调参数错误:invalid param image")
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
|
||||||
}
|
}
|
||||||
if req.UserId == 0 && req.GuestId == 0 {
|
//存base64打印测试
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id")
|
/* f, _ := os.Create("b.txt")
|
||||||
}
|
defer f.Close()
|
||||||
|
f.WriteString(req.Image)*/
|
||||||
// 上传文件
|
// 上传文件
|
||||||
var upload = file.Upload{
|
var upload = file.Upload{
|
||||||
Ctx: l.ctx,
|
Ctx: l.ctx,
|
||||||
@ -67,7 +66,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
|||||||
FileByte: nil,
|
FileByte: nil,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error("渲染回调上传文件失败:", err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image")
|
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image")
|
||||||
}
|
}
|
||||||
//遍历websocket链接把数据传进去
|
//遍历websocket链接把数据传进去
|
||||||
@ -75,37 +74,24 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
|||||||
//断言连接
|
//断言连接
|
||||||
ws, ok := value.(wsConnectItem)
|
ws, ok := value.(wsConnectItem)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
logx.Error("渲染回调断言websocket连接失败")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
//关闭标识
|
//记录收到unity渲染结果时间
|
||||||
if ws.isClose {
|
ws.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||||
return true
|
Option: 2,
|
||||||
}
|
TaskProperty: renderTask{
|
||||||
//查询有无该渲染任务
|
UnityRenderEndTime: time.Now().UTC().Unix(),
|
||||||
renderId, ok := ws.renderProperty.renderImageTask[req.TaskId]
|
},
|
||||||
if !ok {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
b := ws.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
|
||||||
RenderId: renderId,
|
|
||||||
Image: uploadRes.ResourceUrl,
|
|
||||||
})
|
})
|
||||||
deleteTask := renderImageControlChanItem{
|
//发送处理并删除任务
|
||||||
|
ws.deleteRenderTask(renderImageControlChanItem{
|
||||||
Option: 0, //0删除 1添加
|
Option: 0, //0删除 1添加
|
||||||
TaskId: req.TaskId,
|
TaskId: req.TaskId,
|
||||||
RenderId: renderId,
|
RenderNotifyImageUrl: uploadRes.ResourceUrl,
|
||||||
}
|
})
|
||||||
select {
|
|
||||||
case <-ws.closeChan: //关闭了
|
|
||||||
return true
|
|
||||||
case ws.renderProperty.renderImageTaskCtlChan <- deleteTask: //删除对应的需要渲染的图片map
|
|
||||||
//发送数据到out chan
|
|
||||||
ws.sendToOutChan(b)
|
|
||||||
case <-time.After(time.Second * 3): //超时丢弃
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
logx.Info("渲染回调成功######################")
|
logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl)
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/service/repositories"
|
"fusenapi/service/repositories"
|
||||||
"fusenapi/utils/curl"
|
"fusenapi/utils/curl"
|
||||||
@ -18,16 +19,25 @@ import (
|
|||||||
|
|
||||||
// 云渲染属性
|
// 云渲染属性
|
||||||
type renderProperty struct {
|
type renderProperty struct {
|
||||||
renderImageTask map[string]string //需要渲染的图片任务 key是taskId val 是renderId
|
renderImageTask map[string]*renderTask //需要渲染的图片任务 key是taskId val 是renderId
|
||||||
renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增移除的控制通道
|
renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增移除的控制通道
|
||||||
renderChan chan []byte //渲染的缓冲队列
|
renderChan chan []byte //渲染的缓冲队列
|
||||||
}
|
}
|
||||||
|
type renderTask struct {
|
||||||
|
RenderId string //渲染id(前端传的)
|
||||||
|
CombineBeginTime int64 //合图开始时间
|
||||||
|
CombineEndTime int64 //合图结束时间
|
||||||
|
UnityRenderBeginTime int64 //发送给unity时间
|
||||||
|
UnityRenderEndTime int64 //unity回调结果时间
|
||||||
|
}
|
||||||
|
|
||||||
// 渲染任务新增移除的控制通道的数据
|
// 渲染任务新增移除的控制通道的数据
|
||||||
type renderImageControlChanItem struct {
|
type renderImageControlChanItem struct {
|
||||||
Option int // 0删除 1添加
|
Option int // 0删除 1添加
|
||||||
TaskId string //map的key
|
TaskId string //map的key
|
||||||
RenderId string // map的val
|
RenderId string // map的val(增加任务时候传)
|
||||||
|
RenderNotifyImageUrl string //渲染回调数据(删除任务时候传)
|
||||||
|
TaskProperty renderTask //渲染任务的属性
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送到渲染缓冲池
|
// 发送到渲染缓冲池
|
||||||
@ -35,14 +45,14 @@ func (w *wsConnectItem) sendToRenderChan(data []byte) {
|
|||||||
select {
|
select {
|
||||||
case <-w.closeChan: //已经关闭
|
case <-w.closeChan: //已经关闭
|
||||||
return
|
return
|
||||||
case w.renderProperty.renderChan <- data:
|
case w.renderProperty.renderChan <- data: //发入到缓冲池
|
||||||
return
|
return
|
||||||
case <-time.After(time.Second * 3):
|
case <-time.After(time.Second * 3): //三秒没进入缓冲池就丢弃
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 渲染发送到组装数据组装数据
|
// 渲染发送到组装数据组装数据(缓冲池)
|
||||||
func (w *wsConnectItem) renderImage() {
|
func (w *wsConnectItem) renderImage() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
@ -69,7 +79,6 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||||||
logx.Error("invalid format of websocket render image message", err)
|
logx.Error("invalid format of websocket render image message", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logx.Info("收到请求云渲染图片数据:", renderImageData)
|
|
||||||
if renderImageData.RenderId == "" {
|
if renderImageData.RenderId == "" {
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty"))
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty"))
|
||||||
logx.Error("invalid format of websocket render image message:render_id is empty")
|
logx.Error("invalid format of websocket render image message:render_id is empty")
|
||||||
@ -116,7 +125,10 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||||||
hashVal := renderImageData.RenderData
|
hashVal := renderImageData.RenderData
|
||||||
hashVal.UserId = 0
|
hashVal.UserId = 0
|
||||||
hashVal.GuestId = 0
|
hashVal.GuestId = 0
|
||||||
taskId := hash.JsonHashKey(hashVal)
|
hashByte, _ := json.Marshal(hashVal)
|
||||||
|
var hashData map[string]interface{}
|
||||||
|
_ = json.Unmarshal(hashByte, &hashData)
|
||||||
|
taskId := hash.JsonHashKey(hashData)
|
||||||
//查询有没有缓存的资源,有就返回######################
|
//查询有没有缓存的资源,有就返回######################
|
||||||
resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId)
|
resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -129,6 +141,8 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||||||
b := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
b := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||||
RenderId: renderImageData.RenderId,
|
RenderId: renderImageData.RenderId,
|
||||||
Image: *resource.ResourceUrl,
|
Image: *resource.ResourceUrl,
|
||||||
|
CombineTakesTime: "耗时0秒(缓存)",
|
||||||
|
UnityRenderTakesTime: "耗时0秒(缓存)",
|
||||||
})
|
})
|
||||||
//发送数据到out chan
|
//发送数据到out chan
|
||||||
w.sendToOutChan(b)
|
w.sendToOutChan(b)
|
||||||
@ -136,11 +150,11 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||||||
}
|
}
|
||||||
//###########################################
|
//###########################################
|
||||||
//把需要渲染的图片任务加进去
|
//把需要渲染的图片任务加进去
|
||||||
w.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{
|
w.createRenderTask(renderImageControlChanItem{
|
||||||
Option: 1, //0删除 1添加
|
Option: 1, //0删除 1添加
|
||||||
TaskId: taskId,
|
TaskId: taskId,
|
||||||
RenderId: renderImageData.RenderId,
|
RenderId: renderImageData.RenderId,
|
||||||
}
|
})
|
||||||
//组装数据
|
//组装数据
|
||||||
if err = w.assembleRenderData(taskId, renderImageData); err != nil {
|
if err = w.assembleRenderData(taskId, renderImageData); err != nil {
|
||||||
logx.Error("组装数据失败:", err)
|
logx.Error("组装数据失败:", err)
|
||||||
@ -165,8 +179,15 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
logx.Error("failed to get template info:", err)
|
logx.Error("failed to get template info:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
//记录刀版图合成开始时间
|
||||||
|
w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||||
|
Option: 2,
|
||||||
|
TaskProperty: renderTask{
|
||||||
|
CombineBeginTime: time.Now().UTC().Unix(),
|
||||||
|
},
|
||||||
|
})
|
||||||
//获取刀版图
|
//获取刀版图
|
||||||
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &repositories.LogoCombineReq{
|
combineReq := repositories.LogoCombineReq{
|
||||||
UserId: info.RenderData.UserId,
|
UserId: info.RenderData.UserId,
|
||||||
GuestId: info.RenderData.GuestId,
|
GuestId: info.RenderData.GuestId,
|
||||||
TemplateId: productTemplate.Id,
|
TemplateId: productTemplate.Id,
|
||||||
@ -175,9 +196,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
Slogan: info.RenderData.Slogan,
|
Slogan: info.RenderData.Slogan,
|
||||||
Address: info.RenderData.Address,
|
Address: info.RenderData.Address,
|
||||||
Phone: info.RenderData.Phone,
|
Phone: info.RenderData.Phone,
|
||||||
})
|
}
|
||||||
|
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error("合成刀版图失败:", err)
|
logx.Error("合成刀版图失败,合成请求数据:", combineReq, "错误信息:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
combineImage := "" //刀版图
|
combineImage := "" //刀版图
|
||||||
@ -187,17 +209,18 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
|
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logx.Info("合成刀版图成功:", *res.ResourceUrl)
|
//记录刀版图合成结束时间
|
||||||
|
w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||||
|
Option: 2,
|
||||||
|
TaskProperty: renderTask{
|
||||||
|
CombineEndTime: time.Now().UTC().Unix(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
logx.Info("合成刀版图成功,合成刀版图数据:", combineReq, ",logo图片:", info.RenderData.Logo, " 刀版图:", *res.ResourceUrl)
|
||||||
//获取渲染设置信息
|
//获取渲染设置信息
|
||||||
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
|
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
// todo 没有图就给他返回一张默认(后面要删除)
|
|
||||||
defaultImg := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
|
||||||
RenderId: info.RenderId,
|
|
||||||
Image: "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/695463af6e9b93c003db39ddf728241f9523efc55b20dc37f30fe5d96ed54fb5",
|
|
||||||
})
|
|
||||||
w.sendToOutChan(defaultImg)
|
|
||||||
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -208,6 +231,9 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
refletion := -1
|
refletion := -1
|
||||||
if element.Refletion != nil && *element.Refletion != "" {
|
if element.Refletion != nil && *element.Refletion != "" {
|
||||||
refletion, err = strconv.Atoi(*element.Refletion)
|
refletion, err = strconv.Atoi(*element.Refletion)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error("err refletion:set default -1")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//组装data数据
|
//组装data数据
|
||||||
var mode map[string]interface{}
|
var mode map[string]interface{}
|
||||||
@ -272,7 +298,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
"folder": "", //todo 千人千面需要使用
|
"folder": "", //todo 千人千面需要使用
|
||||||
}
|
}
|
||||||
//请求unity接口
|
//请求unity接口
|
||||||
url := "http://api.fusen.3718.cn:4050/api/render/queue/push"
|
url := w.logic.svcCtx.Config.Unity.Host + "/api/render/queue/push"
|
||||||
header := make(map[string]string)
|
header := make(map[string]string)
|
||||||
header["content-type"] = "application/json"
|
header["content-type"] = "application/json"
|
||||||
t := time.Now().UTC()
|
t := time.Now().UTC()
|
||||||
@ -283,17 +309,66 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
"create_at": t,
|
"create_at": t,
|
||||||
"render_data": sendData,
|
"render_data": sendData,
|
||||||
}
|
}
|
||||||
p, _ := json.Marshal(postData)
|
postDataBytes, _ := json.Marshal(postData)
|
||||||
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*10)
|
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(postDataBytes), time.Second*10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error("failed to send data to unity")
|
logx.Error("failed to send data to unity")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logx.Info("发送到unity成功################")
|
//记录发送到unity时间
|
||||||
|
w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
|
||||||
|
Option: 2,
|
||||||
|
TaskProperty: renderTask{
|
||||||
|
UnityRenderBeginTime: time.Now().UTC().Unix(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
logx.Info("发送到unity成功,刀版图:", combineImage, " 请求unity的数据:", string(postDataBytes))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 操作连接中渲染任务的增加/删除
|
// 增加渲染任务
|
||||||
|
func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) {
|
||||||
|
//强制设为增加
|
||||||
|
data.Option = 1
|
||||||
|
select {
|
||||||
|
case <-w.closeChan: //关闭
|
||||||
|
return
|
||||||
|
case w.renderProperty.renderImageTaskCtlChan <- data:
|
||||||
|
return
|
||||||
|
case <-time.After(time.Second * 3):
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染回调处理并删除渲染任务
|
||||||
|
func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) {
|
||||||
|
//强制设为删除
|
||||||
|
data.Option = 0
|
||||||
|
select {
|
||||||
|
case <-w.closeChan: //关闭
|
||||||
|
return
|
||||||
|
case w.renderProperty.renderImageTaskCtlChan <- data:
|
||||||
|
return
|
||||||
|
case <-time.After(time.Second * 3):
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改耗时属性(只有耗时属性可以更新)
|
||||||
|
func (w *wsConnectItem) modifyRenderTaskTimeConsuming(data renderImageControlChanItem) {
|
||||||
|
//强制设为修改耗时属性
|
||||||
|
data.Option = 2
|
||||||
|
select {
|
||||||
|
case <-w.closeChan: //关闭
|
||||||
|
return
|
||||||
|
case w.renderProperty.renderImageTaskCtlChan <- data:
|
||||||
|
return
|
||||||
|
case <-time.After(time.Second * 3):
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 操作连接中渲染任务的增加/删除(任务map不能读写并发,所以放在chan里面串行执行)
|
||||||
func (w *wsConnectItem) operationRenderTask() {
|
func (w *wsConnectItem) operationRenderTask() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -301,10 +376,46 @@ func (w *wsConnectItem) operationRenderTask() {
|
|||||||
return
|
return
|
||||||
case data := <-w.renderProperty.renderImageTaskCtlChan:
|
case data := <-w.renderProperty.renderImageTaskCtlChan:
|
||||||
switch data.Option {
|
switch data.Option {
|
||||||
case 0: //删除任务
|
case 0: //渲染结果回调,删除任务
|
||||||
|
//存在任务,则发送渲染结果给前端
|
||||||
|
if taskData, ok := w.renderProperty.renderImageTask[data.TaskId]; ok {
|
||||||
|
CombineTakesTime := ""
|
||||||
|
UnityRenderTakesTime := ""
|
||||||
|
if taskData.CombineBeginTime > 0 && taskData.CombineEndTime > 0 {
|
||||||
|
CombineTakesTime = fmt.Sprintf("耗时%d秒", taskData.CombineEndTime-taskData.CombineBeginTime)
|
||||||
|
}
|
||||||
|
if taskData.UnityRenderBeginTime > 0 && taskData.UnityRenderEndTime > 0 {
|
||||||
|
UnityRenderTakesTime = fmt.Sprintf("耗时%d秒", taskData.UnityRenderEndTime-taskData.UnityRenderBeginTime)
|
||||||
|
}
|
||||||
|
//发送到出口
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||||
|
RenderId: taskData.RenderId,
|
||||||
|
Image: data.RenderNotifyImageUrl,
|
||||||
|
CombineTakesTime: CombineTakesTime,
|
||||||
|
UnityRenderTakesTime: UnityRenderTakesTime,
|
||||||
|
}))
|
||||||
|
}
|
||||||
delete(w.renderProperty.renderImageTask, data.TaskId)
|
delete(w.renderProperty.renderImageTask, data.TaskId)
|
||||||
case 1: //新增任务
|
case 1: //新增任务
|
||||||
w.renderProperty.renderImageTask[data.TaskId] = data.RenderId
|
w.renderProperty.renderImageTask[data.TaskId] = &renderTask{
|
||||||
|
RenderId: data.RenderId,
|
||||||
|
}
|
||||||
|
case 2: //修改(耗时)属性
|
||||||
|
if taskData, ok := w.renderProperty.renderImageTask[data.TaskId]; ok {
|
||||||
|
if data.TaskProperty.CombineBeginTime != 0 {
|
||||||
|
taskData.CombineBeginTime = data.TaskProperty.CombineBeginTime
|
||||||
|
}
|
||||||
|
if data.TaskProperty.CombineEndTime != 0 {
|
||||||
|
taskData.CombineEndTime = data.TaskProperty.CombineEndTime
|
||||||
|
}
|
||||||
|
if data.TaskProperty.UnityRenderBeginTime != 0 {
|
||||||
|
taskData.UnityRenderBeginTime = data.TaskProperty.UnityRenderBeginTime
|
||||||
|
}
|
||||||
|
if data.TaskProperty.UnityRenderEndTime != 0 {
|
||||||
|
taskData.UnityRenderEndTime = data.TaskProperty.UnityRenderEndTime
|
||||||
|
}
|
||||||
|
logx.Info("**********:", taskData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
@ -22,7 +23,7 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
//合成client后缀,不是同个后缀的不能复用
|
//合成client后缀,不是同个后缀的不能复用
|
||||||
userPart := getUserPart(w.userId, w.guestId)
|
userPart := getUserJoinPart(w.userId, w.guestId)
|
||||||
lenUserPart := len(userPart)
|
lenUserPart := len(userPart)
|
||||||
if lenClientId <= lenUserPart {
|
if lenClientId <= lenUserPart {
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to short"))
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to short"))
|
||||||
@ -36,14 +37,32 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) {
|
|||||||
publicMutex.Lock()
|
publicMutex.Lock()
|
||||||
defer publicMutex.Unlock()
|
defer publicMutex.Unlock()
|
||||||
//存在是不能给他申请重新绑定
|
//存在是不能给他申请重新绑定
|
||||||
if _, ok := mapConnPool.Load(clientId); ok {
|
if v, ok := mapConnPool.Load(clientId); ok {
|
||||||
|
obj, ok := v.(wsConnectItem)
|
||||||
|
if !ok {
|
||||||
|
logx.Error("连接断言失败")
|
||||||
|
}
|
||||||
|
//是当前自己占用
|
||||||
|
if obj.uniqueId == w.uniqueId {
|
||||||
|
//重新绑定
|
||||||
|
w.uniqueId = clientId
|
||||||
|
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId)
|
||||||
|
w.sendToOutChan(rsp)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ")
|
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ")
|
||||||
w.sendToOutChan(rsp)
|
w.sendToOutChan(rsp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//重新绑定
|
//重新绑定
|
||||||
w.uniqueId = clientId
|
w.uniqueId = clientId
|
||||||
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId)
|
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId)
|
||||||
w.sendToOutChan(rsp)
|
w.sendToOutChan(rsp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取用户拼接部分(复用标识用到)
|
||||||
|
func getUserJoinPart(userId, guestId int64) string {
|
||||||
|
return fmt.Sprintf("_%d_%d", userId, guestId)
|
||||||
|
}
|
||||||
|
@ -301,6 +301,7 @@ type GetRecommandProductListRsp {
|
|||||||
type GetTagProductListReq {
|
type GetTagProductListReq {
|
||||||
Cid int64 `form:"cid,optional"` //分类id
|
Cid int64 `form:"cid,optional"` //分类id
|
||||||
Size uint32 `form:"size,optional"` //尺寸
|
Size uint32 `form:"size,optional"` //尺寸
|
||||||
|
TemplateTag string `form:"template_tag,optional"` //模板标签
|
||||||
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
||||||
}
|
}
|
||||||
type GetTagProductListRsp {
|
type GetTagProductListRsp {
|
||||||
@ -325,6 +326,7 @@ type TagProduct {
|
|||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
//彩膜列表
|
//彩膜列表
|
||||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
|
DefaultTemplateId int64 `json:"default_template_id"`
|
||||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
Recommended bool `json:"recommended"`
|
Recommended bool `json:"recommended"`
|
||||||
}
|
}
|
||||||
@ -387,7 +389,7 @@ type GetSizeByPidRsp {
|
|||||||
type GetTemplateByPidReq {
|
type GetTemplateByPidReq {
|
||||||
Pid string `form:"pid"`
|
Pid string `form:"pid"`
|
||||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
ProductSizeId int64 `form:"product_size_id,optional"`
|
||||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
TemplateTag string `form:"template_tag"`
|
||||||
}
|
}
|
||||||
//获取产品配件数据
|
//获取产品配件数据
|
||||||
type GetFittingByPidReq {
|
type GetFittingByPidReq {
|
||||||
|
@ -13,10 +13,23 @@ service resource {
|
|||||||
@handler LogoCombineHandler
|
@handler LogoCombineHandler
|
||||||
post /api/resource/logo-combine(LogoCombineReq) returns (response);
|
post /api/resource/logo-combine(LogoCombineReq) returns (response);
|
||||||
|
|
||||||
|
@handler LogoRemovebgHandler
|
||||||
|
post /api/resource/logo-removebg(LogoRemovebgReq) returns (response);
|
||||||
|
|
||||||
@handler ResourceInfoHandler
|
@handler ResourceInfoHandler
|
||||||
get /api/resource/info(ResourceInfoReq) returns (response);
|
get /api/resource/info(ResourceInfoReq) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
LogoRemovebgReq {
|
||||||
|
IsRemoveBg string `form:"is_remove_bg"`
|
||||||
|
LogoFile string `form:"logo_file"`
|
||||||
|
Width string `form:"width"`
|
||||||
|
Height string `form:"height"`
|
||||||
|
Proportion int64 `form:"proportion"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
ResourceInfoReq {
|
ResourceInfoReq {
|
||||||
ResourceId string `form:"resource_id,optional"` // 资源ID
|
ResourceId string `form:"resource_id,optional"` // 资源ID
|
||||||
|
@ -42,8 +42,21 @@ service upload {
|
|||||||
@handler UploadFileBaseHandler
|
@handler UploadFileBaseHandler
|
||||||
post /api/upload/upload-file-base(UploadFileBaseReq) returns (response);
|
post /api/upload/upload-file-base(UploadFileBaseReq) returns (response);
|
||||||
|
|
||||||
|
@handler UploadLogoStandardHandler
|
||||||
|
post /api/upload/up-standard-logo(UploadLogoStandardReq) returns (response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
UploadLogoStandardReq {
|
||||||
|
IsRemoveBg string `form:"is_remove_bg"`
|
||||||
|
LogoFile string `form:"logo_file"`
|
||||||
|
Width string `form:"width"`
|
||||||
|
Height string `form:"height"`
|
||||||
|
Proportion int64 `form:"proportion"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
UploadFileBaseReq {
|
UploadFileBaseReq {
|
||||||
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/curl"
|
"fusenapi/utils/curl"
|
||||||
@ -37,6 +38,9 @@ type (
|
|||||||
|
|
||||||
// logo合图
|
// logo合图
|
||||||
LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error)
|
LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error)
|
||||||
|
|
||||||
|
// logo裁剪
|
||||||
|
LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,6 +56,7 @@ type (
|
|||||||
Address string `json:"address"` // 合图参数
|
Address string `json:"address"` // 合图参数
|
||||||
Phone string `json:"phone"` // 合图参数
|
Phone string `json:"phone"` // 合图参数
|
||||||
Qrcode string `json:"qrcode"` // 合图参数
|
Qrcode string `json:"qrcode"` // 合图参数
|
||||||
|
LogoUrl string `json:"logo_url"` // 合图参数
|
||||||
}
|
}
|
||||||
LogoCombineRes struct {
|
LogoCombineRes struct {
|
||||||
ResourceId string
|
ResourceId string
|
||||||
@ -61,11 +66,36 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
|
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
|
||||||
|
// 查询logo最新基础信息
|
||||||
|
var metadata *string
|
||||||
|
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
|
||||||
|
userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
metadata = userMaterialInfoDefault.Metadata
|
||||||
|
} else {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
metadata = userMaterialInfo.Metadata
|
||||||
|
}
|
||||||
|
|
||||||
// 根据hash 查询数据资源
|
// 根据hash 查询数据资源
|
||||||
var hashKeyData = *in
|
var hashKeyData = *in
|
||||||
hashKeyData.GuestId = 0
|
hashKeyData.GuestId = 0
|
||||||
hashKeyData.UserId = 0
|
hashKeyData.UserId = 0
|
||||||
var resourceId string = hash.JsonHashKey(hashKeyData)
|
hashKeyData.LogoUrl = *userMaterialInfo.ResourceUrl
|
||||||
|
var hashKeyDataMap map[string]interface{}
|
||||||
|
hashKeyDataB, _ := json.Marshal(hashKeyData)
|
||||||
|
json.Unmarshal(hashKeyDataB, &hashKeyDataMap)
|
||||||
|
var resourceId string = hash.JsonHashKey(hashKeyDataMap)
|
||||||
|
|
||||||
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
|
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
|
||||||
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
|
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
|
||||||
@ -105,33 +135,15 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
|||||||
groupOptions = templateInfo["groupOptions"].(map[string]interface{})
|
groupOptions = templateInfo["groupOptions"].(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("合图开始时间:", time.Now())
|
||||||
|
logx.Infof("合图请求算法--开始时间:%v", time.Now())
|
||||||
|
|
||||||
var moduleDataMap = make(map[string]interface{}, 4)
|
var moduleDataMap = make(map[string]interface{}, 4)
|
||||||
moduleDataMap["id"] = productTemplateV2Info.Id
|
moduleDataMap["id"] = productTemplateV2Info.Id
|
||||||
moduleDataMap["material"] = productTemplateV2Info.MaterialImg
|
moduleDataMap["material"] = productTemplateV2Info.MaterialImg
|
||||||
moduleDataMap["groupOptions"] = groupOptions
|
moduleDataMap["groupOptions"] = groupOptions
|
||||||
moduleDataMap["materialList"] = materialList
|
moduleDataMap["materialList"] = materialList
|
||||||
|
|
||||||
// 查询logo最新基础信息
|
|
||||||
var metadata *string
|
|
||||||
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
|
|
||||||
userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
metadata = userMaterialInfoDefault.Metadata
|
|
||||||
} else {
|
|
||||||
logx.Error(err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
metadata = userMaterialInfo.Metadata
|
|
||||||
}
|
|
||||||
|
|
||||||
var combineParam map[string]interface{}
|
var combineParam map[string]interface{}
|
||||||
json.Unmarshal([]byte(*metadata), &combineParam)
|
json.Unmarshal([]byte(*metadata), &combineParam)
|
||||||
combineParam["template_tagid"] = in.TemplateTag
|
combineParam["template_tagid"] = in.TemplateTag
|
||||||
@ -142,14 +154,162 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
|||||||
combineParam["qrcode"] = in.Qrcode
|
combineParam["qrcode"] = in.Qrcode
|
||||||
|
|
||||||
var postMap = make(map[string]interface{}, 2)
|
var postMap = make(map[string]interface{}, 2)
|
||||||
|
fmt.Println(combineParam)
|
||||||
postMap["module_data"] = moduleDataMap
|
postMap["module_data"] = moduleDataMap
|
||||||
postMap["param_data"] = combineParam
|
postMap["param_data"] = combineParam
|
||||||
postMapB, _ := json.Marshal(postMap)
|
postMapB, _ := json.Marshal(postMap)
|
||||||
|
|
||||||
var headerData = make(map[string]string, 1)
|
var headerData = make(map[string]string, 1)
|
||||||
headerData["Content-Type"] = "application/json"
|
headerData["Content-Type"] = "application/json"
|
||||||
result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoCombine, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20)
|
result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoCombine, "POST", headerData, strings.NewReader(string(postMapB)), time.Minute*5)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer result.Body.Close()
|
||||||
|
b, err := io.ReadAll(result.Body)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
logx.Infof("合图请求算法--结束时间:%v", time.Now())
|
||||||
|
|
||||||
|
var resultStr string
|
||||||
|
if string(b) == "Internal Server Error" {
|
||||||
|
err = errors.New("BLMService fail Internal Server Error")
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
var resData map[string]interface{}
|
||||||
|
err = json.Unmarshal(b, &resData)
|
||||||
|
if err != nil || resData == nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resData != nil {
|
||||||
|
if resData["code"].(string) == "200" {
|
||||||
|
resultStr = resData["data"].(string)
|
||||||
|
} else {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var resultData map[string]interface{}
|
||||||
|
err = json.Unmarshal([]byte(resultStr), &resultData)
|
||||||
|
if err != nil || resultData == nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("合图结束时间:", time.Now())
|
||||||
|
// {
|
||||||
|
// id: "",
|
||||||
|
// logo_url:"https://s3.amazon.com/xxxx",
|
||||||
|
// result: "$saa541afaldjaldjasldjsadjsapsaasda"
|
||||||
|
// }
|
||||||
|
var fileBase = resultData["result"].(string)
|
||||||
|
|
||||||
|
// 上传文件
|
||||||
|
var upload = file.Upload{
|
||||||
|
Ctx: ctx,
|
||||||
|
MysqlConn: l.MysqlConn,
|
||||||
|
AwsSession: l.AwsSession,
|
||||||
|
}
|
||||||
|
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
||||||
|
Source: "combine-image",
|
||||||
|
FileHash: resourceId,
|
||||||
|
FileData: fileBase,
|
||||||
|
UploadBucket: 1,
|
||||||
|
ApiType: 2,
|
||||||
|
UserId: in.UserId,
|
||||||
|
GuestId: in.GuestId,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &LogoCombineRes{
|
||||||
|
ResourceId: uploadRes.ResourceId,
|
||||||
|
ResourceUrl: &uploadRes.ResourceUrl,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/* logo合图 */
|
||||||
|
type (
|
||||||
|
LogoStandardReq struct {
|
||||||
|
IsRemoveBg string `json:"is_remove_bg"`
|
||||||
|
LogoFile string `json:"logo_file"`
|
||||||
|
Width string `json:"width"`
|
||||||
|
Height string `json:"height"`
|
||||||
|
Proportion int64 `json:"proportion"`
|
||||||
|
}
|
||||||
|
LogoStandardRes struct {
|
||||||
|
ResourceId string
|
||||||
|
ResourceUrl string
|
||||||
|
IsmaxProportion bool
|
||||||
|
ImgColor []string
|
||||||
|
}
|
||||||
|
LogoStandardMetaData struct {
|
||||||
|
Param LogoStandardReq `json:"param"`
|
||||||
|
Result LogoStandardRes `json:"result"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/* 图片裁剪 */
|
||||||
|
func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) {
|
||||||
|
var ismaxProportion bool
|
||||||
|
var imgColor []string
|
||||||
|
var logoStandardMetaData LogoStandardMetaData
|
||||||
|
|
||||||
|
var hashKeyDataMap map[string]interface{}
|
||||||
|
hashKeyDataB, _ := json.Marshal(in)
|
||||||
|
json.Unmarshal(hashKeyDataB, &hashKeyDataMap)
|
||||||
|
var resourceId string = hash.JsonHashKey(hashKeyDataMap)
|
||||||
|
|
||||||
|
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
|
||||||
|
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
|
||||||
|
if err == nil && resourceInfo.ResourceId != "" {
|
||||||
|
if resourceInfo.Metadata != nil {
|
||||||
|
json.Unmarshal([]byte(*resourceInfo.Metadata), &logoStandardMetaData)
|
||||||
|
}
|
||||||
|
// 取出参数
|
||||||
|
ismaxProportion = logoStandardMetaData.Result.IsmaxProportion
|
||||||
|
imgColor = logoStandardMetaData.Result.ImgColor
|
||||||
|
|
||||||
|
return &LogoStandardRes{
|
||||||
|
ResourceId: resourceInfo.ResourceId,
|
||||||
|
ResourceUrl: *resourceInfo.ResourceUrl,
|
||||||
|
IsmaxProportion: ismaxProportion,
|
||||||
|
ImgColor: imgColor,
|
||||||
|
}, nil
|
||||||
|
} else {
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var postMap = make(map[string]interface{}, 5)
|
||||||
|
postMap["is_remove_bg"] = in.IsRemoveBg
|
||||||
|
postMap["logo_file"] = in.LogoFile
|
||||||
|
postMap["width"] = in.Width
|
||||||
|
postMap["height"] = in.Height
|
||||||
|
postMap["proportion"] = in.Proportion
|
||||||
|
postMapB, _ := json.Marshal(postMap)
|
||||||
|
|
||||||
|
var headerData = make(map[string]string, 1)
|
||||||
|
headerData["Content-Type"] = "application/json"
|
||||||
|
result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoRemovebg, "POST", headerData, strings.NewReader(string(postMapB)), time.Minute*5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -192,12 +352,29 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// {
|
|
||||||
// id: "",
|
//$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}'
|
||||||
// logo_url:"https://s3.amazon.com/xxxx",
|
|
||||||
// result: "$saa541afaldjaldjasldjsadjsapsaasda"
|
var fileBase = resultData["nobg_url"].(string)
|
||||||
// }
|
ismaxProportion = resultData["ismax_proportion"].(bool)
|
||||||
var fileBase = resultData["result"]
|
|
||||||
|
for _, v := range resultData["img_color"].([]interface{}) {
|
||||||
|
imgColor = append(imgColor, v.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
var logoStandardRes LogoStandardRes
|
||||||
|
logoStandardRes.IsmaxProportion = ismaxProportion
|
||||||
|
logoStandardRes.ImgColor = imgColor
|
||||||
|
|
||||||
|
logoStandardMetaData.Param = *in
|
||||||
|
logoStandardMetaData.Result = logoStandardRes
|
||||||
|
metadataB, err := json.Marshal(logoStandardMetaData)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var metadata = string(metadataB)
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
var upload = file.Upload{
|
var upload = file.Upload{
|
||||||
@ -206,22 +383,23 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
|||||||
AwsSession: l.AwsSession,
|
AwsSession: l.AwsSession,
|
||||||
}
|
}
|
||||||
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
||||||
Source: "combine-image",
|
Source: "combine-removebg",
|
||||||
FileHash: resourceId,
|
FileHash: resourceId,
|
||||||
FileData: fileBase.(string),
|
FileData: fileBase,
|
||||||
UploadBucket: 1,
|
UploadBucket: 1,
|
||||||
ApiType: 2,
|
ApiType: 2,
|
||||||
UserId: in.UserId,
|
Metadata: metadata,
|
||||||
GuestId: in.GuestId,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &LogoCombineRes{
|
return &LogoStandardRes{
|
||||||
ResourceId: uploadRes.ResourceId,
|
ResourceId: uploadRes.ResourceId,
|
||||||
ResourceUrl: &uploadRes.ResourceUrl,
|
ResourceUrl: uploadRes.ResourceUrl,
|
||||||
|
IsmaxProportion: ismaxProportion,
|
||||||
|
ImgColor: imgColor,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/* logo合图 */
|
/* 图片裁剪 */
|
||||||
|
@ -5,13 +5,12 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
func JsonHashKey(v interface{}) string {
|
func JsonHashKey(v interface{}) string {
|
||||||
|
|
||||||
if reflect.TypeOf(v).Kind() == reflect.String {
|
if _, ok := v.(string); ok {
|
||||||
var obj interface{}
|
var obj interface{}
|
||||||
err := json.Unmarshal([]byte(v.(string)), &obj)
|
err := json.Unmarshal([]byte(v.(string)), &obj)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -27,6 +27,8 @@ type RenderData struct {
|
|||||||
type RenderImageRspMsg struct {
|
type RenderImageRspMsg struct {
|
||||||
RenderId string `json:"render_id"` //渲染id
|
RenderId string `json:"render_id"` //渲染id
|
||||||
Image string `json:"image"` //渲染结果图片
|
Image string `json:"image"` //渲染结果图片
|
||||||
|
CombineTakesTime string `json:"combine_takes_time"` //合图需要时间
|
||||||
|
UnityRenderTakesTime string `json:"unity_render_takes_time"` //unity渲染用时
|
||||||
}
|
}
|
||||||
type ThirdPartyLoginRspMsg struct {
|
type ThirdPartyLoginRspMsg struct {
|
||||||
//websocket三方登录的通知数据
|
//websocket三方登录的通知数据
|
||||||
|
Loading…
x
Reference in New Issue
Block a user