feat: 升级 samber/do v1 → v2

This commit is contained in:
2026-05-15 09:04:12 +08:00
parent 7741f7584d
commit 9ad5d25836
47 changed files with 1456 additions and 684 deletions
+15 -9
View File
@@ -6,7 +6,9 @@ import (
"strings"
"git.fsdpf.net/go/contracts"
"github.com/samber/do"
"git.fsdpf.net/go/db"
"git.fsdpf.net/go/req"
"github.com/samber/do/v2"
)
type PkgVersion struct {
@@ -39,7 +41,7 @@ func (this PkgVersion) GetSourceMapPath(prefix ...string) string {
)
}
func (this PkgVersion) GetFile(app *do.Injector) (file string, err error) {
func (this PkgVersion) GetFile(app do.Injector, u req.User) (file string, err error) {
if this.Id == 0 {
return file, contracts.ErrPkgUnknown
}
@@ -50,23 +52,27 @@ func (this PkgVersion) GetFile(app *do.Injector) (file string, err error) {
return file, contracts.ErrResNotFound
}
_, err = res.GetDBTable().Where("id", this.Id).Value(&file, "file")
ok, err = res.GetDBTable(u).Where(db.C("id").Eq(this.Id)).Select("file").ScanVal(&file)
if !ok {
return file, contracts.ErrResNotFound
}
return file, err
}
func (this PkgVersion) GetSourceMap(app *do.Injector) (file string, err error) {
func (this PkgVersion) GetSourceMap(app do.Injector) (file string, err error) {
if this.Id == 0 {
return file, contracts.ErrPkgUnknown
}
res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion")
// res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion")
if !ok {
return file, contracts.ErrResNotFound
}
// if !ok {
// return file, contracts.ErrResNotFound
// }
_, err = res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap")
// _, err = res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap")
return file, err
}