From 8bd3f6063098a4346fb8465da726793bf9684477 Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Tue, 19 Aug 2025 22:21:57 +0800
Subject: [PATCH] 售后审核优化
---
oying-system/src/main/java/com/oying/modules/system/rest/UserController.java | 44 ++++++++------------------------------------
1 files changed, 8 insertions(+), 36 deletions(-)
diff --git a/oying-system/src/main/java/com/oying/modules/system/rest/UserController.java b/oying-system/src/main/java/com/oying/modules/system/rest/UserController.java
index 29c06fe..21c859d 100644
--- a/oying-system/src/main/java/com/oying/modules/system/rest/UserController.java
+++ b/oying-system/src/main/java/com/oying/modules/system/rest/UserController.java
@@ -1,8 +1,6 @@
package com.oying.modules.system.rest;
-import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.oying.modules.system.domain.Dept;
import com.oying.modules.system.domain.Role;
import com.oying.modules.system.domain.User;
import com.oying.modules.system.domain.dto.UserPassVo;
@@ -12,9 +10,7 @@
import lombok.RequiredArgsConstructor;
import com.oying.annotation.Log;
import com.oying.config.properties.RsaProperties;
-import com.oying.modules.system.service.DataService;
import com.oying.exception.BadRequestException;
-import com.oying.modules.system.service.DeptService;
import com.oying.modules.system.service.RoleService;
import com.oying.modules.system.domain.dto.UserQueryCriteria;
import com.oying.modules.system.service.VerifyService;
@@ -24,8 +20,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -47,8 +41,6 @@
private final PasswordEncoder passwordEncoder;
private final UserService userService;
- private final DataService dataService;
- private final DeptService deptService;
private final RoleService roleService;
private final VerifyService verificationCodeService;
@@ -64,28 +56,8 @@
@PreAuthorize("@el.check('user:list')")
public ResponseEntity<Object> queryUser(UserQueryCriteria criteria) {
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
- if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
- criteria.getDeptIds().add(criteria.getDeptId());
- // 先查找是否存在子节点
- List<Dept> data = deptService.findByPid(criteria.getDeptId());
- // 然后把子节点的ID都加入到集合中
- criteria.getDeptIds().addAll(deptService.getDeptChildren(data));
- }
// 数据权限
- List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername()));
- // criteria.getDeptIds() 不为空并且数据权限不为空则取交集
- if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
- // 取交集
- criteria.getDeptIds().retainAll(dataScopes);
- if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
- return new ResponseEntity<>(R.success(userService.queryAll(criteria, page)), HttpStatus.OK);
- }
- } else {
- // 否则取并集
- criteria.getDeptIds().addAll(dataScopes);
- return new ResponseEntity<>(R.success(userService.queryAll(criteria, page)), HttpStatus.OK);
- }
- return new ResponseEntity<>(R.success(), HttpStatus.OK);
+ return new ResponseEntity<>(R.success(userService.queryAll(criteria, page)), HttpStatus.OK);
}
@Log("新增用户")
@@ -97,7 +69,7 @@
// 默认密码 123456
resources.setPassword(passwordEncoder.encode("123456"));
userService.create(resources);
- return new ResponseEntity<>(R.success(),HttpStatus.CREATED);
+ return new ResponseEntity<>(R.success(), HttpStatus.CREATED);
}
@Log("修改用户")
@@ -107,7 +79,7 @@
public ResponseEntity<Object> updateUser(@Validated(User.Update.class) @RequestBody User resources) throws Exception {
checkLevel(resources);
userService.update(resources);
- return new ResponseEntity<>(R.success(),HttpStatus.NO_CONTENT);
+ return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT);
}
@Log("修改用户:个人中心")
@@ -118,7 +90,7 @@
throw new BadRequestException("不能修改他人资料");
}
userService.updateCenter(resources);
- return new ResponseEntity<>(R.success(),HttpStatus.NO_CONTENT);
+ return new ResponseEntity<>(R.success(), HttpStatus.NO_CONTENT);
}
@Log("删除用户")
@@ -134,7 +106,7 @@
}
}
userService.delete(ids);
- return new ResponseEntity<>(R.success(),HttpStatus.OK);
+ return new ResponseEntity<>(R.success(), HttpStatus.OK);
}
@ApiOperation("修改密码")
@@ -150,7 +122,7 @@
throw new BadRequestException("新密码不能与旧密码相同");
}
userService.updatePass(user.getUsername(), passwordEncoder.encode(newPass));
- return new ResponseEntity<>(R.success(),HttpStatus.OK);
+ return new ResponseEntity<>(R.success(), HttpStatus.OK);
}
@ApiOperation("重置密码")
@@ -158,7 +130,7 @@
public ResponseEntity<Object> resetPwd(@RequestBody Set<Long> ids) {
String pwd = passwordEncoder.encode("123456");
userService.resetPwd(ids, pwd);
- return new ResponseEntity<>(R.success(),HttpStatus.OK);
+ return new ResponseEntity<>(R.success(), HttpStatus.OK);
}
@ApiOperation("修改头像")
@@ -178,7 +150,7 @@
}
verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + resources.getEmail(), code);
userService.updateEmail(user.getUsername(), resources.getEmail());
- return new ResponseEntity<>(R.success(),HttpStatus.OK);
+ return new ResponseEntity<>(R.success(), HttpStatus.OK);
}
/**
--
Gitblit v1.9.3