Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions server/internal/website_config/internal/web/vo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package web
// IndexConfigVO 首页信息
type IndexConfigVO struct {
WebsiteConfig WebsiteConfigVO `json:"website_config"`
OwnerConfig OwnerConfigVO `json:"owner_config"`
NoticeConfigVO NoticeConfigVO `json:"notice_config"`
SocialInfoConfigVO SocialInfoConfigVO `json:"social_info_config"`
PayInfoConfigVO []PayInfoConfigVO `json:"pay_info_config"`
Expand All @@ -26,9 +25,9 @@ type IndexConfigVO struct {
}

type OwnerConfigVO struct {
Name string `json:"name"`
Profile string `json:"profile"`
Picture string `json:"picture"`
WebsiteOwner string `json:"website_owner"`
WebsiteOwnerProfile string `json:"website_owner_profile"`
WebsiteOwnerAvatar string `json:"website_owner_avatar"`
}

type PayInfoConfigVO struct {
Expand All @@ -53,9 +52,12 @@ type WebsiteConfigVO struct {
}

type WebsiteConfigMetaVO struct {
WebsiteName string `json:"website_name"`
WebsiteIcon string `json:"website_icon"`
WebsiteOwner string `json:"website_owner"`
WebsiteName string `json:"website_name"`
WebsiteIcon string `json:"website_icon"`
WebsiteOwner string `json:"website_owner"`
WebsiteOwnerProfile string `json:"website_owner_profile"`
WebsiteOwnerAvatar string `json:"website_owner_avatar"`
WebsiteRuntime int64 `json:"website_runtime,omitempty"`
}

type SocialInfoConfigVO struct {
Expand Down
25 changes: 19 additions & 6 deletions server/internal/website_config/internal/web/website_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ func (h *WebsiteConfigHandler) RegisterGinRoutes(engine *gin.Engine) {
adminGroup.GET("/check-initialization", apiwrap.Wrap(h.GetInitStatus))
adminGroup.POST("/initialization", apiwrap.WrapWithBody(h.InitializeWebsite))

// 站长信息
routerGroup.GET("/owner", apiwrap.Wrap(h.GetWebsiteOwnerConfig))

// website
routerGroup.GET("/website", apiwrap.Wrap(h.GetWebsiteConfig))
adminGroup.GET("/website", apiwrap.Wrap(h.AdminGetWebsiteConfig))
adminGroup.GET("/website/meta", apiwrap.Wrap(h.AdminGetWebsiteConfig4Meta))
adminGroup.PUT("/website", apiwrap.WrapWithBody(h.AdminUpdateWebsiteConfig))
Expand Down Expand Up @@ -144,6 +146,14 @@ func (h *WebsiteConfigHandler) toWebsiteConfigVO(webMasterCfg *domain.WebsiteCon
}
}

func (h *WebsiteConfigHandler) toWebsiteOwnerVO(webMasterCfg *domain.WebsiteConfig) OwnerConfigVO {
return OwnerConfigVO{
WebsiteOwner: webMasterCfg.WebsiteOwner,
WebsiteOwnerProfile: webMasterCfg.WebsiteOwnerProfile,
WebsiteOwnerAvatar: webMasterCfg.WebsiteOwnerAvatar,
}
}

func (h *WebsiteConfigHandler) toNoticeConfigVO(noticeCfg *domain.NoticeConfig) NoticeConfigVO {
return NoticeConfigVO{Title: noticeCfg.Title, Content: noticeCfg.Content, PublishTime: noticeCfg.PublishTime.Unix()}
}
Expand Down Expand Up @@ -629,12 +639,12 @@ func (h *WebsiteConfigHandler) AdminUpdateIntroduction4FriendConfig(ctx *gin.Con
return apiwrap.SuccessResponse(), h.serv.UpdateIntroduction4FriendConfig(ctx, gkit.GetValueOrDefault(req.Introduction))
}

func (h *WebsiteConfigHandler) GetWebsiteConfig(ctx *gin.Context) (*apiwrap.ResponseBody[WebsiteConfigVO], error) {
func (h *WebsiteConfigHandler) GetWebsiteOwnerConfig(ctx *gin.Context) (*apiwrap.ResponseBody[OwnerConfigVO], error) {
config, err := h.serv.GetWebSiteConfig(ctx)
if err != nil {
return nil, err
}
return apiwrap.SuccessResponseWithData(h.toWebsiteConfigVO(config)), nil
return apiwrap.SuccessResponseWithData(h.toWebsiteOwnerVO(config)), nil
}

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

func (h *WebsiteConfigHandler) toMetaConfigVO(wc *domain.WebsiteConfig) WebsiteConfigMetaVO {
return WebsiteConfigMetaVO{
WebsiteName: wc.WebsiteName,
WebsiteIcon: wc.WebsiteIcon,
WebsiteOwner: wc.WebsiteOwner,
WebsiteName: wc.WebsiteName,
WebsiteIcon: wc.WebsiteIcon,
WebsiteOwner: wc.WebsiteOwner,
WebsiteOwnerProfile: wc.WebsiteOwnerProfile,
WebsiteOwnerAvatar: wc.WebsiteOwnerAvatar,
WebsiteRuntime: wc.WebsiteRuntime.Unix(),
}
}

Expand Down
Loading