whyclxw
2025-03-24 1b1a6c26d819f386e8c66bbed3aafc49e6413963
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.pojo.db_user.UserInf;
import com.whyc.service.UserInfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
 
@RestController
@Api(tags = "用户管理")
@RequestMapping("userInf")
public class UserInfController {
    @Autowired
    private UserInfService service;
 
    @ApiOperation(value = "查询所有用户信息",notes = "排除uid在100以内的(100以内默认是管理员)")
    @GetMapping("getAllUser")
    public Response getAllUser(@RequestParam(required = false) String uname,@RequestParam(required = false) String realName
            ,@RequestParam int areaId ,@RequestParam int pageCurr, @RequestParam int pageSize){
        return service.getAllUser(uname,realName,areaId,pageCurr,pageSize);
    }
 
    @ApiOperation(value = "查询所有用户信息(不分页除内置用户外用于下拉)")
    @GetMapping("getUinf")
    public Response getUinf(){
        return service.getUinf();
    }
 
    /*@ApiOperation(value = "编辑用户名")
    @GetMapping("updateUser")
    public Response updateUser(@RequestParam int uid,@RequestParam(required = false) String uname){
        return service.updateUser(uid,uname);
    }*/
    @ApiOperation(value = "新添加用户信息")
    @PostMapping("addUser")
    public Response addUser(@RequestBody UserInf uinf){
        return service.addUser(uinf);
    }
    @ApiOperation(value = "删除用户信息")
    @GetMapping("deleteUser")
    public Response deleteUser(@RequestParam String uname){
        return service.delUser(uname);
    }
 
    @ApiOperation(value = "将用户添加至100~1000管理员")
    @GetMapping("improveRole")
    public Response improveRole(@RequestParam int uid){
        return service.improveRole(uid);
    }
 
    @ApiOperation(value = "将管理员变成普通用户")
    @GetMapping("dropRole")
    public Response dropRole(@RequestParam int uid, HttpServletRequest request){
        return service.dropRole(uid,request);
    }
 
    @GetMapping("getUserNameList")
    @ApiOperation(tags = "操作日志",value = "操作人姓名-查询-操作日志使用")
    public Response getUserNameList(){
        return service.getUserNameList();
    }
 
    @GetMapping("resetSnId")
    @ApiOperation(value = "重置密码")
    public Response resetSnId(@RequestParam int uid){
        return service.resetSnId( uid);
    }
 
    @GetMapping("getUnloadUinf")
    @ApiOperation(value = "查询未被指定区域的用户")
    public Response getUnloadUinf(){
        return service.getUnloadUinf();
    }
    @GetMapping("getLockWithAuth")
    @ApiOperation(value = "查询当前用户授予权限的锁")
    public Response getLockWithAuth(){
        return service.getLockWithAuth();
    }
 
    @ApiOperation(value = "编辑用户信息")
    @PostMapping("updateUinf")
    public Response updateUinf(@RequestBody UserInf uinf){
        return service.updateUinf(uinf);
    }
 
    @GetMapping("searchUKeyToUName")
    @ApiOperation(value = "根据Ukey查询用户")
    public Response searchUKeyToUName(@RequestParam String ukeyId){
        UserInf userInf = service.getUserByUKeyId(ukeyId);
        Response response = new Response();
        if (userInf!=null){
            response.setII(1,true,userInf,"UKey有绑定用户");
        }else{
            response.set(1,false,"Ukey没有绑定用户");
        }
        return response;
    }
 
    @GetMapping("searchUNameToUKey")
    @ApiOperation(value = "根据用户名查绑定的Ukey")
    public Response searchUNameToUKey(@RequestParam String uname){
        UserInf userInf = service.getUserByUserName(uname);
        Response response = new Response();
        if (userInf!=null){
            if (StringUtils.isEmpty(userInf.getUkeyId())){
                response.set(-1,false,"该用户没有绑定Ukey");
            }else {
                response.setII(1,true,userInf,"该用户有绑定Ukey");
            }
        }else{
            response.set(0,false,"该用户不存在");
        }
        return response;
    }
    @PostMapping("bindUkey")
    @ApiOperation(value = "绑定uKey")
    public Response bindUkey(@RequestBody UserInf userInf){
        boolean b = service.bindUkey(userInf);
        if (b){
            return new Response().set(1,true,"绑定成功");
        }else {
            return new Response().set(1,false,"绑定失败");
        }
 
    }
 
}