92 lines
3.3 KiB
Go
92 lines
3.3 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 (
|
||
|
serverMiddleMarketLogsFieldNames = builder.RawFieldNames(&ServerMiddleMarketLogs{})
|
||
|
serverMiddleMarketLogsRows = strings.Join(serverMiddleMarketLogsFieldNames, ",")
|
||
|
serverMiddleMarketLogsRowsExpectAutoSet = strings.Join(stringx.Remove(serverMiddleMarketLogsFieldNames, "`log_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||
|
serverMiddleMarketLogsRowsWithPlaceHolder = strings.Join(stringx.Remove(serverMiddleMarketLogsFieldNames, "`log_id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
serverMiddleMarketLogsModel interface {
|
||
|
Insert(ctx context.Context, data *ServerMiddleMarketLogs) (sql.Result, error)
|
||
|
FindOne(ctx context.Context, logId uint64) (*ServerMiddleMarketLogs, error)
|
||
|
Update(ctx context.Context, data *ServerMiddleMarketLogs) error
|
||
|
Delete(ctx context.Context, logId uint64) error
|
||
|
}
|
||
|
|
||
|
defaultServerMiddleMarketLogsModel struct {
|
||
|
conn sqlx.SqlConn
|
||
|
table string
|
||
|
}
|
||
|
|
||
|
ServerMiddleMarketLogs struct {
|
||
|
LogId uint64 `db:"log_id"`
|
||
|
Url string `db:"url"`
|
||
|
Type string `db:"type"`
|
||
|
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 newServerMiddleMarketLogsModel(conn sqlx.SqlConn) *defaultServerMiddleMarketLogsModel {
|
||
|
return &defaultServerMiddleMarketLogsModel{
|
||
|
conn: conn,
|
||
|
table: "`server_middle_market_logs`",
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m *defaultServerMiddleMarketLogsModel) 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 *defaultServerMiddleMarketLogsModel) FindOne(ctx context.Context, logId uint64) (*ServerMiddleMarketLogs, error) {
|
||
|
query := fmt.Sprintf("select %s from %s where `log_id` = ? limit 1", serverMiddleMarketLogsRows, m.table)
|
||
|
var resp ServerMiddleMarketLogs
|
||
|
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 *defaultServerMiddleMarketLogsModel) Insert(ctx context.Context, data *ServerMiddleMarketLogs) (sql.Result, error) {
|
||
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?)", m.table, serverMiddleMarketLogsRowsExpectAutoSet)
|
||
|
ret, err := m.conn.ExecCtx(ctx, query, data.Url, data.Type, data.Code, data.Data, data.Resp, data.Status)
|
||
|
return ret, err
|
||
|
}
|
||
|
|
||
|
func (m *defaultServerMiddleMarketLogsModel) Update(ctx context.Context, data *ServerMiddleMarketLogs) error {
|
||
|
query := fmt.Sprintf("update %s set %s where `log_id` = ?", m.table, serverMiddleMarketLogsRowsWithPlaceHolder)
|
||
|
_, err := m.conn.ExecCtx(ctx, query, data.Url, data.Type, data.Code, data.Data, data.Resp, data.Status, data.LogId)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultServerMiddleMarketLogsModel) tableName() string {
|
||
|
return m.table
|
||
|
}
|