lxw
2023-04-24 e2b4ed00f1a0012236e737a608ecfb2abbfc2eb4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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){
        QueryWrapper<UserInf> query = Wrappers.query();
        query.eq("uId",userId).last(" limit 1");
        UserInf userInf = mapper.selectOne(query);
        ActionUtil.getSession().setAttribute("user",userInf);
    }
 
}