|
|
@@ -1,14 +1,13 @@
|
|
|
package cn.reghao.devops.web.account.controller.page;
|
|
|
|
|
|
import cn.reghao.devops.web.account.db.query.UserQuery;
|
|
|
-import cn.reghao.devops.web.account.model.po.Role;
|
|
|
import cn.reghao.devops.web.account.model.po.User;
|
|
|
+import cn.reghao.devops.web.account.model.vo.RoleVO;
|
|
|
import cn.reghao.devops.web.account.model.vo.UserVO;
|
|
|
import cn.reghao.devops.web.account.service.AccountSessionService;
|
|
|
import cn.reghao.devops.web.account.service.RoleService;
|
|
|
import cn.reghao.devops.web.account.service.UserContext;
|
|
|
import cn.reghao.devops.web.util.db.PageSort;
|
|
|
-import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
@@ -18,7 +17,6 @@ import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -40,6 +38,20 @@ public class UserPageController {
|
|
|
this.accountSessionService = accountSessionService;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "个人信息页面")
|
|
|
+ @GetMapping("/profile")
|
|
|
+ public String userInfoPage(Model model) {
|
|
|
+ User user = UserContext.getUser();
|
|
|
+ model.addAttribute("user", user);
|
|
|
+ return "/rbac/user/userinfo";
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改个人密码页面")
|
|
|
+ @GetMapping("/passwd/edit")
|
|
|
+ public String editPasswdPage(Model model) {
|
|
|
+ return "/rbac/user/userpasswd";
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "用户列表页面")
|
|
|
@GetMapping
|
|
|
public String userPage(@RequestParam(value = "screenName", required = false) String screenName, Model model) {
|
|
|
@@ -52,12 +64,12 @@ public class UserPageController {
|
|
|
page = userQuery.getUserVOByPage(pageRequest);
|
|
|
}
|
|
|
|
|
|
- Map<Integer, LocalDateTime> map = accountSessionService.getLastRequest();
|
|
|
+ Map<Integer, String> map = accountSessionService.getLastAccess();
|
|
|
page.getContent().forEach(userVO -> {
|
|
|
int userId = userVO.getUserId();
|
|
|
- LocalDateTime lastAccess = map.get(userId);
|
|
|
- if (lastAccess != null) {
|
|
|
- userVO.setLastAccess(DateTimeConverter.format(lastAccess));
|
|
|
+ String lastAccessStr = map.get(userId);
|
|
|
+ if (lastAccessStr != null) {
|
|
|
+ userVO.setLastAccess(lastAccessStr);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -69,68 +81,41 @@ public class UserPageController {
|
|
|
@ApiOperation(value = "新增用户页面")
|
|
|
@GetMapping("/add")
|
|
|
public String addUserPage(Model model) {
|
|
|
- Set<Role> allRoles = new HashSet<>(roleService.getAllRoles());
|
|
|
- Set<Role> userRoles = Collections.emptySet();
|
|
|
-
|
|
|
+ Set<RoleVO> allRoles = roleService.getAllRoles();
|
|
|
model.addAttribute("allRoles", allRoles);
|
|
|
- model.addAttribute("userRoles", userRoles);
|
|
|
+ model.addAttribute("userRoles", Collections.emptySet());
|
|
|
return "/rbac/user/add";
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "用户信息编辑页面")
|
|
|
- @GetMapping("/edit/{id}")
|
|
|
- @Deprecated
|
|
|
- public String editUserPage(@PathVariable("id") User user, Model model) {
|
|
|
- Set<Role> allRoles = new HashSet<>(roleService.getAllRoles());
|
|
|
- Set<Role> userRoles = roleService.getUserRoles(user.getId());
|
|
|
-
|
|
|
- model.addAttribute("allRoles", allRoles);
|
|
|
- model.addAttribute("userRoles", userRoles);
|
|
|
- model.addAttribute("user", user);
|
|
|
- return "/rbac/user/edit";
|
|
|
- }
|
|
|
-
|
|
|
@ApiOperation(value = "用户详细信息页面")
|
|
|
@GetMapping("/detail/{id}")
|
|
|
public String userDetailPage(@PathVariable("id") int id, Model model) {
|
|
|
User user = userQuery.findById(id);
|
|
|
- Set<Role> roles = roleService.getUserRoles(user.getId());
|
|
|
- List<String> names = roles.stream().map(Role::getName).collect(Collectors.toList());
|
|
|
+ Set<RoleVO> roles = roleService.getUserRoles(user.getId());
|
|
|
+ List<String> names = roles.stream().map(RoleVO::getName).collect(Collectors.toList());
|
|
|
|
|
|
model.addAttribute("roles", names.toString());
|
|
|
model.addAttribute("user", user);
|
|
|
return "/rbac/user/detail";
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/profile")
|
|
|
- public String userInfoPage(Model model) {
|
|
|
- User user = UserContext.getUser();
|
|
|
- model.addAttribute("user", user);
|
|
|
- return "/rbac/user/userinfo";
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "用户修改密码页面")
|
|
|
+ @ApiOperation(value = "重置用户密码页面")
|
|
|
@GetMapping("/passwd/{id}")
|
|
|
public String modifyPasswordPage(@PathVariable("id") Integer id, Model model) {
|
|
|
model.addAttribute("id", id);
|
|
|
return "/rbac/user/passwd";
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/passwd/edit")
|
|
|
- public String editPasswdPage(Model model) {
|
|
|
- return "/rbac/user/editpasswd";
|
|
|
- }
|
|
|
-
|
|
|
@ApiOperation(value = "用户角色分配页面")
|
|
|
@GetMapping("/role/{id}")
|
|
|
public String assignRolePage(@PathVariable("id") User user, Model model) {
|
|
|
- Set<Role> roles = new HashSet<>(roleService.getAllRoles());
|
|
|
+ Set<RoleVO> allRoles = roleService.getAllRoles();
|
|
|
int userId = user.getId();
|
|
|
- Set<Role> authRoles = roleService.getUserRoles(userId);
|
|
|
+ Set<RoleVO> userRoles = roleService.getUserRoles(userId);
|
|
|
|
|
|
model.addAttribute("id", userId);
|
|
|
- model.addAttribute("list", roles);
|
|
|
- model.addAttribute("authRoles", authRoles);
|
|
|
+ model.addAttribute("list", allRoles);
|
|
|
+ model.addAttribute("authRoles", userRoles);
|
|
|
return "/rbac/user/role";
|
|
|
}
|
|
|
}
|