[feat] 完善 PkgVersion GetFile() GetSourceMap()
This commit is contained in:
parent
fefaa09793
commit
911852d14e
@ -1,6 +1,12 @@
|
|||||||
package base
|
package base
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.fsdpf.net/go/contracts"
|
||||||
|
"github.com/samber/do"
|
||||||
|
)
|
||||||
|
|
||||||
type PkgVersion struct {
|
type PkgVersion struct {
|
||||||
|
Id int64 `db:"id"`
|
||||||
Name string `db:"pkg"`
|
Name string `db:"pkg"`
|
||||||
Bundle string `db:"bundle"`
|
Bundle string `db:"bundle"`
|
||||||
Hash string `db:"hash"`
|
Hash string `db:"hash"`
|
||||||
@ -13,8 +19,41 @@ type PkgVersion struct {
|
|||||||
CreatedAt string `db:"created_at"`
|
CreatedAt string `db:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this PkgVersion) GetFile() []byte
|
func (this PkgVersion) GetFile(app *do.Injector) ([]byte, error) {
|
||||||
func (this PkgVersion) GetSourceMap() []byte
|
if this.Id == 0 {
|
||||||
|
return nil, contracts.ErrPkgUnknown
|
||||||
|
}
|
||||||
|
|
||||||
|
res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion")
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return nil, contracts.ErrResNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
file := []byte{}
|
||||||
|
|
||||||
|
_, err := res.GetDBTable().Where("id", this.Id).Value(&file, "file")
|
||||||
|
|
||||||
|
return file, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this PkgVersion) GetSourceMap(app *do.Injector) ([]byte, error) {
|
||||||
|
if this.Id == 0 {
|
||||||
|
return nil, contracts.ErrPkgUnknown
|
||||||
|
}
|
||||||
|
|
||||||
|
res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion")
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return nil, contracts.ErrResNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
file := []byte{}
|
||||||
|
|
||||||
|
_, err := res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap")
|
||||||
|
|
||||||
|
return file, err
|
||||||
|
}
|
||||||
|
|
||||||
type GetPkgVersion func(pkg string, opts ...PkgOption) (PkgVersion, bool)
|
type GetPkgVersion func(pkg string, opts ...PkgOption) (PkgVersion, bool)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user