|
- /* ******************************************************************************
- * 2019 - present Contributed by Apulis Technology (Shenzhen) Co. LTD
- *
- * This program and the accompanying materials are made available under the
- * terms of the MIT License, which is available at
- * https://www.opensource.org/licenses/MIT
- *
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- * SPDX-License-Identifier: MIT
- ******************************************************************************/
- package services
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "net/http"
- "net/url"
- "time"
-
- "github.com/apulis/app/ai-arts-backend/internal/configs"
- "github.com/apulis/app/ai-arts-backend/internal/dto"
- "github.com/apulis/app/ai-arts-backend/internal/utils"
- "github.com/apulis/app/ai-arts-backend/pkg/exports"
- )
-
- var globalApWorkShopService = &ApWorkShopService{}
-
- type ApWorkShopService struct{}
-
- func GetGlobalApWorkShopService() *ApWorkShopService {
- return globalApWorkShopService
- }
-
- func (p *ApWorkShopService) GetModelTmpPath(req *dto.ApWorkShopGetTmpReq, header http.Header) (*dto.ApWorkShopGetTmpResp, *exports.CommResponse, error) {
- defer utils.TimeCost(time.Now(), "ApWorkShopService.GetModelTmpPath")
- urlpath := configs.GetAppConfig().Resources.ApWorkShop + "/studioModelGetTmp"
- u, _ := url.Parse(urlpath)
-
- b, _ := json.Marshal(req)
- fmt.Println(string(b))
- r := bytes.NewReader(b)
-
- resp, err := DoRequest(u.String(), "POST", header, r)
-
- if err != nil {
- return nil, nil, err
- }
- data := dto.ApWorkShopGetTmpResp{}
- commResponse, err := ParseResponse(resp, &data)
- return &data, commResponse, err
- }
-
- func (p *ApWorkShopService) GetModelVersionDetail(req *dto.GetModelVersionDetailReq, header http.Header) (*dto.GetModelVersionDetailResp, *exports.CommResponse, error) {
- defer utils.TimeCost(time.Now(), "ApWorkShopService.GetModelVersionDetail")
- urlpath := configs.GetAppConfig().Resources.ApWorkShop + fmt.Sprintf("/studioModelVersion/%s/%s", req.Id, req.VersionId)
- u, _ := url.Parse(urlpath)
- resp, err := DoRequest(u.String(), "GET", header, nil)
- if err != nil {
- return nil, nil, err
- }
- data := dto.GetModelVersionDetailResp{}
- commResponse, err := ParseResponse(resp, &data)
- return &data, commResponse, err
- }
|