@@ -54,6 +54,7 @@ func (h *WebsiteConfigHandler) RegisterGinRoutes(engine *gin.Engine) {
5454
5555 // 获取首页的配置信息
5656 routerGroup .GET ("/index" , apiwrap .Wrap (h .GetIndexConfig ))
57+ routerGroup .GET ("/common" , apiwrap .Wrap (h .GetCommonConfig ))
5758
5859 // 轮播图
5960 routerGroup .GET ("/index/carousel" , apiwrap .Wrap (h .GetCarouselConfig ))
@@ -63,18 +64,23 @@ func (h *WebsiteConfigHandler) RegisterGinRoutes(engine *gin.Engine) {
6364 adminGroup .GET ("/carousel" , apiwrap .Wrap (h .AdminGetCarouselConfig ))
6465 adminGroup .PUT ("/carousel/:id/show" , apiwrap .WrapWithBody (h .AdminUpdateCarouselShowStatus ))
6566
67+ // 初始化相关
6668 routerGroup .GET ("/check-initialization" , apiwrap .Wrap (h .GetInitStatus ))
67-
6869 adminGroup .GET ("/check-initialization" , apiwrap .Wrap (h .GetInitStatus ))
6970 adminGroup .POST ("/initialization" , apiwrap .WrapWithBody (h .InitializeWebsite ))
71+
72+ // website
73+ routerGroup .GET ("/website" , apiwrap .Wrap (h .GetWebsiteConfig ))
7074 adminGroup .GET ("/website" , apiwrap .Wrap (h .AdminGetWebsiteConfig ))
7175 adminGroup .GET ("/website/meta" , apiwrap .Wrap (h .AdminGetWebsiteConfig4Meta ))
7276 adminGroup .PUT ("/website" , apiwrap .WrapWithBody (h .AdminUpdateWebsiteConfig ))
7377 adminGroup .POST ("/website/records" , apiwrap .WrapWithBody (h .AdminAddRecordInWebsiteConfig ))
7478 adminGroup .DELETE ("/website/records" , apiwrap .Wrap (h .AdminDeleteRecordInWebsiteConfig ))
79+
7580 // seo
7681 adminGroup .GET ("/seo" , apiwrap .Wrap (h .AdminGetSeoConfig ))
7782 adminGroup .PUT ("/seo" , apiwrap .WrapWithBody (h .AdminUpdateSeoConfig ))
83+
7884 // 评论
7985 adminGroup .GET ("/comment" , apiwrap .Wrap (h .AdminGetCommentConfig ))
8086 adminGroup .PUT ("/comment" , apiwrap .WrapWithBody (h .AdminUpdateCommentConfig ))
@@ -86,6 +92,8 @@ func (h *WebsiteConfigHandler) RegisterGinRoutes(engine *gin.Engine) {
8692 adminGroup .GET ("/email" , apiwrap .Wrap (h .AdminGetEmailConfig ))
8793 adminGroup .PUT ("/email" , apiwrap .WrapWithBody (h .AdminUpdateEmailConfig ))
8894
95+ // 公告配置
96+ routerGroup .GET ("/notice" , apiwrap .Wrap (h .GetNoticeConfig ))
8997 adminGroup .GET ("/notice" , apiwrap .Wrap (h .AdminGetNoticeConfig ))
9098 adminGroup .PUT ("/notice" , apiwrap .WrapWithBody (h .AdminUpdateNoticeConfig ))
9199 adminGroup .PUT ("/notice/enabled" , apiwrap .WrapWithBody (h .AdminUpdateNoticeEnabled ))
@@ -137,7 +145,7 @@ func (h *WebsiteConfigHandler) toWebsiteConfigVO(webMasterCfg *domain.WebsiteCon
137145}
138146
139147func (h * WebsiteConfigHandler ) toNoticeConfigVO (noticeCfg * domain.NoticeConfig ) NoticeConfigVO {
140- return NoticeConfigVO {Title : noticeCfg .Title , Content : noticeCfg .Content , Enabled : noticeCfg . Enabled , PublishTime : noticeCfg .PublishTime .Unix ()}
148+ return NoticeConfigVO {Title : noticeCfg .Title , Content : noticeCfg .Content , PublishTime : noticeCfg .PublishTime .Unix ()}
141149}
142150
143151func (h * WebsiteConfigHandler ) toSocialInfoConfigVO (socialINfoConfig * domain.SocialInfoConfig ) SocialInfoConfigVO {
@@ -620,3 +628,42 @@ func (h *WebsiteConfigHandler) DeleteCarouselElem(ctx *gin.Context) (*apiwrap.Re
620628func (h * WebsiteConfigHandler ) AdminUpdateIntroduction4FriendConfig (ctx * gin.Context , req UpdateFriendIntroConfigReq ) (* apiwrap.ResponseBody [any ], error ) {
621629 return apiwrap .SuccessResponse (), h .serv .UpdateIntroduction4FriendConfig (ctx , gkit .GetValueOrDefault (req .Introduction ))
622630}
631+
632+ func (h * WebsiteConfigHandler ) GetWebsiteConfig (ctx * gin.Context ) (* apiwrap.ResponseBody [WebsiteConfigVO ], error ) {
633+ config , err := h .serv .GetWebSiteConfig (ctx )
634+ if err != nil {
635+ return nil , err
636+ }
637+ return apiwrap .SuccessResponseWithData (h .toWebsiteConfigVO (config )), nil
638+ }
639+
640+ func (h * WebsiteConfigHandler ) GetCommonConfig (ctx * gin.Context ) (* apiwrap.ResponseBody [CommonConfigVO ], error ) {
641+ config , err := h .serv .GetCommonConfig (ctx )
642+ if err != nil {
643+ return nil , err
644+ }
645+
646+ return apiwrap .SuccessResponseWithData (CommonConfigVO {
647+ WebsiteMeta : h .toMetaConfigVO (& config .WebSiteConfig ),
648+ SeoMeta : h .toSeoMetaConfigVO (& config .SeoMetaConfig ),
649+ TPSVVO : h .toTPSVVO (config .TPSVConfig ),
650+ Records : config .WebSiteConfig .WebsiteRecords ,
651+ }), nil
652+
653+ }
654+
655+ func (h * WebsiteConfigHandler ) toMetaConfigVO (wc * domain.WebsiteConfig ) WebsiteConfigMetaVO {
656+ return WebsiteConfigMetaVO {
657+ WebsiteName : wc .WebsiteName ,
658+ WebsiteIcon : wc .WebsiteIcon ,
659+ WebsiteOwner : wc .WebsiteOwner ,
660+ }
661+ }
662+
663+ func (h * WebsiteConfigHandler ) GetNoticeConfig (ctx * gin.Context ) (* apiwrap.ResponseBody [NoticeConfigVO ], error ) {
664+ config , err := h .serv .GetNoticeConfig (ctx )
665+ if err != nil {
666+ return nil , err
667+ }
668+ return apiwrap .SuccessResponseWithData (h .toNoticeConfigVO (& config )), nil
669+ }
0 commit comments