transfer_middleware/genModel/serverMiddleZltxLogsModel_g...

91 lines
3.2 KiB
Go
Executable File

// Code generated by goctl. DO NOT EDIT.
package genModel
import (
"context"
"database/sql"
"fmt"
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
serverMiddleZltxLogsFieldNames = builder.RawFieldNames(&ServerMiddleZltxLogs{})
serverMiddleZltxLogsRows = strings.Join(serverMiddleZltxLogsFieldNames, ",")
serverMiddleZltxLogsRowsExpectAutoSet = strings.Join(stringx.Remove(serverMiddleZltxLogsFieldNames, "`log_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
serverMiddleZltxLogsRowsWithPlaceHolder = strings.Join(stringx.Remove(serverMiddleZltxLogsFieldNames, "`log_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
serverMiddleZltxLogsModel interface {
Insert(ctx context.Context, data *ServerMiddleZltxLogs) (sql.Result, error)
FindOne(ctx context.Context, logId uint64) (*ServerMiddleZltxLogs, error)
Update(ctx context.Context, data *ServerMiddleZltxLogs) error
Delete(ctx context.Context, logId uint64) error
}
defaultServerMiddleZltxLogsModel struct {
conn sqlx.SqlConn
table string
}
ServerMiddleZltxLogs struct {
LogId uint64 `db:"log_id"`
Url string `db:"url"`
Code int64 `db:"code"`
Data string `db:"data"`
Resp string `db:"resp"`
CreateTime time.Time `db:"create_time"`
UpdateTime time.Time `db:"update_time"`
Status int64 `db:"status"`
}
)
func newServerMiddleZltxLogsModel(conn sqlx.SqlConn) *defaultServerMiddleZltxLogsModel {
return &defaultServerMiddleZltxLogsModel{
conn: conn,
table: "`server_middle_zltx_logs`",
}
}
func (m *defaultServerMiddleZltxLogsModel) Delete(ctx context.Context, logId uint64) error {
query := fmt.Sprintf("delete from %s where `log_id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, logId)
return err
}
func (m *defaultServerMiddleZltxLogsModel) FindOne(ctx context.Context, logId uint64) (*ServerMiddleZltxLogs, error) {
query := fmt.Sprintf("select %s from %s where `log_id` = ? limit 1", serverMiddleZltxLogsRows, m.table)
var resp ServerMiddleZltxLogs
err := m.conn.QueryRowCtx(ctx, &resp, query, logId)
switch err {
case nil:
return &resp, nil
case sqlx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultServerMiddleZltxLogsModel) Insert(ctx context.Context, data *ServerMiddleZltxLogs) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, serverMiddleZltxLogsRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.Url, data.Code, data.Data, data.Resp, data.Status)
return ret, err
}
func (m *defaultServerMiddleZltxLogsModel) Update(ctx context.Context, data *ServerMiddleZltxLogs) error {
query := fmt.Sprintf("update %s set %s where `log_id` = ?", m.table, serverMiddleZltxLogsRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.Url, data.Code, data.Data, data.Resp, data.Status, data.LogId)
return err
}
func (m *defaultServerMiddleZltxLogsModel) tableName() string {
return m.table
}