This commit is contained in:
2026-08-15 03:14:56 +08:00
parent a34133cce5
commit 2a3c55bb53
71 changed files with 1445 additions and 1076 deletions
+10 -10
View File
@@ -12,21 +12,21 @@ import (
type VersionService struct{ uc *biz.VersionUsecase }
func NewVersionService(uc *biz.VersionUsecase) *VersionService { return &VersionService{uc: uc} }
func versionDTO(v *biz.Version) map[string]any {
return map[string]any{"ID": v.ID, "CreatedAt": v.CreatedAt, "UpdatedAt": v.UpdatedAt, "DeletedAt": nil, "versionName": v.Name, "versionCode": v.Code, "description": v.Description, "versionData": v.Data}
func versionDTO(v *biz.Version) *dto.VersionResponse {
return &dto.VersionResponse{ID: v.ID, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, DeletedAt: nil, VersionName: v.Name, VersionCode: v.Code, Description: v.Description, VersionData: v.Data}
}
func (s *VersionService) Versions(ctx context.Context, page, size int, name, code string, createdAtRange []*time.Time) ([]map[string]any, int64, error) {
func (s *VersionService) Versions(ctx context.Context, page, size int, name, code string, createdAtRange []*time.Time) ([]*dto.VersionResponse, int64, error) {
items, total, err := s.uc.ListVersions(ctx, page, size, name, code, createdAtRange)
if err != nil {
return nil, 0, err
}
out := make([]map[string]any, 0, len(items))
out := make([]*dto.VersionResponse, 0, len(items))
for _, v := range items {
out = append(out, versionDTO(v))
}
return out, total, nil
}
func (s *VersionService) Version(ctx context.Context, id uint) (map[string]any, error) {
func (s *VersionService) Version(ctx context.Context, id uint) (*dto.VersionResponse, error) {
v, err := s.uc.FindVersion(ctx, id)
if err != nil {
return nil, err
@@ -53,15 +53,15 @@ func (s *VersionService) Export(ctx context.Context, name, code, description str
bundle.Code = code
bundle.Description = description
bundle.ExportTime = time.Now().Format("2006-01-02 15:04:05")
menus := make([]map[string]any, 0, len(bundle.Menus))
menus := make([]*dto.MenuResponse, 0, len(bundle.Menus))
for _, v := range bundle.Menus {
menus = append(menus, convertMenu(v))
menus = append(menus, menuResponse(v))
}
apis := make([]map[string]any, 0, len(bundle.APIs))
apis := make([]*dto.APIResponse, 0, len(bundle.APIs))
for _, v := range bundle.APIs {
apis = append(apis, apiDTO(v))
apis = append(apis, apiResponse(v))
}
dicts := make([]map[string]any, 0, len(bundle.Dictionaries))
dicts := make([]*dto.DictionaryResponse, 0, len(bundle.Dictionaries))
for _, v := range bundle.Dictionaries {
dicts = append(dicts, dictionaryDTO(v))
}