| | |
| | | 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.BattInfMapper; |
| | | import com.whyc.mapper.UserMapper; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.catalina.User; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @RestController |
| | | @RequestMapping("changeUser") |
| | | @Api(tags = "切换用户") |
| | | public class ChangeUserController { |
| | | |
| | | @Resource |
| | | private UserMapper mapper; |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "切换用户") |
| | | public void changeUser(@RequestParam Long userId){ |
| | | UserInf userInf = new UserInf(); |
| | | userInf.setUName("superuser"); |
| | | userInf.setUId(userId); |
| | | QueryWrapper<UserInf> query = Wrappers.query(); |
| | | query.eq("uId",userId).last(" limit 1"); |
| | | UserInf userInf = mapper.selectOne(query); |
| | | ActionUtil.getSession().setAttribute("user",userInf); |
| | | } |
| | | |