Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c62f529e3 | ||
|
|
9d3b3404e4 | ||
| bfccf4d468 | |||
| cd72620e49 |
@@ -58,8 +58,8 @@ var (
|
|||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
const (
|
const (
|
||||||
signKey = "8E853B589944FF7A56BEF02AAA51D6F4"
|
signKey = "1F36659EC27CFFF849E068EA80B1A4CA"
|
||||||
LICENCE_KEY = "TRAIN_LICENCE_KEY"
|
LICENCE_KEY = "BLOCKS_KEY"
|
||||||
)
|
)
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
36
types/db.go
36
types/db.go
@@ -10,42 +10,42 @@ type (
|
|||||||
|
|
||||||
// sql options
|
// sql options
|
||||||
SqlOptions struct {
|
SqlOptions struct {
|
||||||
MaxIdleConns int
|
MaxIdleConns int `gorm:"column:max_idle_conns;" json:"max_idle_conns"`
|
||||||
MaxOpenConns int
|
MaxOpenConns int `gorm:"column:max_open_conns;" json:"max_open_conns"`
|
||||||
ConnMaxLifetime time.Duration
|
ConnMaxLifetime time.Duration
|
||||||
|
|
||||||
LogStdout bool
|
LogStdout bool `gorm:"column:log_stdout;" json:"log_stdout"`
|
||||||
Debug bool
|
Debug bool `gorm:"column:debug;" json:"debug"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID,Identity definition.
|
// standard ID,Identity definition.
|
||||||
Std_IDIdentity struct {
|
Std_IDIdentity struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"column:id;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位为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:"column:id;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位为ULID
|
||||||
CreatedAt time.Time `gorm:"" json:"created_at"`
|
CreatedAt time.Time `gorm:"column:created_at;" json:"created_at"`
|
||||||
UpdatedAt time.Time `gorm:"" json:"updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at;" json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;" json:"deleted_at"`
|
||||||
Status int8 `gorm:"default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
Status int8 `gorm:"column:status;default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID,Identity,Created,Updated,Deleted,Status definition.
|
// standard ID,Identity,Created,Updated,Deleted,Status definition.
|
||||||
Std_ICUD struct {
|
Std_ICUD struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"column:id;primarykey;" json:"id"`
|
||||||
CreatedAt time.Time `gorm:"" json:"created_at"`
|
CreatedAt time.Time `gorm:"column:created_at;" json:"created_at"`
|
||||||
UpdatedAt time.Time `gorm:"" json:"updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at;" json:"updated_at"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index;" json:"deleted_at"`
|
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index;" json:"deleted_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard ID,Created definition.
|
// standard ID,Created definition.
|
||||||
Std_IdCreated struct {
|
Std_IdCreated struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"column:id;primarykey;" json:"id"`
|
||||||
CreatedAt time.Time `gorm:"" json:"created_at"`
|
CreatedAt time.Time `gorm:"column:created_at;" json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard PassportID,PassportIdentity definition.
|
// standard PassportID,PassportIdentity definition.
|
||||||
@@ -62,7 +62,7 @@ type (
|
|||||||
|
|
||||||
// standard ID definition.
|
// standard ID definition.
|
||||||
Std_ID struct {
|
Std_ID struct {
|
||||||
ID uint `gorm:"primarykey;" json:"id"`
|
ID uint `gorm:"column:id;primarykey;" json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard Identity definition.
|
// standard Identity definition.
|
||||||
@@ -72,6 +72,6 @@ type (
|
|||||||
|
|
||||||
// standard Status definition.
|
// standard Status definition.
|
||||||
Std_Status struct {
|
Std_Status struct {
|
||||||
Status int64 `gorm:"default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
Status int64 `gorm:"column:status;default:0;index;" json:"status"` // 状态:默认为0,-1禁止,1为正常
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
10
utils/net.go
10
utils/net.go
@@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -121,6 +122,15 @@ func HttpGet(url string) ([]byte, error) {
|
|||||||
return body, err
|
return body, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HttpPostJSON(url string, header map[string]string, data map[string]any) ([]byte, error) {
|
||||||
|
bytes, err := json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return HttpPost(url, header, bytes)
|
||||||
|
}
|
||||||
|
|
||||||
func HttpPost(url string, header map[string]string, data []byte) ([]byte, error) {
|
func HttpPost(url string, header map[string]string, data []byte) ([]byte, error) {
|
||||||
var err error
|
var err error
|
||||||
reader := bytes.NewBuffer(data)
|
reader := bytes.NewBuffer(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user