fix
This commit is contained in:
parent
dfe171ea94
commit
52cc2a3d30
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/ddl/fs_faq.sql" dialect="MariaDB" />
|
||||
<file url="file://$PROJECT_DIR$/ddl/fs_font.sql" dialect="MariaDB" />
|
||||
</component>
|
||||
</project>
|
16
ddl/fs_product_size.sql
Normal file
16
ddl/fs_product_size.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
-- fusentest.fs_product_size definition
|
||||
|
||||
CREATE TABLE `fs_product_size` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`product_id` int(10) unsigned NOT NULL COMMENT '产品ID',
|
||||
`title` text NOT NULL COMMENT '标题 10*10*20',
|
||||
`cover` varchar(255) DEFAULT NULL COMMENT '封面图',
|
||||
`cover_img` varchar(255) DEFAULT NULL COMMENT '背景图',
|
||||
`capacity` varchar(255) NOT NULL COMMENT '自己填的尺寸名称',
|
||||
`status` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '状态位 显示 删除',
|
||||
`sort` smallint(6) NOT NULL DEFAULT '50' COMMENT '排序',
|
||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注信息',
|
||||
`parts_can_deleted` tinyint(1) NOT NULL DEFAULT '1' COMMENT '配件是否可移除 1是0否',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `product_id` (`product_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=130 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='产品尺寸表';
|
24
model/fsproductsizemodel.go
Executable file
24
model/fsproductsizemodel.go
Executable file
|
@ -0,0 +1,24 @@
|
|||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsProductSizeModel = (*customFsProductSizeModel)(nil)
|
||||
|
||||
type (
|
||||
// FsProductSizeModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsProductSizeModel.
|
||||
FsProductSizeModel interface {
|
||||
fsProductSizeModel
|
||||
}
|
||||
|
||||
customFsProductSizeModel struct {
|
||||
*defaultFsProductSizeModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsProductSizeModel returns a model for the database table.
|
||||
func NewFsProductSizeModel(conn sqlx.SqlConn) FsProductSizeModel {
|
||||
return &customFsProductSizeModel{
|
||||
defaultFsProductSizeModel: newFsProductSizeModel(conn),
|
||||
}
|
||||
}
|
100
model/fsproductsizemodel_gen.go
Executable file
100
model/fsproductsizemodel_gen.go
Executable file
|
@ -0,0 +1,100 @@
|
|||
// 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 (
|
||||
fsProductSizeFieldNames = builder.RawFieldNames(&FsProductSize{})
|
||||
fsProductSizeRows = strings.Join(fsProductSizeFieldNames, ",")
|
||||
fsProductSizeRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductSizeFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
fsProductSizeRowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductSizeFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
fsProductSizeModel interface {
|
||||
Insert(ctx context.Context, data *FsProductSize) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*FsProductSize, error)
|
||||
Update(ctx context.Context, data *FsProductSize) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
CountByStatus(ctx context.Context, status int) (total int, err error)
|
||||
}
|
||||
|
||||
defaultFsProductSizeModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
FsProductSize struct {
|
||||
Id int64 `db:"id"`
|
||||
ProductId int64 `db:"product_id"` // 产品ID
|
||||
Title string `db:"title"` // 标题 10*10*20
|
||||
Cover sql.NullString `db:"cover"` // 封面图
|
||||
CoverImg sql.NullString `db:"cover_img"` // 背景图
|
||||
Capacity string `db:"capacity"` // 自己填的尺寸名称
|
||||
Status int64 `db:"status"` // 状态位 显示 删除
|
||||
Sort int64 `db:"sort"` // 排序
|
||||
Remark sql.NullString `db:"remark"` // 备注信息
|
||||
PartsCanDeleted int64 `db:"parts_can_deleted"` // 配件是否可移除 1是0否
|
||||
}
|
||||
)
|
||||
|
||||
func newFsProductSizeModel(conn sqlx.SqlConn) *defaultFsProductSizeModel {
|
||||
return &defaultFsProductSizeModel{
|
||||
conn: conn,
|
||||
table: "`fs_product_size`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsProductSizeModel) 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 *defaultFsProductSizeModel) FindOne(ctx context.Context, id int64) (*FsProductSize, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductSizeRows, m.table)
|
||||
var resp FsProductSize
|
||||
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 *defaultFsProductSizeModel) Insert(ctx context.Context, data *FsProductSize) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductSizeRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.ProductId, data.Title, data.Cover, data.CoverImg, data.Capacity, data.Status, data.Sort, data.Remark, data.PartsCanDeleted)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultFsProductSizeModel) Update(ctx context.Context, data *FsProductSize) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductSizeRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.ProductId, data.Title, data.Cover, data.CoverImg, data.Capacity, data.Status, data.Sort, data.Remark, data.PartsCanDeleted, data.Id)
|
||||
return err
|
||||
}
|
||||
func (m *defaultFsProductSizeModel) CountByStatus(ctx context.Context, status int) (total int, err error) {
|
||||
query := fmt.Sprintf("select %s from %s where `status` = ? limit 1", "count(*) as num", m.table)
|
||||
err = m.conn.QueryRowCtx(ctx, &total, query, status)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (m *defaultFsProductSizeModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -125,6 +125,13 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, login
|
|||
if tagInfo == nil {
|
||||
return &types.Response{Code: 510, Message: "classification not exists "}, nil
|
||||
}
|
||||
//获取产品尺寸数量
|
||||
productSizeModel := model.NewFsProductSizeModel(l.svcCtx.MysqlConn)
|
||||
productSizeCount, err := productSizeModel.CountByStatus(l.ctx, 1)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "get product size count err "}, nil
|
||||
}
|
||||
//拼接返回
|
||||
itemList := make([]types.Items, 0, productLen)
|
||||
for _, v := range productList {
|
||||
|
@ -147,7 +154,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, login
|
|||
CoverImg: v.CoverImg,
|
||||
IsEnv: v.IsProtection,
|
||||
IsMicro: v.IsMicrowave,
|
||||
SizeNum: 1, //????????????????
|
||||
SizeNum: uint32(productSizeCount),
|
||||
MiniPrice: format.CentoDollar(minPrice),
|
||||
}
|
||||
if req.Size > 0 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user