| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户信息 |
| | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysUser user) |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | return getDataTable(list); |
| | | return userService.selectPageUserList(user); |
| | | } |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | if (StringUtils.isNotNull(userId)) |
| | | if (Validator.isNotNull(userId)) |
| | | { |
| | | ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId)); |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | |
| | | { |
| | | return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | else if (Validator.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | else if (Validator.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | if (Validator.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) |
| | | { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | else if (Validator.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) |
| | | { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) |