| Line 32... |
Line 32... |
| 32 |
import javax.servlet.http.HttpServletRequest;
|
32 |
import javax.servlet.http.HttpServletRequest;
|
| 33 |
import java.time.LocalDateTime;
|
33 |
import java.time.LocalDateTime;
|
| 34 |
import java.util.HashMap;
|
34 |
import java.util.HashMap;
|
| 35 |
import java.util.List;
|
35 |
import java.util.List;
|
| 36 |
import java.util.Map;
|
36 |
import java.util.Map;
|
| - |
|
37 |
import java.util.stream.Collectors;
|
| 37 |
|
38 |
|
| 38 |
@Controller
|
39 |
@Controller
|
| 39 |
@Transactional(rollbackFor = Throwable.class)
|
40 |
@Transactional(rollbackFor = Throwable.class)
|
| 40 |
public class AuthUserController {
|
41 |
public class AuthUserController {
|
| 41 |
|
42 |
|
| Line 70... |
Line 71... |
| 70 |
|
71 |
|
| 71 |
@Autowired
|
72 |
@Autowired
|
| 72 |
@Qualifier("userUserRepository")
|
73 |
@Qualifier("userUserRepository")
|
| 73 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
74 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 74 |
|
75 |
|
| - |
|
76 |
|
| 75 |
@GetMapping(value = "/createAuthUser")
|
77 |
@GetMapping(value = "/createAuthUser")
|
| 76 |
public String getcreateAuthUser(HttpServletRequest request,
|
78 |
public String getcreateAuthUser(HttpServletRequest request,
|
| 77 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
79 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 78 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
80 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 79 |
throws ProfitMandiBusinessException {
|
81 |
throws ProfitMandiBusinessException {
|
| 80 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
82 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
| 81 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser(offset, limit);
|
- |
|
| 82 |
|
- |
|
| 83 |
long size = authRepository.selectCountAuthUser();
|
- |
|
| 84 |
|
- |
|
| 85 |
List<AuthUser> activeAuthUsers = authRepository.selectAllActiveUser();
|
83 |
List<AuthUser> activeAuthUsers = authRepository.selectAllActiveUser();
|
| - |
|
84 |
List<AuthUser> authUsers = activeAuthUsers.stream().skip(offset).limit(limit).collect(Collectors.toList());
|
| 86 |
|
85 |
|
| 87 |
Map<Integer, AuthUser> userManagerMap = new HashMap<>();
|
86 |
Map<Integer, AuthUser> userManagerMap = activeAuthUsers.stream()
|
| 88 |
|
- |
|
| 89 |
for (AuthUser authUser : authUsers) {
|
87 |
.filter(x -> x.getManagerId() != 0)
|
| 90 |
if (authUser.getManagerId() != 0) {
|
88 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 91 |
userManagerMap.put(authUser.getId(), authRepository.selectById(authUser.getManagerId()));
|
89 |
long size = activeAuthUsers.size();
|
| 92 |
}
|
- |
|
| 93 |
}
|
- |
|
| 94 |
|
- |
|
| 95 |
model.addAttribute("userManagerMap", userManagerMap);
|
90 |
model.addAttribute("userManagerMap", userManagerMap);
|
| 96 |
model.addAttribute("activeAuthUsers", activeAuthUsers);
|
91 |
model.addAttribute("activeAuthUsers", activeAuthUsers);
|
| 97 |
model.addAttribute("authUsers", authUsers);
|
92 |
model.addAttribute("authUsers", authUsers);
|
| 98 |
model.addAttribute("start", offset + 1);
|
93 |
model.addAttribute("start", offset + 1);
|
| 99 |
model.addAttribute("size", size);
|
94 |
model.addAttribute("size", size);
|
| Line 106... |
Line 101... |
| 106 |
}
|
101 |
}
|
| 107 |
|
102 |
|
| 108 |
return "create-auth-user";
|
103 |
return "create-auth-user";
|
| 109 |
|
104 |
|
| 110 |
}
|
105 |
}
|
| 111 |
|
- |
|
| 112 |
@PostMapping(value = "/addManagerId")
|
106 |
@PostMapping(value = "/addManagerId")
|
| 113 |
public String addManagerId(HttpServletRequest request, @RequestParam(name = "authId") int authId,
|
107 |
public String addManagerId(HttpServletRequest request, @RequestParam(name = "authId") int authId,
|
| 114 |
@RequestParam(name = "managerId") int managerId, Model model) throws Exception {
|
108 |
@RequestParam(name = "managerId") int managerId, Model model) throws Exception {
|
| 115 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
109 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
| 116 |
AuthUser authUser = authRepository.selectById(authId);
|
110 |
AuthUser authUser = authRepository.selectById(authId);
|