refactor: 消息模块重构,infra包路径简写等

This commit is contained in:
meilin.huang
2025-07-27 21:02:48 +08:00
parent e96379b6c0
commit 6ad6c69660
149 changed files with 969 additions and 1098 deletions

View File

@@ -268,17 +268,6 @@ func (br *RepoImpl[T]) NewModel() T {
return newModel.(T)
}
// func (br *RepoImpl[T]) NewModes() *[]T {
// // 创建一个空的切片
// slice := reflect.MakeSlice(reflect.SliceOf(reflect.PointerTo(br.getModelType())), 0, 0)
// // 创建指向切片的指针
// ptrToSlice := reflect.New(slice.Type())
// // 设置指向切片的指针为创建的空切片
// ptrToSlice.Elem().Set(slice)
// // 转换指向切片的指针
// return ptrToSlice.Interface().(*[]T)
// }
// getModel 获取表的模型实例
func (br *RepoImpl[T]) GetModel() T {
if br.model != nil {

View File

@@ -9,8 +9,8 @@ import (
"github.com/go-playground/validator/v10"
)
// 绑定并校验请求结构体参数
func BindJsonAndValid[T any](rc *Ctx) T {
// BindJson 绑定并校验请求结构体参数
func BindJson[T any](rc *Ctx) T {
data := structx.NewInstance[T]()
if err := rc.BindJSON(data); err != nil {
panic(ConvBindValidationError(data, err))
@@ -19,13 +19,13 @@ func BindJsonAndValid[T any](rc *Ctx) T {
}
}
// 绑定请求体中的json至form结构体并拷贝至指定结构体
// BindJsonAndCopyTo 绑定请求体中的json至form结构体并拷贝至指定结构体
func BindJsonAndCopyTo[F, T any](rc *Ctx) (F, T) {
f := BindJsonAndValid[F](rc)
f := BindJson[F](rc)
return f, structx.CopyTo[T](f)
}
// 绑定查询字符串到指定结构体
// BindQuery 绑定查询字符串到指定结构体
func BindQuery[T any](rc *Ctx) T {
data := structx.NewInstance[T]()
if err := rc.BindQuery(data); err != nil {
@@ -35,7 +35,7 @@ func BindQuery[T any](rc *Ctx) T {
}
}
// 绑定查询字符串到指定结构体,并将分页信息也返回
// BindQueryAndPage 绑定查询字符串到指定结构体,并将分页信息也返回
func BindQueryAndPage[T any](rc *Ctx) (T, model.PageParam) {
data := structx.NewInstance[T]()
if err := rc.BindQuery(data); err != nil {