|
@@ -8,19 +8,20 @@ package org.eco.vip.auth.controller.user;
|
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
import jakarta.validation.Valid;
|
|
|
-import org.eco.vip.auth.domain.user.User;
|
|
|
+import jakarta.validation.constraints.NotEmpty;
|
|
|
import org.eco.vip.auth.domain.user.pojo.UserBO;
|
|
|
import org.eco.vip.auth.domain.user.pojo.UserVO;
|
|
|
import org.eco.vip.auth.service.user.IUserService;
|
|
|
import org.eco.vip.orm.pojo.CommonResult;
|
|
|
+import org.eco.vip.orm.pojo.LoginUser;
|
|
|
import org.eco.vip.orm.pojo.PageResult;
|
|
|
+import org.eco.vip.security.utils.LoginHelper;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-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.bind.annotation.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static org.eco.vip.orm.pojo.CommonResult.fail;
|
|
|
import static org.eco.vip.orm.pojo.CommonResult.success;
|
|
|
|
|
|
/**
|
|
@@ -37,24 +38,42 @@ public class UserController {
|
|
|
@Resource
|
|
|
private IUserService userService;
|
|
|
|
|
|
-// @GetMapping("/list")
|
|
|
-// public List<User> list() {
|
|
|
-// return userService.getUsers();
|
|
|
-// }
|
|
|
-
|
|
|
@GetMapping("/page")
|
|
|
- public CommonResult<PageResult<UserVO>> page(@RequestBody @Valid UserBO userBO) {
|
|
|
+ public CommonResult<PageResult<UserVO>> page(UserBO userBO) {
|
|
|
return success(userService.selectPage(userBO));
|
|
|
}
|
|
|
|
|
|
- @PostMapping(("/add"))
|
|
|
- public Boolean add(@RequestBody UserBO userBO) {
|
|
|
- return userService.insert(userBO);
|
|
|
+ @GetMapping("/list")
|
|
|
+ public CommonResult<List<UserVO>> list(UserBO userBO) {
|
|
|
+ return success(userService.selectList(userBO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ public CommonResult<String> add(@RequestBody @Valid UserBO userBO) {
|
|
|
+ boolean result = userService.insert(userBO);
|
|
|
+ if (!result) {
|
|
|
+ return fail("新增用户失败!");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/update")
|
|
|
- public Boolean update(@RequestBody User user) {
|
|
|
- return userService.updateById(user);
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public CommonResult<String> edit(@RequestBody @Valid UserBO userBO) {
|
|
|
+ return success();
|
|
|
}
|
|
|
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空") List<String> ids) {
|
|
|
+ boolean result = userService.delete(ids);
|
|
|
+ if (!result) {
|
|
|
+ return fail("删除用户失败!");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/info")
|
|
|
+ public CommonResult<LoginUser> getInfo() {
|
|
|
+ LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
+ return success(loginUser);
|
|
|
+ }
|
|
|
}
|