package com.heyu.api.controller.doc;


import com.heyu.api.baidu.handle.doc.BDocRepairHandle;
import com.heyu.api.baidu.request.doc.BDocRepairRequest;
import com.heyu.api.baidu.response.doc.BDocRepairResp;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.doc.DocRepairResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 *
 * https://console.bce.baidu.com/support/?_=1740667714316&timestamp=1742718778563#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%96%87%E6%A1%A3%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86&api=rest%2F2.0%2Fimage-process%2Fv1%2Fdoc_repair&method=post
 *
 *
 * 接口描述
 * 自动识别并去除文档图片中的底纹，使图片更加清晰，便于阅读。示意图如下：
 *
 *
 *
 */
@Slf4j
@RestController
@RequestMapping("/doc")
@NotIntercept
public class DocRepairController {


    @Autowired
    private BDocRepairHandle bDocRepairHandle;

    @RequestMapping("/repair")
    @CacheResult
    public R repair(BDocRepairRequest request) {
        DocRepairResp resp = new DocRepairResp();

        ApiR<BDocRepairResp> bR = bDocRepairHandle.handle(request);
        if (bR.isSuccess()) {
            BDocRepairResp bDocRepairResp = bR.getData();

            resp.setImageURL(bDocRepairResp.getResult());
            return R.ok().setData(resp);

        }

        return R.error(bR.getErrorMsg());
    }


}
