特朗普头像任务

This commit is contained in:
lianghuanjie
2025-01-20 21:55:43 +08:00
parent 38bb283fa1
commit 9c742c50c3
18 changed files with 266 additions and 32 deletions

View File

@@ -0,0 +1,29 @@
package model
import "github.com/zeromicro/go-zero/core/stores/sqlx"
var _ NhGamesPropertyLogsModel = (*customNhGamesPropertyLogsModel)(nil)
type (
// NhGamesPropertyLogsModel is an interface to be customized, add more methods here,
// and implement the added methods in customNhGamesPropertyLogsModel.
NhGamesPropertyLogsModel interface {
nhGamesPropertyLogsModel
WithSession(session sqlx.Session) NhGamesPropertyLogsModel
}
customNhGamesPropertyLogsModel struct {
*defaultNhGamesPropertyLogsModel
}
)
// NewNhGamesPropertyLogsModel returns a model for the database table.
func NewNhGamesPropertyLogsModel(conn sqlx.SqlConn) NhGamesPropertyLogsModel {
return &customNhGamesPropertyLogsModel{
defaultNhGamesPropertyLogsModel: newNhGamesPropertyLogsModel(conn),
}
}
func (m *customNhGamesPropertyLogsModel) WithSession(session sqlx.Session) NhGamesPropertyLogsModel {
return NewNhGamesPropertyLogsModel(sqlx.NewSqlConnFromSession(session))
}

View File

@@ -0,0 +1,96 @@
// 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/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
nhGamesPropertyLogsFieldNames = builder.RawFieldNames(&NhGamesPropertyLogs{})
nhGamesPropertyLogsRows = strings.Join(nhGamesPropertyLogsFieldNames, ",")
nhGamesPropertyLogsRowsExpectAutoSet = strings.Join(stringx.Remove(nhGamesPropertyLogsFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
nhGamesPropertyLogsRowsWithPlaceHolder = strings.Join(stringx.Remove(nhGamesPropertyLogsFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)
type (
nhGamesPropertyLogsModel interface {
Insert(ctx context.Context, data *NhGamesPropertyLogs) (sql.Result, error)
FindOne(ctx context.Context, id uint) (*NhGamesPropertyLogs, error)
Update(ctx context.Context, data *NhGamesPropertyLogs) error
Delete(ctx context.Context, id uint) error
}
defaultNhGamesPropertyLogsModel struct {
conn sqlx.SqlConn
table string
}
NhGamesPropertyLogs struct {
Id uint `db:"id"`
Uid uint `db:"uid"` // 用户ID
RoleId int64 `db:"role_id"` // 角色id
PropertyId string `db:"property_id"` // 道具ID
PropertyNum uint `db:"property_num"` // 道具数量
Scene uint `db:"scene"` // 场景1=积分活动
CallbackStatus int8 `db:"callback_status"` // 下发通知状态:0未通知,1已通知,2通知异常
CallbackNum int `db:"callback_num"` // 交易成功发送通知次数
CallbackAt sql.NullTime `db:"callback_at"` // 发送通知最新时间
CallbackRemark string `db:"callback_remark"` // 通知回调备注
CreatedAt time.Time `db:"created_at"` // 创建时间
UpdatedAt time.Time `db:"updated_at"` // 修改时间
}
)
func newNhGamesPropertyLogsModel(conn sqlx.SqlConn) *defaultNhGamesPropertyLogsModel {
return &defaultNhGamesPropertyLogsModel{
conn: conn,
table: "`nh_games_property_logs`",
}
}
func (m *defaultNhGamesPropertyLogsModel) Delete(ctx context.Context, id uint) error {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, id)
return err
}
func (m *defaultNhGamesPropertyLogsModel) FindOne(ctx context.Context, id uint) (*NhGamesPropertyLogs, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhGamesPropertyLogsRows, m.table)
var resp NhGamesPropertyLogs
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
switch err {
case nil:
return &resp, nil
case sqlx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultNhGamesPropertyLogsModel) Insert(ctx context.Context, data *NhGamesPropertyLogs) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, nhGamesPropertyLogsRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.Uid, data.RoleId, data.PropertyId, data.PropertyNum, data.Scene, data.CallbackStatus, data.CallbackNum, data.CallbackAt, data.CallbackRemark)
return ret, err
}
func (m *defaultNhGamesPropertyLogsModel) Update(ctx context.Context, data *NhGamesPropertyLogs) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhGamesPropertyLogsRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.Uid, data.RoleId, data.PropertyId, data.PropertyNum, data.Scene, data.CallbackStatus, data.CallbackNum, data.CallbackAt, data.CallbackRemark, data.Id)
return err
}
func (m *defaultNhGamesPropertyLogsModel) tableName() string {
return m.table
}

