feat: 添加租后须知功能并优化发布默认设置

新增功能:
- 添加租后须知查看功能(PC端+移动端)
- 管理后台支持配置租后须知内容
- 默认提供完整的租后须知模板

功能实现:
- 后端:新增 PostRentalNotice API 接口和配置管理
- PC端:在用户下拉菜单添加租后须知入口,独立页面展示
- 移动端:在个人中心实名认证下方添加入口,弹窗展示
- 管理端:新增租后须知配置弹窗,支持编辑和恢复默认

优化改进:
- 修复发布页面默认选中"参考比例"而非"自定比例"
- 移除错误的迁移测试脚本(与 MySQL 8.0 不兼容)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yml
2026-06-05 09:55:11 +08:00
co-authored by Claude Opus 4.7
parent 0b9b0b5ea7
commit 5d5bd5af77
15 changed files with 563 additions and 201 deletions
@@ -59,6 +59,17 @@ func (s *Service) OrderAgreements() (*OrderAgreementsDTO, error) {
return &agreements, nil
}
func (s *Service) PostRentalNotice() (*PostRentalNoticeDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
notice, err := s.postRentalNotice()
if err != nil {
return nil, err
}
return &notice, nil
}
func (s *Service) publishOptions() (PublishOptionsDTO, error) {
value, err := s.repo.FindValue(publishOptionsConfigKey)
if err != nil {
@@ -98,6 +109,19 @@ func (s *Service) orderAgreements() (OrderAgreementsDTO, error) {
return agreements, nil
}
func (s *Service) postRentalNotice() (PostRentalNoticeDTO, error) {
value, err := s.repo.FindValue(postRentalNoticeConfigKey)
if err != nil {
return PostRentalNoticeDTO{}, err
}
notice := DefaultPostRentalNotice()
if err := json.Unmarshal([]byte(value), &notice); err != nil {
notice = DefaultPostRentalNotice()
}
normalizePostRentalNotice(&notice)
return notice, nil
}
func (s *Service) HomeAnnouncements() (*HomeAnnouncementsDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
@@ -223,6 +247,18 @@ func normalizeOrderAgreements(agreements *OrderAgreementsDTO) {
}
}
func normalizePostRentalNotice(notice *PostRentalNoticeDTO) {
defaults := DefaultPostRentalNotice()
notice.Title = strings.TrimSpace(notice.Title)
notice.Content = strings.TrimSpace(notice.Content)
if notice.Title == "" {
notice.Title = defaults.Title
}
if notice.Content == "" {
notice.Content = defaults.Content
}
}
func normalizePublishOptions(options *PublishOptionsDTO) {
defaults := DefaultPublishOptions()
if len(options.ServerOptions) == 0 {