fusenapi/model/fsstandardlogomodel_gen.go

88 lines
2.9 KiB
Go
Raw Normal View History

2023-06-07 11:47:45 +00:00
// Code generated by goctl. DO NOT EDIT.
package model
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 (
fsStandardLogoFieldNames = builder.RawFieldNames(&FsStandardLogo{})
fsStandardLogoRows = strings.Join(fsStandardLogoFieldNames, ",")
fsStandardLogoRowsExpectAutoSet = strings.Join(stringx.Remove(fsStandardLogoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
fsStandardLogoRowsWithPlaceHolder = strings.Join(stringx.Remove(fsStandardLogoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
fsStandardLogoModel interface {
Insert(ctx context.Context, data *FsStandardLogo) (sql.Result, error)
FindOne(ctx context.Context, id int64) (*FsStandardLogo, error)
Update(ctx context.Context, data *FsStandardLogo) error
Delete(ctx context.Context, id int64) error
}
defaultFsStandardLogoModel struct {
conn sqlx.SqlConn
table string
}
FsStandardLogo struct {
Id int64 `db:"id"` // ID
Name string `db:"name"` // logo名称
Image string `db:"image"` // 图片地址
Ctime int64 `db:"ctime"` // 添加时间
Status int64 `db:"status"` // 状态 1正常 0删除
}
)
func newFsStandardLogoModel(conn sqlx.SqlConn) *defaultFsStandardLogoModel {
return &defaultFsStandardLogoModel{
conn: conn,
table: "`fs_standard_logo`",
}
}
func (m *defaultFsStandardLogoModel) 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 *defaultFsStandardLogoModel) FindOne(ctx context.Context, id int64) (*FsStandardLogo, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsStandardLogoRows, m.table)
var resp FsStandardLogo
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 *defaultFsStandardLogoModel) Insert(ctx context.Context, data *FsStandardLogo) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, fsStandardLogoRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.Name, data.Image, data.Ctime, data.Status)
return ret, err
}
func (m *defaultFsStandardLogoModel) Update(ctx context.Context, data *FsStandardLogo) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsStandardLogoRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.Name, data.Image, data.Ctime, data.Status, data.Id)
return err
}
func (m *defaultFsStandardLogoModel) tableName() string {
return m.table
}