Compare commits
No commits in common. "master" and "v1.3.0" have entirely different histories.
|
@ -1,30 +0,0 @@
|
||||||
package sql
|
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
// key,value To like sql
|
|
||||||
func Like(key, val string) string {
|
|
||||||
if val == "" {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
key = strings.TrimSpace(key)
|
|
||||||
val = strings.TrimSpace(val)
|
|
||||||
return key + " LIKE '%" + val + "%'"
|
|
||||||
}
|
|
||||||
|
|
||||||
// map strings to like sqls
|
|
||||||
func Likes(in map[string]string) string {
|
|
||||||
var ar []string
|
|
||||||
for key, val := range in {
|
|
||||||
sql := Like(key, val)
|
|
||||||
if sql != "" {
|
|
||||||
ar = append(ar, sql)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ar) == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(ar, " AND ")
|
|
||||||
}
|
|
|
@ -24,14 +24,14 @@ func NewPostgreSql(dsn string, options *types.SqlOptions) (*gorm.DB, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//控制台和文件同时输出日志
|
//控制台和文件同时输出日志
|
||||||
//var newLogger = setLogger(vars.ServiceKey, options.LogStdout)
|
var newLogger = setLogger(vars.ServiceKey, options.LogStdout)
|
||||||
|
|
||||||
gormDb, err := gorm.Open(postgres.New(postgres.Config{
|
gormDb, err := gorm.Open(postgres.New(postgres.Config{
|
||||||
DSN: dsn,
|
DSN: dsn,
|
||||||
// PreferSimpleProtocol: true, disables implicit prepared statement usage
|
// PreferSimpleProtocol: true, disables implicit prepared statement usage
|
||||||
|
|
||||||
}), &gorm.Config{
|
}), &gorm.Config{
|
||||||
//Logger:newLogger,
|
Logger: newLogger,
|
||||||
DisableForeignKeyConstraintWhenMigrating: true,
|
DisableForeignKeyConstraintWhenMigrating: true,
|
||||||
NamingStrategy: schema.NamingStrategy{
|
NamingStrategy: schema.NamingStrategy{
|
||||||
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
|
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
|
||||||
|
|
|
@ -14,7 +14,7 @@ var MeshEnv *types.MeshEnv = nil
|
||||||
func NewEnv() *types.MeshEnv {
|
func NewEnv() *types.MeshEnv {
|
||||||
if MeshEnv == nil {
|
if MeshEnv == nil {
|
||||||
MeshEnv = &types.MeshEnv{
|
MeshEnv = &types.MeshEnv{
|
||||||
Workspace: GetEnvDefault("BlocksMesh_Workspace", "def"),
|
Workspace: GetEnvDefault("BlocksMesh_Workspace", "bsm"),
|
||||||
JwtSecretKey: GetEnvDefault("BlocksMesh_JwtSecretKey", "Cblocksmesh2022C"),
|
JwtSecretKey: GetEnvDefault("BlocksMesh_JwtSecretKey", "Cblocksmesh2022C"),
|
||||||
RuntimeMode: strings.ToLower(GetEnvDefault("BlocksMesh_RuntimeMode", "dev")),
|
RuntimeMode: strings.ToLower(GetEnvDefault("BlocksMesh_RuntimeMode", "dev")),
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,4 @@ var (
|
||||||
ErrAuthClient = Errorf(209, "Auth Token Client Not Passed")
|
ErrAuthClient = Errorf(209, "Auth Token Client Not Passed")
|
||||||
ErrJsonDecode = Errorf(210, "Auth JSON Decode Error")
|
ErrJsonDecode = Errorf(210, "Auth JSON Decode Error")
|
||||||
ErrJsonEncode = Errorf(211, "Auth JSON Encode Error")
|
ErrJsonEncode = Errorf(211, "Auth JSON Encode Error")
|
||||||
ErrAccountNotFound = Errorf(202, "Account Not Found")
|
|
||||||
)
|
)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
||||||
module git.apinb.com/bsm-sdk/engine
|
module git.apinb.com/bsm-sdk/engine
|
||||||
|
|
||||||
go 1.23.3
|
go 1.23
|
||||||
|
|
|
@ -34,7 +34,7 @@ func Register(srvKey string, cfg any) {
|
||||||
// get config file.
|
// get config file.
|
||||||
cf := fmt.Sprintf("%s_%s.yaml", srvKey, env.MeshEnv.RuntimeMode)
|
cf := fmt.Sprintf("%s_%s.yaml", srvKey, env.MeshEnv.RuntimeMode)
|
||||||
cf = filepath.Join(env.MeshEnv.Prefix, "etc", cf)
|
cf = filepath.Join(env.MeshEnv.Prefix, "etc", cf)
|
||||||
print.Info("[Blocks Service] %s Config File: %s", vars.ServiceKey, cf)
|
|
||||||
configure.LoadYamlFile(cf, args, cfg)
|
configure.LoadYamlFile(cf, args, cfg)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
12
types/db.go
12
types/db.go
|
@ -18,16 +18,10 @@ type (
|
||||||
Debug bool
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID,Identity definition.
|
|
||||||
Std_IDIdentity struct {
|
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
|
||||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
|
||||||
}
|
|
||||||
|
|
||||||
// standard ID,Created,Updated,Deleted definition.
|
// standard ID,Created,Updated,Deleted definition.
|
||||||
Std_IICUDS struct {
|
Std_IICUDS struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"primarykey;" json:"id"`
|
||||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为UUID
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
||||||
|
@ -51,7 +45,7 @@ type (
|
||||||
// standard PassportID,PassportIdentity definition.
|
// standard PassportID,PassportIdentity definition.
|
||||||
Std_Passport struct {
|
Std_Passport struct {
|
||||||
PassportID uint `gorm:"column:passport_id;Index;" json:"passport_id"`
|
PassportID uint `gorm:"column:passport_id;Index;" json:"passport_id"`
|
||||||
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;" json:"passport_identity"` // 用户唯一标识,24位NanoID,36位为ULID
|
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;" json:"passport_identity"` // 用户唯一标识,24位NanoID,36位为UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID definition.
|
// standard ID definition.
|
||||||
|
@ -61,7 +55,7 @@ type (
|
||||||
|
|
||||||
// standard Identity definition.
|
// standard Identity definition.
|
||||||
Std_Identity struct {
|
Std_Identity struct {
|
||||||
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为ULID
|
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;" json:"identity"` // 唯一标识,24位NanoID,36位为UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard Status definition.
|
// standard Status definition.
|
||||||
|
|
Loading…
Reference in New Issue