updated image

This commit is contained in:
tzwang 2025-05-15 16:11:45 +08:00
parent 214f596ba9
commit 937b73cc16
2 changed files with 34 additions and 17 deletions

View File

@ -4,8 +4,8 @@ import (
"github.com/gin-gonic/gin"
"gitlink.org.cn/JointCloud/pcm-openi/common"
"gitlink.org.cn/JointCloud/pcm-openi/model"
"gitlink.org.cn/JointCloud/pcm-openi/service"
"net/http"
"strconv"
)
func GetImageRecommended(ctx *gin.Context) {
@ -17,22 +17,10 @@ func GetImageRecommended(ctx *gin.Context) {
return
}
reqUrl := common.OPENIPREFIX + common.IMAGERECOMMENDED
var resp model.ImageRecommended
req := common.GetRestyRequest(common.TIMEOUT)
_, err := req.
SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("computeResource", param.ComputeResource).
SetQueryParam("cloudbrainType", strconv.Itoa(param.CloudbrainType)).
SetQueryParam("q", param.Q).
SetQueryParam("spec", strconv.Itoa(param.Spec)).
SetQueryParam("trainType", param.TrainType).
SetQueryParam("page", strconv.Itoa(param.Page)).
SetQueryParam("pageSize", strconv.Itoa(param.PageSize)).
SetResult(&resp).
Get(reqUrl)
resp, err := service.GetImageRecommended(token, &param)
if err != nil {
return
}
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)

29
service/image.go Normal file
View File

@ -0,0 +1,29 @@
package service
import (
"github.com/go-resty/resty/v2"
"gitlink.org.cn/JointCloud/pcm-openi/common"
"gitlink.org.cn/JointCloud/pcm-openi/model"
"net/http"
"strconv"
)
func GetImageRecommended(token string, param *model.ImageRecommendedParam) (resp *model.ImageRecommended, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.IMAGERECOMMENDED, http.MethodGet, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("computeResource", param.ComputeResource).
SetQueryParam("cloudbrainType", strconv.Itoa(param.CloudbrainType)).
SetQueryParam("q", param.Q).
SetQueryParam("spec", strconv.Itoa(param.Spec)).
SetQueryParam("trainType", param.TrainType).
SetQueryParam("page", strconv.Itoa(param.Page)).
SetQueryParam("pageSize", strconv.Itoa(param.PageSize)).
SetError(&respErr).
SetResult(&resp)
})
if err != nil {
return nil, err
}
return
}