View File

@@ -16,6 +16,7 @@ type (
nhRoleModel
withSession(session sqlx.Session) NhRoleModel
AccountExist(ctx context.Context, account string) (bool, error)
FindRoleUserId(ctx context.Context, roleId int64) (uint, error)
}
customNhRoleModel struct {
@@ -23,6 +24,20 @@ type (
}
)
func (m *customNhRoleModel) FindRoleUserId(ctx context.Context, roleId int64) (uint, error) {
query := fmt.Sprintf("SELECT u.id FROM `nh_user` u JOIN %s r ON u.email = r.account WHERE r.role_id = ?", m.table)
var resp uint
err := m.conn.QueryRowPartialCtx(ctx, &resp, query, roleId)
switch {
case err == nil:
return resp, nil
case errors.Is(err, sqlx.ErrNotFound):
return 0, nil
default:
return 0, err
}
}
func (m *customNhRoleModel) AccountExist(ctx context.Context, account string) (bool, error) {
query := fmt.Sprintf("select count(*) as `count` from %s where `account` = ?", m.table)
var count int64

View File

@@ -22,6 +22,7 @@ const (
TASKTYPE_DAILY_PAY = 9 // 每日支出任务
TASKTYPE_INVITE_USER = 10 // 邀请任务
TASKTYPE_AMBASSADOR_TASK = 11 // 大使任务
TASKTYPE_TRUMP_HEAD = 12 // trump_head
)
type (

View File

@@ -53,6 +53,8 @@ type (
UpdatedAt time.Time `db:"updated_at"` // 修改时间
Param string `db:"param"` // 备用参数,如果是邀请任务,可以填邀请的人数
Sort int `db:"sort"` // 数字越小越靠前
PropertyId string `db:"property_id"` // 道具ID
RewardType int8 `db:"reward_type"` // 奖励类型0=积分1=道具2=castile
}
)
@@ -84,14 +86,14 @@ func (m *defaultNhTaskModel) FindOne(ctx context.Context, id uint) (*NhTask, err
}
func (m *defaultNhTaskModel) Insert(ctx context.Context, data *NhTask) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, nhTaskRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.CommunityId, data.Title, data.SubTitle, data.Description, data.Points, data.ButtonText, data.Type, data.Url, data.Status, data.StartAt, data.EndAt, data.Param, data.Sort)
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, nhTaskRowsExpectAutoSet)
ret, err := m.conn.ExecCtx(ctx, query, data.CommunityId, data.Title, data.SubTitle, data.Description, data.Points, data.ButtonText, data.Type, data.Url, data.Status, data.StartAt, data.EndAt, data.Param, data.Sort, data.PropertyId, data.RewardType)
return ret, err
}
func (m *defaultNhTaskModel) Update(ctx context.Context, data *NhTask) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhTaskRowsWithPlaceHolder)
_, err := m.conn.ExecCtx(ctx, query, data.CommunityId, data.Title, data.SubTitle, data.Description, data.Points, data.ButtonText, data.Type, data.Url, data.Status, data.StartAt, data.EndAt, data.Param, data.Sort, data.Id)
_, err := m.conn.ExecCtx(ctx, query, data.CommunityId, data.Title, data.SubTitle, data.Description, data.Points, data.ButtonText, data.Type, data.Url, data.Status, data.StartAt, data.EndAt, data.Param, data.Sort, data.PropertyId, data.RewardType, data.Id)
return err
}