package cn.qinys.platform.mobile.controller;

import cn.qinys.platform.base.dto.AttachmentDTO;
import cn.qinys.platform.base.response.Result;
import cn.qinys.platform.mobile.service.AttachmentService;
import jakarta.annotation.Resource;
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;

@Slf4j
@RestController
@RequestMapping("/dgapi/mobile/upload")
public class FileUploadController {

    @Resource
    private AttachmentService attachmentService;


    @PostMapping("/image")
    public Result<AttachmentDTO> uploadImage(@RequestParam("file") MultipartFile file) {
        AttachmentDTO attachmentDTO = attachmentService.uploadFileAttachment(file);
        return new Result<>(attachmentDTO);
    }
}
