master
dtapps 1 month ago
parent 8238616ab5
commit b99cbca10a

@ -3,7 +3,6 @@ module go.dtapp.net/dorm
go 1.22.1
require (
github.com/basgys/goxml2json v1.1.0
github.com/redis/go-redis/v9 v9.5.1
github.com/sirupsen/logrus v1.9.3
go.dtapp.net/gojson v1.0.4
@ -17,6 +16,7 @@ require (
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/basgys/goxml2json v1.1.0 // indirect
github.com/bytedance/sonic v1.11.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect

@ -13,10 +13,12 @@ import (
// GormClientFun *GormClient 驱动
type GormClientFun func() *GormClient
// GormClientTableFun *GormClient 驱动
// GormClientTableFun
// *GormClient 驱动
// string 表名
type GormClientTableFun func() (*GormClient, string)
// GormClientConfig 配置
type GormClientConfig struct {
Dns string // 地址
LogStatus bool // 日志 - 状态

@ -8,10 +8,12 @@ import (
// GormGenClientFun *GormClient 驱动
type GormGenClientFun func() *GormGenClient
// GormGenClientTableFun *GormClient 驱动
// GormGenClientTableFun
// *GormClient 驱动
// string 表名
type GormGenClientTableFun func() (*GormGenClient, string)
// GormGenClientConfig 配置
type GormGenClientConfig struct {
Dns string // dns地址
Db *gorm.DB // db驱动

@ -7,6 +7,7 @@ import (
"gorm.io/gorm"
)
// NewGormGenMysqlClient 创建GormGenClient实例 mysql
func NewGormGenMysqlClient(ctx context.Context, config *GormGenClientConfig) (*GormGenClient, error) {
c := &GormGenClient{config: config}

@ -7,6 +7,7 @@ import (
"gorm.io/gorm"
)
// NewGormGenPostgresClient 创建GormGenClient实例 postgres
func NewGormGenPostgresClient(ctx context.Context, config *GormGenClientConfig) (*GormGenClient, error) {
c := &GormGenClient{config: config}

@ -7,6 +7,7 @@ import (
"gorm.io/gorm"
)
// NewGormGenPostgresqlClient 创建GormGenClient实例 postgresql
func NewGormGenPostgresqlClient(ctx context.Context, config *GormGenClientConfig) (*GormGenClient, error) {
c := &GormGenClient{config: config}

@ -11,6 +11,7 @@ import (
"time"
)
// NewGormMysqlClient 创建GormClient实例 mysql
func NewGormMysqlClient(ctx context.Context, config *GormClientConfig) (*GormClient, error) {
var err error

@ -11,6 +11,7 @@ import (
"time"
)
// NewGormPostgresClient 创建GormClient实例 postgres
func NewGormPostgresClient(ctx context.Context, config *GormClientConfig) (*GormClient, error) {
var err error

@ -11,6 +11,7 @@ import (
"time"
)
// NewGormPostgresqlClient 创建GormClient实例 postgresql
func NewGormPostgresqlClient(ctx context.Context, config *GormClientConfig) (*GormClient, error) {
var err error

@ -1,18 +0,0 @@
package dorm
import (
"go.dtapp.net/gojson"
)
// JsonDecodeNoError json字符串转结构体不报错
func JsonDecodeNoError(b []byte) map[string]interface{} {
var data map[string]interface{}
_ = gojson.Unmarshal(b, &data)
return data
}
// JsonEncodeNoError 结构体转json字符串不报错
func JsonEncodeNoError(data interface{}) string {
jsons, _ := gojson.Marshal(data)
return string(jsons)
}

@ -12,7 +12,8 @@ import (
// string 库名
type MongoClientFun func() (*MongoClient, string)
// MongoClientCollectionFun *MongoClient 驱动
// MongoClientCollectionFun
// *MongoClient 驱动
// string 库名
// string 集合
type MongoClientCollectionFun func() (*MongoClient, string, string)

@ -1,21 +0,0 @@
package dorm
import (
"github.com/basgys/goxml2json"
"go.dtapp.net/gojson"
"strings"
)
// XmlDecodeNoError xml字符串转结构体不报错
func XmlDecodeNoError(b []byte) map[string]interface{} {
xtj := strings.NewReader(string(b))
jtx, _ := xml2json.Convert(xtj)
var data map[string]interface{}
_ = gojson.Unmarshal(jtx.Bytes(), &data)
return data
}
// XmlEncodeNoError 结构体转json字符串不报错
func XmlEncodeNoError(data interface{}) string {
return JsonEncodeNoError(data)
}
Loading…
Cancel
Save