mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-07 16:30:26 +08:00
feat: 新增简易版ioc
This commit is contained in:
@@ -27,16 +27,15 @@ type Resource interface {
|
||||
GetAccountResources(accountId uint64, toEntity any) error
|
||||
}
|
||||
|
||||
func newResourceApp(resourceRepo repository.Resource) Resource {
|
||||
return &resourceAppImpl{
|
||||
base.AppImpl[*entity.Resource, repository.Resource]{Repo: resourceRepo},
|
||||
}
|
||||
}
|
||||
|
||||
type resourceAppImpl struct {
|
||||
base.AppImpl[*entity.Resource, repository.Resource]
|
||||
}
|
||||
|
||||
// 注入ResourceRepo
|
||||
func (r *resourceAppImpl) InjectResourceRepo(repo repository.Resource) {
|
||||
r.Repo = repo
|
||||
}
|
||||
|
||||
func (r *resourceAppImpl) Save(ctx context.Context, resource *entity.Resource) error {
|
||||
// 更新操作
|
||||
if resource.Id != 0 {
|
||||
|
||||
Reference in New Issue
Block a user