增加提取castile到游戏的数据库表,定义API接口等;
This commit is contained in:
@@ -6,6 +6,7 @@ import "admin.api"
|
||||
import "game7.api"
|
||||
import "kgen.api"
|
||||
import "stakepoint.api"
|
||||
import "transfercastile.api"
|
||||
|
||||
info (
|
||||
desc: "nova api"
|
||||
|
||||
42
doc/api/transfercastile.api
Normal file
42
doc/api/transfercastile.api
Normal file
@@ -0,0 +1,42 @@
|
||||
syntax = "v1"
|
||||
|
||||
@server (
|
||||
prefix: /gapi/transfercastile/v1
|
||||
jwt: Auth
|
||||
group: transfercastile
|
||||
)
|
||||
service novatask {
|
||||
@doc "提取castile到游戏"
|
||||
@handler TransferCastileToGame
|
||||
post /save (TransferCastileToGameReq) returns (TransferCastileToGameResp)
|
||||
|
||||
@doc "获取提取castile到游戏的记录"
|
||||
@handler TransferCastileToGameList
|
||||
post /list (TransferCastileToGameListReq) returns (TransferCastileToGameResp)
|
||||
}
|
||||
|
||||
type TransferCastileToGameReq {
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
}
|
||||
|
||||
type TransferCastileToGameResp {
|
||||
TransferToGameLog
|
||||
}
|
||||
|
||||
type TransferCastileToGameListReq {
|
||||
RoleID int64 `json:"role_id,optional"` // 角色id
|
||||
}
|
||||
|
||||
type TransferToGameLog {
|
||||
Id int `json:"id"` // id
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
Status string `json:"elf_name"` // 状态
|
||||
}
|
||||
|
||||
type TransferCastileToGameListResp {
|
||||
Total int `json:"total"` // 总数
|
||||
List []TransferToGameLog `json:"list"` // 列表
|
||||
}
|
||||
|
||||
@@ -136,3 +136,37 @@ CREATE TABLE `nh_stake_points_log`
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX (`uid`, `role_id`)
|
||||
) COMMENT ='积分质押表';
|
||||
|
||||
|
||||
|
||||
CREATE TABLE `nh_castile_token`
|
||||
(
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uid` int unsigned NOT NULL default 0 COMMENT '用户id',
|
||||
`email` varchar(80) NOT NULL default '' COMMENT '账号',
|
||||
`amount1` int(11) unsigned NOT NULL default 0 COMMENT '一测奖励',
|
||||
`amount2` int(11) unsigned NOT NULL default 0 COMMENT '二测奖励',
|
||||
`amount3` int(11) unsigned NOT NULL default 0 COMMENT '三测奖励',
|
||||
`total` int(11) unsigned NOT NULL default 0 COMMENT '总奖励',
|
||||
`transfer` int(11) unsigned NOT NULL default 0 COMMENT '已提取到游戏内',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uid` (`uid`) USING BTREE,
|
||||
UNIQUE KEY `email` (`email`) USING BTREE
|
||||
) COMMENT ='CASTILE代币表';
|
||||
|
||||
CREATE TABLE `nh_castile_token_log`
|
||||
(
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uid` int unsigned NOT NULL COMMENT '用户id',
|
||||
`role_id` bigint unsigned NOT NULL COMMENT '角色id',
|
||||
`amount` int(11) unsigned NOT NULL COMMENT '提取的数量',
|
||||
`callback_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '下发通知状态:0未通知,1已通知,2通知异常',
|
||||
`action` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '操作类型:1=提取到游戏',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `uid` (`uid`) USING BTREE,
|
||||
KEY `role_id` (`role_id`) USING BTREE
|
||||
) COMMENT ='CASTILE代币提取记录表';
|
||||
@@ -894,6 +894,70 @@
|
||||
"multipart/form-data"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/gapi/transfercastile/v1/list": {
|
||||
"post": {
|
||||
"summary": "获取提取castile到游戏的记录",
|
||||
"operationId": "TransferCastileToGameList",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/TransferCastileToGameResp"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/TransferCastileToGameListReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"transfercastile"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"apiKey": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/gapi/transfercastile/v1/save": {
|
||||
"post": {
|
||||
"summary": "提取castile到游戏",
|
||||
"operationId": "TransferCastileToGame",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/TransferCastileToGameResp"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/TransferCastileToGameReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"transfercastile"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"apiKey": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
@@ -1859,6 +1923,115 @@
|
||||
"finish_state"
|
||||
]
|
||||
},
|
||||
"TransferCastileToGameListReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"role_id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 角色id"
|
||||
}
|
||||
},
|
||||
"title": "TransferCastileToGameListReq"
|
||||
},
|
||||
"TransferCastileToGameListResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"total": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": " 总数"
|
||||
},
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/TransferToGameLog"
|
||||
},
|
||||
"description": " 列表"
|
||||
}
|
||||
},
|
||||
"title": "TransferCastileToGameListResp",
|
||||
"required": [
|
||||
"total",
|
||||
"list"
|
||||
]
|
||||
},
|
||||
"TransferCastileToGameReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"role_id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 角色id"
|
||||
},
|
||||
"amount": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 数量"
|
||||
}
|
||||
},
|
||||
"title": "TransferCastileToGameReq",
|
||||
"required": [
|
||||
"role_id",
|
||||
"amount"
|
||||
]
|
||||
},
|
||||
"TransferCastileToGameResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": " id"
|
||||
},
|
||||
"role_id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 角色id"
|
||||
},
|
||||
"amount": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 数量"
|
||||
},
|
||||
"elf_name": {
|
||||
"type": "string",
|
||||
"description": " 状态"
|
||||
}
|
||||
},
|
||||
"title": "TransferCastileToGameResp"
|
||||
},
|
||||
"TransferToGameLog": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": " id"
|
||||
},
|
||||
"role_id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 角色id"
|
||||
},
|
||||
"amount": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": " 数量"
|
||||
},
|
||||
"elf_name": {
|
||||
"type": "string",
|
||||
"description": " 状态"
|
||||
}
|
||||
},
|
||||
"title": "TransferToGameLog",
|
||||
"required": [
|
||||
"id",
|
||||
"role_id",
|
||||
"amount",
|
||||
"elf_name"
|
||||
]
|
||||
},
|
||||
"UnStakeNftReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.6
|
||||
// goctl 1.7.3
|
||||
|
||||
package handler
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
kgen "nova_task/internal/handler/kgen"
|
||||
stakepoint "nova_task/internal/handler/stakepoint"
|
||||
task "nova_task/internal/handler/task"
|
||||
transfercastile "nova_task/internal/handler/transfercastile"
|
||||
"nova_task/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
@@ -235,4 +236,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/gapi/task/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 获取提取castile到游戏的记录
|
||||
Method: http.MethodPost,
|
||||
Path: "/list",
|
||||
Handler: transfercastile.TransferCastileToGameListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 提取castile到游戏
|
||||
Method: http.MethodPost,
|
||||
Path: "/save",
|
||||
Handler: transfercastile.TransferCastileToGameHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
rest.WithPrefix("/gapi/transfercastile/v1"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package transfercastile
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/transfercastile"
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
)
|
||||
|
||||
// 提取castile到游戏
|
||||
func TransferCastileToGameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TransferCastileToGameReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := transfercastile.NewTransferCastileToGameLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TransferCastileToGame(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package transfercastile
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/transfercastile"
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
)
|
||||
|
||||
// 获取提取castile到游戏的记录
|
||||
func TransferCastileToGameListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TransferCastileToGameListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := transfercastile.NewTransferCastileToGameListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TransferCastileToGameList(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package transfercastile
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type TransferCastileToGameListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 获取提取castile到游戏的记录
|
||||
func NewTransferCastileToGameListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TransferCastileToGameListLogic {
|
||||
return &TransferCastileToGameListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *TransferCastileToGameListLogic) TransferCastileToGameList(req *types.TransferCastileToGameListReq) (resp *types.TransferCastileToGameResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package transfercastile
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type TransferCastileToGameLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 提取castile到游戏
|
||||
func NewTransferCastileToGameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TransferCastileToGameLogic {
|
||||
return &TransferCastileToGameLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *TransferCastileToGameLogic) TransferCastileToGame(req *types.TransferCastileToGameReq) (resp *types.TransferCastileToGameResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
29
internal/model/nh_castile_token_log_model.go
Normal file
29
internal/model/nh_castile_token_log_model.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ NhCastileTokenLogModel = (*customNhCastileTokenLogModel)(nil)
|
||||
|
||||
type (
|
||||
// NhCastileTokenLogModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customNhCastileTokenLogModel.
|
||||
NhCastileTokenLogModel interface {
|
||||
nhCastileTokenLogModel
|
||||
withSession(session sqlx.Session) NhCastileTokenLogModel
|
||||
}
|
||||
|
||||
customNhCastileTokenLogModel struct {
|
||||
*defaultNhCastileTokenLogModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewNhCastileTokenLogModel returns a model for the database table.
|
||||
func NewNhCastileTokenLogModel(conn sqlx.SqlConn) NhCastileTokenLogModel {
|
||||
return &customNhCastileTokenLogModel{
|
||||
defaultNhCastileTokenLogModel: newNhCastileTokenLogModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhCastileTokenLogModel) withSession(session sqlx.Session) NhCastileTokenLogModel {
|
||||
return NewNhCastileTokenLogModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
92
internal/model/nh_castile_token_log_model_gen.go
Normal file
92
internal/model/nh_castile_token_log_model_gen.go
Normal file
@@ -0,0 +1,92 @@
|
||||
// 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 (
|
||||
nhCastileTokenLogFieldNames = builder.RawFieldNames(&NhCastileTokenLog{})
|
||||
nhCastileTokenLogRows = strings.Join(nhCastileTokenLogFieldNames, ",")
|
||||
nhCastileTokenLogRowsExpectAutoSet = strings.Join(stringx.Remove(nhCastileTokenLogFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
nhCastileTokenLogRowsWithPlaceHolder = strings.Join(stringx.Remove(nhCastileTokenLogFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
nhCastileTokenLogModel interface {
|
||||
Insert(ctx context.Context, data *NhCastileTokenLog) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id uint) (*NhCastileTokenLog, error)
|
||||
Update(ctx context.Context, data *NhCastileTokenLog) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
}
|
||||
|
||||
defaultNhCastileTokenLogModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
NhCastileTokenLog struct {
|
||||
Id uint `db:"id"`
|
||||
Uid uint `db:"uid"` // 用户id
|
||||
RoleId uint64 `db:"role_id"` // 角色id
|
||||
Amount uint `db:"amount"` // 提取的数量
|
||||
CallbackStatus int8 `db:"callback_status"` // 下发通知状态:0未通知,1已通知,2通知异常
|
||||
Action uint8 `db:"action"` // 操作类型:1=提取到游戏
|
||||
CreatedAt time.Time `db:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `db:"updated_at"` // 修改时间
|
||||
}
|
||||
)
|
||||
|
||||
func newNhCastileTokenLogModel(conn sqlx.SqlConn) *defaultNhCastileTokenLogModel {
|
||||
return &defaultNhCastileTokenLogModel{
|
||||
conn: conn,
|
||||
table: "`nh_castile_token_log`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenLogModel) 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 *defaultNhCastileTokenLogModel) FindOne(ctx context.Context, id uint) (*NhCastileTokenLog, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhCastileTokenLogRows, m.table)
|
||||
var resp NhCastileTokenLog
|
||||
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 *defaultNhCastileTokenLogModel) Insert(ctx context.Context, data *NhCastileTokenLog) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, nhCastileTokenLogRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Uid, data.RoleId, data.Amount, data.CallbackStatus, data.Action)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenLogModel) Update(ctx context.Context, data *NhCastileTokenLog) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhCastileTokenLogRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.Uid, data.RoleId, data.Amount, data.CallbackStatus, data.Action, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenLogModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
29
internal/model/nh_castile_token_model.go
Normal file
29
internal/model/nh_castile_token_model.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ NhCastileTokenModel = (*customNhCastileTokenModel)(nil)
|
||||
|
||||
type (
|
||||
// NhCastileTokenModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customNhCastileTokenModel.
|
||||
NhCastileTokenModel interface {
|
||||
nhCastileTokenModel
|
||||
withSession(session sqlx.Session) NhCastileTokenModel
|
||||
}
|
||||
|
||||
customNhCastileTokenModel struct {
|
||||
*defaultNhCastileTokenModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewNhCastileTokenModel returns a model for the database table.
|
||||
func NewNhCastileTokenModel(conn sqlx.SqlConn) NhCastileTokenModel {
|
||||
return &customNhCastileTokenModel{
|
||||
defaultNhCastileTokenModel: newNhCastileTokenModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhCastileTokenModel) withSession(session sqlx.Session) NhCastileTokenModel {
|
||||
return NewNhCastileTokenModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
124
internal/model/nh_castile_token_model_gen.go
Normal file
124
internal/model/nh_castile_token_model_gen.go
Normal file
@@ -0,0 +1,124 @@
|
||||
// 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 (
|
||||
nhCastileTokenFieldNames = builder.RawFieldNames(&NhCastileToken{})
|
||||
nhCastileTokenRows = strings.Join(nhCastileTokenFieldNames, ",")
|
||||
nhCastileTokenRowsExpectAutoSet = strings.Join(stringx.Remove(nhCastileTokenFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
nhCastileTokenRowsWithPlaceHolder = strings.Join(stringx.Remove(nhCastileTokenFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
nhCastileTokenModel interface {
|
||||
Insert(ctx context.Context, data *NhCastileToken) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id uint) (*NhCastileToken, error)
|
||||
FindOneByEmail(ctx context.Context, email string) (*NhCastileToken, error)
|
||||
FindOneByUid(ctx context.Context, uid uint) (*NhCastileToken, error)
|
||||
Update(ctx context.Context, data *NhCastileToken) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
}
|
||||
|
||||
defaultNhCastileTokenModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
NhCastileToken struct {
|
||||
Id uint `db:"id"`
|
||||
Uid uint `db:"uid"` // 用户id
|
||||
Email string `db:"email"` // 账号
|
||||
Amount1 uint `db:"amount1"` // 一测奖励
|
||||
Amount2 uint `db:"amount2"` // 二测奖励
|
||||
Amount3 uint `db:"amount3"` // 三测奖励
|
||||
Total uint `db:"total"` // 总奖励
|
||||
Transfer uint `db:"transfer"` // 已提取到游戏内
|
||||
CreatedAt time.Time `db:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `db:"updated_at"` // 修改时间
|
||||
}
|
||||
)
|
||||
|
||||
func newNhCastileTokenModel(conn sqlx.SqlConn) *defaultNhCastileTokenModel {
|
||||
return &defaultNhCastileTokenModel{
|
||||
conn: conn,
|
||||
table: "`nh_castile_token`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenModel) 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 *defaultNhCastileTokenModel) FindOne(ctx context.Context, id uint) (*NhCastileToken, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", nhCastileTokenRows, m.table)
|
||||
var resp NhCastileToken
|
||||
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 *defaultNhCastileTokenModel) FindOneByEmail(ctx context.Context, email string) (*NhCastileToken, error) {
|
||||
var resp NhCastileToken
|
||||
query := fmt.Sprintf("select %s from %s where `email` = ? limit 1", nhCastileTokenRows, m.table)
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, email)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlx.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenModel) FindOneByUid(ctx context.Context, uid uint) (*NhCastileToken, error) {
|
||||
var resp NhCastileToken
|
||||
query := fmt.Sprintf("select %s from %s where `uid` = ? limit 1", nhCastileTokenRows, m.table)
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, uid)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlx.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenModel) Insert(ctx context.Context, data *NhCastileToken) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, nhCastileTokenRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Uid, data.Email, data.Amount1, data.Amount2, data.Amount3, data.Total, data.Transfer)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenModel) Update(ctx context.Context, newData *NhCastileToken) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhCastileTokenRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, newData.Uid, newData.Email, newData.Amount1, newData.Amount2, newData.Amount3, newData.Total, newData.Transfer, newData.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultNhCastileTokenModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.6
|
||||
// goctl 1.7.3
|
||||
|
||||
package types
|
||||
|
||||
@@ -240,6 +240,31 @@ type Task struct {
|
||||
FinishState int8 `json:"finish_state"` // 0:未完成 1:待校验 2:已完成未领取 3:已领取 4:不可参与
|
||||
}
|
||||
|
||||
type TransferCastileToGameListReq struct {
|
||||
RoleID int64 `json:"role_id,optional"` // 角色id
|
||||
}
|
||||
|
||||
type TransferCastileToGameListResp struct {
|
||||
Total int `json:"total"` // 总数
|
||||
List []TransferToGameLog `json:"list"` // 列表
|
||||
}
|
||||
|
||||
type TransferCastileToGameReq struct {
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
}
|
||||
|
||||
type TransferCastileToGameResp struct {
|
||||
TransferToGameLog
|
||||
}
|
||||
|
||||
type TransferToGameLog struct {
|
||||
Id int `json:"id"` // id
|
||||
RoleID int64 `json:"role_id"` // 角色id
|
||||
Amount int64 `json:"amount"` // 数量
|
||||
Status string `json:"elf_name"` // 状态
|
||||
}
|
||||
|
||||
type UnStakeNftReq struct {
|
||||
TokenId string `json:"token_id"` // nftID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user