|
@@ -32,13 +32,12 @@ import com.boman.system.api.model.LoginUser;
|
|
|
|
|
|
/**
|
|
|
* 用户信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/user")
|
|
|
-public class SysUserController extends BaseController
|
|
|
-{
|
|
|
+public class SysUserController extends BaseController {
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
|
|
@@ -59,8 +58,7 @@ public class SysUserController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "system:user:list")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(SysUser user)
|
|
|
- {
|
|
|
+ public TableDataInfo list(SysUser user) {
|
|
|
startPage();
|
|
|
List<SysUser> list = userService.selectUserList(user);
|
|
|
return getDataTable(list);
|
|
@@ -69,8 +67,7 @@ public class SysUserController extends BaseController
|
|
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
|
|
@PreAuthorize(hasPermi = "system:user:export")
|
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, SysUser user) throws IOException
|
|
|
- {
|
|
|
+ public void export(HttpServletResponse response, SysUser user) throws IOException {
|
|
|
List<SysUser> list = userService.selectUserList(user);
|
|
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
util.exportExcel(response, list, "用户数据");
|
|
@@ -79,8 +76,7 @@ public class SysUserController extends BaseController
|
|
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
|
|
@PreAuthorize(hasPermi = "system:user:import")
|
|
|
@PostMapping("/importData")
|
|
|
- public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
|
|
- {
|
|
|
+ public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
|
|
String operName = SecurityUtils.getUsername();
|
|
@@ -89,8 +85,7 @@ public class SysUserController extends BaseController
|
|
|
}
|
|
|
|
|
|
@PostMapping("/importTemplate")
|
|
|
- public void importTemplate(HttpServletResponse response) throws IOException
|
|
|
- {
|
|
|
+ public void importTemplate(HttpServletResponse response) throws IOException {
|
|
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
util.importTemplateExcel(response, "用户数据");
|
|
|
}
|
|
@@ -99,11 +94,9 @@ public class SysUserController extends BaseController
|
|
|
* 获取当前用户信息
|
|
|
*/
|
|
|
@GetMapping("/info/{username}")
|
|
|
- public R<LoginUser> info(@PathVariable("username") String username)
|
|
|
- {
|
|
|
+ public R<LoginUser> info(@PathVariable("username") String username) {
|
|
|
SysUser sysUser = userService.selectUserByUserName(username);
|
|
|
- if (StringUtils.isNull(sysUser))
|
|
|
- {
|
|
|
+ if (StringUtils.isNull(sysUser)) {
|
|
|
return R.fail("用户名或密码错误");
|
|
|
}
|
|
|
LoginUser sysUserVo = new LoginUser();
|
|
@@ -143,12 +136,11 @@ public class SysUserController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 获取用户信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @return 用户信息
|
|
|
*/
|
|
|
@GetMapping("getInfo")
|
|
|
- public AjaxResult getInfo()
|
|
|
- {
|
|
|
+ public AjaxResult getInfo() {
|
|
|
Long id = SecurityUtils.getUserId();
|
|
|
// 角色集合
|
|
|
Set<String> roles = permissionService.getRolePermission(id);
|
|
@@ -171,15 +163,13 @@ public class SysUserController extends BaseController
|
|
|
* 根据用户编号获取详细信息
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "system:user:query")
|
|
|
- @GetMapping(value = { "/", "/{id}" })
|
|
|
- public AjaxResult getInfo(@PathVariable(value = "id", required = false) Long id)
|
|
|
- {
|
|
|
+ @GetMapping(value = {"/", "/{id}"})
|
|
|
+ public AjaxResult getInfo(@PathVariable(value = "id", required = false) Long id) {
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
List<SysRole> roles = roleService.selectRoleAll();
|
|
|
ajax.put("roles", SysUser.isAdmin(id) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
|
|
ajax.put("posts", postService.selectPostAll());
|
|
|
- if (StringUtils.isNotNull(id))
|
|
|
- {
|
|
|
+ if (StringUtils.isNotNull(id)) {
|
|
|
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(id));
|
|
|
ajax.put("postIds", postService.selectPostListById(id));
|
|
|
ajax.put("roleIds", roleService.selectRoleListById(id));
|
|
@@ -193,20 +183,14 @@ public class SysUserController extends BaseController
|
|
|
@PreAuthorize(hasPermi = "system:user:add")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@Validated @RequestBody SysUser user)
|
|
|
- {
|
|
|
- if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
|
|
- {
|
|
|
+ public AjaxResult add(@Validated @RequestBody SysUser user) {
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
|
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
|
|
- }
|
|
|
- else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
|
|
- && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
|
|
- {
|
|
|
+ } else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
|
|
+ && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
|
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
|
|
- }
|
|
|
- else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
- && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
|
|
- {
|
|
|
+ } else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
+ && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
|
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
|
}
|
|
|
user.setCreateBy(SecurityUtils.getUsername());
|
|
@@ -220,17 +204,13 @@ public class SysUserController extends BaseController
|
|
|
@PreAuthorize(hasPermi = "system:user:edit")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@Validated @RequestBody SysUser user)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
|
|
userService.checkUserAllowed(user);
|
|
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
|
|
- && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
|
|
- {
|
|
|
+ && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
|
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
|
|
- }
|
|
|
- else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
- && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
|
|
- {
|
|
|
+ } else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
+ && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
|
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
|
}
|
|
|
user.setUpdateBy(SecurityUtils.getUsername());
|
|
@@ -243,8 +223,7 @@ public class SysUserController extends BaseController
|
|
|
@PreAuthorize(hasPermi = "system:user:remove")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(userService.deleteUserByIds(ids));
|
|
|
}
|
|
|
|
|
@@ -254,8 +233,7 @@ public class SysUserController extends BaseController
|
|
|
@PreAuthorize(hasPermi = "system:user:edit")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/resetPwd")
|
|
|
- public AjaxResult resetPwd(@RequestBody SysUser user)
|
|
|
- {
|
|
|
+ public AjaxResult resetPwd(@RequestBody SysUser user) {
|
|
|
userService.checkUserAllowed(user);
|
|
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
user.setUpdateBy(SecurityUtils.getUsername());
|
|
@@ -268,8 +246,7 @@ public class SysUserController extends BaseController
|
|
|
@PreAuthorize(hasPermi = "system:user:edit")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/changeStatus")
|
|
|
- public AjaxResult changeStatus(@RequestBody SysUser user)
|
|
|
- {
|
|
|
+ public AjaxResult changeStatus(@RequestBody SysUser user) {
|
|
|
userService.checkUserAllowed(user);
|
|
|
user.setUpdateBy(SecurityUtils.getUsername());
|
|
|
return toAjax(userService.updateUserStatus(user));
|
|
@@ -282,7 +259,7 @@ public class SysUserController extends BaseController
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
@PostMapping("/listByDeptId")
|
|
|
public List<SysUser> listByDeptId(@RequestBody List<Long> deptIdList) {
|
|
|
- return userService.listByDeptId(deptIdList);
|
|
|
+ return userService.listByDeptId(deptIdList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -295,12 +272,13 @@ public class SysUserController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 为用户档案定制新增接口
|
|
|
+ *
|
|
|
* @param result 结果
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/addUser")
|
|
|
public void addUser(@Validated @RequestBody List<JSONObject> result) {
|
|
|
- userService.addUser(result);
|
|
|
+ userService.addUser(result);
|
|
|
}
|
|
|
|
|
|
|