This commit is contained in:
laodaming 2023-06-16 19:05:38 +08:00
parent 87c9246c34
commit 350c6a5548
25 changed files with 0 additions and 744 deletions

View File

@ -1,23 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp FsAddress, err error) {
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsAddress{}, err
}
return resp, nil
}
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) {
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = ?", userId, 1).Order("`id` DESC").Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,25 +0,0 @@
package gmodel
import (
"context"
)
func (c *FsCanteenProductModel) GetAllByCanteenTypeId(ctx context.Context, typeId int64) (resp []FsCanteenProduct, err error) {
err = c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`canteen_type` = ? and `status` = ?", typeId, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
func (c *FsCanteenProductModel) UpdateById(ctx context.Context, id int64, data *FsCanteenProduct) error {
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` = ? ", id).Updates(&data).Error
}
func (c *FsCanteenProductModel) UpdateByIdArr(ctx context.Context, ids []int64, data *FsCanteenProduct) error {
if len(ids) == 0 {
return nil
}
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`id` in (?) ", ids).Updates(&data).Error
}
func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProduct) error {
return c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Create(data).Error
}

View File

@ -1,31 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
// FsGetTypeCanteenType GetType返回前端的结构
type FsGetTypeCanteenType struct {
Id int64 `gorm:"id" json:"key"` // ID
Name string `gorm:"name" json:"name"` // 餐厅名字
}
// TODO: 使用model的属性做你想做的
func (c *FsCanteenTypeModel) FindAllGetType(ctx context.Context) (resp []*FsGetTypeCanteenType, err error) {
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Select("id,name").Order("sort desc").Where("`status` = ?", 1).Find(&resp).Error
if err != nil {
return resp, err
}
return resp, nil
}
func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp FsCanteenType, err error) {
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ?", id).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return resp, err
}
return resp, nil
}

View File

@ -1,114 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
<<<<<<< HEAD:model/gmodel/fscartmodel.go
type FsCart struct {
Id int64 `gorm:"primary_key" json:"id"` // id
UserId *int64 `gorm:"default:0" json:"user_id"` // 用户ID
ProductId *int64 `gorm:"default:0" json:"product_id"` // 产品ID
TemplateId *int64 `gorm:"default:0" json:"template_id"` // 模板ID
PriceId *int64 `gorm:"default:0" json:"price_id"` // 价格ID
MaterialId *int64 `gorm:"default:0" json:"material_id"` // 材质ID
SizeId *int64 `gorm:"default:0" json:"size_id"` // 尺寸ID
BuyNum *int64 `gorm:"default:0" json:"buy_num"` // 购买数量
Cover *string `gorm:"default:''" json:"cover"` // 截图
DesignId *int64 `gorm:"default:0" json:"design_id"` // 设计ID
Ctime *int64 `gorm:"default:0" json:"ctime"` // 添加时间
Status *int64 `gorm:"default:1" json:"status"` // 状态位
OptionalId *int64 `gorm:"default:0" json:"optional_id"` // 选项ID
IsCheck *int64 `gorm:"default:0" json:"is_check"` // 是否选中状态0未选中1选中
TsTime *time.Time `gorm:"" json:"ts_time"`
IsEmail *int64 `gorm:"default:0" json:"is_email"` // 是否发送邮件
}
type FsCartModel struct {
db *gorm.DB
}
func NewFsCartModel(db *gorm.DB) *FsCartModel {
return &FsCartModel{db}
}
=======
>>>>>>> c6292a97dd29b5dc14f96ed71adc82e9ead8ef28:model/gmodel/fs_cart_logic.go
type FindOneCartByParamsReq struct {
UserId *int64
ProductId *int64
TemplateId *int64
PriceId *int64
DesignId *int64
MaterialId *int64
Status *int64
}
func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp FsCart, err error) {
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).Take(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsCart{}, err
}
return resp, nil
}
func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp FsCart, err error) {
db := c.db.WithContext(ctx).Model(&FsCart{})
if req.UserId != nil {
db = db.Where("`user_id` = ?", req.UserId)
}
if req.ProductId != nil {
db = db.Where("`product_id` = ?", req.ProductId)
}
if req.TemplateId != nil {
db = db.Where("`template_id` = ?", req.TemplateId)
}
if req.PriceId != nil {
db = db.Where("`price_id` = ?", req.PriceId)
}
if req.DesignId != nil {
db = db.Where("`design_id` = ?", req.DesignId)
}
if req.MaterialId != nil {
db = db.Where("`material_id` = ?", req.MaterialId)
}
if req.Status != nil {
db = db.Where("`status` = ?", req.Status)
}
if err = db.Take(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsCart{}, err
}
return resp, nil
}
func (c *FsCartModel) Create(ctx context.Context, data FsCart) error {
return c.db.WithContext(ctx).Model(&FsCart{}).Create(&data).Error
}
func (c *FsCartModel) Update(ctx context.Context, id int64, data FsCart) error {
return c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).Updates(data).Error
}
func (c *FsCartModel) UpdateByIdUserId(ctx context.Context, id int64, userId int64, data FsCart) error {
return c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ? and `user_id` = ?", id, userId).Updates(data).Error
}
func (c *FsCartModel) CountUserCart(ctx context.Context, userId int64) (total int64, err error) {
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`user_id` = ? and `status` = ? limit 1", userId, 1).Count(&total).Error
if err != nil {
return 0, err
}
return
}
func (c *FsCartModel) GetAllByUserId(ctx context.Context, userId int64, sort string) (resp []FsCart, err error) {
db := c.db.WithContext(ctx).Model(&FsCart{}).Where("`user_id` = ? and `status` = ?", userId, 1)
switch sort {
case "ctime-desc":
db = db.Order("`ctime` DESC")
case "ctime-asc":
db = db.Order("`ctime` ASC")
}
err = db.Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,21 +0,0 @@
package gmodel
import (
"context"
)
// TODO: 使用model的属性做你想做的
func (m *FsFontModel) FindAllOrderSortByDesc(ctx context.Context) ([]*FsFont, error) {
var fonts []*FsFont
err := m.db.Model(&FsFont{}).Order("sort desc").Find(&fonts).Error
switch err {
case nil:
return fonts, nil
case ErrRecordNotFound:
return nil, nil
default:
return nil, err
}
}

View File

@ -1,11 +0,0 @@
package gmodel
import "context"
func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context) (resp []FsMapLibrary, err error) {
err = ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 0).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,13 +0,0 @@
package gmodel
import (
"context"
)
func (od *FsOrderDetailModel) GetOrderDetailsByOrderId(ctx context.Context, orderId int64) (resp []FsOrderDetail, err error) {
err = od.db.WithContext(ctx).Model(&FsOrderDetail{}).Where("`order_id` = ?", orderId).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,16 +0,0 @@
package gmodel
import (
"context"
)
func (dt *FsOrderDetailTemplateModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsOrderDetailTemplate, err error) {
if len(ids) == 0 {
return
}
err = dt.db.WithContext(ctx).Model(&FsOrderDetailTemplate{}).Where("`id` in (?)", ids).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,18 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp FsOrder, err error) {
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsOrder{}, err
}
return resp, nil
}
func (o *FsOrderModel) Update(ctx context.Context, id int64, data FsOrder) error {
return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", id).Updates(data).Error
}

View File

@ -1,18 +0,0 @@
package gmodel
import "context"
func (p *FsPayModel) GetListByOrderNumber(ctx context.Context, sn string) (resp []FsPay, err error) {
err = p.db.WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? ", sn).Find(&resp).Error
if err != nil {
return nil, err
}
return resp, nil
}
func (p *FsPayModel) GetOrderPayList(ctx context.Context, sn string, payStatus int64, isRefund int64) (resp []FsPay, err error) {
err = p.db.WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? and `pay_status` = ? and `is_refund` = ?", sn, payStatus, isRefund).Find(&resp).Error
if err != nil {
return nil, err
}
return resp, nil
}

View File

@ -1,25 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string) (resp FsProductDesign, err error) {
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `status` = ?", sn, 1).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsProductDesign{}, err
}
return resp, nil
}
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,47 +0,0 @@
package gmodel
import "context"
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
if len(productIds) == 0 {
return
}
db := p.db.Model(&FsProduct{}).
Where("`id` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productIds, 0, 1, 1)
switch sort {
case "sort-asc":
db = db.Order("`sort` ASC")
case "sort-desc":
db = db.Order("`sort` DESC")
}
if err = db.Find(&resp).Error; err != nil {
return nil, err
}
return
}
func (p *FsProductModel) GetProductListByTypeIds(ctx context.Context, productTypes []int64, sort string) (resp []FsProduct, err error) {
if len(productTypes) == 0 {
return
}
db := p.db.WithContext(ctx).Model(&FsProduct{}).Where("`type` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productTypes, 0, 1, 1)
switch sort {
case "sort-asc":
db = db.Order("`sort` ASC")
case "sort-desc":
db = db.Order("`sort` DESC")
}
err = db.Find(&resp).Error
if err != nil {
return nil, err
}
return
}
func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (resp []FsProduct, err error) {
err = p.db.WithContext(ctx).Model(&FsProduct{}).
Where("`is_del` =? and `is_shelf` = ?", 0, 1).Order("RAND()").Limit(limit).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1 +0,0 @@
package gmodel

View File

@ -1,26 +0,0 @@
package gmodel
import (
"context"
)
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ?", ids, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) {
if len(ids) == 0 {
return
}
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,73 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
type GetPriceListByProductIdsRsp struct {
ProductId int64 `json:"product_id"`
Price string `json:"price"`
}
func (p *FsProductPriceModel) GetSimplePriceListByProductIds(ctx context.Context, productIds []int64) (resp []GetPriceListByProductIdsRsp, err error) {
if len(productIds) == 0 {
return nil, nil
}
db := p.db.WithContext(ctx).Model(&FsProductPrice{}).Select("product_id,group_concat(step_price) as price").
Where("`product_id` in (?) and `status` = ? group by product_id", productIds, 1)
if err = db.Find(&resp).Error; err != nil {
return nil, err
}
return
}
func (p *FsProductPriceModel) GetPriceListBySizeIds(ctx context.Context, sizeIds []int64) (resp []FsProductPrice, err error) {
if len(sizeIds) == 0 {
return
}
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`size_id` in (?) and `status` = ? ", sizeIds, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
type FindOneProductPriceByParamsReq struct {
ProductId *int64
MaterialId *int64
SizeId *int64
Status *int64
}
func (p *FsProductPriceModel) FindOneProductPriceByParams(ctx context.Context, req FindOneProductPriceByParamsReq) (resp FsProductPrice, err error) {
db := p.db.WithContext(ctx).Model(&FsProductPrice{})
if req.ProductId != nil {
db = db.Where("`product_id` = ?", *req.ProductId)
}
if req.MaterialId != nil {
db = db.Where("`material_id` = ?", *req.MaterialId)
}
if req.SizeId != nil {
db = db.Where("`size_id` = ?", *req.SizeId)
}
if req.Status != nil {
db = db.Where("`status` = ?", *req.Status)
}
if err = db.Take(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsProductPrice{}, err
}
return resp, nil
}
func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, productIds []int64) (resp []FsProductPrice, err error) {
if len(productIds) == 0 {
return nil, nil
}
db := p.db.WithContext(ctx).Model(&FsProductPrice{}).
Where("`product_id` in (?) and `status` = ?", productIds, 1)
if err = db.Find(&resp).Error; err != nil {
return nil, err
}
return
}

View File

@ -1,43 +0,0 @@
package gmodel
import (
"context"
)
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
if len(ids) == 0 {
return
}
db := s.db.Model(&FsProductSize{}).Where("`id` in (?) and `status` = ?", ids, 1)
switch sort {
case "sort-asc":
db = db.Order("`sort` ASC")
case "sort-desc":
db = db.Order("`sort` DESC")
}
if err = db.Find(&resp).Error; err != nil {
return nil, err
}
return
}
func (s *FsProductSizeModel) CountByStatus(ctx context.Context, status int) (total int64, err error) {
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`status` = ? limit 1", status).Count(&total).Error
if err != nil {
return 0, err
}
return
}
func (s *FsProductSizeModel) GetAllByProductIds(ctx context.Context, productIds []int64, sort string) (resp []FsProductSize, err error) {
db := s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`product_id` in(?) and `status` = ?", productIds, 1)
switch sort {
case "sort-asc":
db = db.Order("`sort` ASC")
case "sort-desc":
db = db.Order("`sort` DESC")
}
err = db.Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,16 +0,0 @@
package gmodel
import (
"context"
)
func (pt *FsProductTemplateTagsModel) GetListByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateTags, err error) {
if len(ids) == 0 {
return
}
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`id` in (?)", ids).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,16 +0,0 @@
package gmodel
import (
"context"
)
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
if len(productIds) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,22 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`status` = ?", 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp FsQrcodeSet, err error) {
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`id` = ?", id).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsQrcodeSet{}, err
}
return resp, nil
}

View File

@ -1,13 +0,0 @@
package gmodel
import (
"context"
)
func (l *FsStandardLogoModel) GetAll(ctx context.Context) (resp []FsStandardLogo, err error) {
err = l.db.WithContext(ctx).Model(&FsStandardLogo{}).Where("`status` = ? ", 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,32 +0,0 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp FsTags, err error) {
err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsTags{}, err
}
return resp, nil
}
func (t *FsTagsModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsTags, err error) {
if len(ids) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` in(?) and `status` = ?", ids, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}
func (t *FsTagsModel) GetAllByLevel(ctx context.Context, level int) (resp []FsTags, err error) {
err = t.db.Model(&FsTags{}).Where("`level` = ? and `status` = ?", level, 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}

View File

@ -1,54 +0,0 @@
package gmodel
import (
"context"
)
// TODO: 使用model的属性做你想做的
type UserBasicInfoForSave struct {
ID uint `gorm:"primary_key" json:"id"`
FirstName string `gorm:"" json:"first_name"`
LastName string `gorm:"" json:"last_name"`
Mobile string `gorm:"" json:"mobile"`
Company string `gorm:"" json:"company"`
IsOrderStatusEmail int64 `gorm:"" json:"is_order_status_email"`
IsEmailAdvertisement int64 `gorm:"" json:"is_email_advertisement"`
IsOrderStatusPhone int64 `gorm:"" json:"is_order_status_phone"`
IsPhoneAdvertisement int64 `gorm:"" json:"is_phone_advertisement"`
Type int64 `gorm:"" json:"type"`
IsOpenRender int64 `gorm:"" json:"is_open_render"`
IsLowRendering int64 `gorm:"" json:"is_low_rendering"`
IsRemoveBg int64 `gorm:"" json:"is_remove_bg"`
}
func (u *FsUserModel) FindUserByEmail(ctx context.Context, emailname string) (resp FsUser, err error) {
err = u.db.WithContext(ctx).Model(&FsUser{PasswordHash: new(string)}).Where("`email` = ?", emailname).Take(&resp).Error
return resp, err
}
func (u *FsUserModel) FindUserById(ctx context.Context, Id int64) (resp FsUser, err error) {
err = u.db.WithContext(ctx).Model(&FsUser{}).Where("`id` = ? and is_del = ?", Id, 0).Take(&resp).Error
return resp, err
}
func (u *FsUserModel) UpdateUserBasicInfoById(ctx context.Context, Id int64, user *UserBasicInfoForSave) (err error) {
err = u.db.WithContext(ctx).Model(&FsUser{}).
Where("`id` = ? and is_del = ? and status = ?", Id, 0, 1).
Updates(map[string]interface{}{
"first_name": user.FirstName,
"last_name": user.LastName,
"mobile": user.Mobile,
"company": user.Company,
"is_order_status_email": user.IsOrderStatusEmail,
"is_email_advertisement": user.IsEmailAdvertisement,
"is_order_status_phone": user.IsOrderStatusPhone,
"is_phone_advertisement": user.IsPhoneAdvertisement,
"type": user.Type,
"is_open_render": user.IsOpenRender,
"is_low_rendering": user.IsLowRendering,
"is_remove_bg": user.IsRemoveBg,
}).Error
return err
}

View File

@ -1,24 +0,0 @@
package gmodel
import (
"database/sql"
"gorm.io/gorm"
)
type FsFaq struct {
Id int64 `gorm:"primary_key" json:"id"`
TagId *int64 `gorm:"default:0" json:"tag_id"` // 分类ID
TagName *string `gorm:"default:''" json:"tag_name"` // 分类名称
Title *string `gorm:"default:''" json:"title"` // 标题
Content *string `gorm:"default:''" json:"content"` // 内容
Status *int64 `gorm:"default:1" json:"status"` // 状态(0:禁用1:启用)
Sort *int64 `gorm:"default:0" json:"sort"` // 排序
Ctime *sql.NullInt64 `gorm:"default:0" json:"ctime"` // 添加时间
}
type FsFaqModel struct {
db *gorm.DB
}
func NewFsFaqModel(db *gorm.DB) *FsFaqModel {
return &FsFaqModel{db}
}

View File

@ -1,57 +0,0 @@
package gmodel
import (
"context"
"fusenapi/utils/auth"
"time"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
type FsGuest struct {
GuestId int64 `gorm:"primary_key" json:"guest_id"` // 游客ID
AuthKey *string `gorm:"" json:"auth_key"` // jwt token
Status *int64 `gorm:"" json:"status"` // 1正常 0不正常
IsDel *int64 `gorm:"" json:"is_del"` // 是否删除 1删除
CreatedAt *int64 `gorm:"" json:"created_at"` // 添加时间
UpdatedAt *int64 `gorm:"" json:"updated_at"` // 更新时间
IsOpenRender *int64 `gorm:"" json:"is_open_render"` // 是否打开个性化渲染1开启0关闭
IsThousandFace *int64 `gorm:"" json:"is_thousand_face"` // 是否已经存在千人千面1存在0不存在
IsLowRendering *int64 `gorm:"" json:"is_low_rendering"` // 是否开启低渲染模型渲染
IsRemoveBg *int64 `gorm:"" json:"is_remove_bg"` // 用户上传logo是否去除背景
}
type FsGuestModel struct{ db *gorm.DB }
func NewFsGuestModel(db *gorm.DB) *FsGuestModel { return &FsGuestModel{db} }
func (m *FsGuestModel) GenerateGuestID(ctx context.Context, AccessSecret *string) (authKey string, err error) {
err = m.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
now := time.Now().Unix()
exp := now + 31536000
var record = &FsGuest{CreatedAt: &now, UpdatedAt: &exp, AuthKey: &authKey}
tx.Create(record)
authKey, err = auth.GenerateJwtToken(AccessSecret, now, 31536000, 0, record.GuestId)
if err != nil {
logx.Error(err)
return err
}
record.AuthKey = &authKey
record.CreatedAt = &now
err = tx.Updates(record).Error
if err != nil {
logx.Error(err)
return err
}
return nil
})
if err != nil {
return "", err
}
return authKey, nil
}

View File

@ -1,5 +0,0 @@
package gmodel
import "gorm.io/gorm"
var ErrRecordNotFound = gorm.ErrRecordNotFound