95 lines
3.6 KiB
Go
Executable File
95 lines
3.6 KiB
Go
Executable File
// Code generated by goctl. DO NOT EDIT.
|
|
|
|
package gmodel
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
"github.com/zeromicro/go-zero/core/stringx"
|
|
)
|
|
|
|
var (
|
|
fsQrcodeSetFieldNames = builder.RawFieldNames(&FsQrcodeSet{})
|
|
fsQrcodeSetRows = strings.Join(fsQrcodeSetFieldNames, ",")
|
|
fsQrcodeSetRowsExpectAutoSet = strings.Join(stringx.Remove(fsQrcodeSetFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
|
fsQrcodeSetRowsWithPlaceHolder = strings.Join(stringx.Remove(fsQrcodeSetFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
|
)
|
|
|
|
type (
|
|
fsQrcodeSetModel interface {
|
|
Insert(ctx context.Context, data *FsQrcodeSet) (sql.Result, error)
|
|
FindOne(ctx context.Context, id int64) (*FsQrcodeSet, error)
|
|
Update(ctx context.Context, data *FsQrcodeSet) error
|
|
Delete(ctx context.Context, id int64) error
|
|
}
|
|
|
|
defaultFsQrcodeSetModel struct {
|
|
conn sqlx.SqlConn
|
|
table string
|
|
}
|
|
|
|
FsQrcodeSet struct {
|
|
Id int64 `db:"id"` // id
|
|
Name string `db:"name"` // 二维码组件名称
|
|
Size int64 `db:"size"` // 二维码内容尺寸
|
|
IndexX int64 `db:"index_x"` // x偏移量
|
|
IndexY int64 `db:"index_y"` // y偏移量
|
|
SvgWebsite sql.NullString `db:"svg_website"` // website d数据
|
|
SvgInstagram sql.NullString `db:"svg_instagram"` // svg instagram d数据
|
|
SvgFacebook sql.NullString `db:"svg_facebook"` // svg facebook d数据
|
|
Status int64 `db:"status"` // 状态
|
|
AdminId int64 `db:"admin_id"` // 操作人
|
|
Ctime int64 `db:"ctime"` // 添加时间
|
|
Utime int64 `db:"utime"` // 更新时间
|
|
}
|
|
)
|
|
|
|
func newFsQrcodeSetModel(conn sqlx.SqlConn) *defaultFsQrcodeSetModel {
|
|
return &defaultFsQrcodeSetModel{
|
|
conn: conn,
|
|
table: "`fs_qrcode_set`",
|
|
}
|
|
}
|
|
|
|
func (m *defaultFsQrcodeSetModel) Delete(ctx context.Context, id int64) error {
|
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
|
_, err := m.conn.ExecCtx(ctx, query, id)
|
|
return err
|
|
}
|
|
|
|
func (m *defaultFsQrcodeSetModel) FindOne(ctx context.Context, id int64) (*FsQrcodeSet, error) {
|
|
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsQrcodeSetRows, m.table)
|
|
var resp FsQrcodeSet
|
|
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
|
switch err {
|
|
case nil:
|
|
return &resp, nil
|
|
case sqlc.ErrNotFound:
|
|
return nil, ErrNotFound
|
|
default:
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
func (m *defaultFsQrcodeSetModel) Insert(ctx context.Context, data *FsQrcodeSet) (sql.Result, error) {
|
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsQrcodeSetRowsExpectAutoSet)
|
|
ret, err := m.conn.ExecCtx(ctx, query, data.Name, data.Size, data.IndexX, data.IndexY, data.SvgWebsite, data.SvgInstagram, data.SvgFacebook, data.Status, data.AdminId, data.Ctime, data.Utime)
|
|
return ret, err
|
|
}
|
|
|
|
func (m *defaultFsQrcodeSetModel) Update(ctx context.Context, data *FsQrcodeSet) error {
|
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsQrcodeSetRowsWithPlaceHolder)
|
|
_, err := m.conn.ExecCtx(ctx, query, data.Name, data.Size, data.IndexX, data.IndexY, data.SvgWebsite, data.SvgInstagram, data.SvgFacebook, data.Status, data.AdminId, data.Ctime, data.Utime, data.Id)
|
|
return err
|
|
}
|
|
|
|
func (m *defaultFsQrcodeSetModel) tableName() string {
|
|
return m.table
|
|
}
|