You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
598 B
30 lines
598 B
package dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"{{.ModPrefix}}{{.Name}}/internal/model"
|
|
"github.com/bilibili/kratos/pkg/conf/paladin"
|
|
"github.com/bilibili/kratos/pkg/database/sql"
|
|
)
|
|
|
|
func NewDB() (db *sql.DB, cf func(), err error) {
|
|
var (
|
|
cfg sql.Config
|
|
ct paladin.TOML
|
|
)
|
|
if err = paladin.Get("db.toml").Unmarshal(&ct); err != nil {
|
|
return
|
|
}
|
|
if err = ct.Get("Client").UnmarshalTOML(&cfg); err != nil {
|
|
return
|
|
}
|
|
db = sql.NewMySQL(&cfg)
|
|
cf = func() {db.Close()}
|
|
return
|
|
}
|
|
|
|
func (d *dao) RawArticle(ctx context.Context, id int64) (art *model.Article, err error) {
|
|
// get data from db
|
|
return
|
|
}
|
|
|