Merge branch 'develop' into feature/auth

This commit is contained in:
eson 2023-08-22 10:34:21 +08:00
commit d35ffd793a
79 changed files with 1360 additions and 495 deletions

View File

@ -1,5 +1,6 @@
package constants
const (
BLMServiceUrlLogoCombine string = "/LogoCombine"
BLMServiceUrlLogoCombine string = "/LogoCombine"
BLMServiceUrlLogoRemovebg string = "/removebg"
)

View File

@ -12,8 +12,6 @@ const (
WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT"
//请求恢复为上次连接的标识错误
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"
//数据格式错误

View File

@ -9,10 +9,10 @@ type FsAuthItem struct {
Name string `gorm:"primary_key;default:'';" json:"name"` // 角色或权限名称
Type *int64 `gorm:"index;default:0;" json:"type"` // 权限类型1 表示角色2 表示权限
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"` // 角色或权限的额外数据
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` //
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` //
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间
// FsAuthItemIbfk1 foreign `gorm:"" json:"fs_auth_item_ibfk_1"`//
}
type FsAuthItemModel struct {

View File

@ -8,8 +8,8 @@ import (
type FsAuthRule struct {
Name string `gorm:"primary_key;default:'';" json:"name"` // 规则名称
Data *[]byte `gorm:"default:'';" json:"data"` // 规则的额外数据
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` //
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` //
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间
}
type FsAuthRuleModel struct {
db *gorm.DB

View File

@ -6,14 +6,16 @@ import (
// fs_canteen_product 餐厅类别产品对应表
type FsCanteenProduct struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
CanteenType *int64 `gorm:"index;default:0;" json:"canteen_type"` // 餐厅类别id
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
Sid *string `gorm:"default:'';" json:"sid"` // 前端带入的id
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
CanteenType *int64 `gorm:"index;default:0;" json:"canteen_type"` // 餐厅类别id
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
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 {
db *gorm.DB

View File

@ -8,7 +8,7 @@ import (
// fs_cart 购物车
type FsCart struct {
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
TemplateId *int64 `gorm:"index;default:0;" json:"template_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"` // 购买数量
Cover *string `gorm:"default:'';" json:"cover"` // 截图
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"` // 状态位
OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID
IsCheck *int64 `gorm:"default:0;" json:"is_check"` // 是否选中状态0未选中1选中

View File

@ -8,7 +8,6 @@ import (
type FsCloudRenderLog struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"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"` //
PostUrl *string `gorm:"default:'';" json:"post_url"` //
Title *string `gorm:"index;default:'';" json:"title"` //

View File

@ -11,8 +11,8 @@ type FsContact struct {
Email *string `gorm:"index;default:'';" json:"email"` // 邮箱
Subject *int64 `gorm:"default:0;" json:"subject"` // 主题
Message *string `gorm:"default:'';" json:"message"` // 消息
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Status *int64 `gorm:"default:0;" json:"status"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否已处理
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
}
type FsContactModel struct {

View File

@ -12,10 +12,10 @@ type FsContactService struct {
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
Name *string `gorm:"default:'';" json:"name"` // 联系人姓名
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"` // 备注内容
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"` // 处理备注
HandleUid *int64 `gorm:"default:0;" json:"handle_uid"` // 处理人
HandleTime *int64 `gorm:"default:0;" json:"handle_time"` // 处理时间

View File

@ -10,10 +10,10 @@ type FsEmailTemplate struct {
Type *int64 `gorm:"default:0;" json:"type"` // 模板类型
Name *string `gorm:"default:'';" json:"name"` // 模板名称
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"` // 模板内容
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 {
db *gorm.DB

View File

@ -13,7 +13,7 @@ type FsFaq struct {
Content *string `gorm:"default:'';" json:"content"` // 内容
Status *int64 `gorm:"default:0;" json:"status"` // 状态(0:禁用1:启用)
Sort *int64 `gorm:"default:1;" json:"sort"` // 排序
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
}
type FsFaqModel struct {
db *gorm.DB

View File

@ -10,12 +10,12 @@ type FsGerent struct {
Username *string `gorm:"unique_key;default:'';" json:"username"` // 用户名
AuthKey *string `gorm:"default:'';" json:"auth_key"` // token
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"` // 邮箱
Status *int64 `gorm:"default:10;" json:"status"` // 状态
CreatedAt *int64 `gorm:"default:0;" json:"created_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
}
type FsGerentModel struct {

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -11,7 +11,7 @@ type FsMerchantCategory struct {
EnName *string `gorm:"default:'';" json:"en_name"` // 英文名
Icon *string `gorm:"default:'';" json:"icon"` // 图标
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"` // 状态
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
}

View File

@ -9,7 +9,7 @@ type FsOrderDetail struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 唯一编码
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
OrderDetailTemplateId *int64 `gorm:"default:0;" json:"order_detail_template_id"` // 详情templateID
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID

View File

@ -16,7 +16,7 @@ type FsOrderDetailTemplate struct {
EachBoxNum *int64 `gorm:"default:0;" json:"each_box_num"` // 每一箱的个数
EachBoxWeight *float64 `gorm:"default:0.00;" json:"each_box_weight"` // 每一箱的重量 单位KG
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 {
db *gorm.DB

View File

@ -9,17 +9,17 @@ import (
type FsOrder struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
UserId *int64 `gorm:"index;default:0;" json:"user_id"` //
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` //
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // 销售员ID 0:自主下单
TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价
PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Utime *int64 `gorm:"default:0;" json:"utime"` //
Ptime *int64 `gorm:"default:0;" json:"ptime"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
Ptime *int64 `gorm:"default:0;" json:"ptime"` // 最后一次 支付时间(可能多次支付)
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址ID或者云仓ID
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"` // 后台订单备注
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 详细地址信息JSON
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"` // 是否退款中01
IsRefunded *int64 `gorm:"default:0;" json:"is_refunded"` // 是否退款完成01
IsDeleted *int64 `gorm:"default:0;" json:"is_deleted"` // 是否删除01
RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` //
RefundReason *string `gorm:"default:'';" json:"refund_reason"` //
RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` // 取消订单原因ID
RefundReason *string `gorm:"default:'';" json:"refund_reason"` // 取消订单原因
TsTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ts_time"` //
IsSure *int64 `gorm:"default:0;" json:"is_sure"` // 是否确认订单 1确认0未确认
DeliverSn *string `gorm:"default:'';" json:"deliver_sn"` // 发货单号

View File

@ -8,18 +8,19 @@ import (
type FsProductDesignGather struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
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
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
SizeId *int64 `gorm:"index;default:0;" json:"size_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"` // 保留的设计信息
Utime *int64 `gorm:"default:0;" json:"utime"` //
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
Status *int64 `gorm:"default:1;" json:"status"` // 状态位1显示0删除
ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip
ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识
InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版
}
type FsProductDesignGatherModel struct {
db *gorm.DB

View File

@ -23,6 +23,7 @@ type FsProductDesign struct {
IsPay *int64 `gorm:"default:0;" json:"is_pay"` // 是否已有支付 0 未 1 有
LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选项
PageGuid *string `gorm:"default:'';" json:"page_guid"` // 页面识别id
InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版用
}
type FsProductDesignModel struct {
db *gorm.DB

View File

@ -17,11 +17,11 @@ type FsProduct struct {
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
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
TagIds *string `gorm:"default:'';" json:"tag_ids"` //
TagIds *string `gorm:"default:'';" json:"tag_ids"` // 标签 逗号间隔
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
DeliveryDays *int64 `gorm:"default:0;" json:"delivery_days"` // 运送天数

View File

@ -8,7 +8,6 @@ import (
type FsProductModel3d struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"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场景
Title *string `gorm:"default:'';" json:"title"` // 标题
Name *string `gorm:"default:'';" json:"name"` // 详情页展示名称
@ -25,6 +24,7 @@ type FsProductModel3d struct {
OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板
Price *int64 `gorm:"default:0;" json:"price"` // 仅配件用,配件的价格, 单位:美分
Sku *string `gorm:"default:'';" json:"sku"` // sku
IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门
}
type FsProductModel3dModel struct {
db *gorm.DB

View File

@ -10,7 +10,7 @@ type FsProductModel3dLight struct {
Name *string `gorm:"default:'';" json:"name"` // 灯光名称
Info *string `gorm:"default:'';" json:"info"` // 灯光数据json格式
Status *int64 `gorm:"default:1;" json:"status"` // 状态值1显示0删除
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
}
type FsProductModel3dLightModel struct {
db *gorm.DB

View File

@ -8,19 +8,20 @@ import (
type FsProductRenderDesign struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
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
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
SizeId *int64 `gorm:"index;default:0;" json:"size_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"` // 保留的设计信息
Utime *int64 `gorm:"default:0;" json:"utime"` //
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
Status *int64 `gorm:"default:1;" json:"status"` // 状态位1显示0删除
ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip
ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识
LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选颜色
InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版用
}
type FsProductRenderDesignModel struct {
db *gorm.DB

View File

@ -8,15 +8,15 @@ import (
type FsProductSize struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"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
Cover *string `gorm:"default:'';" json:"cover"` //
CoverImg *string `gorm:"default:'';" json:"cover_img"` //
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
CoverImg *string `gorm:"default:'';" json:"cover_img"` // 背景图
Capacity *string `gorm:"default:'';" json:"capacity"` // 自己填的尺寸名称
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除
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否
IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门
}
type FsProductSizeModel struct {
db *gorm.DB

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -8,22 +8,22 @@ import (
type FsProductTemplateElement struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
ModelId *int64 `gorm:"index;default:0;" json:"model_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"` //
ModelId *int64 `gorm:"index;default:0;" json:"model_id"` // 产品模型id
Main *string `gorm:"default:'';" json:"main"` // 废弃
Second *string `gorm:"default:'';" json:"second"` // 废弃
Base *string `gorm:"default:'';" json:"base"` // 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"` // 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 *string `gorm:"default:'';" json:"refletion"` // 反射探头组
}

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -8,7 +8,7 @@ import (
type FsProductTemplateTags struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
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可用
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
Groups *string `gorm:"default:'';" json:"groups"` // 分组信息

View File

@ -9,21 +9,21 @@ type FsProductTemplateV2 struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID
Title *string `gorm:"default:'';" json:"title"` //
Name *string `gorm:"default:'';" json:"name"` //
CoverImg *string `gorm:"default:'';" json:"cover_img"` //
TemplateInfo *string `gorm:"default:'';" json:"template_info"` //
MaterialImg *string `gorm:"default:'';" json:"material_img"` //
Title *string `gorm:"default:'';" json:"title"` // 模板sku,预留字段
Name *string `gorm:"default:'';" json:"name"` // 名称
CoverImg *string `gorm:"default:'';" json:"cover_img"` // 模板背景图
TemplateInfo *string `gorm:"default:'';" json:"template_info"` // 模板详情
MaterialImg *string `gorm:"default:'';" json:"material_img"` // 合成好的贴图
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用1:可以0不可以
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
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删除
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息
Version *int64 `gorm:"default:0;" json:"version"` // 默认1
}
type FsProductTemplateV2Model struct {
db *gorm.DB

View File

@ -4,11 +4,14 @@ import (
"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 {
return
}
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 {
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) {
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
}
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.status = ? and t.is_del = ?", 1, 0).
Where("s.status = ?", 1).
Order("s.sort ASC").
Order("t.sort ASC,s.sort ASC").
Take(&resp).Error
return resp, err
}
@ -150,3 +153,17 @@ func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Co
err = db.Find(&resp).Error
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
}

View File

@ -11,8 +11,8 @@ type FsQrcodeLog struct {
QrcodeId *int64 `gorm:"default:0;" json:"qrcode_id"` // 二维码ID
TagId *int64 `gorm:"default:0;" json:"tag_id"` // 分组ID
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间
Platform *string `gorm:"default:'';" json:"platform"` //
UserAgent *string `gorm:"default:'';" json:"user_agent"` //
Platform *string `gorm:"default:'';" json:"platform"` // 系统信息
UserAgent *string `gorm:"default:'';" json:"user_agent"` // 浏览器
}
type FsQrcodeLogModel struct {
db *gorm.DB

View File

@ -19,7 +19,6 @@ type FsQuotation struct {
DesignId *int64 `gorm:"default:0;" json:"design_id"` // 设计人员
QuotationId *int64 `gorm:"default:0;" json:"quotation_id"` // 报价人员
IsMark *int64 `gorm:"default:0;" json:"is_mark"` // 星标
Qid *int64 `gorm:"default:0;" json:"qid"` //
}
type FsQuotationModel struct {
db *gorm.DB

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -6,20 +6,23 @@ import (
// fs_quotation_product 报价单产品表
type FsQuotationProduct struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
QuotationId *int64 `gorm:"index;default:0;" json:"quotation_id"` // 报价单id
Name *string `gorm:"default:'';" json:"name"` // 产品名
Size *string `gorm:"default:'';" json:"size"` // 产品规格
Cycle *int64 `gorm:"default:0;" json:"cycle"` // 交付周期
IsGift *int64 `gorm:"default:0;" json:"is_gift"` // 是否赠品
Img *string `gorm:"default:'';" json:"img"` // 效果图
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
Sid *string `gorm:"default:'';" json:"sid"` // 前端sid
PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格信息
Remark *string `gorm:"default:'';" json:"remark"` // 备注
Num *int64 `gorm:"default:0;" json:"num"` // 产品数量
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
QuotationId *int64 `gorm:"index;default:0;" json:"quotation_id"` // 报价单id
Name *string `gorm:"default:'';" json:"name"` // 产品名
Size *string `gorm:"default:'';" json:"size"` // 产品规格
Cycle *int64 `gorm:"default:0;" json:"cycle"` // 交付周期
IsGift *int64 `gorm:"default:0;" json:"is_gift"` // 是否赠品
Img *string `gorm:"default:'';" json:"img"` // 效果图
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
Sid *string `gorm:"default:'';" json:"sid"` // 前端sid
PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格信息
Remark *string `gorm:"default:'';" json:"remark"` // 备注
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 {
db *gorm.DB

View 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"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -13,7 +13,7 @@ type FsResource struct {
ResourceType *string `gorm:"index;default:'';" json:"resource_type"` // 资源类型
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
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格式,存储图像分率
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型1=对外2=对内

View File

@ -13,10 +13,10 @@ type FsTrade struct {
TradeSn *string `gorm:"unique_key;default:'';" json:"trade_sn"` // 三方交易号
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID
Amount *int64 `gorm:"default:0;" json:"amount"` // 支付金额
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Utime *int64 `gorm:"default:0;" json:"utime"` //
Desc *string `gorm:"default:'';" json:"desc"` //
Status *int64 `gorm:"default:0;" json:"status"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
Desc *string `gorm:"default:'';" json:"desc"` // 简要描述
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否支付成功
}
type FsTradeModel struct {
db *gorm.DB

View File

@ -7,13 +7,13 @@ import (
// fs_user_design 废弃表
type FsUserDesign struct {
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
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID
Info *string `gorm:"default:'';" json:"info"` // 其他设计信息
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
}
type FsUserDesignModel struct {
db *gorm.DB

View File

@ -9,11 +9,11 @@ type FsUser struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
FaceId *int64 `gorm:"default:0;" json:"face_id"` // facebook的userid
GoogleId *int64 `gorm:"default:0;" json:"google_id"` // google的sub
FirstName *string `gorm:"default:'';" json:"first_name"` //
LastName *string `gorm:"default:'';" json:"last_name"` //
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
Username *string `gorm:"unique_key;default:'';" json:"username"` //
Company *string `gorm:"default:'';" json:"company"` //
Mobile *string `gorm:"default:'';" json:"mobile"` //
Company *string `gorm:"default:'';" json:"company"` // 公司名称
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
AuthKey *string `gorm:"default:'';" json:"auth_key"` //
PasswordHash *string `gorm:"default:'';" json:"password_hash"` //
VerificationToken *string `gorm:"default:'';" json:"verification_token"` //
@ -30,7 +30,7 @@ type FsUser struct {
IsPhoneAdvertisement *int64 `gorm:"default:0;" json:"is_phone_advertisement"` // 是否接收短信广告
IsOpenRender *int64 `gorm:"default:0;" json:"is_open_render"` // 是否打开个性化渲染1开启0关闭
IsThousandFace *int64 `gorm:"default:0;" json:"is_thousand_face"` // 是否已经存在千人千面1存在0不存在
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` // 是否开启低渲染模型渲染
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` //
IsRemoveBg *int64 `gorm:"default:1;" json:"is_remove_bg"` // 用户上传logo是否去除背景
}
type FsUserModel struct {

View File

@ -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) {
if userId == 0 && guestId == 0 {
return FsUserMaterial{}, nil
}
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).
Order("id DESC")

View File

@ -4,191 +4,205 @@ import "gorm.io/gorm"
// AllModelsGen 所有Model集合,修改单行,只要不改字段名,不会根据新的内容修改,需要修改的话手动删除
type AllModelsGen struct {
FsAddress *FsAddressModel // fs_address 用户地址表
FsAuthAssignment *FsAuthAssignmentModel // fs_auth_assignment 用户角色和权限信息
FsAuthItem *FsAuthItemModel // fs_auth_item 用户角色和权限信息
FsAuthItemChild *FsAuthItemChildModel // fs_auth_item_child 角色和权限关系表
FsAuthRule *FsAuthRuleModel // fs_auth_rule 规则表
FsBackendUser *FsBackendUserModel // fs_backend_user 管理员表
FsCanteenProduct *FsCanteenProductModel // fs_canteen_product 餐厅类别产品对应表
FsCanteenType *FsCanteenTypeModel // fs_canteen_type 餐厅类型表
FsCard *FsCardModel // fs_card 卡号表
FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表
FsCart *FsCartModel // fs_cart 购物车
FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表
FsCloud *FsCloudModel // fs_cloud 云仓表
FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp
FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp
FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单
FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情
FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单
FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every
FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表
FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃
FsContact *FsContactModel // fs_contact 该表暂未使用
FsContactService *FsContactServiceModel // fs_contact_service
FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用)
FsDeliver *FsDeliverModel // fs_deliver 发货表 云仓 直发 通用(已废弃)
FsDeliverEvery *FsDeliverEveryModel // fs_deliver_every 发货详细表(已废弃)
FsDepartment *FsDepartmentModel // fs_department 部门表
FsEmailLogs *FsEmailLogsModel // fs_email_logs 邮件日志表
FsEmailTemplate *FsEmailTemplateModel // fs_email_template 邮件模板表(暂未使用)
FsFactory *FsFactoryModel // fs_factory 该表废弃
FsFactoryDeliver *FsFactoryDeliverModel // fs_factory_deliver 工厂发货主表(废弃)
FsFactoryDeliverEvery *FsFactoryDeliverEveryModel // fs_factory_deliver_every 该表废弃
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
FsFaq *FsFaqModel // fs_faq 常见问题
FsFont *FsFontModel // fs_font 字体配置
FsGerent *FsGerentModel // fs_gerent 管理员表
FsGuest *FsGuestModel // fs_guest 游客表
FsLog *FsLogModel // fs_log 日志表
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
FsMenu *FsMenuModel // fs_menu 后台菜单
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
FsMigration *FsMigrationModel // fs_migration 版本库
FsOrder *FsOrderModel // fs_order
FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等
FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表
FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表
FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表
FsPay *FsPayModel // fs_pay 支付记录
FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志
FsProduct *FsProductModel // fs_product 产品表
FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表
FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表
FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather
FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
FsProductPrice *FsProductPriceModel // fs_product_price 阶梯价格表
FsProductRenderDesign *FsProductRenderDesignModel // fs_product_render_design
FsProductScene *FsProductSceneModel // fs_product_scene 产品场景表
FsProductSize *FsProductSizeModel // fs_product_size 产品尺寸表
FsProductTagProp *FsProductTagPropModel // fs_product_tag_prop 产品标签相关属性表
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
FsQrcode *FsQrcodeModel // fs_qrcode
FsQrcodeLog *FsQrcodeLogModel // fs_qrcode_log 二维码扫描日志
FsQrcodeSet *FsQrcodeSetModel // fs_qrcode_set 二维码边框配置表
FsQrcodeUser *FsQrcodeUserModel // fs_qrcode_user 二维码-用户名表
FsQuotation *FsQuotationModel // fs_quotation 报价单信息表
FsQuotationProduct *FsQuotationProductModel // fs_quotation_product 报价单产品表
FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板
FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表
FsRefundReason *FsRefundReasonModel // fs_refund_reason
FsResource *FsResourceModel // fs_resource 资源表
FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo
FsTags *FsTagsModel // fs_tags 产品分类表
FsToolLogs *FsToolLogsModel // fs_tool_logs 3d设计工具日志表
FsToolTemplate *FsToolTemplateModel // fs_tool_template 设计工具模板(废弃)
FsToolUser *FsToolUserModel // fs_tool_user 3d设计工具用户表
FsTrade *FsTradeModel // fs_trade
FsUser *FsUserModel // fs_user 用户表
FsUserDesign *FsUserDesignModel // fs_user_design 废弃表
FsUserInfo *FsUserInfoModel // fs_user_info 用户信息表
FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表
FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存
FsWebSet *FsWebSetModel // fs_web_set 网站配置表
FsAddress *FsAddressModel // fs_address 用户地址表
FsAuthAssignment *FsAuthAssignmentModel // fs_auth_assignment 用户角色和权限信息
FsAuthItem *FsAuthItemModel // fs_auth_item 用户角色和权限信息
FsAuthItemChild *FsAuthItemChildModel // fs_auth_item_child 角色和权限关系表
FsAuthRule *FsAuthRuleModel // fs_auth_rule 规则表
FsBackendUser *FsBackendUserModel // fs_backend_user 管理员表
FsCanteenProduct *FsCanteenProductModel // fs_canteen_product 餐厅类别产品对应表
FsCanteenType *FsCanteenTypeModel // fs_canteen_type 餐厅类型表
FsCard *FsCardModel // fs_card 卡号表
FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表
FsCart *FsCartModel // fs_cart 购物车
FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表
FsCloud *FsCloudModel // fs_cloud 云仓表
FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp
FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp
FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单
FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情
FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单
FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every
FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表
FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃
FsContact *FsContactModel // fs_contact 该表暂未使用
FsContactService *FsContactServiceModel // fs_contact_service
FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用)
FsDeliver *FsDeliverModel // fs_deliver 发货表 云仓 直发 通用(已废弃)
FsDeliverEvery *FsDeliverEveryModel // fs_deliver_every 发货详细表(已废弃)
FsDepartment *FsDepartmentModel // fs_department 部门表
FsEmailLogs *FsEmailLogsModel // fs_email_logs 邮件日志表
FsEmailTemplate *FsEmailTemplateModel // fs_email_template 邮件模板表(暂未使用)
FsFactory *FsFactoryModel // fs_factory 该表废弃
FsFactoryDeliver *FsFactoryDeliverModel // fs_factory_deliver 工厂发货主表(废弃)
FsFactoryDeliverEvery *FsFactoryDeliverEveryModel // fs_factory_deliver_every 该表废弃
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
FsFaq *FsFaqModel // fs_faq 常见问题
FsFont *FsFontModel // fs_font 字体配置
FsGerent *FsGerentModel // fs_gerent 管理员表
FsGuest *FsGuestModel // fs_guest 游客表
FsLog *FsLogModel // fs_log 日志表
FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
FsMenu *FsMenuModel // fs_menu 后台菜单
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
FsMigration *FsMigrationModel // fs_migration 版本库
FsOrder *FsOrderModel // fs_order
FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等
FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表
FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表
FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表
FsPay *FsPayModel // fs_pay 支付记录
FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志
FsProduct *FsProductModel // fs_product 产品表
FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表
FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表
FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather
FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
FsProductPrice *FsProductPriceModel // fs_product_price 阶梯价格表
FsProductRenderDesign *FsProductRenderDesignModel // fs_product_render_design
FsProductScene *FsProductSceneModel // fs_product_scene 产品场景表
FsProductSize *FsProductSizeModel // fs_product_size 产品尺寸表
FsProductTagProp *FsProductTagPropModel // fs_product_tag_prop 产品标签相关属性表
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
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 模板标签表
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
FsQrcode *FsQrcodeModel // fs_qrcode
FsQrcodeLog *FsQrcodeLogModel // fs_qrcode_log 二维码扫描日志
FsQrcodeSet *FsQrcodeSetModel // fs_qrcode_set 二维码边框配置表
FsQrcodeUser *FsQrcodeUserModel // fs_qrcode_user 二维码-用户名表
FsQuotation *FsQuotationModel // fs_quotation 报价单信息表
FsQuotationPrice *FsQuotationPriceModel // fs_quotation_price 报价单价格表
FsQuotationProduct *FsQuotationProductModel // fs_quotation_product 报价单产品表
FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板
FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表
FsQuotationSizeLayout *FsQuotationSizeLayoutModel // fs_quotation_size_layout 产品尺寸排版表
FsRefundReason *FsRefundReasonModel // fs_refund_reason
FsResource *FsResourceModel // fs_resource 资源表
FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo
FsTags *FsTagsModel // fs_tags 产品分类表
FsToolLogs *FsToolLogsModel // fs_tool_logs 3d设计工具日志表
FsToolTemplate *FsToolTemplateModel // fs_tool_template 设计工具模板(废弃)
FsToolUser *FsToolUserModel // fs_tool_user 3d设计工具用户表
FsTrade *FsTradeModel // fs_trade
FsUser *FsUserModel // fs_user 用户表
FsUserDesign *FsUserDesignModel // fs_user_design 废弃表
FsUserInfo *FsUserInfoModel // fs_user_info 用户信息表
FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表
FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存
FsWebSet *FsWebSetModel // fs_web_set 网站配置表
}
func NewAllModels(gdb *gorm.DB) *AllModelsGen {
models := &AllModelsGen{
FsAddress: NewFsAddressModel(gdb),
FsAuthAssignment: NewFsAuthAssignmentModel(gdb),
FsAuthItem: NewFsAuthItemModel(gdb),
FsAuthItemChild: NewFsAuthItemChildModel(gdb),
FsAuthRule: NewFsAuthRuleModel(gdb),
FsBackendUser: NewFsBackendUserModel(gdb),
FsCanteenProduct: NewFsCanteenProductModel(gdb),
FsCanteenType: NewFsCanteenTypeModel(gdb),
FsCard: NewFsCardModel(gdb),
FsCardGroup: NewFsCardGroupModel(gdb),
FsCart: NewFsCartModel(gdb),
FsChangeCode: NewFsChangeCodeModel(gdb),
FsCloud: NewFsCloudModel(gdb),
FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb),
FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb),
FsCloudPickUp: NewFsCloudPickUpModel(gdb),
FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb),
FsCloudReceive: NewFsCloudReceiveModel(gdb),
FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb),
FsCloudRenderLog: NewFsCloudRenderLogModel(gdb),
FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb),
FsContact: NewFsContactModel(gdb),
FsContactService: NewFsContactServiceModel(gdb),
FsCoupon: NewFsCouponModel(gdb),
FsDeliver: NewFsDeliverModel(gdb),
FsDeliverEvery: NewFsDeliverEveryModel(gdb),
FsDepartment: NewFsDepartmentModel(gdb),
FsEmailLogs: NewFsEmailLogsModel(gdb),
FsEmailTemplate: NewFsEmailTemplateModel(gdb),
FsFactory: NewFsFactoryModel(gdb),
FsFactoryDeliver: NewFsFactoryDeliverModel(gdb),
FsFactoryDeliverEvery: NewFsFactoryDeliverEveryModel(gdb),
FsFactoryProduct: NewFsFactoryProductModel(gdb),
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
FsFaq: NewFsFaqModel(gdb),
FsFont: NewFsFontModel(gdb),
FsGerent: NewFsGerentModel(gdb),
FsGuest: NewFsGuestModel(gdb),
FsLog: NewFsLogModel(gdb),
FsMapLibrary: NewFsMapLibraryModel(gdb),
FsMenu: NewFsMenuModel(gdb),
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
FsMigration: NewFsMigrationModel(gdb),
FsOrder: NewFsOrderModel(gdb),
FsOrderAffiliate: NewFsOrderAffiliateModel(gdb),
FsOrderDetail: NewFsOrderDetailModel(gdb),
FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb),
FsOrderRemark: NewFsOrderRemarkModel(gdb),
FsPay: NewFsPayModel(gdb),
FsPayEvent: NewFsPayEventModel(gdb),
FsProduct: NewFsProductModel(gdb),
FsProductCopy1: NewFsProductCopy1Model(gdb),
FsProductDesign: NewFsProductDesignModel(gdb),
FsProductDesignGather: NewFsProductDesignGatherModel(gdb),
FsProductModel3d: NewFsProductModel3dModel(gdb),
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
FsProductOption: NewFsProductOptionModel(gdb),
FsProductPrice: NewFsProductPriceModel(gdb),
FsProductRenderDesign: NewFsProductRenderDesignModel(gdb),
FsProductScene: NewFsProductSceneModel(gdb),
FsProductSize: NewFsProductSizeModel(gdb),
FsProductTagProp: NewFsProductTagPropModel(gdb),
FsProductTemplate: NewFsProductTemplateModel(gdb),
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
FsQrcode: NewFsQrcodeModel(gdb),
FsQrcodeLog: NewFsQrcodeLogModel(gdb),
FsQrcodeSet: NewFsQrcodeSetModel(gdb),
FsQrcodeUser: NewFsQrcodeUserModel(gdb),
FsQuotation: NewFsQuotationModel(gdb),
FsQuotationProduct: NewFsQuotationProductModel(gdb),
FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb),
FsQuotationSaler: NewFsQuotationSalerModel(gdb),
FsRefundReason: NewFsRefundReasonModel(gdb),
FsResource: NewFsResourceModel(gdb),
FsStandardLogo: NewFsStandardLogoModel(gdb),
FsTags: NewFsTagsModel(gdb),
FsToolLogs: NewFsToolLogsModel(gdb),
FsToolTemplate: NewFsToolTemplateModel(gdb),
FsToolUser: NewFsToolUserModel(gdb),
FsTrade: NewFsTradeModel(gdb),
FsUser: NewFsUserModel(gdb),
FsUserDesign: NewFsUserDesignModel(gdb),
FsUserInfo: NewFsUserInfoModel(gdb),
FsUserMaterial: NewFsUserMaterialModel(gdb),
FsUserStock: NewFsUserStockModel(gdb),
FsWebSet: NewFsWebSetModel(gdb),
FsAddress: NewFsAddressModel(gdb),
FsAuthAssignment: NewFsAuthAssignmentModel(gdb),
FsAuthItem: NewFsAuthItemModel(gdb),
FsAuthItemChild: NewFsAuthItemChildModel(gdb),
FsAuthRule: NewFsAuthRuleModel(gdb),
FsBackendUser: NewFsBackendUserModel(gdb),
FsCanteenProduct: NewFsCanteenProductModel(gdb),
FsCanteenType: NewFsCanteenTypeModel(gdb),
FsCard: NewFsCardModel(gdb),
FsCardGroup: NewFsCardGroupModel(gdb),
FsCart: NewFsCartModel(gdb),
FsChangeCode: NewFsChangeCodeModel(gdb),
FsCloud: NewFsCloudModel(gdb),
FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb),
FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb),
FsCloudPickUp: NewFsCloudPickUpModel(gdb),
FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb),
FsCloudReceive: NewFsCloudReceiveModel(gdb),
FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb),
FsCloudRenderLog: NewFsCloudRenderLogModel(gdb),
FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb),
FsContact: NewFsContactModel(gdb),
FsContactService: NewFsContactServiceModel(gdb),
FsCoupon: NewFsCouponModel(gdb),
FsDeliver: NewFsDeliverModel(gdb),
FsDeliverEvery: NewFsDeliverEveryModel(gdb),
FsDepartment: NewFsDepartmentModel(gdb),
FsEmailLogs: NewFsEmailLogsModel(gdb),
FsEmailTemplate: NewFsEmailTemplateModel(gdb),
FsFactory: NewFsFactoryModel(gdb),
FsFactoryDeliver: NewFsFactoryDeliverModel(gdb),
FsFactoryDeliverEvery: NewFsFactoryDeliverEveryModel(gdb),
FsFactoryProduct: NewFsFactoryProductModel(gdb),
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
FsFaq: NewFsFaqModel(gdb),
FsFont: NewFsFontModel(gdb),
FsGerent: NewFsGerentModel(gdb),
FsGuest: NewFsGuestModel(gdb),
FsLog: NewFsLogModel(gdb),
FsLogoCartoon: NewFsLogoCartoonModel(gdb),
FsMapLibrary: NewFsMapLibraryModel(gdb),
FsMenu: NewFsMenuModel(gdb),
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
FsMigration: NewFsMigrationModel(gdb),
FsOrder: NewFsOrderModel(gdb),
FsOrderAffiliate: NewFsOrderAffiliateModel(gdb),
FsOrderDetail: NewFsOrderDetailModel(gdb),
FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb),
FsOrderRemark: NewFsOrderRemarkModel(gdb),
FsPay: NewFsPayModel(gdb),
FsPayEvent: NewFsPayEventModel(gdb),
FsProduct: NewFsProductModel(gdb),
FsProductCopy1: NewFsProductCopy1Model(gdb),
FsProductDesign: NewFsProductDesignModel(gdb),
FsProductDesignGather: NewFsProductDesignGatherModel(gdb),
FsProductModel3d: NewFsProductModel3dModel(gdb),
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
FsProductOption: NewFsProductOptionModel(gdb),
FsProductPrice: NewFsProductPriceModel(gdb),
FsProductRenderDesign: NewFsProductRenderDesignModel(gdb),
FsProductScene: NewFsProductSceneModel(gdb),
FsProductSize: NewFsProductSizeModel(gdb),
FsProductTagProp: NewFsProductTagPropModel(gdb),
FsProductTemplate: NewFsProductTemplateModel(gdb),
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
FsProductTemplateElement0826: NewFsProductTemplateElement0826Model(gdb),
FsProductTemplateElement22: NewFsProductTemplateElement22Model(gdb),
FsProductTemplateElementBackup1018: NewFsProductTemplateElementBackup1018Model(gdb),
FsProductTemplateElementKongde: NewFsProductTemplateElementKongdeModel(gdb),
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
FsQrcode: NewFsQrcodeModel(gdb),
FsQrcodeLog: NewFsQrcodeLogModel(gdb),
FsQrcodeSet: NewFsQrcodeSetModel(gdb),
FsQrcodeUser: NewFsQrcodeUserModel(gdb),
FsQuotation: NewFsQuotationModel(gdb),
FsQuotationPrice: NewFsQuotationPriceModel(gdb),
FsQuotationProduct: NewFsQuotationProductModel(gdb),
FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb),
FsQuotationSaler: NewFsQuotationSalerModel(gdb),
FsQuotationSizeLayout: NewFsQuotationSizeLayoutModel(gdb),
FsRefundReason: NewFsRefundReasonModel(gdb),
FsResource: NewFsResourceModel(gdb),
FsStandardLogo: NewFsStandardLogoModel(gdb),
FsTags: NewFsTagsModel(gdb),
FsToolLogs: NewFsToolLogsModel(gdb),
FsToolTemplate: NewFsToolTemplateModel(gdb),
FsToolUser: NewFsToolUserModel(gdb),
FsTrade: NewFsTradeModel(gdb),
FsUser: NewFsUserModel(gdb),
FsUserDesign: NewFsUserDesignModel(gdb),
FsUserInfo: NewFsUserInfoModel(gdb),
FsUserMaterial: NewFsUserMaterialModel(gdb),
FsUserStock: NewFsUserStockModel(gdb),
FsWebSet: NewFsWebSetModel(gdb),
}
return models
}

View File

@ -1,6 +1,7 @@
package main
import (
"crypto/tls"
"fmt"
"io"
"io/ioutil"
@ -41,6 +42,8 @@ func SetCors(w http.ResponseWriter, r *http.Request) {
var pathdict sync.Map = sync.Map{}
func main() {
log.SetFlags(log.Llongfile)
// 将静态资源路径存储到pathdict
pathdict.Store("/css", true)
pathdict.Store("/fonts", true)
@ -81,6 +84,12 @@ func main() {
fs := http.FileServer(http.Dir(vueBuild))
indexHtmlPath := vueBuild + "/index.html"
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/") {
// 对/api开头的请求进行反向代理
proxy := httputil.NewSingleHostReverseProxy(apiURL)
@ -108,7 +117,34 @@ func main() {
ServerAddress := ":9900"
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{
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: 60 * time.Second,
Timeout: 300 * time.Second,
KeepAlive: 60 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
IdleConnTimeout: 300 * time.Second,
TLSHandshakeTimeout: 300 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
},
}

View File

@ -73,7 +73,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us
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 {
logx.Error(err)
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,
Price: *fitting.Price,
ModelInfo: modelInfo,
IsPopular: *fitting.IsPopular > 0,
IsPopular: *fitting.IsHot > 0,
})
}
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)

View File

@ -99,7 +99,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
}
//获取模板
productTemplateModel := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
productTemplatesV2, err := productTemplateModel.FindAllByProductIds(l.ctx, productIds)
productTemplatesV2, err := productTemplateModel.FindAllByProductIds(l.ctx, productIds, "")
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")

View File

@ -48,7 +48,7 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
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 {
logx.Error(err)
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,
PartsCanDeleted: *sizeInfo.PartsCanDeleted > 0,
ModelId: modelList[modelIndex].Id,
IsPopular: *sizeInfo.IsPopular > 0,
IsPopular: *sizeInfo.IsHot > 0,
MinPrice: float64(minPrice) / 100,
})
}

View File

@ -63,6 +63,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info")
}
//前台用的分类是1
if *tagData.Category != 1 {
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag")
}
@ -90,7 +91,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表select 字段需要看查询的地方)
productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表select 字段需要看查询的地方)
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
mapProductTemplate = make(map[int64]struct{}) //产品模板map
mapProductTemplate = make(map[int64]int64) //产品模板map
)
//携带产品
if req.WithProduct {
@ -169,14 +170,22 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
}
}
//获取模板(只是获取产品product_id)
productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "product_id")
//获取模板(只是获取产品product_id,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 {
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 {
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)
@ -209,9 +218,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
logx.Error(err)
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{
TotalCategoryProduct: len(productList),
TagList: l.organizationLevelRelation(minLevel, mapTagLevel), //组装等级从属关系
TotalCategoryProduct: TotalCategoryProduct,
TagList: rspTagList,
})
}
@ -223,7 +234,7 @@ type dealWithTagMenuDataReq struct {
MapTagProp map[int64][]types.CoverDefaultItem
ProductTagPropList []gmodel.FsProductTagProp
MapProductMinPrice map[int64]int64
MapProductTemplate map[int64]struct{}
MapProductTemplate map[int64]int64
MapProductSizeCount map[int64]int64
MapTagLevel map[string]*types.TagItem
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{})
//设置归属关系
for prefix, tagItem := range mapTagLevel {
@ -316,22 +327,23 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
if len(mapTagLevel[prefix].TagProductList) == 0 {
continue
}
productCount += len(mapTagLevel[prefix].TagProductList)
rspList = append(rspList, *mapTagLevel[prefix])
}
//排序
sort.SliceStable(rspList, func(i, j int) bool {
return rspList[i].Sort < rspList[j].Sort
})
return rspList
return rspList, productCount
}
// 获取对应tag的产品列表
// 获取某个tag的直属产品
type getTagProductsReq struct {
TagId int64
ProductList []gmodel.FsProduct
MapTagProp map[int64][]types.CoverDefaultItem
MapProductMinPrice map[int64]int64
MapProductTemplate map[int64]struct{}
MapProductTemplate map[int64]int64
MapProductSizeCount map[int64]int64
MapProductHaveOptionFitting map[int64]struct{}
Size uint32
@ -347,7 +359,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
continue
}
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
_, tmpOk := req.MapProductTemplate[productInfo.Id]
templateId, tmpOk := req.MapProductTemplate[productInfo.Id]
//无最小价格则不显示 || 没有模板也不显示
if !ok || !tmpOk {
continue
@ -367,6 +379,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
Title: *productInfo.Title,
SizeNum: uint32(sizeNum),
CoverDefault: []types.CoverDefaultItem{},
DefaultTemplateId: templateId,
MinPrice: minPrice,
HaveOptionalFitting: haveOptionalFitting,
Recommended: *productInfo.IsRecommend > 0,

View File

@ -37,8 +37,8 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
if req.Pid == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty")
}
if req.ProductTemplateTagId <= 0 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id")
if req.TemplateTag == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag")
}
//获取产品信息(只获取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 { //指定物料
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获取模型
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
if err != nil {
@ -92,7 +83,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
mapModel[v.Id] = k
}
//查询模型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 {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")
@ -113,17 +104,42 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
logx.Error(err)
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 != "" {
_ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo)
}
}*/
modelInfo := modelList[modelIndex]
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
rsp[mapKey] = map[string]interface{}{
"id": templateInfo.Id,
"material": *templateInfo.MaterialImg,
"material_data": switchInfo,
"id": templateInfo.Id,
"material": *templateInfo.MaterialImg,
//写死的数据
"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)

View File

@ -130,7 +130,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
}
}
//获取模板(只是获取产品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 {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err")

View File

@ -249,6 +249,7 @@ type GetRecommandProductListRsp struct {
type GetTagProductListReq struct {
Cid int64 `form:"cid,optional"` //分类id
Size uint32 `form:"size,optional"` //尺寸
TemplateTag string `form:"template_tag,optional"` //模板标签
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
}
@ -275,6 +276,7 @@ type TagProduct struct {
SizeNum uint32 `json:"size_num"`
MinPrice int64 `json:"min_price"`
CoverDefault []CoverDefaultItem `json:"cover_default"`
DefaultTemplateId int64 `json:"default_template_id"`
HaveOptionalFitting bool `json:"have_optional_fitting"`
Recommended bool `json:"recommended"`
}
@ -340,9 +342,9 @@ type GetSizeByPidRsp struct {
}
type GetTemplateByPidReq struct {
Pid string `form:"pid"`
ProductSizeId int64 `form:"product_size_id,optional"`
ProductTemplateTagId int64 `form:"product_template_tag_id"`
Pid string `form:"pid"`
ProductSizeId int64 `form:"product_size_id,optional"`
TemplateTag string `form:"template_tag"`
}
type GetFittingByPidReq struct {

View File

@ -2,7 +2,7 @@ Name: resource
Host: 0.0.0.0
Port: 9916
ReplicaId: 60
Timeout: 15000 #服务超时时间(毫秒)
Timeout: 150000 #服务超时时间(毫秒)
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth:
AccessSecret: fusen2023

View 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)
}
}
}

View File

@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/api/resource/logo-combine",
Handler: LogoCombineHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/resource/logo-removebg",
Handler: LogoRemovebgHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/api/resource/info",

View 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,
})
}

View File

@ -5,6 +5,14 @@ import (
"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 {
ResourceId string `form:"resource_id,optional"` // 资源ID
ResourceKey string `form:"resource_key,optional"` // 资源唯一标识

View File

@ -2,7 +2,8 @@ Name: upload
Host: localhost
Port: 9912
ReplicaId: 70
Timeout: 15000 #服务超时时间
Timeout: 150000 #服务超时时间
MaxBytes: 104857600 #传输字节大小
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
Env: "test"
Auth:

View File

@ -57,6 +57,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/api/upload/upload-file-base",
Handler: UploadFileBaseHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/upload/up-standard-logo",
Handler: UploadLogoStandardHandler(serverCtx),
},
},
)
}

View 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)
}
}
}

View File

@ -3,6 +3,7 @@ package logic
import (
"encoding/json"
"errors"
"fmt"
"fusenapi/model/gmodel"
"fusenapi/utils/auth"
"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")
}
// 限制上传文件大小 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)
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")
}
logx.Infof("上传logo请求算法--开始时间:%v", time.Now())
var logoWidth int64
var logoHeight int64
// 查看sku是否存在
@ -146,35 +155,39 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
}
var resultStr string
var postMap = make(map[string]interface{}, 1)
var postMap = make(map[string]string, 1)
postMap["logo_url"] = uploadRes.ResourceUrl
postMapB, _ := json.Marshal(postMap)
fmt.Println(string(postMapB))
var headerData = make(map[string]string, 1)
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 {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 01")
}
defer result.Body.Close()
b, err := io.ReadAll(result.Body)
if err != nil {
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" {
err = errors.New("BLMService fail Internal Server Error")
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 03")
} else {
var resData map[string]interface{}
err = json.Unmarshal(b, &resData)
if err != nil || resData == nil {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 04")
}
if resData != nil {
@ -182,11 +195,11 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
resultStr = resData["data"].(string)
} else {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail")
return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail 05")
}
} else {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 06")
}
}

View 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)
}

View File

@ -5,6 +5,14 @@ import (
"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 {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
FileKey string `form:"file_key"` // 上传唯一标识信息

View File

@ -3,7 +3,6 @@ package logic
import (
"bytes"
"encoding/json"
"fmt"
"fusenapi/constants"
"fusenapi/utils/auth"
"fusenapi/utils/id_generator"
@ -81,7 +80,13 @@ type wsConnectItem struct {
renderProperty renderProperty //扩展云渲染属性
}
// 请求建立连接升级websocket协议
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
conn, err := upgrade.Upgrade(w, r, nil)
if err != nil {
@ -90,29 +95,18 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
}
defer conn.Close()
//鉴权不成功后断开
/*var (
var (
userInfo *auth.UserInfo
isAuth bool
)
isAuth, userInfo = l.checkAuth(r)
if !isAuth {
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)
//未授权响应消息
l.unAuthResponse(conn)
return
}*/
//测试的目前写死 39
var userInfo auth.UserInfo
userInfo.UserId = 39
}
//设置连接
ws := l.setConnPool(conn, userInfo)
ws := l.setConnPool(conn, *userInfo)
defer ws.close()
//循环读客户端信息
go ws.readLoop()
@ -144,7 +138,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
userId: userInfo.UserId,
guestId: userInfo.GuestId,
renderProperty: renderProperty{
renderImageTask: make(map[string]string),
renderImageTask: make(map[string]*renderTask),
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100),
renderChan: make(chan []byte, 100),
},
@ -153,7 +147,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
mapConnPool.Store(uniqueId, ws)
go func() {
//把连接成功消息发回去
time.Sleep(time.Second * 1) //兼容下火狐
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId))
}()
return ws
@ -162,24 +156,20 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
// 获取唯一id
func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string {
//后面拼接上用户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 {
uniqueId = l.getUniqueId(userInfo)
}
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) {
// 解析JWT token,并对空用户进行判断
claims, err := l.svcCtx.ParseJwtToken(r)
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
if err != nil {
logx.Error(err)
return false, nil
}
if claims != nil {
@ -187,6 +177,7 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a
userInfo, err = auth.GetUserInfoFormMapClaims(claims)
// 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
if err != nil {
logx.Error(err)
return false, nil
}
//不是登录用户也不是游客
@ -198,6 +189,22 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a
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() {
tick := time.Tick(time.Second * 5)

View File

@ -1,18 +1,14 @@
package logic
import (
"fusenapi/constants"
"context"
"fusenapi/server/websocket/internal/svc"
"fusenapi/server/websocket/internal/types"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/file"
"fusenapi/utils/websocket_data"
"time"
"context"
"fusenapi/server/websocket/internal/svc"
"fusenapi/server/websocket/internal/types"
"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) {
if req.TaskId == "" {
logx.Error("渲染回调参数错误invalid param task_id")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
}
if req.Image == "" {
logx.Error("渲染回调参数错误invalid param image")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
}
if req.UserId == 0 && req.GuestId == 0 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id")
}
//存base64打印测试
/* f, _ := os.Create("b.txt")
defer f.Close()
f.WriteString(req.Image)*/
// 上传文件
var upload = file.Upload{
Ctx: l.ctx,
@ -67,7 +66,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
FileByte: nil,
})
if err != nil {
logx.Error(err)
logx.Error("渲染回调上传文件失败:", err)
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image")
}
//遍历websocket链接把数据传进去
@ -75,37 +74,24 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
//断言连接
ws, ok := value.(wsConnectItem)
if !ok {
logx.Error("渲染回调断言websocket连接失败")
return true
}
//关闭标识
if ws.isClose {
return true
}
//查询有无该渲染任务
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,
//记录收到unity渲染结果时间
ws.modifyRenderTaskTimeConsuming(renderImageControlChanItem{
Option: 2,
TaskProperty: renderTask{
UnityRenderEndTime: time.Now().UTC().Unix(),
},
})
//发送处理并删除任务
ws.deleteRenderTask(renderImageControlChanItem{
Option: 0, //0删除 1添加
TaskId: req.TaskId,
RenderNotifyImageUrl: uploadRes.ResourceUrl,
})
deleteTask := renderImageControlChanItem{
Option: 0, //0删除 1添加
TaskId: req.TaskId,
RenderId: renderId,
}
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
})
logx.Info("渲染回调成功######################")
logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl)
return resp.SetStatusWithMessage(basic.CodeOK, "success")
}

View File

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"fusenapi/constants"
"fusenapi/service/repositories"
"fusenapi/utils/curl"
@ -18,16 +19,25 @@ import (
// 云渲染属性
type renderProperty struct {
renderImageTask map[string]string //需要渲染的图片任务 key是taskId val 是renderId
renderImageTask map[string]*renderTask //需要渲染的图片任务 key是taskId val 是renderId
renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增移除的控制通道
renderChan chan []byte //渲染的缓冲队列
}
type renderTask struct {
RenderId string //渲染id(前端传的)
CombineBeginTime int64 //合图开始时间
CombineEndTime int64 //合图结束时间
UnityRenderBeginTime int64 //发送给unity时间
UnityRenderEndTime int64 //unity回调结果时间
}
// 渲染任务新增移除的控制通道的数据
type renderImageControlChanItem struct {
Option int // 0删除 1添加
TaskId string //map的key
RenderId string // map的val
Option int // 0删除 1添加
TaskId string //map的key
RenderId string // map的val(增加任务时候传)
RenderNotifyImageUrl string //渲染回调数据(删除任务时候传)
TaskProperty renderTask //渲染任务的属性
}
// 发送到渲染缓冲池
@ -35,14 +45,14 @@ func (w *wsConnectItem) sendToRenderChan(data []byte) {
select {
case <-w.closeChan: //已经关闭
return
case w.renderProperty.renderChan <- data:
case w.renderProperty.renderChan <- data: //发入到缓冲池
return
case <-time.After(time.Second * 3):
case <-time.After(time.Second * 3): //三秒没进入缓冲池就丢弃
return
}
}
// 渲染发送到组装数据组装数据
// 渲染发送到组装数据组装数据(缓冲池)
func (w *wsConnectItem) renderImage() {
defer func() {
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)
return
}
logx.Info("收到请求云渲染图片数据:", renderImageData)
if renderImageData.RenderId == "" {
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")
@ -116,7 +125,10 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
hashVal := renderImageData.RenderData
hashVal.UserId = 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)
if err != nil {
@ -127,8 +139,10 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
} else {
//返回给客户端
b := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
RenderId: renderImageData.RenderId,
Image: *resource.ResourceUrl,
RenderId: renderImageData.RenderId,
Image: *resource.ResourceUrl,
CombineTakesTime: "耗时0秒(缓存)",
UnityRenderTakesTime: "耗时0秒(缓存)",
})
//发送数据到out chan
w.sendToOutChan(b)
@ -136,11 +150,11 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
}
//###########################################
//把需要渲染的图片任务加进去
w.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{
w.createRenderTask(renderImageControlChanItem{
Option: 1, //0删除 1添加
TaskId: taskId,
RenderId: renderImageData.RenderId,
}
})
//组装数据
if err = w.assembleRenderData(taskId, renderImageData); err != nil {
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)
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,
GuestId: info.RenderData.GuestId,
TemplateId: productTemplate.Id,
@ -175,9 +196,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
Slogan: info.RenderData.Slogan,
Address: info.RenderData.Address,
Phone: info.RenderData.Phone,
})
}
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
if err != nil {
logx.Error("合成刀版图失败:", err)
logx.Error("合成刀版图失败,合成请求数据:", combineReq, "错误信息:", err)
return err
}
combineImage := "" //刀版图
@ -187,17 +209,18 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
logx.Error("合成刀版图失败,合成的刀版图是空指针:", 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)
if err != nil {
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)
return err
}
@ -208,6 +231,9 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
refletion := -1
if element.Refletion != nil && *element.Refletion != "" {
refletion, err = strconv.Atoi(*element.Refletion)
if err != nil {
logx.Error("err refletion:set default -1")
}
}
//组装data数据
var mode map[string]interface{}
@ -272,7 +298,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
"folder": "", //todo 千人千面需要使用
}
//请求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["content-type"] = "application/json"
t := time.Now().UTC()
@ -283,17 +309,66 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
"create_at": t,
"render_data": sendData,
}
p, _ := json.Marshal(postData)
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*10)
postDataBytes, _ := json.Marshal(postData)
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(postDataBytes), time.Second*10)
if err != nil {
logx.Error("failed to send data to unity")
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
}
// 操作连接中渲染任务的增加/删除
// 增加渲染任务
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() {
for {
select {
@ -301,10 +376,46 @@ func (w *wsConnectItem) operationRenderTask() {
return
case data := <-w.renderProperty.renderImageTaskCtlChan:
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)
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)
}
}
}
}

View File

@ -2,6 +2,7 @@ package logic
import (
"encoding/json"
"fmt"
"fusenapi/constants"
"github.com/zeromicro/go-zero/core/logx"
)
@ -22,7 +23,7 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) {
return
}
//合成client后缀,不是同个后缀的不能复用
userPart := getUserPart(w.userId, w.guestId)
userPart := getUserJoinPart(w.userId, w.guestId)
lenUserPart := len(userPart)
if lenClientId <= lenUserPart {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to short"))
@ -36,10 +37,23 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) {
publicMutex.Lock()
defer publicMutex.Unlock()
//存在是不能给他申请重新绑定
if _, ok := mapConnPool.Load(clientId); ok {
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ")
w.sendToOutChan(rsp)
return
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 ")
w.sendToOutChan(rsp)
return
}
}
//重新绑定
w.uniqueId = clientId
@ -47,3 +61,8 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) {
w.sendToOutChan(rsp)
return
}
// 获取用户拼接部分(复用标识用到)
func getUserJoinPart(userId, guestId int64) string {
return fmt.Sprintf("_%d_%d", userId, guestId)
}

View File

@ -301,6 +301,7 @@ type GetRecommandProductListRsp {
type GetTagProductListReq {
Cid int64 `form:"cid,optional"` //分类id
Size uint32 `form:"size,optional"` //尺寸
TemplateTag string `form:"template_tag,optional"` //模板标签
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
}
type GetTagProductListRsp {
@ -325,6 +326,7 @@ type TagProduct {
MinPrice int64 `json:"min_price"`
//彩膜列表
CoverDefault []CoverDefaultItem `json:"cover_default"`
DefaultTemplateId int64 `json:"default_template_id"`
HaveOptionalFitting bool `json:"have_optional_fitting"`
Recommended bool `json:"recommended"`
}
@ -385,9 +387,9 @@ type GetSizeByPidRsp {
}
//获取产品模板
type GetTemplateByPidReq {
Pid string `form:"pid"`
ProductSizeId int64 `form:"product_size_id,optional"`
ProductTemplateTagId int64 `form:"product_template_tag_id"`
Pid string `form:"pid"`
ProductSizeId int64 `form:"product_size_id,optional"`
TemplateTag string `form:"template_tag"`
}
//获取产品配件数据
type GetFittingByPidReq {

View File

@ -13,10 +13,23 @@ service resource {
@handler LogoCombineHandler
post /api/resource/logo-combine(LogoCombineReq) returns (response);
@handler LogoRemovebgHandler
post /api/resource/logo-removebg(LogoRemovebgReq) returns (response);
@handler ResourceInfoHandler
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 (
ResourceInfoReq {
ResourceId string `form:"resource_id,optional"` // 资源ID

View File

@ -42,8 +42,21 @@ service upload {
@handler UploadFileBaseHandler
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 (
UploadFileBaseReq {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"fusenapi/constants"
"fusenapi/model/gmodel"
"fusenapi/utils/curl"
@ -37,6 +38,9 @@ type (
// logo合图
LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error)
// logo裁剪
LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error)
}
)
@ -47,11 +51,12 @@ type (
GuestId int64 `json:"guest_id"`
TemplateId int64 `json:"template_id"`
TemplateTag string `json:"template_tag"`
Website string `json:"website"` // 合图参数
Slogan string `json:"slogan"` // 合图参数
Address string `json:"address"` // 合图参数
Phone string `json:"phone"` // 合图参数
Qrcode string `json:"qrcode"` // 合图参数
Website string `json:"website"` // 合图参数
Slogan string `json:"slogan"` // 合图参数
Address string `json:"address"` // 合图参数
Phone string `json:"phone"` // 合图参数
Qrcode string `json:"qrcode"` // 合图参数
LogoUrl string `json:"logo_url"` // 合图参数
}
LogoCombineRes struct {
ResourceId string
@ -61,11 +66,36 @@ type (
)
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 查询数据资源
var hashKeyData = *in
hashKeyData.GuestId = 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)
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{})
}
fmt.Println("合图开始时间:", time.Now())
logx.Infof("合图请求算法--开始时间:%v", time.Now())
var moduleDataMap = make(map[string]interface{}, 4)
moduleDataMap["id"] = productTemplateV2Info.Id
moduleDataMap["material"] = productTemplateV2Info.MaterialImg
moduleDataMap["groupOptions"] = groupOptions
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{}
json.Unmarshal([]byte(*metadata), &combineParam)
combineParam["template_tagid"] = in.TemplateTag
@ -142,14 +154,162 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
combineParam["qrcode"] = in.Qrcode
var postMap = make(map[string]interface{}, 2)
fmt.Println(combineParam)
postMap["module_data"] = moduleDataMap
postMap["param_data"] = combineParam
postMapB, _ := json.Marshal(postMap)
var headerData = make(map[string]string, 1)
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 {
logx.Error(err)
return nil, err
@ -192,12 +352,29 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
logx.Error(err)
return nil, err
}
// {
// id: "",
// logo_url:"https://s3.amazon.com/xxxx"
// result: "$saa541afaldjaldjasldjsadjsapsaasda"
// }
var fileBase = resultData["result"]
//$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}'
var fileBase = resultData["nobg_url"].(string)
ismaxProportion = resultData["ismax_proportion"].(bool)
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{
@ -206,22 +383,23 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
AwsSession: l.AwsSession,
}
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
Source: "combine-image",
Source: "combine-removebg",
FileHash: resourceId,
FileData: fileBase.(string),
FileData: fileBase,
UploadBucket: 1,
ApiType: 2,
UserId: in.UserId,
GuestId: in.GuestId,
Metadata: metadata,
})
if err != nil {
logx.Error(err)
return nil, err
}
return &LogoCombineRes{
ResourceId: uploadRes.ResourceId,
ResourceUrl: &uploadRes.ResourceUrl,
return &LogoStandardRes{
ResourceId: uploadRes.ResourceId,
ResourceUrl: uploadRes.ResourceUrl,
IsmaxProportion: ismaxProportion,
ImgColor: imgColor,
}, nil
}
/* logo合图 */
/* 片裁剪 */

View File

@ -5,13 +5,12 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"reflect"
"sort"
)
func JsonHashKey(v interface{}) string {
if reflect.TypeOf(v).Kind() == reflect.String {
if _, ok := v.(string); ok {
var obj interface{}
err := json.Unmarshal([]byte(v.(string)), &obj)
if err == nil {

View File

@ -25,8 +25,10 @@ type RenderData struct {
// websocket发送渲染完的数据
type RenderImageRspMsg struct {
RenderId string `json:"render_id"` //渲染id
Image string `json:"image"` //渲染结果图片
RenderId string `json:"render_id"` //渲染id
Image string `json:"image"` //渲染结果图片
CombineTakesTime string `json:"combine_takes_time"` //合图需要时间
UnityRenderTakesTime string `json:"unity_render_takes_time"` //unity渲染用时
}
type ThirdPartyLoginRspMsg struct {
//websocket三方登录的通知数据