|
@@ -1,27 +1,17 @@
|
|
package com.ym.mec.auth.web.controller;
|
|
package com.ym.mec.auth.web.controller;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
|
-
|
|
|
|
-import java.util.Date;
|
|
|
|
-
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
-
|
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
|
+import com.ym.mec.auth.service.SysRoleService;
|
|
|
|
+import com.ym.mec.auth.service.SysUserRoleService;
|
|
import com.ym.mec.auth.service.SysUserService;
|
|
import com.ym.mec.auth.service.SysUserService;
|
|
import com.ym.mec.auth.web.controller.queryInfo.SysUserQueryInfo;
|
|
import com.ym.mec.auth.web.controller.queryInfo.SysUserQueryInfo;
|
|
import com.ym.mec.common.controller.BaseController;
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
|
+import io.swagger.annotations.*;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
@RestController()
|
|
@RestController()
|
|
@RequestMapping("user")
|
|
@RequestMapping("user")
|
|
@@ -30,12 +20,16 @@ public class UserController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysUserService sysUserService;
|
|
private SysUserService sysUserService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserRoleService sysUserRoleService;
|
|
|
|
|
|
@ApiOperation("根据用户名查询用户信息接口")
|
|
@ApiOperation("根据用户名查询用户信息接口")
|
|
@ApiImplicitParam(name = "username", value = "用户名", required = true, dataType = "String", paramType = "path")
|
|
@ApiImplicitParam(name = "username", value = "用户名", required = true, dataType = "String", paramType = "path")
|
|
@GetMapping("/{username}")
|
|
@GetMapping("/{username}")
|
|
public Object getUser(@PathVariable("username") String username) {
|
|
public Object getUser(@PathVariable("username") String username) {
|
|
- return sysUserService.queryUserInfoByUsername(username);
|
|
|
|
|
|
+ return succeed(sysUserService.queryUserInfoByUsername(username));
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "分页查询用户信息")
|
|
@ApiOperation(value = "分页查询用户信息")
|
|
@@ -79,4 +73,28 @@ public class UserController extends BaseController {
|
|
sysUserService.update(sysUser);
|
|
sysUserService.update(sysUser);
|
|
return succeed();
|
|
return succeed();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "获取用户角色列表")
|
|
|
|
+ @GetMapping("/getRole/{id}")
|
|
|
|
+ public Object getRole(@ApiParam(value = "用户编号", required = true) @PathVariable("id") Integer id) {
|
|
|
|
+ return succeed(sysRoleService.findRoleByUserId(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "用户角色新增")
|
|
|
|
+ @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
|
|
|
|
+ @ApiImplicitParam(name = "roleIds", value = "角色id,逗号分隔", required = true, dataType = "String") })
|
|
|
|
+ @PostMapping("/addRole")
|
|
|
|
+ public Object getRole(Integer userId,String roleIds) {
|
|
|
|
+ sysUserRoleService.batchInsert(userId,roleIds);
|
|
|
|
+ return succeed();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "用户角色删除")
|
|
|
|
+ @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
|
|
|
|
+ @ApiImplicitParam(name = "roleIds", value = "角色id,逗号分隔", required = true, dataType = "String") })
|
|
|
|
+ @DeleteMapping("/delRole")
|
|
|
|
+ public Object delRole(Integer userId,String roleIds) {
|
|
|
|
+ sysUserRoleService.batchDel(userId,roleIds);
|
|
|
|
+ return succeed();
|
|
|
|
+ }
|
|
}
|
|
}
|