完善数据上报,每日支付任务认证
This commit is contained in:
155
internal/model/nh_system_config_model_gen.go
Executable file
155
internal/model/nh_system_config_model_gen.go
Executable file
@@ -0,0 +1,155 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// versions:
|
||||
// goctl version: 1.7.3
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
nhSystemConfigFieldNames = builder.RawFieldNames(&NhSystemConfig{})
|
||||
nhSystemConfigRows = strings.Join(nhSystemConfigFieldNames, ",")
|
||||
nhSystemConfigRowsExpectAutoSet = strings.Join(stringx.Remove(nhSystemConfigFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
nhSystemConfigRowsWithPlaceHolder = strings.Join(stringx.Remove(nhSystemConfigFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cacheNovaHomeNhSystemConfigIdPrefix = "cache:novaHome:nhSystemConfig:id:"
|
||||
cacheNovaHomeNhSystemConfigNamePrefix = "cache:novaHome:nhSystemConfig:name:"
|
||||
)
|
||||
|
||||
type (
|
||||
nhSystemConfigModel interface {
|
||||
Insert(ctx context.Context, data *NhSystemConfig) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id uint64) (*NhSystemConfig, error)
|
||||
FindOneByName(ctx context.Context, name string) (*NhSystemConfig, error)
|
||||
Update(ctx context.Context, data *NhSystemConfig) error
|
||||
Delete(ctx context.Context, id uint64) error
|
||||
}
|
||||
|
||||
defaultNhSystemConfigModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
NhSystemConfig struct {
|
||||
Id uint64 `db:"id"`
|
||||
Module string `db:"module"` // 模块
|
||||
Name string `db:"name"` // 变量名
|
||||
Type string `db:"type"` // 类型text,radio,checkbox,select,input,array等等
|
||||
Value string `db:"value"` // 变量值
|
||||
Remark string `db:"remark"` // 变量注释
|
||||
Sort uint64 `db:"sort"` // 排序
|
||||
CreatedId uint `db:"created_id"` // 创建人ID
|
||||
UpdatedId uint `db:"updated_id"` // 修改人ID
|
||||
CreatedAt time.Time `db:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `db:"updated_at"` // 修改时间
|
||||
}
|
||||
)
|
||||
|
||||
func newNhSystemConfigModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultNhSystemConfigModel {
|
||||
return &defaultNhSystemConfigModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`nh_system_config`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) Delete(ctx context.Context, id uint64) error {
|
||||
data, err := m.FindOne(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
novaHomeNhSystemConfigIdKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigIdPrefix, id)
|
||||
novaHomeNhSystemConfigNameKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigNamePrefix, data.Name)
|
||||
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, novaHomeNhSystemConfigIdKey, novaHomeNhSystemConfigNameKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) FindOne(ctx context.Context, id uint64) (*NhSystemConfig, error) {
|
||||
novaHomeNhSystemConfigIdKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigIdPrefix, id)
|
||||
var resp NhSystemConfig
|
||||
err := m.QueryRowCtx(ctx, &resp, novaHomeNhSystemConfigIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhSystemConfigRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) FindOneByName(ctx context.Context, name string) (*NhSystemConfig, error) {
|
||||
novaHomeNhSystemConfigNameKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigNamePrefix, name)
|
||||
var resp NhSystemConfig
|
||||
err := m.QueryRowIndexCtx(ctx, &resp, novaHomeNhSystemConfigNameKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v any) (i any, e error) {
|
||||
query := fmt.Sprintf("select %s from %s where `name` = ? limit 1", nhSystemConfigRows, m.table)
|
||||
if err := conn.QueryRowCtx(ctx, &resp, query, name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.Id, nil
|
||||
}, m.queryPrimary)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) Insert(ctx context.Context, data *NhSystemConfig) (sql.Result, error) {
|
||||
novaHomeNhSystemConfigIdKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigIdPrefix, data.Id)
|
||||
novaHomeNhSystemConfigNameKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigNamePrefix, data.Name)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, nhSystemConfigRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Module, data.Name, data.Type, data.Value, data.Remark, data.Sort, data.CreatedId, data.UpdatedId)
|
||||
}, novaHomeNhSystemConfigIdKey, novaHomeNhSystemConfigNameKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) Update(ctx context.Context, newData *NhSystemConfig) error {
|
||||
data, err := m.FindOne(ctx, newData.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
novaHomeNhSystemConfigIdKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigIdPrefix, data.Id)
|
||||
novaHomeNhSystemConfigNameKey := fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigNamePrefix, data.Name)
|
||||
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhSystemConfigRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, newData.Module, newData.Name, newData.Type, newData.Value, newData.Remark, newData.Sort, newData.CreatedId, newData.UpdatedId, newData.Id)
|
||||
}, novaHomeNhSystemConfigIdKey, novaHomeNhSystemConfigNameKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cacheNovaHomeNhSystemConfigIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhSystemConfigRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultNhSystemConfigModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
Reference in New Issue
Block a user