package com.heyu.api.controller.doc;


import com.heyu.api.baidu.handle.doc.BRemoveMoireHandle;
import com.heyu.api.baidu.request.doc.BRemoveMoireRequest;
import com.heyu.api.baidu.response.doc.BRemoveMoireResp;
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.RemoveMoireResp;
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=1740671115065#/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%2Fremove_moire&method=post
 *
 * 图片去摩尔纹
 *
 * 去除翻拍电脑、手机等显示屏照片中的摩尔纹，使图片更加清晰。示例图如下：
 *
 *
 */
@Slf4j
@RestController
@RequestMapping("/doc")
@NotIntercept
public class RemoveMoireController {


    @Autowired
    private BRemoveMoireHandle bRemoveMoireHandle;


    @RequestMapping("/removeMoire")
    @CacheResult
    public R repair(BRemoveMoireRequest request) {

        RemoveMoireResp resp = new RemoveMoireResp();

        ApiR<BRemoveMoireResp> bR = bRemoveMoireHandle.handle(request);
        if (bR.isSuccess()) {
            BRemoveMoireResp bRemoveMoireResp = bR.getData();


            resp.setImageBase64(bRemoveMoireResp.getImageProcessed());
            resp.setPdfFileSize(bRemoveMoireResp.getPdfFileSize());

            return R.ok().setData(resp);


        }

        return R.error();
    }


}
