Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
dc0ea32662
@ -1,29 +1,25 @@
|
|||||||
package constants
|
package constants
|
||||||
|
|
||||||
type websocket string
|
type Websocket string
|
||||||
|
|
||||||
// websocket消息类型
|
// websocket消息类型
|
||||||
const (
|
const (
|
||||||
//鉴权失败
|
//鉴权失败
|
||||||
WEBSOCKET_UNAUTH = "WEBSOCKET_UNAUTH"
|
WEBSOCKET_UNAUTH Websocket = "WEBSOCKET_UNAUTH"
|
||||||
//ws连接成功
|
//ws连接成功
|
||||||
WEBSOCKET_CONNECT_SUCCESS = "WEBSOCKET_CONNECT_SUCCESS"
|
WEBSOCKET_CONNECT_SUCCESS Websocket = "WEBSOCKET_CONNECT_SUCCESS"
|
||||||
//请求恢复为上次连接的标识
|
//请求恢复为上次连接的标识
|
||||||
WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT"
|
WEBSOCKET_REQUEST_REUSE_LAST_CONNECT Websocket = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT"
|
||||||
//请求恢复为上次连接的标识错误
|
//请求恢复为上次连接的标识错误
|
||||||
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR"
|
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR Websocket = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR"
|
||||||
//图片渲染
|
//图片渲染
|
||||||
WEBSOCKET_RENDER_IMAGE = "WEBSOCKET_RENDER_IMAGE"
|
WEBSOCKET_RENDER_IMAGE Websocket = "WEBSOCKET_RENDER_IMAGE"
|
||||||
//图片渲染失败消息
|
//图片渲染失败消息
|
||||||
WEBSOCKET_RENDER_IMAGE_ERR = "WEBSOCKET_RENDER_IMAGE_ERR"
|
WEBSOCKET_RENDER_IMAGE_ERR Websocket = "WEBSOCKET_RENDER_IMAGE_ERR"
|
||||||
//传入数据格式错误
|
//传入数据格式错误
|
||||||
WEBSOCKET_ERR_DATA_FORMAT = "WEBSOCKET_ERR_DATA_FORMAT"
|
WEBSOCKET_ERR_DATA_FORMAT Websocket = "WEBSOCKET_ERR_DATA_FORMAT"
|
||||||
//第三方登录通知
|
//登录回调通知
|
||||||
WEBSOCKET_THIRD_PARTY_LOGIN_NOTIFY = "WEBSOCKET_THIRD_PARTY_LOGIN_NOTIFY"
|
WEBSOCKET_LOGIN_NOTIFY Websocket = "WEBSOCKET_LOGIN_NOTIFY"
|
||||||
|
//注册帐号回调通知
|
||||||
|
WEBSOCKET_REGISTER_NOTIFY Websocket = "WEBSOCKET_REGISTER_NOTIFY"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 云渲染完成通知api需要的签名字符串
|
|
||||||
const RENDER_NOTIFY_SIGN_KEY = "fusen-render-notify-%s-%d"
|
|
||||||
|
|
||||||
// 第三方登录通知api需要的签名字符串
|
|
||||||
const THIRD_PARTY_LOGIN_NOTIFY_SIGN_KEY = "fusen-render-notify-%s-%d"
|
|
||||||
|
@ -15,9 +15,9 @@ type FsAddress struct {
|
|||||||
Street *string `gorm:"default:'';" json:"street"` // 街道
|
Street *string `gorm:"default:'';" json:"street"` // 街道
|
||||||
Suite *string `gorm:"default:'';" json:"suite"` // 房号
|
Suite *string `gorm:"default:'';" json:"suite"` // 房号
|
||||||
City *string `gorm:"default:'';" json:"city"` // 城市
|
City *string `gorm:"default:'';" json:"city"` // 城市
|
||||||
State *string `gorm:"default:'';" json:"state"` // 州名
|
State *string `gorm:"default:'';" json:"state"` //
|
||||||
Country *string `gorm:"default:'';" json:"country"` // 国家
|
Country *string `gorm:"default:'';" json:"country"` //
|
||||||
ZipCode *string `gorm:"default:'';" json:"zip_code"` // 邮编
|
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
||||||
IsDefault *int64 `gorm:"index;default:0;" json:"is_default"` // 1默认地址,0非默认地址
|
IsDefault *int64 `gorm:"index;default:0;" json:"is_default"` // 1默认地址,0非默认地址
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
// fs_backend_user 管理员表
|
// fs_backend_user 管理员表
|
||||||
type FsBackendUser struct {
|
type FsBackendUser struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||||
Username *string `gorm:"unique_key;default:'';" json:"username"` // 用户名
|
Username *string `gorm:"unique_key;default:'';" json:"username"` //
|
||||||
AuthKey *string `gorm:"default:'';" json:"auth_key"` // jwt token
|
AuthKey *string `gorm:"default:'';" json:"auth_key"` //
|
||||||
PasswordHash *string `gorm:"default:'';" json:"password_hash"` // 加密密码
|
PasswordHash *string `gorm:"default:'';" json:"password_hash"` //
|
||||||
PasswordResetToken *string `gorm:"default:'';" json:"password_reset_token"` //
|
PasswordResetToken *string `gorm:"default:'';" json:"password_reset_token"` //
|
||||||
Email *string `gorm:"unique_key;default:'';" json:"email"` // 邮箱
|
Email *string `gorm:"unique_key;default:'';" json:"email"` //
|
||||||
Status *int64 `gorm:"default:1;" json:"status"` // 状态
|
Status *int64 `gorm:"default:1;" json:"status"` // 状态
|
||||||
Icon *string `gorm:"default:'';" json:"icon"` //
|
Icon *string `gorm:"default:'';" json:"icon"` //
|
||||||
DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门id
|
DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门id
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
// fs_card_group 卡号分组表
|
// fs_card_group 卡号分组表
|
||||||
type FsCardGroup struct {
|
type FsCardGroup struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||||
GroupName *string `gorm:"default:'';" json:"group_name"` // 分组名字
|
GroupName *string `gorm:"default:'';" json:"group_name"` //
|
||||||
PreNo *string `gorm:"default:'';" json:"pre_no"` // 规则前几位数
|
PreNo *string `gorm:"default:'';" json:"pre_no"` //
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 生成数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 生成数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||||
}
|
}
|
||||||
type FsCardGroupModel struct {
|
type FsCardGroupModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -9,7 +9,7 @@ type FsCloudDeliverEveryTmp struct {
|
|||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
AdminId *int64 `gorm:"default:0;" json:"admin_id"` // 管理员
|
AdminId *int64 `gorm:"default:0;" json:"admin_id"` // 管理员
|
||||||
CloudId *int64 `gorm:"default:0;" json:"cloud_id"` // 云仓ID 暂且只有一个默认为 1
|
CloudId *int64 `gorm:"default:0;" json:"cloud_id"` // 云仓ID 暂且只有一个默认为 1
|
||||||
OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` // 详情modelSn
|
OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` //
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
type FsCloudReceiveEvery struct {
|
type FsCloudReceiveEvery struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
DeliveryId *int64 `gorm:"index;default:0;" json:"delivery_id"` // 云仓收货单id
|
DeliveryId *int64 `gorm:"index;default:0;" json:"delivery_id"` // 云仓收货单id
|
||||||
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` // 详情modelSn
|
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` //
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 收到的数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 收到的数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ type FsCloudReceive struct {
|
|||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
||||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 入库云仓的订单
|
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 入库云仓的订单
|
||||||
Fee *int64 `gorm:"default:0;" json:"fee"` // 运费
|
Fee *int64 `gorm:"default:0;" json:"fee"` // 运费
|
||||||
Delivery *string `gorm:"default:'';" json:"delivery"` // 运单号
|
Delivery *string `gorm:"default:'';" json:"delivery"` //
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 0未收到 1收到
|
Status *int64 `gorm:"default:0;" json:"status"` // 0未收到 1收到
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ type FsCloudRenderLog struct {
|
|||||||
PostUrl *string `gorm:"default:'';" json:"post_url"` //
|
PostUrl *string `gorm:"default:'';" json:"post_url"` //
|
||||||
Title *string `gorm:"index;default:'';" json:"title"` //
|
Title *string `gorm:"index;default:'';" json:"title"` //
|
||||||
Time *int64 `gorm:"default:0;" json:"time"` // 所用时间
|
Time *int64 `gorm:"default:0;" json:"time"` // 所用时间
|
||||||
Result *string `gorm:"default:'';" json:"result"` // 返回结果
|
Result *string `gorm:"default:'';" json:"result"` //
|
||||||
Tag *string `gorm:"index;default:'';" json:"tag"` // 标识
|
Tag *string `gorm:"index;default:'';" json:"tag"` // 标识
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
// fs_coupon 代金券(暂未使用)
|
// fs_coupon 代金券(暂未使用)
|
||||||
type FsCoupon struct {
|
type FsCoupon struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
UserId *int64 `gorm:"default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID 0:暂时未绑定用户
|
||||||
Sn *string `gorm:"default:'';" json:"sn"` // 优惠券码
|
Sn *string `gorm:"default:'';" json:"sn"` //
|
||||||
Type *int64 `gorm:"default:0;" json:"type"` // 类型 1:代金券 2:折扣券 3:满减券
|
Type *int64 `gorm:"default:0;" json:"type"` // 类型 1:代金券 2:折扣券 3:满减券
|
||||||
Amount *int64 `gorm:"default:0;" json:"amount"` // 代金券金额、折扣比例、满减金额
|
Amount *int64 `gorm:"default:0;" json:"amount"` // 代金券金额、折扣比例、满减金额
|
||||||
MinAmount *int64 `gorm:"default:0;" json:"min_amount"` // 满足条件的最小金额 0:不限制
|
MinAmount *int64 `gorm:"default:0;" json:"min_amount"` // 满足条件的最小金额 0:不限制
|
||||||
@ -16,8 +16,8 @@ type FsCoupon struct {
|
|||||||
Stime *int64 `gorm:"default:0;" json:"stime"` // 开始时间 0:立即生效
|
Stime *int64 `gorm:"default:0;" json:"stime"` // 开始时间 0:立即生效
|
||||||
Etime *int64 `gorm:"default:0;" json:"etime"` // 结束时间 0:永久有效
|
Etime *int64 `gorm:"default:0;" json:"etime"` // 结束时间 0:永久有效
|
||||||
Exclude *int64 `gorm:"default:2;" json:"exclude"` // 是否可以与其他优惠券同时使用 1:可以 2:不可以
|
Exclude *int64 `gorm:"default:2;" json:"exclude"` // 是否可以与其他优惠券同时使用 1:可以 2:不可以
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
GetTime *int64 `gorm:"default:0;" json:"get_time"` //
|
GetTime *int64 `gorm:"default:0;" json:"get_time"` // 上架时间
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态 是否可用 是否已绑定到订单
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态 是否可用 是否已绑定到订单
|
||||||
}
|
}
|
||||||
type FsCouponModel struct {
|
type FsCouponModel struct {
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
type FsDeliverEvery struct {
|
type FsDeliverEvery struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
DeliverId *int64 `gorm:"index;default:0;" json:"deliver_id"` // 发货ID
|
DeliverId *int64 `gorm:"index;default:0;" json:"deliver_id"` // 发货ID
|
||||||
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` // 订单详情模板sn
|
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` //
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` //
|
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
||||||
}
|
}
|
||||||
type FsDeliverEveryModel struct {
|
type FsDeliverEveryModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -12,7 +12,7 @@ type FsDeliver struct {
|
|||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
AdminId *int64 `gorm:"index;default:0;" json:"admin_id"` // 操作人id
|
AdminId *int64 `gorm:"index;default:0;" json:"admin_id"` // 操作人id
|
||||||
Fee *int64 `gorm:"default:0;" json:"fee"` // 运费价格
|
Fee *int64 `gorm:"default:0;" json:"fee"` // 运费价格
|
||||||
Tel *string `gorm:"default:'';" json:"tel"` // 电话
|
Tel *string `gorm:"default:'';" json:"tel"` //
|
||||||
DeliveryType *int64 `gorm:"default:0;" json:"delivery_type"` // 发货公司
|
DeliveryType *int64 `gorm:"default:0;" json:"delivery_type"` // 发货公司
|
||||||
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址id
|
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址id
|
||||||
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 地址信息
|
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 地址信息
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
type FsFactoryDeliverEvery struct {
|
type FsFactoryDeliverEvery struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
FactoryDeliverId *int64 `gorm:"index;default:0;" json:"factory_deliver_id"` // 工厂发货表ID
|
FactoryDeliverId *int64 `gorm:"index;default:0;" json:"factory_deliver_id"` // 工厂发货表ID
|
||||||
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` // 订单产品模板sn
|
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` //
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
// fs_factory_deliver 工厂发货主表(废弃)
|
// fs_factory_deliver 工厂发货主表(废弃)
|
||||||
type FsFactoryDeliver struct {
|
type FsFactoryDeliver struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"index;default:'';" json:"sn"` // 工厂发货编号sn
|
Sn *string `gorm:"index;default:'';" json:"sn"` //
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||||
DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 发货方式( 1:直接发货到收获地址 2:云仓)
|
DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 发货方式( 1:直接发货到收获地址 2:云仓)
|
||||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单id
|
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单id
|
||||||
|
@ -9,7 +9,7 @@ type FsFactoryProduct struct {
|
|||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
FactoryId *int64 `gorm:"index;default:0;" json:"factory_id"` // 工厂id
|
FactoryId *int64 `gorm:"index;default:0;" json:"factory_id"` // 工厂id
|
||||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单id
|
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单id
|
||||||
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` // 产品模板sn
|
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` //
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 数量
|
||||||
IsProduct *int64 `gorm:"default:0;" json:"is_product"` // 是否开始生产( 0:未开始 ,1:已开始)
|
IsProduct *int64 `gorm:"default:0;" json:"is_product"` // 是否开始生产( 0:未开始 ,1:已开始)
|
||||||
IsEnd *int64 `gorm:"default:0;" json:"is_end"` // 是否完成(0:未完成,1:已完成)
|
IsEnd *int64 `gorm:"default:0;" json:"is_end"` // 是否完成(0:未完成,1:已完成)
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
// fs_factory_ship_tmp
|
// fs_factory_ship_tmp
|
||||||
type FsFactoryShipTmp struct {
|
type FsFactoryShipTmp struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"default:'';" json:"sn"` // 运单号码
|
Sn *string `gorm:"default:'';" json:"sn"` //
|
||||||
FactoryId *int64 `gorm:"default:0;" json:"factory_id"` // 工厂ID
|
FactoryId *int64 `gorm:"default:0;" json:"factory_id"` // 工厂ID
|
||||||
OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` // 详情modelSn
|
OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` //
|
||||||
UserId *int64 `gorm:"default:0;" json:"user_id"` //
|
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID
|
||||||
AddressSent *string `gorm:"default:'';" json:"address_sent"` // 发货地址
|
AddressSent *string `gorm:"default:'';" json:"address_sent"` // 发货地址
|
||||||
AddressTo *string `gorm:"default:'';" json:"address_to"` // 收获地址 始终是货代公司
|
AddressTo *string `gorm:"default:'';" json:"address_to"` // 收获地址 始终是货代公司
|
||||||
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
// fs_log 日志表
|
// fs_log 日志表
|
||||||
type FsLog struct {
|
type FsLog struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||||
Action *string `gorm:"default:'';" json:"action"` // 执行的动作
|
Action *string `gorm:"default:'';" json:"action"` //
|
||||||
Table *string `gorm:"default:'';" json:"table"` // 表明
|
Table *string `gorm:"default:'';" json:"table"` //
|
||||||
DataChanged *string `gorm:"default:'';" json:"data_changed"` // 修改后的数据
|
DataChanged *string `gorm:"default:'';" json:"data_changed"` // 修改后的数据
|
||||||
DataOld *string `gorm:"default:'';" json:"data_old"` // 变动的数据
|
DataOld *string `gorm:"default:'';" json:"data_old"` // 变动的数据
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
Uid *int64 `gorm:"default:0;" json:"uid"` // 操作人ID
|
Uid *int64 `gorm:"default:0;" json:"uid"` // 操作人ID
|
||||||
Uname *string `gorm:"default:'';" json:"uname"` // 操作人名字
|
Uname *string `gorm:"default:'';" json:"uname"` //
|
||||||
}
|
}
|
||||||
type FsLogModel struct {
|
type FsLogModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
// fs_menu 后台菜单
|
// fs_menu 后台菜单
|
||||||
type FsMenu struct {
|
type FsMenu struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||||
Name *string `gorm:"default:'';" json:"name"` // 菜单名
|
Name *string `gorm:"default:'';" json:"name"` //
|
||||||
Parent *int64 `gorm:"index;default:0;" json:"parent"` //
|
Parent *int64 `gorm:"index;default:0;" json:"parent"` // 父id
|
||||||
Route *string `gorm:"default:'';" json:"route"` //
|
Route *string `gorm:"default:'';" json:"route"` //
|
||||||
Order *int64 `gorm:"default:0;" json:"order"` //
|
Order *int64 `gorm:"default:0;" json:"order"` // 排序
|
||||||
Data *[]byte `gorm:"default:'';" json:"data"` // 其他信息(图标等)
|
Data *[]byte `gorm:"default:'';" json:"data"` // 其他信息(图标等)
|
||||||
}
|
}
|
||||||
type FsMenuModel struct {
|
type FsMenuModel struct {
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
// fs_migration 版本库
|
// fs_migration 版本库
|
||||||
type FsMigration struct {
|
type FsMigration struct {
|
||||||
Version string `gorm:"primary_key;default:'';" json:"version"` // 版本信息
|
Version string `gorm:"primary_key;default:'';" json:"version"` // 版本信息
|
||||||
ApplyTime *int64 `gorm:"default:0;" json:"apply_time"` //
|
ApplyTime *int64 `gorm:"default:0;" json:"apply_time"` // 应用时间
|
||||||
}
|
}
|
||||||
type FsMigrationModel struct {
|
type FsMigrationModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -7,20 +7,20 @@ import (
|
|||||||
// fs_product_copy1 产品表
|
// fs_product_copy1 产品表
|
||||||
type FsProductCopy1 struct {
|
type FsProductCopy1 struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 商品编号 P98f087j
|
Sn *string `gorm:"unique_key;default:'';" json:"sn"` //
|
||||||
Type *int64 `gorm:"default:0;" json:"type"` // 分类ID
|
Type *int64 `gorm:"default:0;" json:"type"` // 分类ID
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 名称
|
Title *string `gorm:"default:'';" json:"title"` //
|
||||||
TitleCn *string `gorm:"default:'';" json:"title_cn"` // 中文名称
|
TitleCn *string `gorm:"default:'';" json:"title_cn"` //
|
||||||
Cover *string `gorm:"default:'';" json:"cover"` // 封面图
|
Cover *string `gorm:"default:'';" json:"cover"` //
|
||||||
Imgs *string `gorm:"default:'';" json:"imgs"` // 一个或多个介绍图或视频
|
Imgs *string `gorm:"default:'';" json:"imgs"` //
|
||||||
Keywords *string `gorm:"default:'';" json:"keywords"` // 关键字
|
Keywords *string `gorm:"default:'';" json:"keywords"` //
|
||||||
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
|
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
|
||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
|
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
View *int64 `gorm:"default:0;" json:"view"` // 浏览量
|
View *int64 `gorm:"default:0;" json:"view"` // 浏览量
|
||||||
SizeIds *string `gorm:"default:'';" json:"size_ids"` //
|
SizeIds *string `gorm:"default:'';" json:"size_ids"` //
|
||||||
MaterialIds *string `gorm:"default:'';" json:"material_ids"` // 材质 1,2,3
|
MaterialIds *string `gorm:"default:'';" json:"material_ids"` //
|
||||||
TagIds *string `gorm:"default:'';" json:"tag_ids"` //
|
TagIds *string `gorm:"default:'';" json:"tag_ids"` //
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否上架 是否推荐 是否热销 是否环保 是否可加入微波炉 是否刪除
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否上架 是否推荐 是否热销 是否环保 是否可加入微波炉 是否刪除
|
||||||
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
|
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
|
||||||
|
@ -7,12 +7,12 @@ import (
|
|||||||
// fs_product_option 产品选项表(已废弃)
|
// fs_product_option 产品选项表(已废弃)
|
||||||
type FsProductOption struct {
|
type FsProductOption struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 名称
|
Title *string `gorm:"default:'';" json:"title"` //
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品id
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品id
|
||||||
Price *int64 `gorm:"default:0;" json:"price"` // 产品单价
|
Price *int64 `gorm:"default:0;" json:"price"` // 产品单价
|
||||||
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸id
|
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸id
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态值(0:禁用,1:启用)
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态值(0:禁用,1:启用)
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||||
}
|
}
|
||||||
type FsProductOptionModel struct {
|
type FsProductOptionModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
// fs_product_template_element_22
|
// fs_product_template_element_22
|
||||||
type FsProductTemplateElement22 struct {
|
type FsProductTemplateElement22 struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 产品模板名称
|
Title *string `gorm:"default:'';" json:"title"` //
|
||||||
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id
|
||||||
Model *string `gorm:"default:'';" json:"model"` //
|
Model *string `gorm:"default:'';" json:"model"` //
|
||||||
Mode *string `gorm:"default:'';" json:"mode"` //
|
Mode *string `gorm:"default:'';" json:"mode"` //
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
type FsProductTemplate struct {
|
type FsProductTemplate struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 标题描述
|
Title *string `gorm:"default:'';" json:"title"` //
|
||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
ModelInfo *string `gorm:"default:'';" json:"model_info"` // 模型详情
|
ModelInfo *string `gorm:"default:'';" json:"model_info"` // 模型详情
|
||||||
|
@ -7,19 +7,19 @@ import (
|
|||||||
// fs_product_v2_tmp 产品表
|
// fs_product_v2_tmp 产品表
|
||||||
type FsProductV2Tmp struct {
|
type FsProductV2Tmp struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 商品编号 P98f087j
|
Sn *string `gorm:"unique_key;default:'';" json:"sn"` //
|
||||||
Type *int64 `gorm:"default:0;" json:"type"` // 分类ID
|
Type *int64 `gorm:"default:0;" json:"type"` // 分类ID
|
||||||
Title *string `gorm:"default:'';" json:"title"` // 名称
|
Title *string `gorm:"default:'';" json:"title"` //
|
||||||
TitleCn *string `gorm:"default:'';" json:"title_cn"` // 中文名称
|
TitleCn *string `gorm:"default:'';" json:"title_cn"` //
|
||||||
Imgs *string `gorm:"default:'';" json:"imgs"` // 一个或多个介绍图或视频
|
Imgs *string `gorm:"default:'';" json:"imgs"` // 一个或多个介绍图或视频
|
||||||
Keywords *string `gorm:"default:'';" json:"keywords"` // 关键字
|
Keywords *string `gorm:"default:'';" json:"keywords"` //
|
||||||
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
|
Intro *string `gorm:"default:'';" json:"intro"` // 简要描述
|
||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
|
SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` //
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
View *int64 `gorm:"default:0;" json:"view"` // 浏览量
|
View *int64 `gorm:"default:0;" json:"view"` // 浏览量
|
||||||
SizeIds *string `gorm:"default:'';" json:"size_ids"` //
|
SizeIds *string `gorm:"default:'';" json:"size_ids"` //
|
||||||
MaterialIds *string `gorm:"default:'';" json:"material_ids"` // 材质 1,2,3
|
MaterialIds *string `gorm:"default:'';" json:"material_ids"` //
|
||||||
TagIds *string `gorm:"default:'';" json:"tag_ids"` //
|
TagIds *string `gorm:"default:'';" json:"tag_ids"` //
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用
|
||||||
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
|
ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
// fs_user_material 用户素材表
|
// fs_user_material 用户素材表
|
||||||
type FsUserMaterial struct {
|
type FsUserMaterial struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 用户 ID
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 用户 ID
|
||||||
Module *string `gorm:"default:'';" json:"module"` // 所属模块:logo
|
Module *string `gorm:"default:'';" json:"module"` //
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID
|
||||||
GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 游客 ID
|
GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 游客 ID
|
||||||
ResourceId *string `gorm:"default:'';" json:"resource_id"` // 资源ID
|
ResourceId *string `gorm:"default:'';" json:"resource_id"` //
|
||||||
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
|
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` //
|
||||||
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
||||||
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 上传时间
|
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 上传时间
|
||||||
}
|
}
|
||||||
|
35
server/websocket/internal/handler/loginnotifyhandler.go
Normal file
35
server/websocket/internal/handler/loginnotifyhandler.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/websocket/internal/logic"
|
||||||
|
"fusenapi/server/websocket/internal/svc"
|
||||||
|
"fusenapi/server/websocket/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LoginNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.LoginNotifyReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewLoginNotifyLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.LoginNotify(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/websocket/internal/logic"
|
||||||
|
"fusenapi/server/websocket/internal/svc"
|
||||||
|
"fusenapi/server/websocket/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterAccountNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.RegisterAccountNotifyReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewRegisterAccountNotifyLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.RegisterAccountNotify(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/websocket/render_notify",
|
Path: "/api/websocket/render_notify",
|
||||||
Handler: RenderNotifyHandler(serverCtx),
|
Handler: RenderNotifyHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/websocket/register_account_notify",
|
||||||
|
Handler: RegisterAccountNotifyHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/websocket/login_notify",
|
||||||
|
Handler: LoginNotifyHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
|
//websocket连接
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -323,7 +324,7 @@ func (w *wsConnectItem) sendToOutChan(data []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 格式化为websocket标准返回格式
|
// 格式化为websocket标准返回格式
|
||||||
func (w *wsConnectItem) respondDataFormat(msgType string, data interface{}) []byte {
|
func (w *wsConnectItem) respondDataFormat(msgType constants.Websocket, data interface{}) []byte {
|
||||||
d := websocket_data.DataTransferData{
|
d := websocket_data.DataTransferData{
|
||||||
T: msgType,
|
T: msgType,
|
||||||
D: data,
|
D: data,
|
||||||
|
56
server/websocket/internal/logic/loginnotifylogic.go
Normal file
56
server/websocket/internal/logic/loginnotifylogic.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
//登录回调
|
||||||
|
import (
|
||||||
|
"fusenapi/constants"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/websocket/internal/svc"
|
||||||
|
"fusenapi/server/websocket/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LoginNotifyLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLoginNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginNotifyLogic {
|
||||||
|
return &LoginNotifyLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *LoginNotifyLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *LoginNotifyLogic) LoginNotify(req *types.LoginNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
if req.Data.WebsocketConnId == "" {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,连接标识不能为空")
|
||||||
|
}
|
||||||
|
value, ok := mapConnPool.Load(req.Data.WebsocketConnId)
|
||||||
|
if !ok {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success,but connection is not found")
|
||||||
|
}
|
||||||
|
ws, ok := value.(wsConnectItem)
|
||||||
|
if !ok {
|
||||||
|
logx.Error("渲染回调断言websocket连接失败")
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "断言连接错误")
|
||||||
|
}
|
||||||
|
//发送消息到出口缓冲池
|
||||||
|
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_LOGIN_NOTIFY, req.Data.Info))
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *LoginNotifyLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
@ -0,0 +1,56 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
//注册帐号回调
|
||||||
|
import (
|
||||||
|
"fusenapi/constants"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/websocket/internal/svc"
|
||||||
|
"fusenapi/server/websocket/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RegisterAccountNotifyLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRegisterAccountNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterAccountNotifyLogic {
|
||||||
|
return &RegisterAccountNotifyLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *RegisterAccountNotifyLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *RegisterAccountNotifyLogic) RegisterAccountNotify(req *types.RegisterAccountNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
if req.Data.WebsocketConnId == "" {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,连接标识不能为空")
|
||||||
|
}
|
||||||
|
value, ok := mapConnPool.Load(req.Data.WebsocketConnId)
|
||||||
|
if !ok {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success,but connection is not found")
|
||||||
|
}
|
||||||
|
ws, ok := value.(wsConnectItem)
|
||||||
|
if !ok {
|
||||||
|
logx.Error("渲染回调断言websocket连接失败")
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "断言连接错误")
|
||||||
|
}
|
||||||
|
//发送消息到出口缓冲池
|
||||||
|
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_REGISTER_NOTIFY, req.Data.Info))
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *RegisterAccountNotifyLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
@ -1,5 +1,6 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
|
//云渲染回调
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fusenapi/server/websocket/internal/svc"
|
"fusenapi/server/websocket/internal/svc"
|
||||||
@ -37,11 +38,11 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend
|
|||||||
|
|
||||||
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
if req.TaskId == "" {
|
if req.TaskId == "" {
|
||||||
logx.Error("渲染回调参数错误:invalid param task_id")
|
logx.Error("渲染回调参数错误:任务标识")
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
||||||
}
|
}
|
||||||
if req.Image == "" {
|
if req.Image == "" {
|
||||||
logx.Error("渲染回调参数错误:invalid param image")
|
logx.Error("渲染回调参数错误:渲染结果图片数据")
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
|
||||||
}
|
}
|
||||||
//存base64打印测试
|
//存base64打印测试
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
|
//处理websocket云渲染任务数据
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -249,7 +250,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
|
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("无渲染设置信息,产品id:%d ,model_id:%d", info.RenderData.ProductId, *productTemplate.ModelId)))
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("无渲染设置信息,产品id:%d ,模板id:%d,模型id:%d", info.RenderData.ProductId, productTemplate.Id, *productTemplate.ModelId)))
|
||||||
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
|
//复用websocket连接标识
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -12,6 +12,28 @@ type RenderNotifyReq struct {
|
|||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RegisterAccountNotifyReq struct {
|
||||||
|
Data RegisterAccountData `json:"data"`
|
||||||
|
Time int64 `json:"time,optional"` //utc时间戳(用于验证签名)
|
||||||
|
Sign string `json:"sign,optional"` //签名
|
||||||
|
}
|
||||||
|
|
||||||
|
type RegisterAccountData struct {
|
||||||
|
WebsocketConnId string `json:"websocket_conn_id"` //连接标识
|
||||||
|
Info map[string]interface{} `json:"info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoginNotifyReq struct {
|
||||||
|
Data LoginNotifyData `json:"data"`
|
||||||
|
Time int64 `json:"time,optional"` //utc时间戳(用于验证签名)
|
||||||
|
Sign string `json:"sign,optional"` //签名
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoginNotifyData struct {
|
||||||
|
WebsocketConnId string `json:"websocket_conn_id"` //连接标识
|
||||||
|
Info map[string]interface{} `json:"info"`
|
||||||
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,4 +101,4 @@ func (resp *Response) SetStatusWithMessage(sr *basic.StatusResponse, msg string,
|
|||||||
newResp.Data = data[0]
|
newResp.Data = data[0]
|
||||||
}
|
}
|
||||||
return newResp
|
return newResp
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,12 @@ service websocket {
|
|||||||
//云渲染完了通知接口
|
//云渲染完了通知接口
|
||||||
@handler RenderNotifyHandler
|
@handler RenderNotifyHandler
|
||||||
post /api/websocket/render_notify(RenderNotifyReq) returns (response);
|
post /api/websocket/render_notify(RenderNotifyReq) returns (response);
|
||||||
|
//注册回调
|
||||||
|
@handler RegisterAccountNotifyHandler
|
||||||
|
post /api/websocket/register_account_notify(RegisterAccountNotifyReq) returns (response);
|
||||||
|
//登录回调
|
||||||
|
@handler LoginNotifyHandler
|
||||||
|
post /api/websocket/login_notify(LoginNotifyReq) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//渲染完了通知接口
|
//渲染完了通知接口
|
||||||
@ -23,4 +29,24 @@ type RenderNotifyReq {
|
|||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
GuestId int64 `json:"guest_id"`
|
GuestId int64 `json:"guest_id"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
|
}
|
||||||
|
//注册回调
|
||||||
|
type RegisterAccountNotifyReq {
|
||||||
|
Data RegisterAccountData `json:"data"`
|
||||||
|
Time int64 `json:"time,optional"` //utc时间戳(用于验证签名)
|
||||||
|
Sign string `json:"sign,optional"` //签名
|
||||||
|
}
|
||||||
|
type RegisterAccountData {
|
||||||
|
WebsocketConnId string `json:"websocket_conn_id"` //连接标识
|
||||||
|
Info map[string]interface{} `json:"info"`
|
||||||
|
}
|
||||||
|
//登录回调
|
||||||
|
type LoginNotifyReq {
|
||||||
|
Data LoginNotifyData `json:"data"`
|
||||||
|
Time int64 `json:"time,optional"` //utc时间戳(用于验证签名)
|
||||||
|
Sign string `json:"sign,optional"` //签名
|
||||||
|
}
|
||||||
|
type LoginNotifyData {
|
||||||
|
WebsocketConnId string `json:"websocket_conn_id"` //连接标识
|
||||||
|
Info map[string]interface{} `json:"info"`
|
||||||
}
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package websocket_data
|
package websocket_data
|
||||||
|
|
||||||
|
import "fusenapi/constants"
|
||||||
|
|
||||||
// websocket数据交互
|
// websocket数据交互
|
||||||
type DataTransferData struct {
|
type DataTransferData struct {
|
||||||
T string `json:"t"` //消息类型
|
T constants.Websocket `json:"t"` //消息类型
|
||||||
D interface{} `json:"d"` //传递的消息
|
D interface{} `json:"d"` //传递的消息
|
||||||
}
|
}
|
||||||
|
|
||||||
// websocket接受要云渲染处理的数据
|
// websocket接受要云渲染处理的数据
|
||||||
|
Loading…
x
Reference in New Issue
Block a user