package com.czg.controller.admin;

import com.czg.product.service.MkOcrCountStickService;
import com.czg.resp.CzgResult;
import com.czg.utils.AssertUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


/**
 * 拍照数签子
 * @author ww
 */
@RestController
@RequestMapping("/admin/stick")
public class StickCountController {

    @Resource
    private MkOcrCountStickService stickCountService;

    /**
     * 文件上传并返回点数统计结果
     *
     * @param file 上传的图片文件
     * @return 点数统计结果
     */
    @PostMapping("/count")
    public CzgResult<Integer> uploadAndCount(MultipartFile file) throws IOException {
        AssertUtil.isNull(file, "上传文件不能为空");
        // 9. 返回成功结果
        return CzgResult.success(stickCountService.getCountStick(file.getBytes(), file.getOriginalFilename()));
    }
}
