A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix: if site info is empty return empty json
LinkinStard78d9e0415a2
diff --git a/internal/service/siteinfo/siteinfo_service.go b/internal/service/siteinfo/siteinfo_service.goindex aecb08c0..cfa0eed5 100644--- a/internal/service/siteinfo/siteinfo_service.go+++ b/internal/service/siteinfo/siteinfo_service.go@@ -35,57 +35,56 @@ func NewSiteInfoService(// GetSiteGeneral get site info generalfunc (s *SiteInfoService) GetSiteGeneral(ctx context.Context) (resp *schema.SiteGeneralResp, err error) {+ resp = &schema.SiteGeneralResp{}siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeGeneral)if err != nil {return nil, err}if !exist {- return nil, errors.BadRequest(reason.SiteInfoNotFound)+ return resp, nil}-- resp = &schema.SiteGeneralResp{}_ = json.Unmarshal([]byte(siteInfo.Content), resp)return resp, nil}// GetSiteInterface get site info interfacefunc (s *SiteInfoService) GetSiteInterface(ctx context.Context) (resp *schema.SiteInterfaceResp, err error) {+ resp = &schema.SiteInterfaceResp{}siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeInterface)if err != nil {return nil, err}if !exist {- return nil, errors.BadRequest(reason.SiteInfoNotFound)+ return resp, nil}- resp = &schema.SiteInterfaceResp{}_ = json.Unmarshal([]byte(siteInfo.Content), resp)return resp, nil}// GetSiteBranding get site info brandingfunc (s *SiteInfoService) GetSiteBranding(ctx context.Context) (resp *schema.SiteBrandingReq, err error) {+ resp = &schema.SiteBrandingReq{}siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeBranding)if err != nil {return nil, err}if !exist {- return nil, errors.BadRequest(reason.SiteInfoNotFound)+ return resp, nil}- resp = &schema.SiteBrandingReq{}_ = json.Unmarshal([]byte(siteInfo.Content), resp)return resp, nil}// GetSiteWrite get site info write-func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWriteResp, err error) {+func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWriteReq, err error) {+ resp = &schema.SiteWriteReq{}siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeWrite)if err != nil {return nil, err}if !exist {- return nil, errors.BadRequest(reason.SiteInfoNotFound)+ return resp, nil}- resp = &schema.SiteWriteResp{}_ = json.Unmarshal([]byte(siteInfo.Content), resp)resp.RecommendTags, err = s.tagCommonService.GetSiteWriteRecommendTag(ctx)@@ -101,14 +100,14 @@ func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWr// GetSiteLegal get site legal infofunc (s *SiteInfoService) GetSiteLegal(ctx context.Context) (resp *schema.SiteLegalResp, err error) {+ resp = &schema.SiteLegalResp{}siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeLegal)if err != nil {return nil, err}if !exist {- return nil, errors.BadRequest(reason.SiteInfoNotFound)+ return resp, nil}- resp = &schema.SiteLegalResp{}_ = json.Unmarshal([]byte(siteInfo.Content), resp)return resp, nil}