优化结构

This commit is contained in:
Yvan
2026-08-22 12:13:16 +08:00
parent d987244d0e
commit b27a66e9d3
200 changed files with 1794 additions and 1715 deletions
+10 -10
View File
@@ -2,20 +2,20 @@ package service
import (
"context"
"kra/internal/biz/system"
"time"
"kra/internal/biz"
"kra/internal/service/dto"
)
type ParameterService struct{ uc *biz.ParameterUsecase }
type ParameterService struct{ uc *system.ParameterUsecase }
func NewParameterService(uc *biz.ParameterUsecase) *ParameterService {
func NewParameterService(uc *system.ParameterUsecase) *ParameterService {
return &ParameterService{uc: uc}
}
func parameterDomain(value *dto.SystemParameterRequest) *biz.SystemParameter {
return &biz.SystemParameter{ID: value.ID, CreatedAt: value.CreatedAt, UpdatedAt: value.UpdatedAt, Name: value.Name, Key: value.Key, Value: value.Value, Desc: value.Description}
func parameterDomain(value *dto.SystemParameterRequest) *system.SystemParameter {
return &system.SystemParameter{ID: value.ID, CreatedAt: value.CreatedAt, UpdatedAt: value.UpdatedAt, Name: value.Name, Key: value.Key, Value: value.Value, Desc: value.Description}
}
func (s *ParameterService) CreateParameterRequest(ctx context.Context, req *dto.SystemParameterRequest) error {
return s.CreateParameter(ctx, parameterDomain(req))
@@ -24,12 +24,12 @@ func (s *ParameterService) UpdateParameterRequest(ctx context.Context, req *dto.
return s.UpdateParameter(ctx, parameterDomain(req))
}
func (s *ParameterService) ParametersFilter(ctx context.Context, page, size int, name, key string, start, end *time.Time) ([]*dto.SystemParameterResponse, int64, error) {
return s.Parameters(ctx, page, size, &biz.SystemParameter{Name: name, Key: key, StartCreatedAt: start, EndCreatedAt: end})
return s.Parameters(ctx, page, size, &system.SystemParameter{Name: name, Key: key, StartCreatedAt: start, EndCreatedAt: end})
}
func parameterDTO(v *biz.SystemParameter) *dto.SystemParameterResponse {
func parameterDTO(v *system.SystemParameter) *dto.SystemParameterResponse {
return &dto.SystemParameterResponse{ID: v.ID, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, DeletedAt: nil, Name: v.Name, Key: v.Key, Value: v.Value, Desc: v.Desc}
}
func (s *ParameterService) Parameters(ctx context.Context, page, size int, q *biz.SystemParameter) ([]*dto.SystemParameterResponse, int64, error) {
func (s *ParameterService) Parameters(ctx context.Context, page, size int, q *system.SystemParameter) ([]*dto.SystemParameterResponse, int64, error) {
items, total, err := s.uc.ListParameters(ctx, page, size, q)
if err != nil {
return nil, 0, err
@@ -54,10 +54,10 @@ func (s *ParameterService) ParameterByKey(ctx context.Context, key string) (*dto
}
return parameterDTO(v), nil
}
func (s *ParameterService) CreateParameter(ctx context.Context, v *biz.SystemParameter) error {
func (s *ParameterService) CreateParameter(ctx context.Context, v *system.SystemParameter) error {
return s.uc.CreateParameter(ctx, v)
}
func (s *ParameterService) UpdateParameter(ctx context.Context, v *biz.SystemParameter) error {
func (s *ParameterService) UpdateParameter(ctx context.Context, v *system.SystemParameter) error {
return s.uc.UpdateParameter(ctx, v)
}
func (s *ParameterService) DeleteParameters(ctx context.Context, ids []string) error {