| Line 17... |
Line 17... |
| 17 |
import org.springframework.web.bind.annotation.RequestParam;
|
17 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 18 |
|
18 |
|
| 19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 21 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
21 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| - |
|
22 |
import com.spice.profitmandi.dao.entity.cs.PartnerPosition;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 22 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
24 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 23 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
25 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 24 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
26 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
| 25 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
27 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.cs.PartnersPositionRepository;
|
| - |
|
29 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
32 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 29 |
import com.spice.profitmandi.service.AuthService;
|
33 |
import com.spice.profitmandi.service.AuthService;
|
| 30 |
import com.spice.profitmandi.web.model.LoginDetails;
|
34 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| Line 53... |
Line 57... |
| 53 |
|
57 |
|
| 54 |
@Autowired
|
58 |
@Autowired
|
| 55 |
private CookiesProcessor cookiesProcessor;
|
59 |
private CookiesProcessor cookiesProcessor;
|
| 56 |
|
60 |
|
| 57 |
@Autowired
|
61 |
@Autowired
|
| - |
|
62 |
private PositionRepository positionRepository;
|
| - |
|
63 |
|
| - |
|
64 |
@Autowired
|
| - |
|
65 |
private PartnersPositionRepository partnerPositionRepository;
|
| - |
|
66 |
|
| - |
|
67 |
@Autowired
|
| 58 |
@Qualifier("userUserRepository")
|
68 |
@Qualifier("userUserRepository")
|
| 59 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
69 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 60 |
|
70 |
|
| 61 |
@GetMapping(value = "/createAuthUser")
|
71 |
@GetMapping(value = "/createAuthUser")
|
| 62 |
public String getcreateAuthUser(HttpServletRequest request,
|
72 |
public String getcreateAuthUser(HttpServletRequest request,
|
| Line 170... |
Line 180... |
| 170 |
|
180 |
|
| 171 |
@GetMapping(value = "/getPaginatedAuthUser")
|
181 |
@GetMapping(value = "/getPaginatedAuthUser")
|
| 172 |
public String getPaginatedAuthUser(HttpServletRequest request,
|
182 |
public String getPaginatedAuthUser(HttpServletRequest request,
|
| 173 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
183 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 174 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
184 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) {
|
| 175 |
//List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
185 |
// List<AuthUser> authUsers = authRepository.selectAll(offset, limit);
|
| 176 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser(offset, limit);
|
186 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser(offset, limit);
|
| 177 |
model.addAttribute("authUsers", authUsers);
|
187 |
model.addAttribute("authUsers", authUsers);
|
| 178 |
return "auth-users-paginated";
|
188 |
return "auth-users-paginated";
|
| 179 |
}
|
189 |
}
|
| 180 |
|
190 |
|
| Line 189... |
Line 199... |
| 189 |
}
|
199 |
}
|
| 190 |
|
200 |
|
| 191 |
@PostMapping(value = "/authuser/remove")
|
201 |
@PostMapping(value = "/authuser/remove")
|
| 192 |
public String removeAuthUser(Model model, @RequestParam int id) throws Exception {
|
202 |
public String removeAuthUser(Model model, @RequestParam int id) throws Exception {
|
| 193 |
AuthUser user = authRepository.selectById(id);
|
203 |
AuthUser user = authRepository.selectById(id);
|
| - |
|
204 |
|
| 194 |
user.setActive(false);
|
205 |
user.setActive(false);
|
| 195 |
authRepository.persist(user);
|
206 |
authRepository.persist(user);
|
| - |
|
207 |
List<Position> positions = positionRepository.selectAll(user.getId());
|
| - |
|
208 |
for (Position position : positions) {
|
| - |
|
209 |
List<PartnerPosition> partnerPositions = partnerPositionRepository.selectByPositionId(position.getId());
|
| - |
|
210 |
positionRepository.delete(position.getId());
|
| - |
|
211 |
for (PartnerPosition partnerPosition : partnerPositions) {
|
| - |
|
212 |
partnerPositionRepository.delete(partnerPosition.getPositionId());
|
| - |
|
213 |
}
|
| - |
|
214 |
}
|
| 196 |
model.addAttribute("response", "true");
|
215 |
model.addAttribute("response", "true");
|
| 197 |
return "response";
|
216 |
return "response";
|
| 198 |
}
|
217 |
}
|
| 199 |
|
218 |
|
| 200 |
}
|
219 |
}
|