|
|
@@ -1,5 +1,9 @@
|
|
|
package cn.reghao.devops.mgr.admin.controller.page;
|
|
|
|
|
|
+import cn.reghao.devops.mgr.admin.model.dto.AccountProfile;
|
|
|
+import cn.reghao.devops.mgr.admin.model.dto.AccountRole;
|
|
|
+import cn.reghao.devops.mgr.admin.model.dto.CreateAccountDto;
|
|
|
+import cn.reghao.devops.mgr.admin.model.dto.UpdatePasswordDto;
|
|
|
import cn.reghao.devops.mgr.admin.model.po.User;
|
|
|
import cn.reghao.devops.mgr.admin.model.vo.RoleVO;
|
|
|
import cn.reghao.devops.mgr.admin.model.vo.UserVO;
|
|
|
@@ -7,16 +11,22 @@ import cn.reghao.devops.mgr.admin.service.AccountService;
|
|
|
import cn.reghao.devops.mgr.admin.service.AccountSessionService;
|
|
|
import cn.reghao.devops.mgr.admin.service.RoleService;
|
|
|
import cn.reghao.devops.mgr.admin.service.UserContext;
|
|
|
+import cn.reghao.jutil.jdk.result.Result;
|
|
|
+import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -123,4 +133,79 @@ public class UserPageController {
|
|
|
model.addAttribute("authRoles", userRoles);
|
|
|
return "/admin/user/role";
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改个人头像", notes = "N")
|
|
|
+ @PostMapping(value = "/avatar", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String userAvatar(MultipartFile file) {
|
|
|
+ return WebResult.failWithMsg("接口未实现");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改个人信息", notes = "N")
|
|
|
+ @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String editUserInfo(@Validated AccountProfile accountProfile) {
|
|
|
+ accountService.updateAccountProfile(accountProfile);
|
|
|
+ return WebResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改个人密码", notes = "N")
|
|
|
+ @PostMapping(value = "/passwd/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String editPasswd(UpdatePasswordDto updatePasswordDto) {
|
|
|
+ return WebResult.failWithMsg("接口未实现");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "创建用户", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String createUser(@Validated CreateAccountDto createAccountDto) {
|
|
|
+ Result result = accountService.createAccount(createAccountDto);
|
|
|
+ return WebResult.result(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "批量创建用户", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(value = "/batch", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String batchAdd(MultipartFile file) {
|
|
|
+ return WebResult.failWithMsg("接口未实现");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除用户", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @DeleteMapping(value = "/delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String deleteAccount(@PathVariable("id") Integer userId) {
|
|
|
+ Result result = accountService.deleteAccount(userId);
|
|
|
+ return WebResult.result(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改用户密码", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(value = "/passwd", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String modifyPassword(@NotNull Integer id, @NotNull String newPassword) {
|
|
|
+ accountService.updateAccountPassword(id, newPassword);
|
|
|
+ return WebResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "分配用户角色", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(value = "/role", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String assignRole(@Validated AccountRole accountRole) {
|
|
|
+ Result result = accountService.updateAccountRole(accountRole);
|
|
|
+ return WebResult.result(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "启用/禁用用户", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(value = "/status/{userId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String updateAccountStatus(@PathVariable("userId") Integer userId) {
|
|
|
+ //userIds.forEach(userId -> accountService.updateAccountStatus(userId, enable));
|
|
|
+ return WebResult.failWithMsg("接口未实现");
|
|
|
+ }
|
|
|
}
|