Skip to content

Commit 2aeb47c

Browse files
部分配置接口响应体字段优化
1 parent 1019820 commit 2aeb47c

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

server/internal/website_config/internal/web/vo.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package web
1717
// IndexConfigVO 首页信息
1818
type IndexConfigVO struct {
1919
WebsiteConfig WebsiteConfigVO `json:"website_config"`
20-
OwnerConfig OwnerConfigVO `json:"owner_config"`
2120
NoticeConfigVO NoticeConfigVO `json:"notice_config"`
2221
SocialInfoConfigVO SocialInfoConfigVO `json:"social_info_config"`
2322
PayInfoConfigVO []PayInfoConfigVO `json:"pay_info_config"`
@@ -26,9 +25,9 @@ type IndexConfigVO struct {
2625
}
2726

2827
type OwnerConfigVO struct {
29-
Name string `json:"name"`
30-
Profile string `json:"profile"`
31-
Picture string `json:"picture"`
28+
WebsiteOwner string `json:"website_owner"`
29+
WebsiteOwnerProfile string `json:"website_owner_profile"`
30+
WebsiteOwnerAvatar string `json:"website_owner_avatar"`
3231
}
3332

3433
type PayInfoConfigVO struct {
@@ -53,9 +52,12 @@ type WebsiteConfigVO struct {
5352
}
5453

5554
type WebsiteConfigMetaVO struct {
56-
WebsiteName string `json:"website_name"`
57-
WebsiteIcon string `json:"website_icon"`
58-
WebsiteOwner string `json:"website_owner"`
55+
WebsiteName string `json:"website_name"`
56+
WebsiteIcon string `json:"website_icon"`
57+
WebsiteOwner string `json:"website_owner"`
58+
WebsiteOwnerProfile string `json:"website_owner_profile"`
59+
WebsiteOwnerAvatar string `json:"website_owner_avatar"`
60+
WebsiteRuntime int64 `json:"website_runtime,omitempty"`
5961
}
6062

6163
type SocialInfoConfigVO struct {

server/internal/website_config/internal/web/website_config.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ func (h *WebsiteConfigHandler) RegisterGinRoutes(engine *gin.Engine) {
6969
adminGroup.GET("/check-initialization", apiwrap.Wrap(h.GetInitStatus))
7070
adminGroup.POST("/initialization", apiwrap.WrapWithBody(h.InitializeWebsite))
7171

72+
// 站长信息
73+
routerGroup.GET("/owner", apiwrap.Wrap(h.GetWebsiteOwnerConfig))
74+
7275
// website
73-
routerGroup.GET("/website", apiwrap.Wrap(h.GetWebsiteConfig))
7476
adminGroup.GET("/website", apiwrap.Wrap(h.AdminGetWebsiteConfig))
7577
adminGroup.GET("/website/meta", apiwrap.Wrap(h.AdminGetWebsiteConfig4Meta))
7678
adminGroup.PUT("/website", apiwrap.WrapWithBody(h.AdminUpdateWebsiteConfig))
@@ -144,6 +146,14 @@ func (h *WebsiteConfigHandler) toWebsiteConfigVO(webMasterCfg *domain.WebsiteCon
144146
}
145147
}
146148

149+
func (h *WebsiteConfigHandler) toWebsiteOwnerVO(webMasterCfg *domain.WebsiteConfig) OwnerConfigVO {
150+
return OwnerConfigVO{
151+
WebsiteOwner: webMasterCfg.WebsiteOwner,
152+
WebsiteOwnerProfile: webMasterCfg.WebsiteOwnerProfile,
153+
WebsiteOwnerAvatar: webMasterCfg.WebsiteOwnerAvatar,
154+
}
155+
}
156+
147157
func (h *WebsiteConfigHandler) toNoticeConfigVO(noticeCfg *domain.NoticeConfig) NoticeConfigVO {
148158
return NoticeConfigVO{Title: noticeCfg.Title, Content: noticeCfg.Content, PublishTime: noticeCfg.PublishTime.Unix()}
149159
}
@@ -629,12 +639,12 @@ func (h *WebsiteConfigHandler) AdminUpdateIntroduction4FriendConfig(ctx *gin.Con
629639
return apiwrap.SuccessResponse(), h.serv.UpdateIntroduction4FriendConfig(ctx, gkit.GetValueOrDefault(req.Introduction))
630640
}
631641

632-
func (h *WebsiteConfigHandler) GetWebsiteConfig(ctx *gin.Context) (*apiwrap.ResponseBody[WebsiteConfigVO], error) {
642+
func (h *WebsiteConfigHandler) GetWebsiteOwnerConfig(ctx *gin.Context) (*apiwrap.ResponseBody[OwnerConfigVO], error) {
633643
config, err := h.serv.GetWebSiteConfig(ctx)
634644
if err != nil {
635645
return nil, err
636646
}
637-
return apiwrap.SuccessResponseWithData(h.toWebsiteConfigVO(config)), nil
647+
return apiwrap.SuccessResponseWithData(h.toWebsiteOwnerVO(config)), nil
638648
}
639649

640650
func (h *WebsiteConfigHandler) GetCommonConfig(ctx *gin.Context) (*apiwrap.ResponseBody[CommonConfigVO], error) {
@@ -654,9 +664,12 @@ func (h *WebsiteConfigHandler) GetCommonConfig(ctx *gin.Context) (*apiwrap.Respo
654664

655665
func (h *WebsiteConfigHandler) toMetaConfigVO(wc *domain.WebsiteConfig) WebsiteConfigMetaVO {
656666
return WebsiteConfigMetaVO{
657-
WebsiteName: wc.WebsiteName,
658-
WebsiteIcon: wc.WebsiteIcon,
659-
WebsiteOwner: wc.WebsiteOwner,
667+
WebsiteName: wc.WebsiteName,
668+
WebsiteIcon: wc.WebsiteIcon,
669+
WebsiteOwner: wc.WebsiteOwner,
670+
WebsiteOwnerProfile: wc.WebsiteOwnerProfile,
671+
WebsiteOwnerAvatar: wc.WebsiteOwnerAvatar,
672+
WebsiteRuntime: wc.WebsiteRuntime.Unix(),
660673
}
661674
}
662675

0 commit comments

Comments
 (0)