fix
This commit is contained in:
24
model/fsproductmodel3dlightmodel.go
Executable file
24
model/fsproductmodel3dlightmodel.go
Executable file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsProductModel3dLightModel = (*customFsProductModel3dLightModel)(nil)
|
||||
|
||||
type (
|
||||
// FsProductModel3dLightModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsProductModel3dLightModel.
|
||||
FsProductModel3dLightModel interface {
|
||||
fsProductModel3dLightModel
|
||||
}
|
||||
|
||||
customFsProductModel3dLightModel struct {
|
||||
*defaultFsProductModel3dLightModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsProductModel3dLightModel returns a model for the database table.
|
||||
func NewFsProductModel3dLightModel(conn sqlx.SqlConn) FsProductModel3dLightModel {
|
||||
return &customFsProductModel3dLightModel{
|
||||
defaultFsProductModel3dLightModel: newFsProductModel3dLightModel(conn),
|
||||
}
|
||||
}
|
||||
88
model/fsproductmodel3dlightmodel_gen.go
Executable file
88
model/fsproductmodel3dlightmodel_gen.go
Executable file
@@ -0,0 +1,88 @@
|
||||
// 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 (
|
||||
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
|
||||
ListByIds(ctx context.Context, ids []string) (resp []FsProductModel3dLight, err 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
|
||||
}
|
||||
@@ -29,6 +29,7 @@ type (
|
||||
Delete(ctx context.Context, id int64) error
|
||||
FindAllByCondition(ctx context.Context, productIds []string) (resp []FsProductTemplateV2, err error)
|
||||
FindAllByModelIdsProduct(ctx context.Context, modelIds []string, productId int64, sort int) (resp []FsProductTemplateV2, err error)
|
||||
FindAllByModelIds(ctx context.Context, modelIds []string, sort int) (resp []FsProductTemplateV2, err error)
|
||||
}
|
||||
|
||||
defaultFsProductTemplateV2Model struct {
|
||||
|
||||
18
model/self_fsproductmodel3dlightmodel.go
Executable file
18
model/self_fsproductmodel3dlightmodel.go
Executable file
@@ -0,0 +1,18 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (m *defaultFsProductModel3dLightModel) ListByIds(ctx context.Context, ids []string) (resp []FsProductModel3dLight, err error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` in (?)", fsProductModel3dLightRows, m.table)
|
||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(ids, ","))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -31,3 +31,20 @@ func (m *defaultFsProductTemplateV2Model) FindAllByModelIdsProduct(ctx context.C
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (m *defaultFsProductTemplateV2Model) FindAllByModelIds(ctx context.Context, modelIds []string, sort int) (resp []FsProductTemplateV2, err error) {
|
||||
if len(modelIds) == 0 {
|
||||
return
|
||||
}
|
||||
query := fmt.Sprintf("select %s from %s where `model_id` in (?) and `is_del` = ? and `status` = ?", fsProductTemplateV2Rows, m.table)
|
||||
switch sort {
|
||||
case 1:
|
||||
query = fmt.Sprintf("%s order by `sort` ASC", query)
|
||||
case 2:
|
||||
query = fmt.Sprintf("%s order by `sort` DESC", query)
|
||||
}
|
||||
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(modelIds, ","), 0, 1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user