package com.czg.controller.user;

import com.czg.resp.CzgResult;
import com.czg.service.account.util.AliOssUtil;
import jakarta.annotation.Resource;
import org.apache.commons.io.FilenameUtils;
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;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/user/common")
public class UCommonController {
    @Resource
    private AliOssUtil aliOssUtil;

    /**
     * 文件上传
     * @param file 文件信息
     * @return 上传路径
     * @throws Exception 异常
     */
    @PostMapping("/upload")
    public CzgResult<?> upload(MultipartFile file) throws Exception {
        return CzgResult.success(aliOssUtil.uploadSuffix(file.getBytes(), FilenameUtils.getExtension(file.getOriginalFilename())));
    }
}
