This commit is contained in:
laodaming
2023-08-28 14:56:01 +08:00
parent 3698705975
commit f9de30a838
4 changed files with 29 additions and 11 deletions

View File

@@ -54,16 +54,23 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
//选了商家类型
if req.MerchantType > 0 {
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindOne(l.ctx, req.MerchantType)
} else {
//随机获取一个商家类型
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindRandOne(l.ctx)
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of merchant type found")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the merchant category is not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant category")
}
} else {
//获取默认的那个
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindDefualtOne(l.ctx)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the default merchant category is not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get default merchant category")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant type info")
}
if *merchantInfo.RecommendProduct == "" {
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})