From b1c7318cd0546c6f62b4c052d31937eb6c331cfb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 07:29:20 +0000 Subject: [PATCH] chore(template): update .template go-zero/model --- .template/go-zero/model/customized.tpl | 28 +++++++++++++------------- .template/go-zero/model/delete.tpl | 16 +++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.template/go-zero/model/customized.tpl b/.template/go-zero/model/customized.tpl index 1d1a6bd3..e61205e3 100644 --- a/.template/go-zero/model/customized.tpl +++ b/.template/go-zero/model/customized.tpl @@ -17,8 +17,8 @@ func (m *custom{{.upperStartCamelObject}}Model) BulkInsert(ctx context.Context, func (m *custom{{.upperStartCamelObject}}Model) FindByCondition(ctx context.Context, session sqlx.Session, conds ...condition.Condition) ([]*{{.upperStartCamelObject}}, error) { sb := sqlbuilder.Select({{.lowerStartCamelObject}}FieldNames...).From(m.table) - condition.ApplySelect(sb, conds...) - statement, args := sb.Build() + builder := condition.Select(*sb, conds...) + statement, args := builder.Build() var resp []*{{.upperStartCamelObject}} var err error @@ -37,9 +37,9 @@ func (m *custom{{.upperStartCamelObject}}Model) FindByCondition(ctx context.Cont func (m *custom{{.upperStartCamelObject}}Model) FindOneByCondition(ctx context.Context, session sqlx.Session, conds ...condition.Condition) (*{{.upperStartCamelObject}}, error) { sb := sqlbuilder.Select({{.lowerStartCamelObject}}FieldNames...).From(m.table) - condition.ApplySelect(sb, conds...) - sb.Limit(1) - statement, args := sb.Build() + builder := condition.Select(*sb, conds...) + builder.Limit(1) + statement, args := builder.Build() var resp {{.upperStartCamelObject}} var err error @@ -59,7 +59,7 @@ func (m *custom{{.upperStartCamelObject}}Model) PageByCondition(ctx context.Cont sb := sqlbuilder.Select({{.lowerStartCamelObject}}FieldNames...).From(m.table) countsb := sqlbuilder.Select("count(*)").From(m.table) - condition.ApplySelect(sb, conds...) + builder := condition.Select(*sb, conds...) var countConds []condition.Condition for _, cond := range conds { @@ -67,12 +67,12 @@ func (m *custom{{.upperStartCamelObject}}Model) PageByCondition(ctx context.Cont countConds = append(countConds, cond) } } - condition.ApplySelect(countsb, countConds...) + countBuilder := condition.Select(*countsb, countConds...) var resp []*{{.upperStartCamelObject}} var err error - statement, args := sb.Build() + statement, args := builder.Build() if session != nil { err = session.QueryRowsCtx(ctx, &resp, statement, args...) @@ -84,7 +84,7 @@ func (m *custom{{.upperStartCamelObject}}Model) PageByCondition(ctx context.Cont } var total int64 - statement, args = countsb.Build() + statement, args = countBuilder.Build() if session != nil { err = session.QueryRowCtx(ctx, &total, statement, args...) } else { @@ -103,15 +103,15 @@ func (m *custom{{.upperStartCamelObject}}Model) UpdateFieldsByCondition(ctx cont } sb := sqlbuilder.Update(m.table) - condition.ApplyUpdate(sb, conds...) + builder := condition.Update(*sb, conds...) var assigns []string for key, value := range field { assigns = append(assigns, sb.Assign(key, value)) } - sb.Set(assigns...) + builder.Set(assigns...) - statement, args := sb.Build() + statement, args := builder.Build() var err error if session != nil { @@ -130,8 +130,8 @@ func (m *custom{{.upperStartCamelObject}}Model) DeleteByCondition(ctx context.Co return nil } sb := sqlbuilder.DeleteFrom(m.table) - condition.ApplyDelete(sb, conds...) - statement, args := sb.Build() + builder := condition.Delete(*sb, conds...) + statement, args := builder.Build() var err error if session != nil { diff --git a/.template/go-zero/model/delete.tpl b/.template/go-zero/model/delete.tpl index 9878b799..6db39ccd 100644 --- a/.template/go-zero/model/delete.tpl +++ b/.template/go-zero/model/delete.tpl @@ -1,13 +1,13 @@ func (m *default{{.upperStartCamelObject}}Model) Delete(ctx context.Context, session sqlx.Session, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error { sb := sqlbuilder.DeleteFrom(m.table) - sb.Where(sb.EQ("{{.originalPrimaryKey}}", {{.lowerStartCamelPrimaryKey}})) - statement, args := sb.Build() - var err error - if session != nil { - _, err = session.ExecCtx(ctx, statement, args...) - }else{ - _, err = m.conn.ExecCtx(ctx, statement, args...) - } + sb.Where(sb.EQ("{{.originalPrimaryKey}}", {{.lowerStartCamelPrimaryKey}})) + statement, args := sb.Build() + var err error + if session != nil { + _, err = session.ExecCtx(ctx, statement, args...) + } else { + _, err = m.conn.ExecCtx(ctx, statement, args...) + } return err }