From 179ce30a7cde5dbf1478e41c2b1c4a1118dc5a5d Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Thu, 13 Mar 2025 17:06:30 +0800 Subject: [PATCH] 13444 --- api/controller/Res.go | 15 +++++++++++++++ api/dto/Res.go | 11 ++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/api/controller/Res.go b/api/controller/Res.go index d767ad9..5541bb7 100644 --- a/api/controller/Res.go +++ b/api/controller/Res.go @@ -6,6 +6,7 @@ import ( "case-open-api/api/requests" "case-open-api/api/responses" "case-open-api/api/service" + "case-open-api/config" "case-open-api/global" "case-open-api/utils" "fmt" @@ -115,6 +116,20 @@ func (b *Res) GetResCaseList(c *gin.Context) { // 处理返回值 g := dto.GetCaseResListDto(cases) + // 获取平台数据 + platformDao := dao.PlatformDao{} + platform, err := platformDao.GetPlatformById(platformId) + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + for _, caseDto := range g { + // 加载访问链接 + link := config.C.DomainName + "/caseIntro" + "?project_id=" + caseDto.ProjectId + "&source=3" + "&platform_key=" + platform.PlatformKey + "&case_id=" + caseDto.SId + caseDto.LoadLink(link) + } + responses.OkWithData(g, c) } diff --git a/api/dto/Res.go b/api/dto/Res.go index d18ccf1..609aec4 100644 --- a/api/dto/Res.go +++ b/api/dto/Res.go @@ -2,7 +2,6 @@ package dto import ( "case-open-api/api/model" - "case-open-api/config" "case-open-api/utils" "fmt" ) @@ -138,9 +137,6 @@ func GetCaseResListDto(m []*model.Case) []*ResCaseDto { StarTime: v.CreatedAt, } - // 加载访问链接 - response.LoadLink(v) - // 将转换后的结构体添加到新切片中 responses[i] = response } @@ -174,11 +170,8 @@ func (r *ResProjectDto) LoadIsRecentlyUpdate(m *model.Case) *ResProjectDto { } // LoadLink 加载访问链接 -func (r *ResCaseDto) LoadLink(m *model.Case) *ResCaseDto { - if m != nil { - link := config.C.DomainName + "/caseIntro" + "?project_id=" + fmt.Sprintf("%d", m.ProjectId) + "&source=3" + "&platform_key=opf$di!3" + "&case_id=" + fmt.Sprintf("%d", m.CaseId) - r.Url = link - } +func (r *ResCaseDto) LoadLink(link string) *ResCaseDto { + r.Url = link return r }