package cn.com.capcloud.api;

import cn.com.capcloud.api.action.ApiFileAction;
import cn.com.capcloud.ccui.core.common.json.JackJSON;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@CrossOrigin//支持跨域请求
@RestController
@RequestMapping("/api/file")
public class ApiFileController {

    @Autowired
    private ApiFileAction apiFileAction;


    @RequestMapping("/upload")
    public KHCResponseEntity upload(HttpServletRequest request) {
        String retStr=apiFileAction.upload(request);
        return JackJSON.parseObject(retStr, KHCResponseEntity.class);
    }

    @RequestMapping("/downFile")
    public void downFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
        apiFileAction.downFile(request, response);
    }

}
