1 Star 0 Fork 0

gabbble/app

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
applogreportrecordmodel_gen.go 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
haozhiyuan0204 提交于 2023-11-08 12:14 +08:00 . modify
// Code generated by goctl. DO NOT EDIT.
package mysql
import (
"context"
"database/sql"
"fmt"
"strings"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
appLogReportRecordFieldNames = builder.RawFieldNames(&AppLogReportRecord{})
appLogReportRecordRows = strings.Join(appLogReportRecordFieldNames, ",")
appLogReportRecordRowsExpectAutoSet = strings.Join(stringx.Remove(appLogReportRecordFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
appLogReportRecordRowsWithPlaceHolder = strings.Join(stringx.Remove(appLogReportRecordFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
appLogReportRecordModel interface {
Insert(ctx context.Context, data *AppLogReportRecord) (sql.Result, error)
FindOne(ctx context.Context, id int64) (*AppLogReportRecord, error)
Update(ctx context.Context, data *AppLogReportRecord) error
Delete(ctx context.Context, id int64) error
}
defaultAppLogReportRecordModel struct {
conn sqlx.SqlConn
table string
}
AppLogReportRecord struct {
Id int64 `db:"id"` // id
Uid int64 `db:"uid"` // user id
LogType string `db:"logType"` // 日志类型
Uuid string `db:"uuid"` // uuid
Platform string `db:"platform"` // 系统
AppVersion string `db:"appVersion"` // app版本
Content sql.NullString `db:"content"` // 创建时间
Ctime int64 `db:"ctime"` // 修改时间
}
)
func newAppLogReportRecordModel(conn sqlx.SqlConn) *defaultAppLogReportRecordModel {
return &defaultAppLogReportRecordModel{
conn: conn,
table: "`app_log_report_record`",
}
}
func (m *defaultAppLogReportRecordModel) Delete(ctx context.Context, id int64) error {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, id)
return err
}
func (m *defaultAppLogReportRecordModel) FindOne(ctx context.Context, id int64) (*AppLogReportRecord, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", appLogReportRecordRows, m.table)
var resp AppLogReportRecord
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
switch err {
case nil:
return &resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultAppLogReportRecordModel) Insert(ctx context.Context, data *AppLogReportRecord) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, appLogReportRecordRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.Uid, data.LogType, data.Uuid, data.Platform, data.AppVersion, data.Content, data.Ctime)
return ret, err
}
func (m *defaultAppLogReportRecordModel) Update(ctx context.Context, data *AppLogReportRecord) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, appLogReportRecordRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.Uid, data.LogType, data.Uuid, data.Platform, data.AppVersion, data.Content, data.Ctime, data.Id)
return err
}
func (m *defaultAppLogReportRecordModel) tableName() string {
return m.table
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/gabbble/app.git
git@gitee.com:gabbble/app.git
gabbble
app
app
9a5bcbd7ccf5

搜索帮助