DownloadAction.java 1.8 KB
package com.cjs.site.action.info;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cjs.site.biz.info.DownloadBiz;
import com.cjs.site.model.download.DownInfo;
import com.cjs.site.util.web.ActionUtil;

/**
 * 下载
 * 
 * @author tongyufu
 *
 */

@Controller
public class DownloadAction {

    @Autowired
    private DownloadBiz download;

    /**页面中转*/
    @RequestMapping("/download")
    public String toDownLoad() {
        return "info/download.jsp";
    }

    /** 文件下载 */
    /*
    public ResponseEntity<byte[]> download(String file, Integer type,
                            HttpServletRequest request) throws IOException {
        DownInfo downInfo = new DownInfo();
        downInfo.setSort(type);
        downInfo.setDownIp(ActionUtil.getIP());
        downInfo.setDownTime(new Date());
        download.addDownLoad(downInfo);
        return download.download(file, request);
    }*/

    /** 客户端下载 */
    @RequestMapping("/downloadFile")
    public void download2(String file, Integer type, HttpServletRequest request,
                          HttpServletResponse response) {
        DownInfo downInfo = new DownInfo();
        if (type != null) {
            downInfo.setSort(type);
        } else {
            downInfo.setSort(0);
        }
        downInfo.setDownIp(ActionUtil.getIP());
        downInfo.setDownTime(new Date());
        download.addDownLoad(downInfo);
        download.download2(file, request, response);
    }

    /**下载统计*/
    public String getCount() {
        download.getCount();
        return null;
    }

}