[feat] 完善 PkgVersion GetFilePath GetSourceMapPath

This commit is contained in:
what 2024-11-23 14:28:22 +08:00
parent 4869409bf7
commit 6f5c443c81

View File

@ -39,38 +39,34 @@ func (this PkgVersion) GetSourceMapPath(prefix ...string) string {
) )
} }
func (this PkgVersion) GetFile(app *do.Injector) ([]byte, error) { func (this PkgVersion) GetFile(app *do.Injector) (file string, err error) {
if this.Id == 0 { if this.Id == 0 {
return nil, contracts.ErrPkgUnknown return file, contracts.ErrPkgUnknown
} }
res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion") res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion")
if !ok { if !ok {
return nil, contracts.ErrResNotFound return file, contracts.ErrResNotFound
} }
file := []byte{} _, err = res.GetDBTable().Where("id", this.Id).Value(&file, "file")
_, err := res.GetDBTable().Where("id", this.Id).Value(&file, "file")
return file, err return file, err
} }
func (this PkgVersion) GetSourceMap(app *do.Injector) ([]byte, error) { func (this PkgVersion) GetSourceMap(app *do.Injector) (file string, err error) {
if this.Id == 0 { if this.Id == 0 {
return nil, contracts.ErrPkgUnknown return file, contracts.ErrPkgUnknown
} }
res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion") res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion")
if !ok { if !ok {
return nil, contracts.ErrResNotFound return file, contracts.ErrResNotFound
} }
file := []byte{} _, err = res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap")
_, err := res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap")
return file, err return file, err
} }