月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-06-02 dc0d4a7907f3affdbc116288cac24ad4ba05f319
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
package com.lf.server.controller.all;
 
import com.lf.server.annotation.SysLog;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.data.DirEntity;
import com.lf.server.entity.sys.RoleEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.service.data.DirService;
import com.lf.server.service.sys.RoleService;
import com.lf.server.service.sys.TokenService;
import com.lf.server.service.sys.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * FME接口控制器
 * @author WWW
 */
@Api(tags = "系统对接\\FME")
@RestController
@RequestMapping("/fmeIt")
public class FmeItController extends BaseController {
    @Autowired
    UserService userService;
 
    @Autowired
    RoleService roleService;
 
    @Autowired
    TokenService tokenService;
 
    @Autowired
    DirService dirService;
 
    @SysLog()
    @ApiOperation(value = "查询是/否为管理员")
    @GetMapping(value = "/selectForIsAdmin")
    public ResponseMsg<Boolean> selectForIsAdmin(HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", false);
            }
 
            Integer rows = userService.selectForIsAdmin(ue.getId());
 
            return success("成功", rows > 0);
        } catch (Exception ex) {
            return fail(ex, false);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "根据ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectUser")
    public ResponseMsg<UserEntity> selectUser(int id) {
        try {
            UserEntity userEntity = userService.selectUser(id);
 
            return success(userEntity);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "根据用户ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户ID", dataType = "String", paramType = "query", example = "admin")
    })
    @GetMapping(value = "/selectByUid")
    public ResponseMsg<UserEntity> selectByUid(String uid) {
        try {
            if (StringHelper.isEmpty(uid)) {
                fail("用户ID不能为空", null);
            }
 
            UserEntity userEntity = userService.selectByUid(uid);
 
            return success(userEntity);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "分页查询用户并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "室"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageForUser")
    public ResponseMsg<List<UserEntity>> selectByPageForUser(String uname, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = userService.selectCount(uname, null);
            if (count == 0) {
                return success(0, null);
            }
            List<UserEntity> rs = userService.selectByPage(uname, null, pageSize, pageSize * (pageIndex - 1));
 
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询是/否为管理员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectIsAdmin")
    public ResponseMsg<Boolean> selectIsAdmin(Integer id) {
        try {
            UserEntity ue = userService.selectUser(id);
            if (ue == null) {
                return fail("用户不存在", false);
            }
 
            Integer rows = userService.selectForIsAdmin(ue.getId());
 
            return success("成功", rows > 0);
        } catch (Exception ex) {
            return fail(ex, false);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询管理员用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "管理员类别", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectAdminUsers")
    public ResponseMsg<Object> selectAdminUsers(Integer type) {
        try {
            if (null == type || type < 1) {
                return fail("管理员类别不能为空或小于1", false);
            }
 
            List<UserEntity> rs = userService.selectAdminUsers(type);
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, false);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "根据用户ID查询角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectRoleByUserId")
    public ResponseMsg<Object> selectRoleByUserId(Integer id) {
        try {
            if (null == id || id < 1) {
                return fail("用户ID不能为空或小于1", false);
            }
 
            List<RoleEntity> rs = userService.selectRoleByUserId(id);
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, false);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "根据角色查询用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "角色ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectUserByRoleId")
    public ResponseMsg<Object> selectUserByRoleId(Integer id) {
        try {
            if (null == id || id < 1) {
                return fail("用户ID不能为空或小于1", false);
            }
 
            List<UserEntity> rs = userService.selectUserByRoleId(id);
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, false);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "根据ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectRole")
    public ResponseMsg<RoleEntity> selectRole(int id) {
        try {
            RoleEntity roleEntity = roleService.selectRole(id);
 
            return success(roleEntity);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "分页查询角色并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "Admin"),
            @ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageForRole")
    public ResponseMsg<List<RoleEntity>> selectByPageForRole(String name, Integer depid, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
 
            int count = roleService.selectCount(name, depid);
            if (count == 0) {
                return success(0, null);
            }
 
            List<RoleEntity> rs = roleService.selectByPage(name, depid, pageSize, pageSize * (pageIndex - 1));
 
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询根目录")
    @GetMapping(value = "/selectDirRoot")
    public ResponseMsg<List<DirEntity>> selectDirRoot() {
        try {
            List<DirEntity> list = dirService.selectDirRoot();
 
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "西")
    })
    @GetMapping(value = "/selectProject")
    public ResponseMsg<List<DirEntity>> selectProject(String name) {
        try {
            List<DirEntity> list = dirService.selectProject(name);
 
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询项目目录树")
    @GetMapping(value = "/selectDirsForPrj")
    public ResponseMsg<List<DirEntity>> selectDirsForPrj() {
        try {
            List<DirEntity> list = dirService.selectDirsForPrj();
 
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
}