mirror of https://gitee.com/answerdev/answer.git
fix: set default version is 0.0.0, return site info is empty when site info can't found. fix dashboard return error when cache not found.
This commit is contained in:
parent
8e8cbf6621
commit
3a713fb0c1
|
@ -20,7 +20,7 @@ var (
|
|||
// Name is the name of the project
|
||||
Name = "answer"
|
||||
// Version is the version of the project
|
||||
Version = "development"
|
||||
Version = "0.0.0"
|
||||
// Revision is the git short commit revision number
|
||||
Revision = ""
|
||||
// Time is the build time of the project
|
||||
|
|
|
@ -76,17 +76,16 @@ func (ds *DashboardService) StatisticalByCache(ctx context.Context) (*schema.Das
|
|||
if err != nil {
|
||||
info, statisticalErr := ds.Statistical(ctx)
|
||||
if statisticalErr != nil {
|
||||
return dashboardInfo, err
|
||||
return nil, statisticalErr
|
||||
}
|
||||
setCacheErr := ds.SetCache(ctx, info)
|
||||
if setCacheErr != nil {
|
||||
log.Error("ds.SetCache", setCacheErr)
|
||||
if setCacheErr := ds.SetCache(ctx, info); setCacheErr != nil {
|
||||
log.Errorf("set dashboard statistical failed: %s", setCacheErr)
|
||||
}
|
||||
return info, err
|
||||
return info, nil
|
||||
}
|
||||
err = json.Unmarshal([]byte(infoStr), dashboardInfo)
|
||||
if err != nil {
|
||||
return dashboardInfo, err
|
||||
if err = json.Unmarshal([]byte(infoStr), dashboardInfo); err != nil {
|
||||
log.Errorf("parsing dashboard information failed: %s", err)
|
||||
return nil, errors.InternalServer(reason.UnknownError)
|
||||
}
|
||||
startTime := time.Now().Unix() - schema.AppStartTime.Unix()
|
||||
dashboardInfo.AppStartTime = fmt.Sprintf("%d", startTime)
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
)
|
||||
|
||||
type SiteInfoService struct {
|
||||
|
@ -38,7 +39,8 @@ func (s *SiteInfoService) GetSiteGeneral(ctx context.Context) (resp *schema.Site
|
|||
resp = &schema.SiteGeneralResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeGeneral)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(err)
|
||||
return resp, nil
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
@ -52,7 +54,8 @@ func (s *SiteInfoService) GetSiteInterface(ctx context.Context) (resp *schema.Si
|
|||
resp = &schema.SiteInterfaceResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeInterface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(err)
|
||||
return resp, nil
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
@ -66,7 +69,8 @@ func (s *SiteInfoService) GetSiteBranding(ctx context.Context) (resp *schema.Sit
|
|||
resp = &schema.SiteBrandingReq{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeBranding)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(err)
|
||||
return resp, nil
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
@ -76,11 +80,12 @@ func (s *SiteInfoService) GetSiteBranding(ctx context.Context) (resp *schema.Sit
|
|||
}
|
||||
|
||||
// GetSiteWrite get site info write
|
||||
func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWriteReq, err error) {
|
||||
resp = &schema.SiteWriteReq{}
|
||||
func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWriteResp, err error) {
|
||||
resp = &schema.SiteWriteResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeWrite)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(err)
|
||||
return resp, nil
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
|
|
@ -23,7 +23,7 @@ func (s *SiteInfoCommonService) GetSiteGeneral(ctx context.Context) (resp *schem
|
|||
resp = &schema.SiteGeneralResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeGeneral)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return resp, err
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
@ -37,7 +37,7 @@ func (s *SiteInfoCommonService) GetSiteInterface(ctx context.Context) (resp *sch
|
|||
resp = &schema.SiteInterfaceResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeInterface)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return resp, err
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
@ -51,7 +51,7 @@ func (s *SiteInfoCommonService) GetSiteBranding(ctx context.Context) (resp *sche
|
|||
resp = &schema.SiteBrandingResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeBranding)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return resp, err
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
@ -65,7 +65,7 @@ func (s *SiteInfoCommonService) GetSiteWrite(ctx context.Context) (resp *schema.
|
|||
resp = &schema.SiteWriteResp{}
|
||||
siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeWrite)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return resp, err
|
||||
}
|
||||
if !exist {
|
||||
return resp, nil
|
||||
|
|
Loading…
Reference in New Issue