91 lines
3.1 KiB
Go
91 lines
3.1 KiB
Go
// 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 (
|
|
serverMiddleRsLogsFieldNames = builder.RawFieldNames(&ServerMiddleRsLogs{})
|
|
serverMiddleRsLogsRows = strings.Join(serverMiddleRsLogsFieldNames, ",")
|
|
serverMiddleRsLogsRowsExpectAutoSet = strings.Join(stringx.Remove(serverMiddleRsLogsFieldNames, "`log_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
|
serverMiddleRsLogsRowsWithPlaceHolder = strings.Join(stringx.Remove(serverMiddleRsLogsFieldNames, "`log_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
|
)
|
|
|
|
type (
|
|
serverMiddleRsLogsModel interface {
|
|
Insert(ctx context.Context, data *ServerMiddleRsLogs) (sql.Result, error)
|
|
FindOne(ctx context.Context, logId uint64) (*ServerMiddleRsLogs, error)
|
|
Update(ctx context.Context, data *ServerMiddleRsLogs) error
|
|
Delete(ctx context.Context, logId uint64) error
|
|
}
|
|
|
|
defaultServerMiddleRsLogsModel struct {
|
|
conn sqlx.SqlConn
|
|
table string
|
|
}
|
|
|
|
ServerMiddleRsLogs 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 newServerMiddleRsLogsModel(conn sqlx.SqlConn) *defaultServerMiddleRsLogsModel {
|
|
return &defaultServerMiddleRsLogsModel{
|
|
conn: conn,
|
|
table: "`server_middle_rs_logs`",
|
|
}
|
|
}
|
|
|
|
func (m *defaultServerMiddleRsLogsModel) 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 *defaultServerMiddleRsLogsModel) FindOne(ctx context.Context, logId uint64) (*ServerMiddleRsLogs, error) {
|
|
query := fmt.Sprintf("select %s from %s where `log_id` = ? limit 1", serverMiddleRsLogsRows, m.table)
|
|
var resp ServerMiddleRsLogs
|
|
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 *defaultServerMiddleRsLogsModel) Insert(ctx context.Context, data *ServerMiddleRsLogs) (sql.Result, error) {
|
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, serverMiddleRsLogsRowsExpectAutoSet)
|
|
ret, err := m.conn.ExecCtx(ctx, query, data.Url, data.Code, data.Data, data.Resp, data.Status)
|
|
return ret, err
|
|
}
|
|
|
|
func (m *defaultServerMiddleRsLogsModel) Update(ctx context.Context, data *ServerMiddleRsLogs) error {
|
|
query := fmt.Sprintf("update %s set %s where `log_id` = ?", m.table, serverMiddleRsLogsRowsWithPlaceHolder)
|
|
_, err := m.conn.ExecCtx(ctx, query, data.Url, data.Code, data.Data, data.Resp, data.Status, data.LogId)
|
|
return err
|
|
}
|
|
|
|
func (m *defaultServerMiddleRsLogsModel) tableName() string {
|
|
return m.table
|
|
}
|