|
@@ -2,6 +2,7 @@ package com.ozs.web.controller.system;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -10,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ozs.common.core.domain.entity.SysUserUpdate;
|
|
|
import com.ozs.common.core.domain.vo.SysUserVo;
|
|
|
import com.ozs.common.utils.AppendUtils;
|
|
|
import com.ozs.common.utils.file.FileUtils;
|
|
@@ -104,9 +106,9 @@ public class SysUserController extends BaseController {
|
|
|
if (!ObjectUtils.isEmpty(sysUserVo.getStatus())) {
|
|
|
wrapper.eq(SysUser::getStatus, sysUserVo.getStatus());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
IPage<SysUser> page = userService.page(new Page<>(sysUserVo.getPageNum(), sysUserVo.getPageSize()), wrapper);
|
|
|
- if(!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())){
|
|
|
+ if (!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())) {
|
|
|
List<SysUser> dto1 = page.getRecords().stream().map(o -> {
|
|
|
SysDept sysDept = deptService.selectDeptById(o.getDeptId());
|
|
|
if (!ObjectUtils.isEmpty(sysDept)) {
|
|
@@ -203,7 +205,7 @@ public class SysUserController extends BaseController {
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @RequestMapping(value ="/edit",method = RequestMethod.PUT)
|
|
|
+ @RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
|
|
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
|
|
boolean matches = user.getPassword().matches(PW_PATTERN);
|
|
|
if (!matches) {
|
|
@@ -224,6 +226,36 @@ public class SysUserController extends BaseController {
|
|
|
return toAjax(userService.updateUsers(user));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改用户-web
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:user:updateUser')")
|
|
|
+ @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
+ @RequestMapping(value = "/updateUser", method = RequestMethod.PUT)
|
|
|
+ public AjaxResult updateUser(@Validated @RequestBody SysUserUpdate user) {
|
|
|
+ if (!StringUtils.isEmpty(user) && !StringUtils.isEmpty(user.getPassword())) {
|
|
|
+ boolean matches = user.getPassword().matches(PW_PATTERN);
|
|
|
+ if (!matches) {
|
|
|
+ return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userService.checkUserAllowedUpdate(user);
|
|
|
+ userService.checkUserDataScope(user.getId());
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUniqueUpdate(user))) {
|
|
|
+ return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
|
|
+ } else if (StringUtils.isNotEmpty(user.getPhoneNum())
|
|
|
+ && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUniqueUpdate(user))) {
|
|
|
+ return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
|
|
+ } else if (StringUtils.isNotEmpty(user.getEmail())
|
|
|
+ && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUniqueUpdate(user))) {
|
|
|
+ return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
|
+ }
|
|
|
+ user.setUpdateBy(getUsername());
|
|
|
+ user.setUpdateTime(new Date());
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
+ return toAjax(userService.updateUsersUpdate(user));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除用户
|
|
|
*/
|
|
@@ -320,10 +352,10 @@ public class SysUserController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/dataPermission/{id}/{dataPermission}")
|
|
|
@ApiOperation("数据权限分配")
|
|
|
- public AjaxResult dataPermission(@PathVariable("id") Long id,@PathVariable("dataPermission") Integer dataPermission) {
|
|
|
- if (userService.dataPermission(id,dataPermission)){
|
|
|
+ public AjaxResult dataPermission(@PathVariable("id") Long id, @PathVariable("dataPermission") Integer dataPermission) {
|
|
|
+ if (userService.dataPermission(id, dataPermission)) {
|
|
|
return success();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return error();
|
|
|
}
|
|
|
}
|