| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.DocUserMapper; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.service.DocUserService; |
| | | import com.whyc.service.LoginService; |
| | | import com.whyc.util.ActionUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | |
| | | @Autowired |
| | | private DocUserService userService; |
| | | |
| | | @Autowired |
| | | private DocUserMapper userMapper; |
| | | |
| | | @Autowired |
| | | private LoginService service; |
| | | |
| | | @PostMapping("/") |
| | | @ApiOperation(value ="登录") |
| | | public Response login(@RequestParam String name, String snId, HttpServletRequest request){ |
| | | return userService.login(name,snId,request); |
| | | } |
| | | |
| | | @PutMapping("changeUser") |
| | | @ApiOperation(value = "切换用户") |
| | | public boolean changeUser(@RequestParam Long userId){ |
| | | QueryWrapper<DocUser> query = Wrappers.query(); |
| | | query.eq("id",userId).last(" limit 1"); |
| | | DocUser userInf = userMapper.selectOne(query); |
| | | ActionUtil.getSession().setAttribute("user",userInf); |
| | | return true; |
| | | } |
| | | |
| | | @PostMapping("logout") |
| | | @ApiOperation(value ="退出登录") |
| | | public void logout(){ |
| | | service.logout(); |
| | | } |
| | | |
| | | } |