| Line 28... |
Line 28... |
| 28 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
28 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 29 |
import com.spice.profitmandi.service.AuthService;
|
29 |
import com.spice.profitmandi.service.AuthService;
|
| 30 |
import com.spice.profitmandi.web.model.LoginDetails;
|
30 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 31 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
31 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 32 |
|
32 |
|
| 33 |
|
- |
|
| 34 |
@Controller
|
33 |
@Controller
|
| 35 |
@Transactional(rollbackFor = Throwable.class)
|
34 |
@Transactional(rollbackFor = Throwable.class)
|
| 36 |
public class AuthUserController {
|
35 |
public class AuthUserController {
|
| 37 |
|
36 |
|
| 38 |
private static final Logger LOGGER = LogManager.getLogger(AuthUserController.class);
|
37 |
private static final Logger LOGGER = LogManager.getLogger(AuthUserController.class);
|
| Line 62... |
Line 61... |
| 62 |
@GetMapping(value = "/createAuthUser")
|
61 |
@GetMapping(value = "/createAuthUser")
|
| 63 |
public String getcreateAuthUser(HttpServletRequest request,
|
62 |
public String getcreateAuthUser(HttpServletRequest request,
|
| 64 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
63 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 65 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
64 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 66 |
throws ProfitMandiBusinessException {
|
65 |
throws ProfitMandiBusinessException {
|
| 67 |
List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
66 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
| - |
|
67 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser(offset, limit);
|
| - |
|
68 |
|
| 68 |
long size = authRepository.selectCountAuthUser();
|
69 |
long size = authRepository.selectCountAuthUser();
|
| 69 |
model.addAttribute("authUsers", authUsers);
|
70 |
model.addAttribute("authUsers", authUsers);
|
| 70 |
model.addAttribute("start", offset + 1);
|
71 |
model.addAttribute("start", offset + 1);
|
| 71 |
model.addAttribute("size", size);
|
72 |
model.addAttribute("size", size);
|
| 72 |
if (authUsers.size() < limit) {
|
73 |
if (authUsers.size() < limit) {
|
| Line 129... |
Line 130... |
| 129 |
authUser.setEmailId(emailId);
|
130 |
authUser.setEmailId(emailId);
|
| 130 |
authUser.setFirstName(firstName);
|
131 |
authUser.setFirstName(firstName);
|
| 131 |
authUser.setLastName(lastName);
|
132 |
authUser.setLastName(lastName);
|
| 132 |
authUser.setMobileNumber(mobileNumber);
|
133 |
authUser.setMobileNumber(mobileNumber);
|
| 133 |
authUser.setGmailId(gmailId);
|
134 |
authUser.setGmailId(gmailId);
|
| 134 |
|
135 |
|
| 135 |
authUser.setCreatedTimestamp(LocalDateTime.now());
|
136 |
authUser.setCreatedTimestamp(LocalDateTime.now());
|
| 136 |
authService.addAuthUser(authUser);
|
137 |
authService.addAuthUser(authUser);
|
| 137 |
|
138 |
|
| 138 |
List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
139 |
List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
| 139 |
long size = authRepository.selectCountAuthUser();
|
140 |
long size = authRepository.selectCountAuthUser();
|
| Line 166... |
Line 167... |
| 166 |
|
167 |
|
| 167 |
@GetMapping(value = "/getPaginatedAuthUser")
|
168 |
@GetMapping(value = "/getPaginatedAuthUser")
|
| 168 |
public String getPaginatedAuthUser(HttpServletRequest request,
|
169 |
public String getPaginatedAuthUser(HttpServletRequest request,
|
| 169 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
170 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 170 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
171 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
| 171 |
List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
172 |
//List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
| - |
|
173 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser(offset, limit);
|
| 172 |
model.addAttribute("authUsers", authUsers);
|
174 |
model.addAttribute("authUsers", authUsers);
|
| 173 |
return "auth-users-paginated";
|
175 |
return "auth-users-paginated";
|
| 174 |
}
|
176 |
}
|
| 175 |
|
177 |
|
| 176 |
@GetMapping(value="/authuser/edit")
|
178 |
@GetMapping(value = "/authuser/edit")
|
| 177 |
public String updateAuthUser(Model model, @RequestParam String gmailId, @RequestParam String emailId) throws Exception {
|
179 |
public String updateAuthUser(Model model, @RequestParam String gmailId, @RequestParam String emailId)
|
| - |
|
180 |
throws Exception {
|
| 178 |
AuthUser user = authRepository.selectByEmailOrMobile(emailId);
|
181 |
AuthUser user = authRepository.selectByEmailOrMobile(emailId);
|
| 179 |
user.setGmailId(gmailId);
|
182 |
user.setGmailId(gmailId);
|
| 180 |
authRepository.persist(user);
|
183 |
authRepository.persist(user);
|
| 181 |
model.addAttribute("response", "true");
|
184 |
model.addAttribute("response", "true");
|
| 182 |
return "response";
|
185 |
return "response";
|
| 183 |
}
|
186 |
}
|
| 184 |
|
187 |
|
| - |
|
188 |
@PostMapping(value = "/authuser/remove")
|
| - |
|
189 |
public String removeAuthUser(Model model, @RequestParam int id)
|
| - |
|
190 |
throws Exception {
|
| - |
|
191 |
AuthUser user = authRepository.selectById(id);
|
| - |
|
192 |
user.setActive(false);
|
| - |
|
193 |
authRepository.persist(user);
|
| - |
|
194 |
model.addAttribute("response", "true");
|
| - |
|
195 |
return "response";
|
| - |
|
196 |
}
|
| 185 |
|
197 |
|
| 186 |
}
|
198 |
}
|