后端重构
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// SysAutoCodePackage 代码包实体
|
||||
type SysAutoCodePackage struct {
|
||||
ID uint
|
||||
Desc string
|
||||
Label string
|
||||
Template string
|
||||
PackageName string
|
||||
Module string
|
||||
}
|
||||
|
||||
// AutoCodePackageRepo 代码包仓储接口
|
||||
type AutoCodePackageRepo interface {
|
||||
Create(ctx context.Context, pkg *SysAutoCodePackage) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
DeleteByNames(ctx context.Context, names []string) error
|
||||
All(ctx context.Context) ([]SysAutoCodePackage, error)
|
||||
First(ctx context.Context, packageName, template string) (*SysAutoCodePackage, error)
|
||||
FindByPackageName(ctx context.Context, packageName string) (*SysAutoCodePackage, error)
|
||||
BatchCreate(ctx context.Context, pkgs []SysAutoCodePackage) error
|
||||
DeleteByIDs(ctx context.Context, ids []uint) error
|
||||
}
|
||||
|
||||
// AutoCodePackageUsecase 代码包用例
|
||||
type AutoCodePackageUsecase struct {
|
||||
repo AutoCodePackageRepo
|
||||
}
|
||||
|
||||
// NewAutoCodePackageUsecase 创建代码包用例
|
||||
func NewAutoCodePackageUsecase(repo AutoCodePackageRepo) *AutoCodePackageUsecase {
|
||||
return &AutoCodePackageUsecase{repo: repo}
|
||||
}
|
||||
|
||||
// Create 创建包
|
||||
func (uc *AutoCodePackageUsecase) Create(ctx context.Context, pkg *SysAutoCodePackage) error {
|
||||
return uc.repo.Create(ctx, pkg)
|
||||
}
|
||||
|
||||
// Delete 删除包
|
||||
func (uc *AutoCodePackageUsecase) Delete(ctx context.Context, id uint) error {
|
||||
return uc.repo.Delete(ctx, id)
|
||||
}
|
||||
|
||||
// DeleteByNames 根据名称删除包
|
||||
func (uc *AutoCodePackageUsecase) DeleteByNames(ctx context.Context, names []string) error {
|
||||
return uc.repo.DeleteByNames(ctx, names)
|
||||
}
|
||||
|
||||
// All 获取所有包
|
||||
func (uc *AutoCodePackageUsecase) All(ctx context.Context) ([]SysAutoCodePackage, error) {
|
||||
return uc.repo.All(ctx)
|
||||
}
|
||||
|
||||
// First 查询包
|
||||
func (uc *AutoCodePackageUsecase) First(ctx context.Context, packageName, template string) (*SysAutoCodePackage, error) {
|
||||
return uc.repo.First(ctx, packageName, template)
|
||||
}
|
||||
|
||||
// FindByPackageName 根据包名查询
|
||||
func (uc *AutoCodePackageUsecase) FindByPackageName(ctx context.Context, packageName string) (*SysAutoCodePackage, error) {
|
||||
return uc.repo.FindByPackageName(ctx, packageName)
|
||||
}
|
||||
|
||||
// BatchCreate 批量创建
|
||||
func (uc *AutoCodePackageUsecase) BatchCreate(ctx context.Context, pkgs []SysAutoCodePackage) error {
|
||||
return uc.repo.BatchCreate(ctx, pkgs)
|
||||
}
|
||||
|
||||
// DeleteByIDs 根据ID批量删除
|
||||
func (uc *AutoCodePackageUsecase) DeleteByIDs(ctx context.Context, ids []uint) error {
|
||||
return uc.repo.DeleteByIDs(ctx, ids)
|
||||
}
|
||||
Reference in New Issue
Block a user