1、泛型化参数,预留泛型约束,方便以后代码扩展的类型安全校验

2、升级goframe至v2.7.3
This commit is contained in:
apefuu
2024-09-19 19:33:00 +08:00
parent 2a87055b62
commit f18ce6384b
57 changed files with 221 additions and 220 deletions

View File

@@ -11,12 +11,12 @@ import (
)
// Context 请求上下文结构
type Context struct {
Module string // 应用模块 adminapihomewebsocket
AddonName string // 插件名称 如果不是插件模块请求,可能为空
User *Identity // 上下文用户信息
Response *Response // 请求响应
Data g.Map // 自定kv变量 业务模块根据需要设置,不固定
type Context[T any] struct {
Module string // 应用模块 adminapihomewebsocket
AddonName string // 插件名称 如果不是插件模块请求,可能为空
User *Identity // 上下文用户信息
Response *Response[T] // 请求响应
Data g.Map // 自定kv变量 业务模块根据需要设置,不固定
}
// Identity 通用身份模型

View File

@@ -37,7 +37,7 @@ func (in *CreditsLogSaveBalanceInp) Filter(ctx context.Context) (err error) {
}
if in.AppId == "" {
in.AppId = contexts.GetModule(ctx)
in.AppId = contexts.GetModule[any](ctx)
}
if in.CreditGroup == "" {
@@ -75,7 +75,7 @@ func (in *CreditsLogSaveIntegralInp) Filter(ctx context.Context) (err error) {
}
if in.AppId == "" {
in.AppId = contexts.GetModule(ctx)
in.AppId = contexts.GetModule[any](ctx)
}
if in.CreditGroup == "" {

View File

@@ -287,8 +287,8 @@ func (in *MemberAddBalanceInp) Filter(ctx context.Context) (err error) {
in.Remark = fmt.Sprintf("扣除余额:%v", in.OtherNum)
}
in.AppId = contexts.GetModule(ctx)
in.AddonsName = contexts.GetAddonName(ctx)
in.AppId = contexts.GetModule[any](ctx)
in.AddonsName = contexts.GetAddonName[any](ctx)
return
}
@@ -330,8 +330,8 @@ func (in *MemberAddIntegralInp) Filter(ctx context.Context) (err error) {
in.Remark = fmt.Sprintf("扣除积分:%v", in.OtherNum)
}
in.AppId = contexts.GetModule(ctx)
in.AddonsName = contexts.GetAddonName(ctx)
in.AppId = contexts.GetModule[any](ctx)
in.AddonsName = contexts.GetAddonName[any](ctx)
return
}

View File

@@ -3,14 +3,13 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package model
// Response HTTP响应
type Response struct {
type Response[T any] struct {
Code int `json:"code" example:"0" description:"状态码"`
Message string `json:"message,omitempty" example:"操作成功" description:"提示消息"`
Data interface{} `json:"data,omitempty" description:"数据集"`
Data T `json:"data,omitempty" description:"数据集"`
Error interface{} `json:"error,omitempty" description:"错误信息"`
Timestamp int64 `json:"timestamp" example:"1640966400" description:"服务器时间戳"`
TraceID string `json:"traceID" v:"0" example:"d0bb93048bc5c9164cdee845dcb7f820" description:"链路ID"`