feat: add backend_v1 migration
Some checks failed
build quyun / Build (push) Has been cancelled

This commit is contained in:
2025-12-19 14:46:58 +08:00
parent 218eb4689c
commit 24bd161df9
119 changed files with 12259 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package services
import (
"go.ipao.vip/atom"
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/contracts"
"go.ipao.vip/atom/opt"
"gorm.io/gorm"
)
func Provide(opts ...opt.Option) error {
if err := container.Container.Provide(func(
db *gorm.DB,
test *test,
) (contracts.Initial, error) {
obj := &services{
db: db,
test: test,
}
if err := obj.Prepare(); err != nil {
return nil, err
}
return obj, nil
}, atom.GroupInitial); err != nil {
return err
}
if err := container.Container.Provide(func() (*test, error) {
obj := &test{}
return obj, nil
}); err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,28 @@
package services
import (
"gorm.io/gorm"
)
var _db *gorm.DB
// exported CamelCase Services
var (
Test *test
)
// @provider(model)
type services struct {
db *gorm.DB
// define Services
test *test
}
func (svc *services) Prepare() error {
_db = svc.db
// set exported Services here
Test = svc.test
return nil
}

View File

@@ -0,0 +1,10 @@
package services
import "context"
// @provider
type test struct{}
func (t *test) Test(ctx context.Context) (string, error) {
return "Test", nil
}

View File

@@ -0,0 +1,41 @@
package services
import (
"testing"
"time"
"quyun/v2/app/commands/testx"
. "github.com/smartystreets/goconvey/convey"
"github.com/stretchr/testify/suite"
_ "go.ipao.vip/atom"
"go.ipao.vip/atom/contracts"
"go.uber.org/dig"
)
type TestSuiteInjectParams struct {
dig.In
Initials []contracts.Initial `group:"initials"` // nolint:structcheck
}
type TestSuite struct {
suite.Suite
TestSuiteInjectParams
}
func Test_Test(t *testing.T) {
providers := testx.Default().With(Provide)
testx.Serve(providers, t, func(p TestSuiteInjectParams) {
suite.Run(t, &TestSuite{TestSuiteInjectParams: p})
})
}
func (t *TestSuite) Test_Test() {
Convey("test_work", t.T(), func() {
t.T().Log("start test at", time.Now())
})
}