package com.sunxung.factoring.web.sys;

import java.util.HashMap;
import java.util.Map;

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.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sunxung.factoring.service.sys.AuthorityService;

@Controller
public class AuthorityController {

    // private static String PREFIX = "sys/authority/";

    @Autowired
    private AuthorityService authorityService;

//    /**
//     * 跳转到登录界面
//     *
//     * @return
//     */
//    @RequestMapping("/authority/goLogin")
//    public String goLogin() {
//        return PREFIX + "goLogin";
//    }
//
//    /**
//     * 进入登录界面
//     *
//     * @param response
//     * @param model
//     * @return
//     */
//    @RequestMapping("/authority/login")
//    public String login(HttpServletResponse response, Model model) {
//        return PREFIX + "login";
//    }

    /**
     * 用户登录
     * 
     * @param loginName
     * @param password
     * @return
     */
    @RequestMapping("/authority/do_login")
    @ResponseBody
    public Object do_login(String loginName, String password) {
        return authorityService.login(loginName, password);
    }

    /**
     * 权限判断
     * 
     * @param response
     * @param model
     * @return
     */
    @RequestMapping("/authority/noPermission")
    @ResponseBody
    public Object noPermission(HttpServletResponse response, Model model) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("success", "false");
        map.put("desc", "无权限");
        return map;
    }
}
