package com.gic.haoban.manage.web.controller.content;

import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.aigc.AIGCContent;
import com.gic.content.api.qdto.aigc.ContentAIGCQDTO;
import com.gic.content.api.service.common.ThirdApiService;
import com.gic.haoban.manage.web.qo.content.ContentAIGCQO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 好办-三方接口
 */
@RestController()
public class ContentThirdController {

    private static final Logger log = LoggerFactory.getLogger(ContentThirdController.class);

    @Autowired
    private ThirdApiService thirdApiService;

    /**
     * AIGC生成文案
     * @param aigcQO
     * @return
     */
    @RequestMapping("/third/aigc")
    @ResponseBody
    public RestResponse<AIGCContent> aigc(@RequestBody ContentAIGCQO aigcQO) {
        String clerkId = aigcQO.getClerkId();
        ContentAIGCQDTO aigcQDTO = EntityUtil.changeEntityNew(ContentAIGCQDTO.class, aigcQO);
        aigcQDTO.setUserId(clerkId);
        ServiceResponse<AIGCContent> response = thirdApiService.aigc(aigcQDTO);
        if (!response.isSuccess()) {
            return RestResponse.failure(response.getCode(), response.getMessage());
        }
        return RestResponse.successResult(response.getResult());
    }
}
