package cn.qinys.platform.upms.api.controller;


import cn.qinys.platform.base.dto.AttachmentDTO;
import cn.qinys.platform.base.response.Result;
import cn.qinys.platform.base.response.ResultCodeEnum;
import cn.qinys.platform.upms.api.service.IAttachmentService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Description:
 *
 * @author tanlie
 * Date: 2024/3/4 15:34
 */
@RestController
@RequestMapping("/upms/attachment")
@AllArgsConstructor
@Slf4j
public class AttachmentController {

    private final IAttachmentService attachmentService;

    /**
     * 上传文件
     *
     * @param file
     * @return
     */
    @PostMapping("/upload-file")
    public Result<AttachmentDTO> uploadFileAttachment(@RequestParam("file") MultipartFile file) {
        AttachmentDTO res = attachmentService.uploadFileAttachment(file);
        return new Result<>(ResultCodeEnum.SUCCESS, res);
    }


}
