// Path: service/src/main/java/com/yuzhi/back/common/JsonResult.java
// @SuppressWarnings("serial")
// public class JsonResult<T> implements Serializable {
// 
// 	private int code;
// 	private String msg;
// 	private T body;
// 	
// 	public JsonResult() {
// 	}
// 	
// 	public JsonResult(int code, String msg) {
// 		this.code = code;
// 		this.msg = msg;
// 	}
// 	
// 	public JsonResult(int code, String msg, T body) {
// 		this.code = code;
// 		this.msg = msg;
// 		this.body = body;
// 	}
// 
//     public static JsonResult success() {
//         return new JsonResult(ResultCode.SUCCESS_CODE, ResultCode.SUCCESS_MSG);
//     }
// 
//     public static JsonResult error() {
//         return new JsonResult(ResultCode.ERROR_CODE, ResultCode.ERROR_MSG);
//     }
// 	
// 	public int getCode() {
// 		return code;
// 	}
// 	public void setCode(int code) {
// 		this.code = code;
// 	}
// 	public String getMsg() {
// 		return msg;
// 	}
// 	public void setMsg(String msg) {
// 		this.msg = msg;
// 	}
// 	public T getBody() {
// 		return body;
// 	}
// 	public void setBody(T body) {
// 		this.body = body;
// 	}
// 
// 	@Override
//     public String toString() {
// 		String bodystr = "null";
// 		if (body != null)
// 			bodystr = body.toString();
//         return "JsonResult{" +
//                 "code=" + code +
//                 ", message=" + msg +
//                 ", body=" + bodystr +
//                 "}";
//     }
// 	
// }
// 
// Path: service/src/main/java/com/yuzhi/back/common/ResultCode.java
// public class ResultCode implements Serializable {
//     //成功
//     public static final int SUCCESS_CODE = 200;
//     public static final String SUCCESS_MSG = "操作成功";
// 
//     //失败
//     public static final int ERROR_CODE = 500;
//     public static final String ERROR_MSG = "服务器内部错误，请重试";
// 
//     /**通用错误码：6xx,记录业务级别通用错误，比如：数据库错误**/
//     public static final int PARAM_ERROR_CODE = 601;
//     public static final String PARAM_ERROR_MSG = "参数错误，请检查参数";
// 
//     public static final int DB_ERROR_CODE = 602;
//     public static final String DB_ERROR_MSG = "数据库操作失败，请稍后再试";
// 
//     //Token有误
//     public static final int TOKEN_ERROR_CODE = 603;
//     public static final String TOKEN_ERROR_MSG = "Token过期，请重新登录";
// 
// 
//     /**业务相关错误码：7xx,记录业务级别具体错误，比如登陆密码错误**/
//     public static final int ERROR_CODE_701 = 701;
//     public static final int ERROR_CODE_702 = 702;
//     public static final int ERROR_CODE_703 = 703;
//     public static final int ERROR_CODE_704 = 704;
//     public static final int ERROR_CODE_705 = 705;
//     public static final int ERROR_CODE_706 = 706;
//     public static final int ERROR_CODE_707 = 707;
//     public static final int ERROR_CODE_708 = 708;
//     public static final int ERROR_CODE_709 = 709;
// 
// }


import com.yuzhi.back.common.JsonResult;
import com.yuzhi.back.common.ResultCode;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
package com.yuzhi.back.web.controller;


/**
 * Created by tiansj on 15/7/14.
 */
@Controller
@RequestMapping(value = "/")
public class LogoutController {

    @RequestMapping(value = "logout")
    public String logout() {
        Subject currentUser = SecurityUtils.getSubject();
        if(currentUser != null) {
            currentUser.logout();
        }
        return "redirect:/login.html";
    }

