mirror of https://gitee.com/answerdev/answer.git
fix: site info write set response empty array when site info not found
This commit is contained in:
parent
04a12ee832
commit
ed9702ab8b
|
@ -87,18 +87,17 @@ func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWr
|
|||
log.Error(err)
|
||||
return resp, nil
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
if exist {
|
||||
_ = json.Unmarshal([]byte(siteInfo.Content), resp)
|
||||
}
|
||||
_ = json.Unmarshal([]byte(siteInfo.Content), resp)
|
||||
|
||||
resp.RecommendTags, err = s.tagCommonService.GetSiteWriteRecommendTag(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(err)
|
||||
}
|
||||
resp.ReservedTags, err = s.tagCommonService.GetSiteWriteReservedTag(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(err)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -82,6 +82,9 @@ func (ts *TagCommonService) SearchTagLike(ctx context.Context, req *schema.Searc
|
|||
func (ts *TagCommonService) GetSiteWriteRecommendTag(ctx context.Context) (tags []string, err error) {
|
||||
tags = make([]string, 0)
|
||||
list, err := ts.tagCommonRepo.GetRecommendTagList(ctx)
|
||||
if err != nil {
|
||||
return tags, err
|
||||
}
|
||||
for _, item := range list {
|
||||
tags = append(tags, item.SlugName)
|
||||
}
|
||||
|
@ -124,6 +127,9 @@ func (ts *TagCommonService) SetSiteWriteTag(ctx context.Context, recommendTags,
|
|||
func (ts *TagCommonService) GetSiteWriteReservedTag(ctx context.Context) (tags []string, err error) {
|
||||
tags = make([]string, 0)
|
||||
list, err := ts.tagCommonRepo.GetReservedTagList(ctx)
|
||||
if err != nil {
|
||||
return tags, err
|
||||
}
|
||||
for _, item := range list {
|
||||
tags = append(tags, item.SlugName)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue