package tag import ( "fmt" "github.com/guonaihong/gout" "gogs.uu.mdfitnesscao.com/Algor/sdk" "gogs.uu.mdfitnesscao.com/Algor/sdk/response" ) // 获取标签分类信息 func DetailTagCategory(id string) (*sdk.BaseResponse[sdk.DetailResponse[*sdk.TagCategory]], *response.ErrCode) { var resp *sdk.BaseResponse[sdk.DetailResponse[*sdk.TagCategory]] resp, err := postReq[*sdk.BaseResponse[sdk.DetailResponse[*sdk.TagCategory]]]("/tagService/openapi/tagCategory/detail", gout.H{ "id": id, }) if err != nil { return nil, &response.ErrCode{ Code: response.PLATFORM_ERROR, Msg: err.Error(), } } if resp == nil { return nil, response.ErrPlatform } if resp.Code != 200 { return nil, &response.ErrCode{ Code: resp.Code, Msg: resp.Message, } } return resp, nil } // 获取标签分类信息 func SetArchivesTag(tagId string, archivesId string, remarks string, operatorName string) (*sdk.BaseResponse[map[string]any], *response.ErrCode) { var resp *sdk.BaseResponse[map[string]any] resp, err := postReq[*sdk.BaseResponse[map[string]any]]("/tagService/openapi/archive/tag", gout.H{ "tagId": tagId, "archiveId": archivesId, "remarks": remarks, "operatorName": operatorName, }) if err != nil { return nil, &response.ErrCode{ Code: response.PLATFORM_ERROR, Msg: err.Error(), } } if resp == nil { return nil, response.ErrPlatform } if resp.Code != 200 { return nil, &response.ErrCode{ Code: resp.Code, Msg: resp.Message, } } return resp, nil } // postReq 发送post请求 func postReq[T any](path string, data gout.H) (T, error) { var res T fmt.Println(sdk.GetConfig()) // 检查配置 if sdk.GetConfig().ApiDomain == "" { return res, fmt.Errorf("请先配置API域名") } url := fmt.Sprintf("%s%s", sdk.GetConfig().ApiDomain, path) fmt.Println("请求地址 ===>", url) err := gout.POST(url).Debug(sdk.GetConfig().AppDebug). SetHeader(gout.H{}). SetJSON(data). BindJSON(&res). Do() if err != nil { fmt.Println("请求失败: ", err) return res, err } return res, nil }