LoginController.java 1.22 KB
package com.server.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.server.shiro.persistent.bean.SysUser;
import com.server.shiro.persistent.service.LoginService;
import com.server.utils.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping(BaseController.OSS_NAMESPACE + "/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录
     *
     * @return
     */
    @PostMapping("/auth")
    public JSONObject authLogin(@RequestParam String username,@RequestParam String password) {
//        CommonUtil.hasAllRequired(requestJson, "username,password");
        JSONObject obj=new JSONObject();
        obj.put("username",username);
        obj.put("password", MD5.md5(MD5.md5(password)));
        return loginService.authLogin(obj);
    }

    /**
     * 查询当前登录用户的信息
     *
     * @return
     */
    @PostMapping("/getInfo")
    public SysUser getInfo() {
        return loginService.getInfo();
    }

    /**
     * 登出
     *
     * @return
     */
    @GetMapping("/logout")
    public void logout() {
        loginService.logout();
    }
}