From fe5ec165f2b8915ba9e6673d41ba37ca32a32237 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 10:15:15 +0800 Subject: [PATCH 01/21] logo search --- model/gmodel/fs_preprocess_logo_logic.go | 89 +++++++++++++++--------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/model/gmodel/fs_preprocess_logo_logic.go b/model/gmodel/fs_preprocess_logo_logic.go index 20fe9048..173c292c 100644 --- a/model/gmodel/fs_preprocess_logo_logic.go +++ b/model/gmodel/fs_preprocess_logo_logic.go @@ -27,24 +27,34 @@ type PreLogoSearchResult struct { // 搜索 func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode string, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) { - keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) - for i, v := range keywords { - keywords[i] = "+" + v + "*" - } - sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) and zip_code = ? limit %d;", count) - - tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " "), zipcode) - err = tx.Scan(&resp).Error - if err != nil { - logx.Error(err) - return nil, err - } - - for i := range resp { - if resp[i].RestaurantType == nil { - resp[i].RestaurantType = FsString("") + keywordsList := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) + var keywords []string + for _, v := range keywordsList { + if len(v) > 1 { + keywords = append(keywords, "+"+v+"*") + } + } + + if len(keywords) != 0 { + + sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) and zip_code = ? limit %d;", count) + + tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " "), zipcode) + err = tx.Scan(&resp).Error + if err != nil { + logx.Error(err) + return nil, err + } + + for i := range resp { + if resp[i].RestaurantType == nil { + resp[i].RestaurantType = FsString("") + } + + if len(*resp[i].ResourceUrl) < 10 { + resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))]) + } } - resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))]) } if resp == nil { @@ -56,24 +66,35 @@ func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode strin // 搜索建议 func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) { - keywords := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) - for i, v := range keywords { - keywords[i] = "+" + v + "*" - } - sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) limit %d;", count) - - tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " ")) - err = tx.Scan(&resp).Error - if err != nil { - logx.Error(err) - return nil, err - } - - for i := range resp { - if resp[i].RestaurantType == nil { - resp[i].RestaurantType = FsString("") + keywordsList := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) + var keywords []string + for _, v := range keywordsList { + if len(v) > 1 { + keywords = append(keywords, "+"+v+"*") } - resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))]) + } + + if len(keywords) != 0 { + sqlstr := fmt.Sprintf("SELECT id,restaurant_name,resource_url,address,zip_code,phone,website,is_branch FROM fs_preprocess_logo WHERE MATCH(restaurant_name) AGAINST(? IN BOOLEAN MODE) limit %d;", count) + + tx := p.db.WithContext(ctx).Model(&FsPreprocessLogo{}).Raw(sqlstr, strings.Join(keywords, " ")) + err = tx.Scan(&resp).Error + if err != nil { + logx.Error(err) + return nil, err + } + + for i := range resp { + if resp[i].RestaurantType == nil { + resp[i].RestaurantType = FsString("") + } + + if len(*resp[i].ResourceUrl) < 10 { + resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))]) + } + + } + } if resp == nil { From 5bf706e52892ecedfc0043a9dc73c17f4648a130 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 10:23:21 +0800 Subject: [PATCH 02/21] logo search --- model/gmodel/fs_preprocess_logo_logic.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/model/gmodel/fs_preprocess_logo_logic.go b/model/gmodel/fs_preprocess_logo_logic.go index 173c292c..85bbab9f 100644 --- a/model/gmodel/fs_preprocess_logo_logic.go +++ b/model/gmodel/fs_preprocess_logo_logic.go @@ -27,7 +27,7 @@ type PreLogoSearchResult struct { // 搜索 func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode string, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) { - keywordsList := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) + keywordsList := SplitSearchKeywords(keywordsStr) var keywords []string for _, v := range keywordsList { if len(v) > 1 { @@ -64,9 +64,14 @@ func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode strin return resp, nil } +func SplitSearchKeywords(keywordsStr string) []string { + return regexp.MustCompile(`\s+|\++`).Split(keywordsStr, -1) +} + // 搜索建议 func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, keywordsStr string, count int) (resp []PreLogoSearchResult, err error) { - keywordsList := regexp.MustCompile(`\s+`).Split(keywordsStr, -1) + // keywordsList := regexp.MustCompile(`\s+|\++`).Split(keywordsStr, -1) + keywordsList := SplitSearchKeywords(keywordsStr) var keywords []string for _, v := range keywordsList { if len(v) > 1 { From 12c9732fa82caf4aa375a5db47e3f59824fda752 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 12:30:37 +0800 Subject: [PATCH 03/21] fix --- model/gmodel/fs_user_info_logic.go | 31 ++++++++++++++++++- .../internal/logic/getproductdetaillogic.go | 17 ++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/model/gmodel/fs_user_info_logic.go b/model/gmodel/fs_user_info_logic.go index ce76d7cb..31101b78 100644 --- a/model/gmodel/fs_user_info_logic.go +++ b/model/gmodel/fs_user_info_logic.go @@ -62,7 +62,7 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in } rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where user_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname) - err := m.db.Raw(rawsql, userId).Take(&baseinfo).Error + err := m.db.WithContext(ctx).Raw(rawsql, userId).Take(&baseinfo).Error if err != nil { return nil, err } @@ -87,3 +87,32 @@ func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int } return resp, err } +func (m *FsUserInfoModel) GetProfileByUserIdGuestId(ctx context.Context, pkey string, userId, guestId int64) (map[string]any, error) { + + var baseinfo map[string]any + tname := fssql.GetGormTableName(m.db, FsUserInfo{}) + + if pkey == "." { + pkey = "" + } else { + pkey = "." + pkey + } + + rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where user_id = ? and guest_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname) + err := m.db.WithContext(ctx).Raw(rawsql, userId, guestId).Take(&baseinfo).Error + if err != nil { + return nil, err + } + + v, ok := baseinfo["query"].(string) + if !ok { + return nil, nil + } + + var info map[string]any + err = json.Unmarshal([]byte(v), &info) + if err != nil { + return nil, err + } + return info, nil +} diff --git a/server/product/internal/logic/getproductdetaillogic.go b/server/product/internal/logic/getproductdetaillogic.go index 79262e10..1b9f8ee9 100644 --- a/server/product/internal/logic/getproductdetaillogic.go +++ b/server/product/internal/logic/getproductdetaillogic.go @@ -12,6 +12,7 @@ import ( "fusenapi/utils/s3url_to_s3id" "fusenapi/utils/template_switch_info" "gorm.io/gorm" + "reflect" "strings" "context" @@ -343,6 +344,22 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR if req.SelectedColorIndex < 0 { return types.TemplateTagColorInfo{}, errors.New("param selected_color_index is invalid") } + if req.Logo == "" { + //颜色选择置0 + req.SelectedColorIndex = 0 + //获取默认profile从中获取logo + profile, err := l.svcCtx.AllModels.FsUserInfo.GetProfileByUserIdGuestId(l.ctx, "logo_selected.logo_url", 0, 0) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return types.TemplateTagColorInfo{}, errors.New("the default profile info is not exists") + } + logx.Error(err) + return types.TemplateTagColorInfo{}, errors.New("failed to get default profile info for without logo") + } + if profile["logo_url"] != nil && reflect.TypeOf(profile["logo_url"]).String() == "string" { + req.Logo = profile["logo_url"].(string) + } + } //根据logo查询素材资源 resourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo) if resourceId == "" { From 6901177f05416b8711efd3de3df98adf4ea9b669 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 13:06:19 +0800 Subject: [PATCH 04/21] fix --- server/product/internal/logic/getproductdetaillogic.go | 3 +++ server/product/internal/types/types.go | 1 + server_api/product.api | 1 + 3 files changed, 5 insertions(+) diff --git a/server/product/internal/logic/getproductdetaillogic.go b/server/product/internal/logic/getproductdetaillogic.go index 1b9f8ee9..0ac63b8d 100644 --- a/server/product/internal/logic/getproductdetaillogic.go +++ b/server/product/internal/logic/getproductdetaillogic.go @@ -245,6 +245,7 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetProductDetailRsp{ + Logo: req.Logo, TemplateTagColorInfo: templateTagColorInfo, ProductInfo: types.ProductInfo{ Id: productInfo.Id, @@ -358,6 +359,8 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR } if profile["logo_url"] != nil && reflect.TypeOf(profile["logo_url"]).String() == "string" { req.Logo = profile["logo_url"].(string) + } else { + return types.TemplateTagColorInfo{}, errors.New("default profile logo url is not set !!") } } //根据logo查询素材资源 diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index a7df34c5..90a91ea4 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -175,6 +175,7 @@ type GetProductDetailReq struct { } type GetProductDetailRsp struct { + Logo string `json:"logo"` //logo TemplateTagColorInfo TemplateTagColorInfo `json:"template_tag_color_info"` //标签颜色信息 ProductInfo ProductInfo `json:"product_info"` //产品基本信息 BaseColors interface{} `json:"base_colors"` //一些返回写死的颜色 diff --git a/server_api/product.api b/server_api/product.api index 450d4b3c..165e3297 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -210,6 +210,7 @@ type GetProductDetailReq { Logo string `form:"logo"` //logo地址 } type GetProductDetailRsp { + Logo string `json:"logo"` //logo TemplateTagColorInfo TemplateTagColorInfo `json:"template_tag_color_info"` //标签颜色信息 ProductInfo ProductInfo `json:"product_info"` //产品基本信息 BaseColors interface{} `json:"base_colors"` //一些返回写死的颜色 From fb89b488d22d39a3522bc231423df2e2e6eb3c55 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 13:11:47 +0800 Subject: [PATCH 05/21] fix --- server_api/product.api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_api/product.api b/server_api/product.api index 165e3297..f3ce9606 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -207,7 +207,7 @@ type GetProductDetailReq { ProductId int64 `form:"product_id"` //产品id TemplateTag string `form:"template_tag"` //模板标签 SelectedColorIndex int `form:"selected_color_index"` //模板标签颜色索引 - Logo string `form:"logo"` //logo地址 + Logo string `form:"logo,optional"` //logo地址 } type GetProductDetailRsp { Logo string `json:"logo"` //logo From 90275a865c3b664112a2848c4885daa13d03f7dc Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 13:12:00 +0800 Subject: [PATCH 06/21] fix --- server/product/internal/types/types.go | 2 +- server_api/product.api | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 90a91ea4..ff998d33 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -171,7 +171,7 @@ type GetProductDetailReq struct { ProductId int64 `form:"product_id"` //产品id TemplateTag string `form:"template_tag"` //模板标签 SelectedColorIndex int `form:"selected_color_index"` //模板标签颜色索引 - Logo string `form:"logo"` //logo地址 + Logo string `form:"logo,optional"` //logo地址 } type GetProductDetailRsp struct { diff --git a/server_api/product.api b/server_api/product.api index f3ce9606..899f8b21 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -207,7 +207,7 @@ type GetProductDetailReq { ProductId int64 `form:"product_id"` //产品id TemplateTag string `form:"template_tag"` //模板标签 SelectedColorIndex int `form:"selected_color_index"` //模板标签颜色索引 - Logo string `form:"logo,optional"` //logo地址 + Logo string `form:"logo,optional"` //logo地址 } type GetProductDetailRsp { Logo string `json:"logo"` //logo From 16fc420030b9804ba9c5a499b10f813c11246694 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 13:14:07 +0800 Subject: [PATCH 07/21] fix --- server/product/internal/logic/getproductdetaillogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/getproductdetaillogic.go b/server/product/internal/logic/getproductdetaillogic.go index 0ac63b8d..5dd14418 100644 --- a/server/product/internal/logic/getproductdetaillogic.go +++ b/server/product/internal/logic/getproductdetaillogic.go @@ -349,7 +349,7 @@ func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailR //颜色选择置0 req.SelectedColorIndex = 0 //获取默认profile从中获取logo - profile, err := l.svcCtx.AllModels.FsUserInfo.GetProfileByUserIdGuestId(l.ctx, "logo_selected.logo_url", 0, 0) + profile, err := l.svcCtx.AllModels.FsUserInfo.GetProfileByUserIdGuestId(l.ctx, "logo_selected", 0, 0) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return types.TemplateTagColorInfo{}, errors.New("the default profile info is not exists") From afc6088f70cf49675b8b0da78da051da9b1fedf1 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:09:12 +0800 Subject: [PATCH 08/21] fix --- server/product/internal/logic/gettagproductlistlogic.go | 9 ++++++--- server/product/internal/types/types.go | 5 +++-- server_api/product.api | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 1dc76dd1..fe68de25 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -129,10 +129,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data") } //组装等级从属关系 - rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct) + rspTagList, mapTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct) return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{ TotalCategoryProduct: TotalCategoryProduct, TagList: rspTagList, + TagMap: mapTagList, }) } @@ -320,8 +321,9 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) } // 组织等级从属关系 -func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, productCount int) { +func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, mapTagList map[int64]types.TagItem, productCount int) { mapTop := make(map[string]struct{}) + mapTagList = make(map[int64]types.TagItem) //设置归属关系 for prefix, tagItem := range mapTagLevel { prefixSlice := strings.Split(prefix, "/") @@ -377,12 +379,13 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL } productCount += len(mapTagLevel[prefix].TagProductList) rspList = append(rspList, *mapTagLevel[prefix]) + mapTagList[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix] } //排序 sort.SliceStable(rspList, func(i, j int) bool { return rspList[i].Sort < rspList[j].Sort }) - return rspList, productCount + return rspList, mapTagList, productCount } // 获取某个tag的直属产品 diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index ff998d33..fa2a8e91 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -35,8 +35,9 @@ type GetTagProductListReq struct { } type GetTagProductListRsp struct { - TotalCategoryProduct int `json:"total_category_product"` - TagList []TagItem `json:"tag_list"` + TotalCategoryProduct int `json:"total_category_product"` + TagList []TagItem `json:"tag_list"` + TagMap interface{} `json:"tag_map"` } type TagItem struct { diff --git a/server_api/product.api b/server_api/product.api index 899f8b21..9b61723b 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -77,8 +77,9 @@ type GetTagProductListReq { WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品 } type GetTagProductListRsp { - TotalCategoryProduct int `json:"total_category_product"` - TagList []TagItem `json:"tag_list"` + TotalCategoryProduct int `json:"total_category_product"` + TagList []TagItem `json:"tag_list"` + TagMap interface{} `json:"tag_map"` } type TagItem { TypeName string `json:"type_name"` From 91f6970eb04798e8735bf43ce7a4f3649ffeaa5f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:13:18 +0800 Subject: [PATCH 09/21] fix --- .../product/internal/logic/gettagproductlistlogic.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index fe68de25..0d7659ba 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -129,11 +129,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data") } //组装等级从属关系 - rspTagList, mapTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct) + rspTagList, mapTagRsp, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct) return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{ TotalCategoryProduct: TotalCategoryProduct, TagList: rspTagList, - TagMap: mapTagList, + TagMap: mapTagRsp, }) } @@ -321,9 +321,9 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) } // 组织等级从属关系 -func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, mapTagList map[int64]types.TagItem, productCount int) { +func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, mapTagRsp map[int64]types.TagItem, productCount int) { mapTop := make(map[string]struct{}) - mapTagList = make(map[int64]types.TagItem) + mapTagRsp = make(map[int64]types.TagItem) //设置归属关系 for prefix, tagItem := range mapTagLevel { prefixSlice := strings.Split(prefix, "/") @@ -379,13 +379,13 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL } productCount += len(mapTagLevel[prefix].TagProductList) rspList = append(rspList, *mapTagLevel[prefix]) - mapTagList[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix] + mapTagRsp[mapTagLevel[prefix].TypeId] = *mapTagLevel[prefix] } //排序 sort.SliceStable(rspList, func(i, j int) bool { return rspList[i].Sort < rspList[j].Sort }) - return rspList, mapTagList, productCount + return rspList, mapTagRsp, productCount } // 获取某个tag的直属产品 From 8dc98d4aca266d1442ed1695ef1d4dde6fbfabee Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:27:47 +0800 Subject: [PATCH 10/21] fix --- server/collection/internal/handler/routes.go | 7 +- .../internal/handler/testaihandler.go | 2 +- .../internal/handler/testpdfhandler.go | 35 -------- .../collection/internal/logic/testailogic.go | 80 ++++--------------- .../collection/internal/logic/testpdflogic.go | 50 ------------ server/collection/internal/types/types.go | 7 +- server_api/collection.api | 12 +-- 7 files changed, 20 insertions(+), 173 deletions(-) delete mode 100644 server/collection/internal/handler/testpdfhandler.go delete mode 100644 server/collection/internal/logic/testpdflogic.go diff --git a/server/collection/internal/handler/routes.go b/server/collection/internal/handler/routes.go index ca29fb08..7c9fa49f 100644 --- a/server/collection/internal/handler/routes.go +++ b/server/collection/internal/handler/routes.go @@ -28,15 +28,10 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Handler: GetCollectProductListHandler(serverCtx), }, { - Method: http.MethodGet, + Method: http.MethodPost, Path: "/api/collection/test_ai", Handler: TestAiHandler(serverCtx), }, - { - Method: http.MethodPost, - Path: "/api/collection/test_pdf", - Handler: TestPdfHandler(serverCtx), - }, }, ) } diff --git a/server/collection/internal/handler/testaihandler.go b/server/collection/internal/handler/testaihandler.go index 7682a6a8..1be6a44d 100644 --- a/server/collection/internal/handler/testaihandler.go +++ b/server/collection/internal/handler/testaihandler.go @@ -26,7 +26,7 @@ func TestAiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { rl := reflect.ValueOf(l) basic.BeforeLogic(w, r, rl) - resp := l.TestAi(&req, userinfo) + resp := l.TestAi(&req, userinfo, w) if !basic.AfterLogic(w, r, rl, resp) { basic.NormalAfterLogic(w, r, resp) diff --git a/server/collection/internal/handler/testpdfhandler.go b/server/collection/internal/handler/testpdfhandler.go deleted file mode 100644 index 6a40187c..00000000 --- a/server/collection/internal/handler/testpdfhandler.go +++ /dev/null @@ -1,35 +0,0 @@ -package handler - -import ( - "net/http" - "reflect" - - "fusenapi/utils/basic" - - "fusenapi/server/collection/internal/logic" - "fusenapi/server/collection/internal/svc" - "fusenapi/server/collection/internal/types" -) - -func TestPdfHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - - var req types.TestPdfReq - userinfo, err := basic.RequestParse(w, r, svcCtx, &req) - if err != nil { - return - } - - // 创建一个业务逻辑层实例 - l := logic.NewTestPdfLogic(r.Context(), svcCtx) - - rl := reflect.ValueOf(l) - basic.BeforeLogic(w, r, rl) - - resp := l.TestPdf(&req, userinfo) - - if !basic.AfterLogic(w, r, rl, resp) { - basic.NormalAfterLogic(w, r, resp) - } - } -} diff --git a/server/collection/internal/logic/testailogic.go b/server/collection/internal/logic/testailogic.go index 03436497..75bf2a41 100644 --- a/server/collection/internal/logic/testailogic.go +++ b/server/collection/internal/logic/testailogic.go @@ -1,15 +1,12 @@ package logic import ( - "encoding/json" - "fmt" "fusenapi/constants" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/curl" - "github.com/google/uuid" - "strings" - "sync" + "math/rand" + "net/http" "time" "context" @@ -34,71 +31,24 @@ func NewTestAiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestAiLogi } } -// 处理进入前逻辑w,r -// func (l *TestAiLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { -// } -var data = `{"module_data":{"groupOptions":{"fill_1":{"list":[{"id":"442c4e24-53ae-2a76-8e6b-7550e2747369","tag":""},{"id":"646004b2-ad82-761f-c939-b85f96f97f9a","tag":""},{"id":"b6e4ab68-b36a-9534-d53f-722c93d54657","tag":""},{"id":"280ced37-6725-562f-4272-79bacfcadb12","tag":""},{"id":"a6aac5c1-8e54-c0f1-5749-9847f0fe497e","tag":""},{"id":"2b2eac02-37ae-0b1e-898e-d9e3166dfc9a","tag":""},{"id":"88181235-0317-fe9e-b202-cc7938acd449","tag":""},{"id":"93aba661-9260-8420-4adc-feef1657f4e3","tag":""},{"id":"50dec384-7501-dfdd-9c65-ddf3142540af","tag":""},{"id":"d8337893-bfab-0e43-2ef2-2606d1612fec","tag":""},{"id":"508859ae-cc8f-0b19-3554-c7632838d3fc","tag":""},{"id":"d5d3a1cb-2b13-2345-088d-b9163edf8aa6","tag":"","type":"color"}],"tag":"","title":"主色","value":"#E71F18"},"fill_2":{"list":[],"tag":"","title":"副色","value":"#000"},"fill_3":{"list":[],"tag":"","title":"备选色","value":"#000"},"fill_4":{"list":[{"id":"dbc50336-de0c-4b4a-f0aa-1a6444a3f615","tag":"","type":"color"},{"id":"cd0bf3b0-761f-e5b4-d7b6-f63fc54baa77","tag":"","type":"color"}],"tag":"","title":"固定色A","value":"#FFFFFF"},"material_1":{"id":"material_1","list":[{"id":"9baa3b65-c4f0-ebd8-866f-7e8d8e26e462","tag":"Logo"},{"id":"d9634ebf-78e2-3ead-30c5-cd545c3bfdaa","tag":"Logo"}],"tag":"Logo","title":"LOGO分组","value":""},"text_1":{"id":"text_1","list":[],"tag":"Slogan","title":"Slogan分组","value":"The ultimate experience"},"text_2":{"id":"text_2","list":[],"tag":"QRcode","title":"二维码分组","value":"www.fusen.cn"}},"id":1108,"material":"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a0914c5b48319ebeed923ae780a5f1a00736056e0b5406a60095cfd4010b31d8","materialList":[{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":1024,"id":"cf7caf81-1470-613a-7691-9c5eac710a0e","ifGroupNoBr":false,"lineHeight":1,"material":"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/c83b49a900c3bffff4fbf0d5b8e7d494033b3b793b660ccd1bf98b2558573adb","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"","text":"","title":"底图","type":"background","verticalAlign":"middle","visible":true,"width":1024,"x":0,"y":0,"zIndex":0},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"0991b333-4baf-8fcc-a8bb-aa5546811815","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"","text":"","title":"SVG元素","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":1},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":["b3ce7508-232a-89aa-72fd-dbbacc32f938","37ffcea7-0134-e6ee-014a-f0dddc466cf0","869c16d3-4b82-b052-6def-9162e126c57a"],"height":100,"id":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"","text":"","title":"合图组","type":"combine","verticalAlign":"middle","visible":false,"width":100,"x":0,"y":0,"zIndex":2},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","group":[],"height":100,"id":"b3ce7508-232a-89aa-72fd-dbbacc32f938","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":false,"tag":"Website","text":"www.fusen.cn","title":"网址","type":"text","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":3},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","group":[],"height":100,"id":"37ffcea7-0134-e6ee-014a-f0dddc466cf0","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":false,"tag":"Address","text":"S Halsted St, Chicago, IL 60608 U.S.","title":"地址","type":"text","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":4},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","group":[],"height":100,"id":"869c16d3-4b82-b052-6def-9162e126c57a","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":false,"tag":"Phone","text":"070-6666666","title":"电话","type":"text","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":5},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_4","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"cd0bf3b0-761f-e5b4-d7b6-f63fc54baa77","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M511.2,513.5H24.7V378.9h486.6V513.5z","systemShow":true,"tag":"","text":"","title":"SVG元素_11","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":6},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_4","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"dbc50336-de0c-4b4a-f0aa-1a6444a3f615","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M508.8,593.6l0,138.8l-51-11.2H78l-51,11.2l0-138.8l3.2-1.1v-16.9h475.4l0,16.9L508.8,593.6z","systemShow":true,"tag":"","text":"","title":"SVG元素_12","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":7},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"d5d3a1cb-2b13-2345-088d-b9163edf8aa6","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M508.3,512.2v12.3h-0.5l-2.2,3c0.1,12.4,0.2,24.8,0.3,37.2c-1.2,0.8-2.4,1.6-3.6,2.3c0.1,8.5,0.2,17.1,0.3,25.6c-15.3-5.5-30.7-11-46-16.5c-18.6-0.2-37.2-0.3-55.8-0.5c0-1.5,0-2.9,0.1-4.4c-17.2,0.1-34.4,0.2-51.6,0.2c0,1.3,0,2.7,0,4c-55.4,0.1-110.8,0.1-166.2,0.2c-0.1-1.5-0.1-3-0.2-4.5c-16.5,0.1-33.1,0.1-49.6,0.2c-0.1,1.4-0.1,2.8-0.2,4.2c-18.4,0.2-36.8,0.3-55.2,0.5v-51.8h0v51.8h0v0.4l-45.9,15.7c0.1-8.2,0.1-16.4,0.2-24.6c-1.6-0.9-3.3-1.8-4.9-2.7l-0.2-37.4l-2.2-2.9h-0.3v-12.3H508.3z","systemShow":true,"tag":"","text":"","title":"SVG元素_13","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":8},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"442c4e24-53ae-2a76-8e6b-7550e2747369","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M78,714.4h379.7V942H78V714.4z","systemShow":true,"tag":"","text":"","title":"SVG元素_14","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":9},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"646004b2-ad82-761f-c939-b85f96f97f9a","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M440.6,145.7h70.6V379l-70.6,0V145.7z","systemShow":true,"tag":"","text":"","title":"SVG元素_15","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":10},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"b6e4ab68-b36a-9534-d53f-722c93d54657","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M83.3,85.2c-0.2-21.2-0.4-42.4-0.7-63.7c17.6-0.2,35.1-0.3,52.7-0.5c0.2-2.1,0.4-4.1,0.7-6.2c15.3-0.1,30.6-0.1,45.8-0.2c0.6,2.2,1.1,4.4,1.7,6.7c55.4-0.2,110.9-0.4,166.3-0.7c0.6-1.9,1.1-3.8,1.7-5.7c15.1-0.1,30.1-0.1,45.2-0.2c0.6,2.1,1.2,4.1,1.8,6.2c17.4,0.1,34.8,0.2,52.2,0.3c-0.1,20.9-0.1,41.8-0.2,62.7c-57.4,0.4-114.8,0.7-172.2,1.1c0.2-1.2,0.6-5-1.7-8.8c-0.6-0.9-3.8-5.8-9.1-5.8c-5,0.1-8.4,4.5-9.7,7.7c-1.1,2.9-0.9,5.5-0.6,6.9C199.3,85.1,141.3,85.2,83.3,85.2z","systemShow":true,"tag":"","text":"","title":"SVG元素_16","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":11},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"280ced37-6725-562f-4272-79bacfcadb12","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M83.3,145.8c0-20.4-0.1-40.8-0.1-61.2c58,0.2,116,0.4,174.1,0.6c0.1,1.2,0.5,4.6,3.1,7.6c0.9,1.1,3.4,3.9,7.3,4c4.2,0.1,6.9-2.8,7.6-3.6c2.9-3.2,3-6.9,3-7.9c57.4-0.4,114.8-0.7,172.2-1.1c0,20.6,0,41.3-0.1,61.9C328,145.9,205.7,145.8,83.3,145.8z","systemShow":true,"tag":"","text":"","title":"SVG元素_17","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":12},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"a6aac5c1-8e54-c0f1-5749-9847f0fe497e","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M452.4,942l-17.3,59.9H100.4L82,942c57.6,0,115.2-0.1,172.8-0.1c-0.1,0.6-1.3,6.2,2.7,10.7c0.5,0.6,3.7,4,8.7,3.8c4.1-0.1,7.2-2.5,8.8-4.8c2.8-3.9,2-8.5,2.2-9.7C278.1,935.1,325.5,933.6,452.4,942z","systemShow":true,"tag":"","text":"","title":"SVG元素_18","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":13},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"2b2eac02-37ae-0b1e-898e-d9e3166dfc9a","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M78,379c0.1-78,0.3-155.9,0.4-233.9c20.8,0.2,41.7,0.4,62.5,0.6v2.9h37.4v-2.9h177.5v2.9h37.4v-2.9c21.5,0,43,0,64.5,0c0.9,77.8,1.9,155.5,2.8,233.3C333.1,379,205.6,379,78,379z","systemShow":true,"tag":"","text":"","title":"SVG元素_19","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":14},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"88181235-0317-fe9e-b202-cc7938acd449","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M451.6,145.6c0.1-21,0.1-41.9,0.2-62.9c3.7-19.3,7.4-38.6,11.2-57.9c14.5,0,29,0.1,43.4,0.1c0,40.2,0,80.4,0,120.6C488.2,145.5,469.9,145.5,451.6,145.6z","systemShow":true,"tag":"","text":"","title":"SVG元素_20","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":15},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"93aba661-9260-8420-4adc-feef1657f4e3","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M79,379l-54.4,0V145.7H79V379z","systemShow":true,"tag":"","text":"","title":"SVG元素_21","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":16},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"50dec384-7501-dfdd-9c65-ddf3142540af","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M26.2,145.6c0-39.9,0-79.8,0-119.7c15,0,30-0.1,45-0.1c3.7,19.5,7.4,39,11.2,58.5c-0.1,20.5-0.2,40.9-0.4,61.4C63.4,145.7,44.8,145.7,26.2,145.6z","systemShow":true,"tag":"","text":"","title":"SVG元素_22","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":17},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"d8337893-bfab-0e43-2ef2-2606d1612fec","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M450.3,714.4l58.5,10.7c0.2,66.5,0.3,133,0.5,199.5c-19.7,6.3-39.3,12.7-59,19V714.4z","systemShow":true,"tag":"","text":"","title":"SVG元素_23","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":18},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"508859ae-cc8f-0b19-3554-c7632838d3fc","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M82.4,943.8c-18.4-6.1-36.7-12.3-55.1-18.4C27.2,858.5,27.1,791.8,27,725l57.3-10.6C83.7,790.8,83.1,867.3,82.4,943.8z","systemShow":true,"tag":"","text":"","title":"SVG元素_24","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":19},{"QRcodeType":1,"algorithm":{"isLogoSplit":true,"list":[{"id":1,"list":[],"type":0},{"id":5,"list":[],"type":2}]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"material_1","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":83.3582,"id":"9baa3b65-c4f0-ebd8-866f-7e8d8e26e462","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"Logo","text":"","title":"logo","type":"image","verticalAlign":"middle","visible":true,"width":158.1738,"x":114.9929,"y":604.1777,"zIndex":20},{"QRcodeType":1,"algorithm":{"isLogoSplit":true,"list":[{"id":2,"list":[],"type":0},{"id":7,"list":[],"type":2}]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"material_1","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":99.896,"id":"d9634ebf-78e2-3ead-30c5-cd545c3bfdaa","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"Logo","text":"","title":"logo_25","type":"image","verticalAlign":"middle","visible":true,"width":228.5687,"x":191.3252,"y":809.4954,"zIndex":21}]},"param_data":{"address":"","is_crop":true,"line":"thick","logo_url":"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/c94100bd48992ea8f88c0bc65571547b2e4bd499a5b15bf0f7ba938e70693614` + "?id={{rand}}" + `","other":"","other1":"","phone":"","qrcode":"","ratio":1,"resolution":"512","shape":"other","slogan":"","template_tag":{"B1":[["#C44137"],["#235C9C"]],"B4":[["#C44137","#235C9C"]],"C1":[["#C44137"],["#235C9C"]],"C2":[["#C44137"],["#235C9C"]],"C3":[["#C44137"],["#235C9C"]],"C5":[["#C44137"],["#235C9C"]],"C6":[["#C44137"],["#235C9C"]]},"template_tag_id":["B1","C1","C2","C3","C5","C6","B4"],"template_tag_selected":{"color":[["#C44137"],["#235C9C"]],"index":0,"template_tag":"C1"},"template_tagid":"C1","version":"2","website":""},"tag_data":[{"fixed":0,"name":"主色","tag":"fill_1","value":""},{"fixed":0,"name":"副色","tag":"fill_2","value":""},{"fixed":0,"name":"备选色","tag":"fill_3","value":""},{"fixed":1,"name":"固定色A","tag":"fill_4","value":"rgba(255,255 ,255,1)"}]}` - -func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (resp *basic.Response) { - return resp.SetStatusWithMessage(basic.CodeOK, "你干嘛,哎哟") - if req.Num > 100 { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "num can`t not large than 100") - } - defer func() { - if err := recover(); err != nil { - logx.Error("测试异常:", err) - } - }() +func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo, w http.ResponseWriter) (resp *basic.Response) { lenAiHost := len(l.svcCtx.Config.BLMService.Urls) if lenAiHost == 0 { return resp.SetStatusWithMessage(basic.CodeServiceErr, "ai host list is 0") } - begin := time.Now().UTC().UnixMilli() - errChan := make(chan string) - w := sync.WaitGroup{} - b := -1 - for i := 0; i < req.Num; i++ { - w.Add(1) - b++ - if b > lenAiHost-1 { - b = 0 - } - go func(hostIndex int) { - defer func() { - if err := recover(); err != nil { - logx.Error("测试异常2:", err) - } - }() - defer w.Done() - data = strings.ReplaceAll(data, "{{rand}}", uuid.New().String()) - var postMap map[string]interface{} - if err := json.Unmarshal([]byte(data), &postMap); err != nil { - errChan <- err.Error() - return - } - var resultBLM constants.BLMServiceUrlResult - logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex]) - err := curl.NewClient(l.ctx, &curl.Config{ - BaseUrl: l.svcCtx.Config.BLMService.Urls[hostIndex], - Url: constants.BLMServiceUrlLogoCombine, - RequireTimeout: time.Second * 15, - }).PostJson(postMap, &resultBLM) - if err != nil { - errChan <- err.Error() - return - } - }(b) + hostIndex := rand.Intn(lenAiHost) - 1 + var resultBLM constants.BLMServiceUrlResult + logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex]) + err := curl.NewClient(l.ctx, &curl.Config{ + BaseUrl: l.svcCtx.Config.BLMService.Urls[hostIndex], + Url: constants.BLMServiceUrlLogoCombine, + RequireTimeout: time.Second * 15, + }).PostJson(req.Data, &resultBLM) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return resp.SetStatusWithMessage(basic.CodeServiceErr, "request failed") } - go func() { - w.Wait() - close(errChan) - }() - for v := range errChan { - return resp.SetStatusWithMessage(basic.CodeServiceErr, v) - } - end := time.Now().UTC().UnixMilli() - begin - avg := end / int64(req.Num) - return resp.SetStatus(basic.CodeOK, fmt.Sprintf("总耗时:%d ms,平均耗时%d ms", end, avg)) + return resp.SetStatusWithMessage(basic.CodeOK, "success") } // 处理逻辑后 w,r 如:重定向, resp 必须重新处理 diff --git a/server/collection/internal/logic/testpdflogic.go b/server/collection/internal/logic/testpdflogic.go deleted file mode 100644 index 941d8273..00000000 --- a/server/collection/internal/logic/testpdflogic.go +++ /dev/null @@ -1,50 +0,0 @@ -package logic - -import ( - "context" - "fusenapi/server/collection/internal/svc" - "fusenapi/server/collection/internal/types" - "fusenapi/utils/auth" - "fusenapi/utils/basic" - "fusenapi/utils/pdf" - - "github.com/zeromicro/go-zero/core/logx" -) - -type TestPdfLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTestPdfLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestPdfLogic { - return &TestPdfLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -// 处理进入前逻辑w,r -// func (l *TestPdfLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { -// } - -func (l *TestPdfLogic) TestPdf(req *types.TestPdfReq, userinfo *auth.UserInfo) (resp *basic.Response) { - return resp.SetStatusWithMessage(basic.CodeOK, "你干嘛,哎哟") - switch req.Type { - case "url": - case "html": - default: - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid type") - } - res, err := pdf.HtmlToPdfBase64(req.Content, req.Type) - if err != nil { - return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error()) - } - return resp.SetStatus(basic.CodeOK, res) -} - -// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 -// func (l *TestPdfLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { -// // httpx.OkJsonCtx(r.Context(), w, resp) -// } diff --git a/server/collection/internal/types/types.go b/server/collection/internal/types/types.go index c6268e1d..7e408a4f 100644 --- a/server/collection/internal/types/types.go +++ b/server/collection/internal/types/types.go @@ -41,12 +41,7 @@ type GetCollectProductListRspItem struct { } type TestAiReq struct { - Num int `form:"num"` -} - -type TestPdfReq struct { - Content string `json:"content"` - Type string `json:"type"` + Data map[string]interface{} `json:"data"` } type Request struct { diff --git a/server_api/collection.api b/server_api/collection.api index ea9fbabb..d653f4c4 100644 --- a/server_api/collection.api +++ b/server_api/collection.api @@ -20,10 +20,7 @@ service collection { get /api/collection/get_collect_product_list(GetCollectProductListReq) returns (response); //测试算法合图并发 @handler TestAiHandler - get /api/collection/test_ai(TestAiReq) returns (response); - //测试pdf - @handler TestPdfHandler - post /api/collection/test_pdf(TestPdfReq) returns (response); + post /api/collection/test_ai(TestAiReq) returns (response); } //收藏产品 @@ -61,10 +58,5 @@ type GetCollectProductListRspItem { } //测试算法 type TestAiReq { - Num int `form:"num"` -} -//测试pdf -type TestPdfReq { - Content string `json:"content"` - Type string `json:"type"` + Data map[string]interface{} `json:"data"` } \ No newline at end of file From 9cb979d8307253d2ce6bb14105696e03f9134229 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:37:32 +0800 Subject: [PATCH 11/21] fix --- server/product/internal/logic/gettagproductlistlogic.go | 6 +++--- server/product/internal/types/types.go | 2 +- server_api/product.api | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 0d7659ba..cce5378b 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -310,8 +310,8 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) }) //tag中产品 for _, tmpProduct := range productListRsp { - tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct.ProductId) - req.MapTagProduct[tmpProduct.ProductId] = tmpProduct + tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct.Id) + req.MapTagProduct[tmpProduct.Id] = tmpProduct } } //加入分类 @@ -427,7 +427,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL haveOptionalFitting = true } item := types.TagProduct{ - ProductId: productInfo.Id, + Id: productInfo.Id, Sn: *productInfo.Sn, Title: *productInfo.Title, SizeNum: uint32(sizeNum), diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index fa2a8e91..c1833896 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -51,7 +51,7 @@ type TagItem struct { } type TagProduct struct { - ProductId int64 `json:"product_id"` + Id int64 `json:"id"` Sn string `json:"sn"` Title string `json:"title"` Cover string `json:"cover"` diff --git a/server_api/product.api b/server_api/product.api index 9b61723b..7dc15731 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -91,7 +91,7 @@ type TagItem { ChildTagList []*TagItem `json:"child_tag_list"` } type TagProduct { - ProductId int64 `json:"product_id"` + Id int64 `json:"id"` Sn string `json:"sn"` Title string `json:"title"` Cover string `json:"cover"` From 6b4617b6e71542f1356e78dc947a1d4fe73e6f2b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:43:49 +0800 Subject: [PATCH 12/21] fix --- service/repositories/image_handle.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index ef42820b..0be29756 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -223,7 +223,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["materialList"] = materialList var combineParam map[string]interface{} - json.Unmarshal([]byte(*resLogoInfo.Metadata), &combineParam) + json.Unmarshal(*resLogoInfo.Metadata, &combineParam) combineParam["resolution"] = in.Resolution combineParam["template_tagid"] = in.TemplateTag combineParam["website"] = in.Website @@ -248,7 +248,8 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq } else { globalBLMServiceIndex = globalBLMServiceIndex + 1 } - + cc, _ := json.Marshal(postMap) + logx.Info("合图数据:", string(cc)) logc.Infof(ctx, "合图--算法请求--合图--开始时间:%v", time.Now().UTC()) var startTimeLogoCombine = time.Now().UnixMilli() //合图--处理--开始时间 From 6430c18d2af76975ae0a144192f97b344c85f1e8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:49:08 +0800 Subject: [PATCH 13/21] fix --- service/repositories/image_handle.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 0be29756..d14e6e0f 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -248,8 +248,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq } else { globalBLMServiceIndex = globalBLMServiceIndex + 1 } - cc, _ := json.Marshal(postMap) - logx.Info("合图数据:", string(cc)) + logc.Infof(ctx, "合图--算法请求--合图--开始时间:%v", time.Now().UTC()) var startTimeLogoCombine = time.Now().UnixMilli() //合图--处理--开始时间 From 735098b2c748651e117aea497c4dca3c57fa9781 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:54:41 +0800 Subject: [PATCH 14/21] fix --- server/collection/internal/logic/testailogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/collection/internal/logic/testailogic.go b/server/collection/internal/logic/testailogic.go index 75bf2a41..aaa82bad 100644 --- a/server/collection/internal/logic/testailogic.go +++ b/server/collection/internal/logic/testailogic.go @@ -36,7 +36,7 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo, w ht if lenAiHost == 0 { return resp.SetStatusWithMessage(basic.CodeServiceErr, "ai host list is 0") } - hostIndex := rand.Intn(lenAiHost) - 1 + hostIndex := rand.Intn(lenAiHost) var resultBLM constants.BLMServiceUrlResult logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex]) err := curl.NewClient(l.ctx, &curl.Config{ From 62dd14a6276380ce46779222247f175f8e20dab2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 14:59:27 +0800 Subject: [PATCH 15/21] fix --- server/product/internal/logic/gettagproductlistlogic.go | 1 + server/product/internal/types/types.go | 1 + server_api/product.api | 1 + 3 files changed, 3 insertions(+) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index cce5378b..bc2f7652 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -428,6 +428,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL } item := types.TagProduct{ Id: productInfo.Id, + ProductId: productInfo.Id, Sn: *productInfo.Sn, Title: *productInfo.Title, SizeNum: uint32(sizeNum), diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index c1833896..1ac32f81 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -52,6 +52,7 @@ type TagItem struct { type TagProduct struct { Id int64 `json:"id"` + ProductId int64 `json:"product_id"` //后面删掉这个 Sn string `json:"sn"` Title string `json:"title"` Cover string `json:"cover"` diff --git a/server_api/product.api b/server_api/product.api index 7dc15731..50a17da0 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -92,6 +92,7 @@ type TagItem { } type TagProduct { Id int64 `json:"id"` + ProductId int64 `json:"product_id"` //后面删掉这个 Sn string `json:"sn"` Title string `json:"title"` Cover string `json:"cover"` From 075f89df4940102cd08a3280f604bbd67c18c1c5 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 15:05:46 +0800 Subject: [PATCH 16/21] fix --- server/collection/internal/handler/routes.go | 5 -- .../internal/handler/testaihandler.go | 35 ------------ .../collection/internal/logic/testailogic.go | 57 ------------------- server/collection/internal/types/types.go | 4 -- server_api/collection.api | 7 --- 5 files changed, 108 deletions(-) delete mode 100644 server/collection/internal/handler/testaihandler.go delete mode 100644 server/collection/internal/logic/testailogic.go diff --git a/server/collection/internal/handler/routes.go b/server/collection/internal/handler/routes.go index 7c9fa49f..1d8b59a5 100644 --- a/server/collection/internal/handler/routes.go +++ b/server/collection/internal/handler/routes.go @@ -27,11 +27,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/collection/get_collect_product_list", Handler: GetCollectProductListHandler(serverCtx), }, - { - Method: http.MethodPost, - Path: "/api/collection/test_ai", - Handler: TestAiHandler(serverCtx), - }, }, ) } diff --git a/server/collection/internal/handler/testaihandler.go b/server/collection/internal/handler/testaihandler.go deleted file mode 100644 index 1be6a44d..00000000 --- a/server/collection/internal/handler/testaihandler.go +++ /dev/null @@ -1,35 +0,0 @@ -package handler - -import ( - "net/http" - "reflect" - - "fusenapi/utils/basic" - - "fusenapi/server/collection/internal/logic" - "fusenapi/server/collection/internal/svc" - "fusenapi/server/collection/internal/types" -) - -func TestAiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - - var req types.TestAiReq - userinfo, err := basic.RequestParse(w, r, svcCtx, &req) - if err != nil { - return - } - - // 创建一个业务逻辑层实例 - l := logic.NewTestAiLogic(r.Context(), svcCtx) - - rl := reflect.ValueOf(l) - basic.BeforeLogic(w, r, rl) - - resp := l.TestAi(&req, userinfo, w) - - if !basic.AfterLogic(w, r, rl, resp) { - basic.NormalAfterLogic(w, r, resp) - } - } -} diff --git a/server/collection/internal/logic/testailogic.go b/server/collection/internal/logic/testailogic.go deleted file mode 100644 index aaa82bad..00000000 --- a/server/collection/internal/logic/testailogic.go +++ /dev/null @@ -1,57 +0,0 @@ -package logic - -import ( - "fusenapi/constants" - "fusenapi/utils/auth" - "fusenapi/utils/basic" - "fusenapi/utils/curl" - "math/rand" - "net/http" - "time" - - "context" - - "fusenapi/server/collection/internal/svc" - "fusenapi/server/collection/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type TestAiLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTestAiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestAiLogic { - return &TestAiLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo, w http.ResponseWriter) (resp *basic.Response) { - lenAiHost := len(l.svcCtx.Config.BLMService.Urls) - if lenAiHost == 0 { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "ai host list is 0") - } - hostIndex := rand.Intn(lenAiHost) - var resultBLM constants.BLMServiceUrlResult - logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex]) - err := curl.NewClient(l.ctx, &curl.Config{ - BaseUrl: l.svcCtx.Config.BLMService.Urls[hostIndex], - Url: constants.BLMServiceUrlLogoCombine, - RequireTimeout: time.Second * 15, - }).PostJson(req.Data, &resultBLM) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) - return resp.SetStatusWithMessage(basic.CodeServiceErr, "request failed") - } - return resp.SetStatusWithMessage(basic.CodeOK, "success") -} - -// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 -// func (l *TestAiLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { -// // httpx.OkJsonCtx(r.Context(), w, resp) -// } diff --git a/server/collection/internal/types/types.go b/server/collection/internal/types/types.go index 7e408a4f..62d68266 100644 --- a/server/collection/internal/types/types.go +++ b/server/collection/internal/types/types.go @@ -40,10 +40,6 @@ type GetCollectProductListRspItem struct { IsDeleted int64 `json:"is_deleted"` } -type TestAiReq struct { - Data map[string]interface{} `json:"data"` -} - type Request struct { } diff --git a/server_api/collection.api b/server_api/collection.api index d653f4c4..37bcf004 100644 --- a/server_api/collection.api +++ b/server_api/collection.api @@ -18,9 +18,6 @@ service collection { //获取收藏列表 @handler GetCollectProductListHandler get /api/collection/get_collect_product_list(GetCollectProductListReq) returns (response); - //测试算法合图并发 - @handler TestAiHandler - post /api/collection/test_ai(TestAiReq) returns (response); } //收藏产品 @@ -55,8 +52,4 @@ type GetCollectProductListRspItem { MinPrice string `json:"min_price"` IsShelf int64 `json:"is_shelf"` IsDeleted int64 `json:"is_deleted"` -} -//测试算法 -type TestAiReq { - Data map[string]interface{} `json:"data"` } \ No newline at end of file From 2c9609d0c3ea14db127969fb478201c5f0f67fc0 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 16:40:38 +0800 Subject: [PATCH 17/21] logo search --- model/gmodel/fs_preprocess_logo_logic.go | 94 ------------------------ 1 file changed, 94 deletions(-) diff --git a/model/gmodel/fs_preprocess_logo_logic.go b/model/gmodel/fs_preprocess_logo_logic.go index 85bbab9f..a6759f81 100644 --- a/model/gmodel/fs_preprocess_logo_logic.go +++ b/model/gmodel/fs_preprocess_logo_logic.go @@ -2,7 +2,6 @@ package gmodel import ( "context" - "math/rand" "fmt" "regexp" @@ -51,9 +50,6 @@ func (p *FsPreprocessLogoModel) PreLogoSearch(ctx context.Context, zipcode strin resp[i].RestaurantType = FsString("") } - if len(*resp[i].ResourceUrl) < 10 { - resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))]) - } } } @@ -94,10 +90,6 @@ func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, ke resp[i].RestaurantType = FsString("") } - if len(*resp[i].ResourceUrl) < 10 { - resp[i].ResourceUrl = FsString(testData[rand.Uint64()%uint64(len(testData))]) - } - } } @@ -108,89 +100,3 @@ func (p *FsPreprocessLogoModel) PreLogoSearchSuggestions(ctx context.Context, ke return resp, nil } - -var testData = []string{ - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7496a14fb62571d07c485a0e9de25440ff178122a4842b73f2ca49833a4ce74d", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/74ca91d9f3beaa1674832565dfa925d801c1b752703307b1205d546dff32e68b", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/75cea2f3993c39f19fe48f1cebb55c83049155fada1397e98a18f5f9c8a647d5", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7657923837e118644fd76d68c8238384c8c29156d2d84f243fd638386c9a6d32", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/76a86fd26acfa828cec89300da307cd83cbf785fb6b6af92afeb18192532ea13", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/78315df91146c77242314d22014083c764f336ba7abd89115eb02001c779e926", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/78feef6e8429e5121ebb160e7229402a3ec121a958c75f9ede07f730f6f25711", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7909c8e6485f3a908105aeb499bd07c6ca18feaca0fd724aac7b4f2d127735ca", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7a5e04ba33105a3935e808e8dcde12a2d793409d7e8b7f7ef465801ae92b982d", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7ad3beb80d268fdda4f312d25e3bc1721c00ef0d1badc133df03f38217c8c207", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7c5f51a90444edc1edf673904d11771f1c43930a9f28de2c42a1bf1164a73ade", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7d072fa805ae0e260e0619cda11ace59233adc4cc8bc63e2017013817dce5011", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7d34b57d47f4faea05ad6ba8ef73d9815fbaf048e945e85e7e36d7c26b02151b", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/7fa3df13072e3fb0e47904be65109526bfb21db795c53cabae8625758135aa6c", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/802f96696e5b8a4fb5ef90bc812cde7ff50e54125d7e8439159a66da9a512bf5", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/81e9384055c708098bf4dfca893d7b39ba94444d980b87ee74385c7e01b94c6f", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/83352df2db64d50efc36d972dd01035a79edca77e7360dd486366fecf5799336", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/83b496eae54768a82c3a828d33e544bfaf46544977371eb8cc7dfdb3d43e453d", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/84e130d75a4cf3e27f1f3851395c75341a171053a42e93ae1a7b69c3e7cf58ad", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8505e9775556ee4d9fd03478098f73cbb9ccfdb3567d5cadc2ada7c43d2150df", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/864c84568b4816fbc29814d38b3bf079aba5a35b5d07f5b57f3dd2a79409b204", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/870446c5543c74cb351696713d4ff85a20a17ea9186da9b4c0bf6db3d6217a7c", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/88e1b79804a776272007a64da435e4a7bfee5d2693da8479f31c79036d45eec8", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/88f7e10f711d726c52fad4e6d378b0ed814067477a3564ed6601c98b9d98fb4c", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8908471ae4ff7b0ac405952d6bc2bd049af0cbff7fd892762076f5ed19a34cee", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/899fb5321402c8f562f072993f81ad22edb3df2feb43c2436e92cb4b97036caa", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8c59b2714ff399f394cc2e728766c2f0b07fc6d39bf090e4fea3c4f344c40508", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8cfcd0cbb8d11707dceb45f0936b8c3c7b6c30f434313c252d22b7629ee72b98", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8d47deacf2960de77ddaf742a3ea8b8c7ea4b40afbf5b4e3652e78973800aeef", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/8f61f8d08c2cbf8b7e45450321037b1c51ae2a16547f8662bbb5c27e82defe84", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/922915f7ab94113afbe287feb1ddcc8a77840ee4b455e818bcef48ac35069818", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/923745c708fc1507d89c42fe3a47424bc89297754c3ff88a261abab0a59e4b8d", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/92a2fd97d6fa5385ff6bf5d64e8467331e32286fe8b179d020baf7674612e2e1", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/92f93ee2fa364b98ea13f0fe3dcf57e55ae939784ccb5489143deb6d2181ea09", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/937615ffe810ec1210d6ac9bc9671b04be4254046ded12264189637282adaa11", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/93b00364dcfd3b9f6d927eccdc65e10e293876cc0b859c0e1af35cb97343d3e4", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/93b4d14bbcf86743699825adac5bbefb737403061fceea2f8ce23027101a9b08", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/957fc76c9c84d6cc177ba1e7d92913a3fdcade6c5501103d7a39b743affd6451", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/958454c580e5708e2ca704893bc31196a8cf68dccca6549ded063e708e59b9a0", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/95bf354437c8c36bcc34979b81006586c3abcc8cbbd13b277fb8539d817a0400", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/95f6d1152a481e19f641272c4f0ef046b383abc8286e3b2ac329cc1558cd2453", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/96813af51fbc66556a5b616e4964434bac5fbdd5faccbd8c147727f0838b266f", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/96e1911af7a506c30c8d1d5a0df6ea7a20a7030fe5f43e26097e1c241e5688bf", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/97589c622074193c4f85afb5041b7fdaa22cde42c878520f190ac657e71bb257", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/98ce764aaf1021f8caf54eb299decaa28839b55bb7ee769804cb7e5ea942a051", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/98f7a95879da3ebe551c8a4484faaa3a3801ef9beb2129b1f1c450149768f28a", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/99ebccb5fe9d7c985bc4ea1cd1f0b9681ee8e4225a422f14c2efc0432b7adc09", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9b559c125a353299331068eb3d7bd5f41c8b922644725dc3df60c3a1a53763b3", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9b8c409168efe89e7b78437d1622f726b7a75c517c4386c30cbff4811665ad86", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9c246614316fe1727a5b36dc428876ac6f1d6424e8ce4feb51d9b6f8b363d39d", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9caf9bd0676e696bc5c0735498a50f2281941bc59ec323d96cfe2536096bdf50", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9d0594ca037f3998681a3f2458a954f1ecb2b4bd7f3dabcc304adc4d9ba452aa", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9d5809781f3f3e284add2a6e2e79965f0e1930744f8264f8e73750c05d3d4b20", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9ef6ded5b910985f35dc6cba469cb5eb20626b07ed6bca449261cc1d8f8147cf", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9f0cc4bf9f3a5642b1510b5a6a911c53f8f2664071dfcbd9239d160a6fb02d32", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/9f91ada7ebc9a2bf623881a2daed0643a81785d2d7624738c3b6bb17cffa58a7", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a26d27fbf27bdd4ab76cefe46a337326432435fc36cce5e5f5e2499e22642f13", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a36543d0d6ee8435bf0ba18ab96fc424c52649a737502f663efd4fc128aaed22", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a4cb2e6c0d93adfb6ebc6c03820dc3dd4b2e5a6bf737782fc910502e5f78d6b7", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a5861470cc5dc7f23a0a66022301fe46a7cf5bf78aa4cbb8aff96bfe1a792220", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a6dbc806559141970a2309c3e20fa019d112eb76c96badc2b99e43c0e19ab17f", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a72eb76e76a2627f8532bc96d8111f22b7132e32795effc628b1acab0a31e8fb", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a827d4012554ea3be1ce1cc86c56d10bb43fa80d6d5e36be5c7ce5ef232e5757", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a93b38fdaf20bddb560ee6a9eb7c2ddf34b3480a771533fe3343905b4e05e4a8", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a9f540186a6e9ecf5dae469e83cd952fd0d1539798edf5c7690af858efbb8cbf", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ab1326e69ff13289c9ac00deac7d61a581a10580e701ff61fe9065937c2c7f11", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/abda7e2720063f576fbf3ada356a721a183c0548e11b1878d414de733cf3754e", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/abecd9297af902c0ec32350f4710b4ed6c4c596d6b24228314a833c95993aa94", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ad4a15c1eaa714e6481812ac938ab09a5f47de116ae8880353be6e12ba8eb64a", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ad677b423fee3d9a1fe3aee24dc00255b5ff0e266fcd0bbca1c2098a2712d91b", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/af0a5621c098fe437a419215105d0485603a27dfdf697df85b966c00fc45b7c8", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/af4d0f94627384bc66fda949052bc1db8d945c1f8e6dcea71dd3d35a011323a0", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/afad479690db35e8371cce3dceae13bfff06fff1a9c0b3487ae6f830e984e416", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b33574c05de24f5963e14813345c601663d66e1db4fedc840b728248e15e1992", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b3723604352d76aa3d6aee1db3cdfd96c3141926f5565efd8d7f7881cfe11ece", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b390c9c5456a1f97e743b2166de1c0dce56e582e4f2b32a0b7aaf842438aafb3", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b420ec89935d2b243600537096046d45bd4ecf071133accd9bd727f92916d442", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b656b871d6663fe0c180c25a001c3e7f0195e4b3e665cee0d52593ccd65a7ec1", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b698198af640aaf742371a873abe537993b086282c153705b65b7244aeccf154", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b95d2daf610d90098669f10b315b89765b011aec63ebac14e2a4aef68ed5fadb", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/b976f1c46cf74753948bec7eb623cc0eb9235c1160f9677a31884bd34521a759", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/ba529a80062844e682f545f5ba50d75ba53ffd59a6ebb0531c962e5c45122846", - "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/bb2652012232cf15c52ab370ae5608621850577369242d9dff0e0f3dbebdab14", -} From 76412c96ce770db56824426e8e2d127a48671276 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 18:21:06 +0800 Subject: [PATCH 18/21] fix --- model/gmodel/fs_product_logic.go | 8 ++++++-- .../internal/logic/getrecommendproductlistlogic.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/model/gmodel/fs_product_logic.go b/model/gmodel/fs_product_logic.go index 1e7d87e9..e2e16e42 100755 --- a/model/gmodel/fs_product_logic.go +++ b/model/gmodel/fs_product_logic.go @@ -89,8 +89,12 @@ func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (r return resp, err } func (p *FsProductModel) GetIgnoreRandomProductList(ctx context.Context, limit int, notInProductIds []int64) (resp []FsProduct, err error) { - err = p.db.WithContext(ctx).Model(&FsProduct{}). - Where("`is_del` =? and `is_shelf` = ? and `id` not in(?)", 0, 1, notInProductIds).Order("RAND()").Limit(limit).Find(&resp).Error + db := p.db.WithContext(ctx).Model(&FsProduct{}). + Where("`is_del` =? and `is_shelf` = ? ", 0, 1) + if len(notInProductIds) > 0 { + db = db.Where("`id` not in(?)", notInProductIds) + } + err = db.Order("RAND()").Limit(limit).Find(&resp).Error return resp, err } func (p *FsProductModel) FindAllOnlyByIds(ctx context.Context, ids []int64) (resp []FsProduct, err error) { diff --git a/server/product/internal/logic/getrecommendproductlistlogic.go b/server/product/internal/logic/getrecommendproductlistlogic.go index 013abab1..072b9164 100644 --- a/server/product/internal/logic/getrecommendproductlistlogic.go +++ b/server/product/internal/logic/getrecommendproductlistlogic.go @@ -3,6 +3,7 @@ package logic import ( "encoding/json" "errors" + "fmt" "fusenapi/constants" "fusenapi/model/gmodel" "fusenapi/utils/auth" @@ -64,6 +65,7 @@ func (l *GetRecommendProductListLogic) GetRecommendProductList(req *types.GetRec recommendProductList = recommendProductList[:req.Num] } } + fmt.Println(recommendProductList) //资源id集合 resourceIds := make([]string, 0, 50) //需要填充时需要忽略的id From bd8615e9f2dc344dffe14a5163a87ef11cd8040f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 18:25:54 +0800 Subject: [PATCH 19/21] fix --- service/repositories/shopping_cart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/repositories/shopping_cart.go b/service/repositories/shopping_cart.go index 6c22d7d4..52b38248 100644 --- a/service/repositories/shopping_cart.go +++ b/service/repositories/shopping_cart.go @@ -138,7 +138,7 @@ func (d *defaultShoppingCart) CaculateStepPrice(purchaseQuantity int64, stepPric //购买数量>起点 if purchaseQuantity > v.StartQuantity { //最后一个 || 小于等于终点 - if k == l-1 || purchaseQuantity <= v.EndQuantity { + if k == l-1 || purchaseQuantity < v.EndQuantity { itemPrice = v.Price + fittingPrice return itemPrice * purchaseQuantity, itemPrice, nil } From 87d3985a60ae92f688e5f202334fd25c46d493bd Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 18:28:45 +0800 Subject: [PATCH 20/21] fix --- service/repositories/shopping_cart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/repositories/shopping_cart.go b/service/repositories/shopping_cart.go index 52b38248..005cd527 100644 --- a/service/repositories/shopping_cart.go +++ b/service/repositories/shopping_cart.go @@ -138,7 +138,7 @@ func (d *defaultShoppingCart) CaculateStepPrice(purchaseQuantity int64, stepPric //购买数量>起点 if purchaseQuantity > v.StartQuantity { //最后一个 || 小于等于终点 - if k == l-1 || purchaseQuantity < v.EndQuantity { + if k == l-1 || (purchaseQuantity < v.EndQuantity && purchaseQuantity >= v.StartQuantity) { itemPrice = v.Price + fittingPrice return itemPrice * purchaseQuantity, itemPrice, nil } From eaf5f86a1908311abf526cdbc46b1231306b9455 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 25 Oct 2023 18:30:52 +0800 Subject: [PATCH 21/21] fix --- service/repositories/shopping_cart.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/repositories/shopping_cart.go b/service/repositories/shopping_cart.go index 005cd527..106ac9d3 100644 --- a/service/repositories/shopping_cart.go +++ b/service/repositories/shopping_cart.go @@ -136,9 +136,9 @@ func (d *defaultShoppingCart) CaculateStepPrice(purchaseQuantity int64, stepPric //遍历查询合适的价格 for k, v := range stepPrice.PriceRange { //购买数量>起点 - if purchaseQuantity > v.StartQuantity { - //最后一个 || 小于等于终点 - if k == l-1 || (purchaseQuantity < v.EndQuantity && purchaseQuantity >= v.StartQuantity) { + if purchaseQuantity >= v.StartQuantity { + //最后一个 || 小于终点 + if k == l-1 || purchaseQuantity < v.EndQuantity { itemPrice = v.Price + fittingPrice return itemPrice * purchaseQuantity, itemPrice, nil }