    @RequestMapping(value = "v1/api0/security/logout")
    @ResponseBody
    public JsonResult logoutAjax() {
        JsonResult jsonResult = new JsonResult(ResultCode.SUCCESS_CODE, ResultCode.SUCCESS_MSG);
        Subject currentUser = SecurityUtils.getSubject();
// Path: service/src/main/java/com/yuzhi/back/common/JsonResult.java
// @SuppressWarnings("serial")
// public class JsonResult<T> implements Serializable {
// 
// 	private int code;
// 	private String msg;
// 	private T body;
// 	
// 	public JsonResult() {
// 	}
// 	
// 	public JsonResult(int code, String msg) {
// 		this.code = code;
// 		this.msg = msg;
// 	}
// 	
// 	public JsonResult(int code, String msg, T body) {
// 		this.code = code;
// 		this.msg = msg;
// 		this.body = body;
// 	}
// 
//     public static JsonResult success() {
//         return new JsonResult(ResultCode.SUCCESS_CODE, ResultCode.SUCCESS_MSG);
//     }
// 
//     public static JsonResult error() {
//         return new JsonResult(ResultCode.ERROR_CODE, ResultCode.ERROR_MSG);
//     }
// 	
// 	public int getCode() {
// 		return code;
// 	}
// 	public void setCode(int code) {
// 		this.code = code;
// 	}
// 	public String getMsg() {
// 		return msg;
// 	}
// 	public void setMsg(String msg) {
// 		this.msg = msg;
// 	}
// 	public T getBody() {
// 		return body;
// 	}
// 	public void setBody(T body) {
// 		this.body = body;
// 	}
// 
// 	@Override
//     public String toString() {
// 		String bodystr = "null";
// 		if (body != null)
// 			bodystr = body.toString();
//         return "JsonResult{" +
//                 "code=" + code +
//                 ", message=" + msg +
//                 ", body=" + bodystr +
//                 "}";
//     }
// 	
// }
// 
// Path: service/src/main/java/com/yuzhi/back/common/ResultCode.java
// public class ResultCode implements Serializable {
//     //成功
//     public static final int SUCCESS_CODE = 200;
//     public static final String SUCCESS_MSG = "操作成功";
// 
//     //失败
//     public static final int ERROR_CODE = 500;
//     public static final String ERROR_MSG = "服务器内部错误，请重试";
// 
//     /**通用错误码：6xx,记录业务级别通用错误，比如：数据库错误**/
//     public static final int PARAM_ERROR_CODE = 601;
//     public static final String PARAM_ERROR_MSG = "参数错误，请检查参数";
// 
//     public static final int DB_ERROR_CODE = 602;
//     public static final String DB_ERROR_MSG = "数据库操作失败，请稍后再试";
// 
//     //Token有误
//     public static final int TOKEN_ERROR_CODE = 603;
//     public static final String TOKEN_ERROR_MSG = "Token过期，请重新登录";
// 
// 
//     /**业务相关错误码：7xx,记录业务级别具体错误，比如登陆密码错误**/
//     public static final int ERROR_CODE_701 = 701;
//     public static final int ERROR_CODE_702 = 702;
//     public static final int ERROR_CODE_703 = 703;
//     public static final int ERROR_CODE_704 = 704;
//     public static final int ERROR_CODE_705 = 705;
//     public static final int ERROR_CODE_706 = 706;
//     public static final int ERROR_CODE_707 = 707;
//     public static final int ERROR_CODE_708 = 708;
//     public static final int ERROR_CODE_709 = 709;
// 
// }


// Path: web/src/main/java/com/yuzhi/back/web/controller/LogoutController.java
import com.yuzhi.back.common.JsonResult;
import com.yuzhi.back.common.ResultCode;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

package com.yuzhi.back.web.controller;


/**
 * Created by tiansj on 15/7/14.
 */
@Controller
@RequestMapping(value = "/")
public class LogoutController {

    @RequestMapping(value = "logout")
    public String logout() {
        Subject currentUser = SecurityUtils.getSubject();
        if(currentUser != null) {
            currentUser.logout();
        }
        return "redirect:/login.html";
    }

    @RequestMapping(value = "v1/api0/security/logout")
    @ResponseBody
    public JsonResult logoutAjax() {
        JsonResult jsonResult = new JsonResult(ResultCode.SUCCESS_CODE, ResultCode.SUCCESS_MSG);
        Subject currentUser = SecurityUtils.getSubject();
        if(currentUser != null) {