优化弹窗和后台设置字体
This commit is contained in:
@@ -48,6 +48,17 @@ func (s *Service) SalePriceConfig() (*PublishSalePriceConfig, error) {
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
func (s *Service) OrderAgreements() (*OrderAgreementsDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
agreements, err := s.orderAgreements()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &agreements, nil
|
||||
}
|
||||
|
||||
func (s *Service) publishOptions() (PublishOptionsDTO, error) {
|
||||
value, err := s.repo.FindValue(publishOptionsConfigKey)
|
||||
if err != nil {
|
||||
@@ -74,6 +85,19 @@ func (s *Service) salePriceConfig() (PublishSalePriceConfig, error) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func (s *Service) orderAgreements() (OrderAgreementsDTO, error) {
|
||||
value, err := s.repo.FindValue(orderAgreementsConfigKey)
|
||||
if err != nil {
|
||||
return OrderAgreementsDTO{}, err
|
||||
}
|
||||
agreements := DefaultOrderAgreements()
|
||||
if err := json.Unmarshal([]byte(value), &agreements); err != nil {
|
||||
agreements = DefaultOrderAgreements()
|
||||
}
|
||||
normalizeOrderAgreements(&agreements)
|
||||
return agreements, nil
|
||||
}
|
||||
|
||||
func (s *Service) HomeAnnouncements() (*HomeAnnouncementsDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
@@ -179,6 +203,26 @@ func normalizeHomeBanners(items []HomeBannerItem) []HomeBannerItem {
|
||||
return normalized
|
||||
}
|
||||
|
||||
func normalizeOrderAgreements(agreements *OrderAgreementsDTO) {
|
||||
defaults := DefaultOrderAgreements()
|
||||
agreements.VirtualAssetPurchase.Title = strings.TrimSpace(agreements.VirtualAssetPurchase.Title)
|
||||
agreements.VirtualAssetPurchase.Content = strings.TrimSpace(agreements.VirtualAssetPurchase.Content)
|
||||
agreements.RenterAgreement.Title = strings.TrimSpace(agreements.RenterAgreement.Title)
|
||||
agreements.RenterAgreement.Content = strings.TrimSpace(agreements.RenterAgreement.Content)
|
||||
if agreements.VirtualAssetPurchase.Title == "" {
|
||||
agreements.VirtualAssetPurchase.Title = defaults.VirtualAssetPurchase.Title
|
||||
}
|
||||
if agreements.VirtualAssetPurchase.Content == "" {
|
||||
agreements.VirtualAssetPurchase.Content = defaults.VirtualAssetPurchase.Content
|
||||
}
|
||||
if agreements.RenterAgreement.Title == "" {
|
||||
agreements.RenterAgreement.Title = defaults.RenterAgreement.Title
|
||||
}
|
||||
if agreements.RenterAgreement.Content == "" {
|
||||
agreements.RenterAgreement.Content = defaults.RenterAgreement.Content
|
||||
}
|
||||
}
|
||||
|
||||
func normalizePublishOptions(options *PublishOptionsDTO) {
|
||||
defaults := DefaultPublishOptions()
|
||||
if len(options.ServerOptions) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user