package org.springblade.applet;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R;
import org.springblade.modules.pl.productRework.entity.ProductReworkEntity;
import org.springblade.modules.resource.builder.OssBuilder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("wx/communal/api")
@Api(value = "产品", tags = "产品相关外放接口")
@Slf4j
public class CommunalApiController {

	private final OssBuilder ossBuilder;

	/**
	 * 文件上传
	 */
	@PostMapping("/upload")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "文件上传", notes = "传入productBatch")
	public R upload(@RequestParam MultipartFile file) {

		BladeFile bladeFile = ossBuilder.template("000000","minio").putFile("rework/"+file.getOriginalFilename(),file);
		return R.success(bladeFile.getLink());
	}
}
