88 lines
3.2 KiB
Go
Executable File
88 lines
3.2 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 (
|
||
fsProductModel3dLightFieldNames = builder.RawFieldNames(&FsProductModel3dLight{})
|
||
fsProductModel3dLightRows = strings.Join(fsProductModel3dLightFieldNames, ",")
|
||
fsProductModel3dLightRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductModel3dLightFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||
fsProductModel3dLightRowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductModel3dLightFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||
)
|
||
|
||
type (
|
||
fsProductModel3dLightModel interface {
|
||
Insert(ctx context.Context, data *FsProductModel3dLight) (sql.Result, error)
|
||
FindOne(ctx context.Context, id int64) (*FsProductModel3dLight, error)
|
||
Update(ctx context.Context, data *FsProductModel3dLight) error
|
||
Delete(ctx context.Context, id int64) error
|
||
}
|
||
|
||
defaultFsProductModel3dLightModel struct {
|
||
conn sqlx.SqlConn
|
||
table string
|
||
}
|
||
|
||
FsProductModel3dLight struct {
|
||
Id int64 `db:"id"`
|
||
Name string `db:"name"` // 灯光名称
|
||
Info string `db:"info"` // 灯光数据(json格式)
|
||
Status int64 `db:"status"` // 状态值(1:显示,0:删除)
|
||
Ctime sql.NullInt64 `db:"ctime"` // 创建时间
|
||
}
|
||
)
|
||
|
||
func newFsProductModel3dLightModel(conn sqlx.SqlConn) *defaultFsProductModel3dLightModel {
|
||
return &defaultFsProductModel3dLightModel{
|
||
conn: conn,
|
||
table: "`fs_product_model3d_light`",
|
||
}
|
||
}
|
||
|
||
func (m *defaultFsProductModel3dLightModel) 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 *defaultFsProductModel3dLightModel) FindOne(ctx context.Context, id int64) (*FsProductModel3dLight, error) {
|
||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductModel3dLightRows, m.table)
|
||
var resp FsProductModel3dLight
|
||
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 *defaultFsProductModel3dLightModel) Insert(ctx context.Context, data *FsProductModel3dLight) (sql.Result, error) {
|
||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, fsProductModel3dLightRowsExpectAutoSet)
|
||
ret, err := m.conn.ExecCtx(ctx, query, data.Name, data.Info, data.Status, data.Ctime)
|
||
return ret, err
|
||
}
|
||
|
||
func (m *defaultFsProductModel3dLightModel) Update(ctx context.Context, data *FsProductModel3dLight) error {
|
||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductModel3dLightRowsWithPlaceHolder)
|
||
_, err := m.conn.ExecCtx(ctx, query, data.Name, data.Info, data.Status, data.Ctime, data.Id)
|
||
return err
|
||
}
|
||
|
||
func (m *defaultFsProductModel3dLightModel) tableName() string {
|
||
return m.table
|
||
}
|