diff --git a/constants/websocket.go b/constants/websocket.go index d529e7db..e4da2cbe 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -1,29 +1,25 @@ package constants -type websocket string +type Websocket string // websocket消息类型 const ( //鉴权失败 - WEBSOCKET_UNAUTH = "WEBSOCKET_UNAUTH" + WEBSOCKET_UNAUTH Websocket = "WEBSOCKET_UNAUTH" //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_THIRD_PARTY_LOGIN_NOTIFY = "WEBSOCKET_THIRD_PARTY_LOGIN_NOTIFY" + WEBSOCKET_ERR_DATA_FORMAT Websocket = "WEBSOCKET_ERR_DATA_FORMAT" + //登录回调通知 + 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" diff --git a/model/gmodel/fs_address_gen.go b/model/gmodel/fs_address_gen.go index 1d2ec36d..17988dd6 100644 --- a/model/gmodel/fs_address_gen.go +++ b/model/gmodel/fs_address_gen.go @@ -15,9 +15,9 @@ type FsAddress struct { Street *string `gorm:"default:'';" json:"street"` // 街道 Suite *string `gorm:"default:'';" json:"suite"` // 房号 City *string `gorm:"default:'';" json:"city"` // 城市 - State *string `gorm:"default:'';" json:"state"` // 州名 - Country *string `gorm:"default:'';" json:"country"` // 国家 - ZipCode *string `gorm:"default:'';" json:"zip_code"` // 邮编 + State *string `gorm:"default:'';" json:"state"` // + Country *string `gorm:"default:'';" json:"country"` // + ZipCode *string `gorm:"default:'';" json:"zip_code"` // Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常 IsDefault *int64 `gorm:"index;default:0;" json:"is_default"` // 1默认地址,0非默认地址 } diff --git a/model/gmodel/fs_backend_user_gen.go b/model/gmodel/fs_backend_user_gen.go index f6cff75f..84c488a8 100644 --- a/model/gmodel/fs_backend_user_gen.go +++ b/model/gmodel/fs_backend_user_gen.go @@ -7,11 +7,11 @@ import ( // fs_backend_user 管理员表 type FsBackendUser struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID - Username *string `gorm:"unique_key;default:'';" json:"username"` // 用户名 - AuthKey *string `gorm:"default:'';" json:"auth_key"` // jwt token - PasswordHash *string `gorm:"default:'';" json:"password_hash"` // 加密密码 + Username *string `gorm:"unique_key;default:'';" json:"username"` // + AuthKey *string `gorm:"default:'';" json:"auth_key"` // + PasswordHash *string `gorm:"default:'';" json:"password_hash"` // 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"` // 状态 Icon *string `gorm:"default:'';" json:"icon"` // DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门id diff --git a/model/gmodel/fs_card_group_gen.go b/model/gmodel/fs_card_group_gen.go index c97ccb97..5a4f9b50 100644 --- a/model/gmodel/fs_card_group_gen.go +++ b/model/gmodel/fs_card_group_gen.go @@ -7,10 +7,10 @@ import ( // fs_card_group 卡号分组表 type FsCardGroup struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id - GroupName *string `gorm:"default:'';" json:"group_name"` // 分组名字 - PreNo *string `gorm:"default:'';" json:"pre_no"` // 规则前几位数 + GroupName *string `gorm:"default:'';" json:"group_name"` // + PreNo *string `gorm:"default:'';" json:"pre_no"` // Num *int64 `gorm:"default:0;" json:"num"` // 生成数量 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间 } type FsCardGroupModel struct { db *gorm.DB diff --git a/model/gmodel/fs_cloud_deliver_every_tmp_gen.go b/model/gmodel/fs_cloud_deliver_every_tmp_gen.go index 5181f203..b04527bc 100644 --- a/model/gmodel/fs_cloud_deliver_every_tmp_gen.go +++ b/model/gmodel/fs_cloud_deliver_every_tmp_gen.go @@ -9,7 +9,7 @@ type FsCloudDeliverEveryTmp struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // AdminId *int64 `gorm:"default:0;" json:"admin_id"` // 管理员 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"` // 发货数量 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } diff --git a/model/gmodel/fs_cloud_receive_every_gen.go b/model/gmodel/fs_cloud_receive_every_gen.go index d4e4d1e9..7eb1d457 100644 --- a/model/gmodel/fs_cloud_receive_every_gen.go +++ b/model/gmodel/fs_cloud_receive_every_gen.go @@ -8,7 +8,7 @@ import ( type FsCloudReceiveEvery struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"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"` // 收到的数量 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } diff --git a/model/gmodel/fs_cloud_receive_gen.go b/model/gmodel/fs_cloud_receive_gen.go index 4871dec9..7b52d73c 100644 --- a/model/gmodel/fs_cloud_receive_gen.go +++ b/model/gmodel/fs_cloud_receive_gen.go @@ -12,7 +12,7 @@ type FsCloudReceive struct { UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 入库云仓的订单 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"` // 创建时间 Status *int64 `gorm:"default:0;" json:"status"` // 0未收到 1收到 } diff --git a/model/gmodel/fs_cloud_render_log_gen.go b/model/gmodel/fs_cloud_render_log_gen.go index a1d8aeae..04a8a495 100644 --- a/model/gmodel/fs_cloud_render_log_gen.go +++ b/model/gmodel/fs_cloud_render_log_gen.go @@ -12,7 +12,7 @@ type FsCloudRenderLog struct { PostUrl *string `gorm:"default:'';" json:"post_url"` // Title *string `gorm:"index;default:'';" json:"title"` // 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"` // 标识 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } diff --git a/model/gmodel/fs_coupon_gen.go b/model/gmodel/fs_coupon_gen.go index 3bd3e32b..c9aa7130 100644 --- a/model/gmodel/fs_coupon_gen.go +++ b/model/gmodel/fs_coupon_gen.go @@ -7,8 +7,8 @@ import ( // fs_coupon 代金券(暂未使用) type FsCoupon struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // - UserId *int64 `gorm:"default:0;" json:"user_id"` // - Sn *string `gorm:"default:'';" json:"sn"` // 优惠券码 + UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID 0:暂时未绑定用户 + Sn *string `gorm:"default:'';" json:"sn"` // Type *int64 `gorm:"default:0;" json:"type"` // 类型 1:代金券 2:折扣券 3:满减券 Amount *int64 `gorm:"default:0;" json:"amount"` // 代金券金额、折扣比例、满减金额 MinAmount *int64 `gorm:"default:0;" json:"min_amount"` // 满足条件的最小金额 0:不限制 @@ -16,8 +16,8 @@ type FsCoupon struct { Stime *int64 `gorm:"default:0;" json:"stime"` // 开始时间 0:立即生效 Etime *int64 `gorm:"default:0;" json:"etime"` // 结束时间 0:永久有效 Exclude *int64 `gorm:"default:2;" json:"exclude"` // 是否可以与其他优惠券同时使用 1:可以 2:不可以 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // - GetTime *int64 `gorm:"default:0;" json:"get_time"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + GetTime *int64 `gorm:"default:0;" json:"get_time"` // 上架时间 Status *int64 `gorm:"default:0;" json:"status"` // 状态 是否可用 是否已绑定到订单 } type FsCouponModel struct { diff --git a/model/gmodel/fs_deliver_every_gen.go b/model/gmodel/fs_deliver_every_gen.go index 4dc241b9..58a70e31 100644 --- a/model/gmodel/fs_deliver_every_gen.go +++ b/model/gmodel/fs_deliver_every_gen.go @@ -8,8 +8,8 @@ import ( type FsDeliverEvery struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // DeliverId *int64 `gorm:"index;default:0;" json:"deliver_id"` // 发货ID - OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` // 订单详情模板sn - Num *int64 `gorm:"default:0;" json:"num"` // + OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` // + Num *int64 `gorm:"default:0;" json:"num"` // 发货数量 } type FsDeliverEveryModel struct { db *gorm.DB diff --git a/model/gmodel/fs_deliver_gen.go b/model/gmodel/fs_deliver_gen.go index 327f5c0d..8a621699 100644 --- a/model/gmodel/fs_deliver_gen.go +++ b/model/gmodel/fs_deliver_gen.go @@ -12,7 +12,7 @@ type FsDeliver struct { UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID AdminId *int64 `gorm:"index;default:0;" json:"admin_id"` // 操作人id 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"` // 发货公司 AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址id AddressInfo *string `gorm:"default:'';" json:"address_info"` // 地址信息 diff --git a/model/gmodel/fs_factory_deliver_every_gen.go b/model/gmodel/fs_factory_deliver_every_gen.go index c349d4ca..fea02254 100644 --- a/model/gmodel/fs_factory_deliver_every_gen.go +++ b/model/gmodel/fs_factory_deliver_every_gen.go @@ -8,7 +8,7 @@ import ( type FsFactoryDeliverEvery struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"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"` // 发货数量 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } diff --git a/model/gmodel/fs_factory_deliver_gen.go b/model/gmodel/fs_factory_deliver_gen.go index dcd08b0f..d6aa5af3 100644 --- a/model/gmodel/fs_factory_deliver_gen.go +++ b/model/gmodel/fs_factory_deliver_gen.go @@ -7,7 +7,7 @@ import ( // fs_factory_deliver 工厂发货主表(废弃) type FsFactoryDeliver struct { 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"` // 创建时间 DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 发货方式( 1:直接发货到收获地址 2:云仓) OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单id diff --git a/model/gmodel/fs_factory_product_gen.go b/model/gmodel/fs_factory_product_gen.go index 332f2a1d..615941e1 100644 --- a/model/gmodel/fs_factory_product_gen.go +++ b/model/gmodel/fs_factory_product_gen.go @@ -9,7 +9,7 @@ type FsFactoryProduct struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // FactoryId *int64 `gorm:"index;default:0;" json:"factory_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"` // 数量 IsProduct *int64 `gorm:"default:0;" json:"is_product"` // 是否开始生产( 0:未开始 ,1:已开始) IsEnd *int64 `gorm:"default:0;" json:"is_end"` // 是否完成(0:未完成,1:已完成) diff --git a/model/gmodel/fs_factory_ship_tmp_gen.go b/model/gmodel/fs_factory_ship_tmp_gen.go index 620cd24b..ba97aafc 100644 --- a/model/gmodel/fs_factory_ship_tmp_gen.go +++ b/model/gmodel/fs_factory_ship_tmp_gen.go @@ -7,10 +7,10 @@ import ( // fs_factory_ship_tmp type FsFactoryShipTmp struct { 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 - OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` // 详情modelSn - UserId *int64 `gorm:"default:0;" json:"user_id"` // + OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` // + UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID AddressSent *string `gorm:"default:'';" json:"address_sent"` // 发货地址 AddressTo *string `gorm:"default:'';" json:"address_to"` // 收获地址 始终是货代公司 Num *int64 `gorm:"default:0;" json:"num"` // 发货数量 diff --git a/model/gmodel/fs_log_gen.go b/model/gmodel/fs_log_gen.go index 03f0ae7d..a83e070a 100644 --- a/model/gmodel/fs_log_gen.go +++ b/model/gmodel/fs_log_gen.go @@ -7,13 +7,13 @@ import ( // fs_log 日志表 type FsLog struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID - Action *string `gorm:"default:'';" json:"action"` // 执行的动作 - Table *string `gorm:"default:'';" json:"table"` // 表明 + Action *string `gorm:"default:'';" json:"action"` // + Table *string `gorm:"default:'';" json:"table"` // DataChanged *string `gorm:"default:'';" json:"data_changed"` // 修改后的数据 DataOld *string `gorm:"default:'';" json:"data_old"` // 变动的数据 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 Uid *int64 `gorm:"default:0;" json:"uid"` // 操作人ID - Uname *string `gorm:"default:'';" json:"uname"` // 操作人名字 + Uname *string `gorm:"default:'';" json:"uname"` // } type FsLogModel struct { db *gorm.DB diff --git a/model/gmodel/fs_menu_gen.go b/model/gmodel/fs_menu_gen.go index bb3a80a9..c62b4571 100644 --- a/model/gmodel/fs_menu_gen.go +++ b/model/gmodel/fs_menu_gen.go @@ -7,10 +7,10 @@ import ( // fs_menu 后台菜单 type FsMenu struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id - Name *string `gorm:"default:'';" json:"name"` // 菜单名 - Parent *int64 `gorm:"index;default:0;" json:"parent"` // + Name *string `gorm:"default:'';" json:"name"` // + Parent *int64 `gorm:"index;default:0;" json:"parent"` // 父id 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"` // 其他信息(图标等) } type FsMenuModel struct { diff --git a/model/gmodel/fs_migration_gen.go b/model/gmodel/fs_migration_gen.go index 8001943c..d6c9494b 100644 --- a/model/gmodel/fs_migration_gen.go +++ b/model/gmodel/fs_migration_gen.go @@ -7,7 +7,7 @@ import ( // fs_migration 版本库 type FsMigration struct { 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 { db *gorm.DB diff --git a/model/gmodel/fs_product_copy1_gen.go b/model/gmodel/fs_product_copy1_gen.go index 92c78e28..7095f334 100644 --- a/model/gmodel/fs_product_copy1_gen.go +++ b/model/gmodel/fs_product_copy1_gen.go @@ -7,20 +7,20 @@ import ( // fs_product_copy1 产品表 type FsProductCopy1 struct { 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 - Title *string `gorm:"default:'';" json:"title"` // 名称 - TitleCn *string `gorm:"default:'';" json:"title_cn"` // 中文名称 - Cover *string `gorm:"default:'';" json:"cover"` // 封面图 - Imgs *string `gorm:"default:'';" json:"imgs"` // 一个或多个介绍图或视频 - Keywords *string `gorm:"default:'';" json:"keywords"` // 关键字 + Title *string `gorm:"default:'';" json:"title"` // + TitleCn *string `gorm:"default:'';" json:"title_cn"` // + Cover *string `gorm:"default:'';" json:"cover"` // + Imgs *string `gorm:"default:'';" json:"imgs"` // + Keywords *string `gorm:"default:'';" json:"keywords"` // Intro *string `gorm:"default:'';" json:"intro"` // 简要描述 Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 View *int64 `gorm:"default:0;" json:"view"` // 浏览量 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"` // Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否上架 是否推荐 是否热销 是否环保 是否可加入微波炉 是否刪除 ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数 diff --git a/model/gmodel/fs_product_option_gen.go b/model/gmodel/fs_product_option_gen.go index c528a1a5..b39687dc 100644 --- a/model/gmodel/fs_product_option_gen.go +++ b/model/gmodel/fs_product_option_gen.go @@ -7,12 +7,12 @@ import ( // fs_product_option 产品选项表(已废弃) type FsProductOption struct { 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 Price *int64 `gorm:"default:0;" json:"price"` // 产品单价 SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸id 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 { db *gorm.DB diff --git a/model/gmodel/fs_product_template_element_22_gen.go b/model/gmodel/fs_product_template_element_22_gen.go index 3c4665b1..cb7be4e2 100644 --- a/model/gmodel/fs_product_template_element_22_gen.go +++ b/model/gmodel/fs_product_template_element_22_gen.go @@ -7,7 +7,7 @@ import ( // 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"` // 产品模板名称 + 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"` // diff --git a/model/gmodel/fs_product_template_gen.go b/model/gmodel/fs_product_template_gen.go index 4a857c80..44cf408d 100644 --- a/model/gmodel/fs_product_template_gen.go +++ b/model/gmodel/fs_product_template_gen.go @@ -8,7 +8,7 @@ import ( type FsProductTemplate struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"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"` // 排序 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 ModelInfo *string `gorm:"default:'';" json:"model_info"` // 模型详情 diff --git a/model/gmodel/fs_product_v2_tmp_gen.go b/model/gmodel/fs_product_v2_tmp_gen.go index b947c85d..372a931d 100644 --- a/model/gmodel/fs_product_v2_tmp_gen.go +++ b/model/gmodel/fs_product_v2_tmp_gen.go @@ -7,19 +7,19 @@ import ( // fs_product_v2_tmp 产品表 type FsProductV2Tmp struct { 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 - Title *string `gorm:"default:'';" json:"title"` // 名称 - TitleCn *string `gorm:"default:'';" json:"title_cn"` // 中文名称 + Title *string `gorm:"default:'';" json:"title"` // + TitleCn *string `gorm:"default:'';" json:"title_cn"` // Imgs *string `gorm:"default:'';" json:"imgs"` // 一个或多个介绍图或视频 - Keywords *string `gorm:"default:'';" json:"keywords"` // 关键字 + Keywords *string `gorm:"default:'';" json:"keywords"` // Intro *string `gorm:"default:'';" json:"intro"` // 简要描述 Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 View *int64 `gorm:"default:0;" json:"view"` // 浏览量 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"` // Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用 ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数 diff --git a/model/gmodel/fs_user_material_gen.go b/model/gmodel/fs_user_material_gen.go index d5592001..78ebfa65 100644 --- a/model/gmodel/fs_user_material_gen.go +++ b/model/gmodel/fs_user_material_gen.go @@ -7,11 +7,11 @@ import ( // fs_user_material 用户素材表 type FsUserMaterial struct { 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 GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 游客 ID - ResourceId *string `gorm:"default:'';" json:"resource_id"` // 资源ID - ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL + ResourceId *string `gorm:"default:'';" json:"resource_id"` // + ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率 CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 上传时间 } diff --git a/server/websocket/internal/handler/loginnotifyhandler.go b/server/websocket/internal/handler/loginnotifyhandler.go new file mode 100644 index 00000000..5ce5173a --- /dev/null +++ b/server/websocket/internal/handler/loginnotifyhandler.go @@ -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) + } + } +} diff --git a/server/websocket/internal/handler/registeraccountnotifyhandler.go b/server/websocket/internal/handler/registeraccountnotifyhandler.go new file mode 100644 index 00000000..94c528d3 --- /dev/null +++ b/server/websocket/internal/handler/registeraccountnotifyhandler.go @@ -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) + } + } +} diff --git a/server/websocket/internal/handler/routes.go b/server/websocket/internal/handler/routes.go index 859ecc5b..dc46d40b 100644 --- a/server/websocket/internal/handler/routes.go +++ b/server/websocket/internal/handler/routes.go @@ -22,6 +22,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/websocket/render_notify", 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), + }, }, ) } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index f5c3e3c3..d77be9a2 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -1,5 +1,6 @@ package logic +//websocket连接 import ( "bytes" "encoding/json" @@ -323,7 +324,7 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { } // 格式化为websocket标准返回格式 -func (w *wsConnectItem) respondDataFormat(msgType string, data interface{}) []byte { +func (w *wsConnectItem) respondDataFormat(msgType constants.Websocket, data interface{}) []byte { d := websocket_data.DataTransferData{ T: msgType, D: data, diff --git a/server/websocket/internal/logic/loginnotifylogic.go b/server/websocket/internal/logic/loginnotifylogic.go new file mode 100644 index 00000000..97c442f9 --- /dev/null +++ b/server/websocket/internal/logic/loginnotifylogic.go @@ -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) +// } diff --git a/server/websocket/internal/logic/registeraccountnotifylogic.go b/server/websocket/internal/logic/registeraccountnotifylogic.go new file mode 100644 index 00000000..c72aa4ae --- /dev/null +++ b/server/websocket/internal/logic/registeraccountnotifylogic.go @@ -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) +// } diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index d9e3aab8..9b6ff45a 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -1,5 +1,6 @@ package logic +//云渲染回调 import ( "context" "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) { if req.TaskId == "" { - logx.Error("渲染回调参数错误:invalid param task_id") + logx.Error("渲染回调参数错误:任务标识") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") } if req.Image == "" { - logx.Error("渲染回调参数错误:invalid param image") + logx.Error("渲染回调参数错误:渲染结果图片数据") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image") } //存base64打印测试 diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 3a050567..a8294400 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -1,5 +1,6 @@ package logic +//处理websocket云渲染任务数据 import ( "bytes" "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) if err != nil { 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) return err } diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go index b31ee320..5ed56d6e 100644 --- a/server/websocket/internal/logic/ws_reuse_last_connect.go +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -1,5 +1,6 @@ package logic +//复用websocket连接标识 import ( "encoding/json" "fmt" diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index 087da9ba..aed31ca9 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -12,6 +12,28 @@ type RenderNotifyReq struct { 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 { } @@ -79,4 +101,4 @@ func (resp *Response) SetStatusWithMessage(sr *basic.StatusResponse, msg string, newResp.Data = data[0] } return newResp -} \ No newline at end of file +} diff --git a/server_api/websocket.api b/server_api/websocket.api index b5adb666..fd856c33 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -15,6 +15,12 @@ service websocket { //云渲染完了通知接口 @handler RenderNotifyHandler 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"` GuestId int64 `json:"guest_id"` 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"` } \ No newline at end of file diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index ca152ded..b95b4169 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -1,9 +1,11 @@ package websocket_data +import "fusenapi/constants" + // websocket数据交互 type DataTransferData struct { - T string `json:"t"` //消息类型 - D interface{} `json:"d"` //传递的消息 + T constants.Websocket `json:"t"` //消息类型 + D interface{} `json:"d"` //传递的消息 } // websocket接受要云渲染处理的数据