|
@@ -1,13 +1,15 @@
|
|
-package com.gihon.user.controller;
|
|
|
|
|
|
+package com.gihon.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.gihon.common.web.response.PageBean;
|
|
import com.gihon.common.web.response.PageBean;
|
|
import com.gihon.common.web.response.PageResponse;
|
|
import com.gihon.common.web.response.PageResponse;
|
|
import com.gihon.common.web.response.Response;
|
|
import com.gihon.common.web.response.Response;
|
|
import com.gihon.common.web.response.ResponseStatus;
|
|
import com.gihon.common.web.response.ResponseStatus;
|
|
-import com.gihon.security.encoder.MyPasswordEncoder;
|
|
|
|
-import com.gihon.user.entity.User;
|
|
|
|
-import com.gihon.user.service.UserService;
|
|
|
|
|
|
+import com.gihon.configSecurity.encoder.MyPasswordEncoder;
|
|
|
|
+import com.gihon.entity.User;
|
|
|
|
+import com.gihon.service.UserService;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -20,6 +22,7 @@ import java.util.List;
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/user")
|
|
@RequestMapping("/user")
|
|
|
|
+@Api(value = "用户接口", tags = "用户接口")
|
|
public class UserController {
|
|
public class UserController {
|
|
@Autowired
|
|
@Autowired
|
|
private UserService userService;
|
|
private UserService userService;
|
|
@@ -34,9 +37,10 @@ public class UserController {
|
|
* @return com.gihon.common.http.Response
|
|
* @return com.gihon.common.http.Response
|
|
*/
|
|
*/
|
|
//@Secured(value = {"ROLE_管理员", "ROLE_超级管理员"})
|
|
//@Secured(value = {"ROLE_管理员", "ROLE_超级管理员"})
|
|
|
|
+ @ApiOperation("分页查询用户列表")
|
|
@GetMapping("/getUsersByPage")
|
|
@GetMapping("/getUsersByPage")
|
|
public PageResponse<PageBean<User>> getUsersByPage(
|
|
public PageResponse<PageBean<User>> getUsersByPage(
|
|
- @RequestParam(required = false,defaultValue = "0") int page,
|
|
|
|
|
|
+ @RequestParam(required = false,defaultValue = "1") int page,
|
|
@RequestParam(required = false, defaultValue = "10") int rows) {
|
|
@RequestParam(required = false, defaultValue = "10") int rows) {
|
|
PageResponse byPage = userService.getByPage(page, rows);
|
|
PageResponse byPage = userService.getByPage(page, rows);
|
|
return byPage;
|
|
return byPage;
|
|
@@ -51,6 +55,7 @@ public class UserController {
|
|
* @return com.gihon.common.http.Response
|
|
* @return com.gihon.common.http.Response
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("查询 用户信息by用户ID")
|
|
@GetMapping("/userByID")
|
|
@GetMapping("/userByID")
|
|
public Response userFindOne(@RequestParam Long id){
|
|
public Response userFindOne(@RequestParam Long id){
|
|
User userInfo = userService.getById(id);
|
|
User userInfo = userService.getById(id);
|
|
@@ -64,7 +69,8 @@ public class UserController {
|
|
* @param id 用户id
|
|
* @param id 用户id
|
|
* @return com.gihon.common.http.Response<java.util.List<java.lang.String>>
|
|
* @return com.gihon.common.http.Response<java.util.List<java.lang.String>>
|
|
*/
|
|
*/
|
|
- @RequestMapping("/getPermissionsByUserId")
|
|
|
|
|
|
+ @ApiOperation("根据用户id 查找对应权限")
|
|
|
|
+ @GetMapping("/getPermissionsByUserId")
|
|
public Response<List<String>> getPermissionsByUserId(Long id){
|
|
public Response<List<String>> getPermissionsByUserId(Long id){
|
|
List<String> permissions = userService.findPermissionsByUserId(id);
|
|
List<String> permissions = userService.findPermissionsByUserId(id);
|
|
return Response.ok(permissions);
|
|
return Response.ok(permissions);
|
|
@@ -83,6 +89,7 @@ public class UserController {
|
|
*/
|
|
*/
|
|
|
|
|
|
//@Secured(value = {"addUser"})
|
|
//@Secured(value = {"addUser"})
|
|
|
|
+ @ApiOperation("增加用户")
|
|
@PostMapping("/addUser")
|
|
@PostMapping("/addUser")
|
|
public Response<User> addUser(@RequestBody User user) {
|
|
public Response<User> addUser(@RequestBody User user) {
|
|
Response<User> addUser = userService.addUser(user);
|
|
Response<User> addUser = userService.addUser(user);
|
|
@@ -98,7 +105,8 @@ public class UserController {
|
|
* @param RoleIds
|
|
* @param RoleIds
|
|
* @return com.gihon.common.web.response.Response
|
|
* @return com.gihon.common.web.response.Response
|
|
*/
|
|
*/
|
|
- @RequestMapping("/addRole4User")
|
|
|
|
|
|
+ @ApiOperation("用户ById")
|
|
|
|
+ @PostMapping("/addRole4User")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public Response addRole4User(@RequestBody User user,@RequestParam("RoleIds") Long[] RoleIds){
|
|
public Response addRole4User(@RequestBody User user,@RequestParam("RoleIds") Long[] RoleIds){
|
|
Response response = userService.addRole4User(user,RoleIds);
|
|
Response response = userService.addRole4User(user,RoleIds);
|
|
@@ -113,6 +121,7 @@ public class UserController {
|
|
* @param id
|
|
* @param id
|
|
* @return com.gihon.common.http.Response
|
|
* @return com.gihon.common.http.Response
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("删除用户")
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@GetMapping(value = "/deleteUser")
|
|
@GetMapping(value = "/deleteUser")
|
|
public Response deleteUser(@RequestParam Long id) {
|
|
public Response deleteUser(@RequestParam Long id) {
|
|
@@ -126,6 +135,7 @@ public class UserController {
|
|
}
|
|
}
|
|
|
|
|
|
//@PreAuthorize("hasAuthority('updateUser')")
|
|
//@PreAuthorize("hasAuthority('updateUser')")
|
|
|
|
+ @ApiOperation("修改密码")
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@PostMapping(value = "/setUser")
|
|
@PostMapping(value = "/setUser")
|
|
/**
|
|
/**
|