package com.wisedu.coeus.web;


import java.io.IOException;

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

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wisedu.coeus.core.security.LoginCheck;
import com.wisedu.coeus.util.UrlUtils;

/**
 * Created by 01312170 on 14-9-11.
 */
@Controller
public class Attachment extends HttpServlet {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@LoginCheck("false")
    @RequestMapping(value = "/attach/userAvatar/{size}/{userId}")
    public void userAvatar(HttpServletRequest request, HttpServletResponse response,
                           @PathVariable Long userId, @PathVariable Long size) throws ServletException, IOException {

        StringBuilder sbUrl = new StringBuilder(1024);
//        CoeusUser user = coeusUserService.queryCoeusUserById(userId);
//        if (user == null) {
//            user = new CoeusUser();
//        }
//
//        String useravatar = user.getUseravatar();
//        if (30==size.intValue()) {
//            useravatar = user.getUseravatar30();
//        } else if (60==size.intValue()) {
//            useravatar = user.getUseravatar60();
//        } else if (90==size.intValue()) {
//            useravatar = user.getUseravatar90();
//        }
//        if(!useravatar.startsWith("/")){
//            sbUrl.append("/");
//        }
//        sbUrl.append(useravatar);

        UrlUtils.redirect(request, response, sbUrl.toString());
    }
}

