v2
This commit is contained in:
@@ -5,6 +5,7 @@ type SearchDto struct {
|
||||
SearchTimeEnd string `json:"searchTimeEnd"`
|
||||
SearchStatus int `json:"searchStatus"`
|
||||
SearchName string `json:"searchName"`
|
||||
SearchID int64 `json:"searchID"`
|
||||
SearchKey string `json:"searchKey"`
|
||||
SearchParentID int `json:"searchParentId"`
|
||||
SearchDepartmentID int `json:"searchDepartmentId"`
|
||||
|
||||
@@ -12,6 +12,7 @@ type DTreeDto struct {
|
||||
Title string `json:"title"`
|
||||
Last bool `json:"last"`
|
||||
ParentId string `json:"parentId"`
|
||||
Spread bool `json:"spread"`
|
||||
|
||||
Children []*DTreeDto `json:"children"`
|
||||
}
|
||||
|
||||
@@ -19,3 +19,9 @@ type XmSelectStrDto struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type XmSelectTreeDto struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
Children []*XmSelectTreeDto `json:"children"`
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
|
||||
// ****************** conn ******************
|
||||
|
||||
func newDsn() string {
|
||||
func newDsn(conf config.DB) string {
|
||||
return fmt.Sprintf("postgresql://%s:%s@%s:%d/%s?sslmode=disable",
|
||||
config.File.DB.Username,
|
||||
config.File.DB.Password,
|
||||
config.File.DB.Host,
|
||||
config.File.DB.Port,
|
||||
config.File.DB.DBName)
|
||||
conf.Username,
|
||||
conf.Password,
|
||||
conf.Host,
|
||||
conf.Port,
|
||||
conf.DBName)
|
||||
}
|
||||
|
||||
// ****************** errors ******************
|
||||
@@ -69,9 +69,26 @@ type SQLStore struct {
|
||||
*Queries
|
||||
}
|
||||
|
||||
func NewIStore(ctx context.Context, conf config.DB) (Store, error) {
|
||||
pool, err := pgxpool.New(ctx, newDsn(conf))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = pool.Ping(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SQLStore{
|
||||
connPool: pool,
|
||||
Queries: New(pool),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewStore creates a new store
|
||||
func NewStore(ctx context.Context) error {
|
||||
pool, err := pgxpool.New(ctx, newDsn())
|
||||
pool, err := pgxpool.New(ctx, newDsn(config.File.DB))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user