This commit is contained in:
laodaming
2023-06-12 17:00:37 +08:00
parent b1393950f2
commit 7f19e29bb3
11 changed files with 203 additions and 34 deletions

View File

@@ -1,6 +1,10 @@
package gmodel
import "gorm.io/gorm"
import (
"context"
"errors"
"gorm.io/gorm"
)
type FsQrcodeSet struct {
Id int64 `gorm:"primary_key" json:"id"` // id
@@ -23,3 +27,17 @@ type FsQrcodeSetModel struct {
func NewFsQrcodeSetModel(db *gorm.DB) *FsQrcodeSetModel {
return &FsQrcodeSetModel{db}
}
func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
err = q.db.WithContext(ctx).Model(&FsQrcodeSetModel{}).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(&FsQrcodeSetModel{}).Where("`id` = ?", id).First(&resp).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return FsQrcodeSet{}, err
}
return
}

View File

@@ -1,6 +1,9 @@
package gmodel
import "gorm.io/gorm"
import (
"context"
"gorm.io/gorm"
)
type FsStandardLogo struct {
Id int64 `gorm:"primary_key" json:"id"` // ID
@@ -16,3 +19,10 @@ type FsStandardLogoModel struct {
func NewFsStandardLogoModel(db *gorm.DB) *FsStandardLogoModel {
return &FsStandardLogoModel{db}
}
func (l *FsStandardLogoModel) GetAll(ctx context.Context) (resp []FsStandardLogo, err error) {
err = l.db.WithContext(ctx).Model(&FsStandardLogoModel{}).Where("`status` = ? ", 1).Find(&resp).Error
if err != nil {
return nil, err
}
return
}