Browse Source
new schema added and table name changes for every services to added in new schema and all serivces and some pages changes
master
new schema added and table name changes for every services to added in new schema and all serivces and some pages changes
master
18 changed files with 5791 additions and 295 deletions
-
2src/main/java/com/gcc_manpower/config/AppUserDetailsService.java
-
117src/main/java/com/gcc_manpower/config/DataSourceConfig.java
-
14src/main/java/com/gcc_manpower/config/SecurityConfig.java
-
48src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java
-
47src/main/java/com/gcc_manpower/gccservicedocuments/service/GccServiceDocumentsService.java
-
68src/main/java/com/gcc_manpower/gccservicepaymenttracker/service/GccServicePaymentTrackerService.java
-
106src/main/java/com/gcc_manpower/gcctapaldetailsmanagement/controller/TapalController.java
-
34src/main/java/com/gcc_manpower/gcctapaldetailsmanagement/service/TapalService.java
-
124src/main/java/com/gcc_manpower/gcctonermanagement/service/TonerService.java
-
141src/main/java/com/gcc_manpower/service/AppUserService.java
-
3src/main/resources/application-local.properties
-
3src/main/resources/application-prod.properties
-
22src/main/resources/templates/fragments/tapalheader.html
-
110src/main/resources/templates/gccadjustmentmanagement/dashboard.html
-
75src/main/resources/templates/gccadjustmentmanagement/details.html
-
5022src/main/resources/templates/gcctapaldetailsmanagement/dashboard.html
-
117src/main/resources/templates/gcctapaldetailsmanagement/login.html
-
25src/main/resources/templates/home/home.html
@ -0,0 +1,106 @@ |
|||||
|
package com.gcc_manpower.gcctapaldetailsmanagement.controller; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.security.authentication.AuthenticationManager; |
||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
||||
|
import org.springframework.security.core.Authentication; |
||||
|
import org.springframework.security.core.AuthenticationException; |
||||
|
import org.springframework.security.core.context.SecurityContextHolder; |
||||
|
import org.springframework.security.web.context.HttpSessionSecurityContextRepository; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.ui.Model; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
|
||||
|
import com.gcc_manpower.gcctapaldetailsmanagement.service.TapalService; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/gcctapaldetailsmanagement") |
||||
|
public class TapalController { |
||||
|
|
||||
|
@Autowired |
||||
|
private TapalService tapalService; |
||||
|
|
||||
|
@Autowired |
||||
|
private AuthenticationManager authenticationManager; |
||||
|
|
||||
|
@GetMapping({ "", "/", "/dashboard" }) |
||||
|
public String viewDashboard(Model model, HttpSession session) { |
||||
|
String username = (String) session.getAttribute("tap_usrName"); |
||||
|
if (username == null) { |
||||
|
return "redirect:/gcctapaldetailsmanagement/login"; |
||||
|
} |
||||
|
|
||||
|
String usrRole = (String) session.getAttribute("tap_usrRole"); |
||||
|
boolean isAdmin = "ADMIN".equalsIgnoreCase(usrRole); |
||||
|
|
||||
|
model.addAttribute("isLoggedIn", true); |
||||
|
model.addAttribute("isAdmin", isAdmin); |
||||
|
model.addAttribute("usrName", username); |
||||
|
model.addAttribute("curPage", "gcctapaldetailsmanagement"); |
||||
|
|
||||
|
return "gcctapaldetailsmanagement/dashboard"; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/login") |
||||
|
public String login(HttpSession session) { |
||||
|
return "gcctapaldetailsmanagement/login"; |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/api/login") |
||||
|
@ResponseBody |
||||
|
public Map<String, Object> validateLogin( |
||||
|
@RequestParam("usrName") String usrName, |
||||
|
@RequestParam("usrPass") String usrPass, |
||||
|
HttpSession session) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(usrName, |
||||
|
usrPass); |
||||
|
Authentication authentication = authenticationManager.authenticate(authenticationToken); |
||||
|
|
||||
|
SecurityContextHolder.getContext().setAuthentication(authentication); |
||||
|
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, |
||||
|
SecurityContextHolder.getContext()); |
||||
|
|
||||
|
String role = authentication.getAuthorities().stream() |
||||
|
.map(auth -> auth.getAuthority().replace("ROLE_", "")) |
||||
|
.findFirst() |
||||
|
.orElse("USER"); |
||||
|
|
||||
|
session.setAttribute("tap_usrName", usrName); |
||||
|
session.setAttribute("tap_usrRole", role); |
||||
|
session.setMaxInactiveInterval(1800); // 30 minutes session timeout |
||||
|
response.put("result", true); |
||||
|
response.put("usrName", usrName); |
||||
|
} catch (AuthenticationException e) { |
||||
|
response.put("result", false); |
||||
|
response.put("error", e.getMessage() != null ? e.getMessage() : "Invalid username or password!"); |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/logout") |
||||
|
public String logout(HttpSession session, HttpServletRequest request) { |
||||
|
SecurityContextHolder.clearContext(); |
||||
|
if (session != null) { |
||||
|
session.removeAttribute("tap_usrName"); |
||||
|
session.removeAttribute("tap_usrRole"); |
||||
|
session.invalidate(); |
||||
|
} |
||||
|
request.getSession(true); |
||||
|
return "redirect:/gcctapaldetailsmanagement/login"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
package com.gcc_manpower.gcctapaldetailsmanagement.service; |
||||
|
|
||||
|
import java.util.Collections; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import javax.sql.DataSource; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class TapalService { |
||||
|
|
||||
|
private JdbcTemplate jdbcTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlItcellManagementDataSource") DataSource dataSource) { |
||||
|
this.jdbcTemplate = new JdbcTemplate(dataSource); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAllTapalsStatus() { |
||||
|
String sql = "select * from tapal_status_list where is_active = 1 and is_delete=0"; |
||||
|
try { |
||||
|
return this.jdbcTemplate.queryForList(sql); |
||||
|
} catch (Exception e) { |
||||
|
System.out.println(e.getMessage()); |
||||
|
return Collections.emptyList(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<th:block th:fragment="tapalheader"> |
||||
|
<!-- Awesome Font --> |
||||
|
<link rel="stylesheet" th:href="@{/assets/font-awesome-6.5.2/css/all.min.css}" type="text/css"> |
||||
|
<!-- Bootstrap CSS --> |
||||
|
<link rel="stylesheet" th:href="@{/assets/bootstrap-5.3.2/css/bootstrap.min.css}" type="text/css"> |
||||
|
<!-- CSS for Header --> |
||||
|
<link rel="stylesheet" th:href="@{/assets/css/header-styles.css}" type="text/css"> |
||||
|
<div class="header"> |
||||
|
<div class="logo-left"> |
||||
|
<img th:src="@{/assets/header-images/gcc1.png}" alt="Greater Chennai Corporation Logo"> |
||||
|
<div class="logo-text"> |
||||
|
<h2>GREATER</h2> |
||||
|
<h2>CHENNAI</h2> |
||||
|
<h2>CORPORATION</h2> |
||||
|
<p>பெருநகர சென்னை மாநகராட்சி</p> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="title"> |
||||
|
<h2>GCC Tapal Details Management</h2> |
||||
|
</div> |
||||
|
</div> |
||||
|
</th:block> |
||||
5022
src/main/resources/templates/gcctapaldetailsmanagement/dashboard.html
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,117 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html xmlns:th="http://www.thymeleaf.org" lang="en"> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>GCC Tapal Details Management - Login</title> |
||||
|
|
||||
|
<!-- CSRF Tokens --> |
||||
|
<meta th:if="${_csrf != null}" name="_csrf" th:content="${_csrf.token}" /> |
||||
|
<meta th:if="${_csrf != null}" name="_csrf_header" th:content="${_csrf.headerName}" /> |
||||
|
|
||||
|
<!-- Include CSS --> |
||||
|
<link rel="stylesheet" type="text/css" th:href="@{/assets/css/login-form-styles.css}"> |
||||
|
|
||||
|
<!-- Awesome Font --> |
||||
|
<link th:href="@{/assets/font-awesome-6.5.2/css/all.min.css}" rel="stylesheet" type="text/css"> |
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div class="container"> |
||||
|
<img th:src="@{/assets/header-images/gcc1.png}" alt="Greater Chennai Corporation" class="small-logo"> |
||||
|
<h3>GREATER CHENNAI CORPORATION</h3> |
||||
|
<h4>பெருநகர சென்னை மாநகராட்சி</h4> |
||||
|
<br> |
||||
|
<h3>GCC Tapal Details Management</h3> |
||||
|
<br> |
||||
|
<h2>Login</h2> |
||||
|
|
||||
|
<div id="error-box" |
||||
|
style="color: #c0392b; font-weight: 500; font-size: 0.85rem; margin-bottom: 1.5rem; text-align: center; display: none;"> |
||||
|
<i class="fa-solid fa-circle-exclamation"></i> <span id="error-text">Invalid username or password!</span> |
||||
|
</div> |
||||
|
|
||||
|
<form id="loginForm" onsubmit="handleLogin(event)"> |
||||
|
<div class="input-field"> |
||||
|
<input type="text" name="usrName" id="usrName" placeholder="Enter Username" required |
||||
|
autocomplete="username"> |
||||
|
<div class="underline"></div> |
||||
|
</div> |
||||
|
<div class="input-field"> |
||||
|
<input type="password" name="usrPass" id="usrPass" placeholder="Enter Password" required |
||||
|
autocomplete="current-password"> |
||||
|
<div class="underline"></div> |
||||
|
</div> |
||||
|
<input type="submit" value="Login" id="submit-btn"> |
||||
|
</form> |
||||
|
</div> |
||||
|
|
||||
|
<!-- Footer Fragment --> |
||||
|
<th:block th:replace="~{fragments/footer :: footer}"></th:block> |
||||
|
|
||||
|
<!-- Custom JS --> |
||||
|
<script th:inline="javascript"> |
||||
|
const contextPath = /*[[@{/}]]*/ ''; |
||||
|
</script> |
||||
|
|
||||
|
<script> |
||||
|
function handleLogin(event) { |
||||
|
event.preventDefault(); |
||||
|
|
||||
|
const errorBox = document.getElementById("error-box"); |
||||
|
const errorText = document.getElementById("error-text"); |
||||
|
const submitBtn = document.getElementById("submit-btn"); |
||||
|
|
||||
|
errorBox.style.display = "none"; |
||||
|
submitBtn.disabled = true; |
||||
|
submitBtn.value = 'Authenticating...'; |
||||
|
|
||||
|
const username = document.getElementById("usrName").value; |
||||
|
const password = document.getElementById("usrPass").value; |
||||
|
|
||||
|
const urlParams = new URLSearchParams(); |
||||
|
urlParams.append('usrName', username); |
||||
|
urlParams.append('usrPass', password); |
||||
|
|
||||
|
// Fetch CSRF tokens |
||||
|
const csrfToken = document.querySelector("meta[name='_csrf']")?.getAttribute("content"); |
||||
|
const csrfHeader = document.querySelector("meta[name='_csrf_header']")?.getAttribute("content"); |
||||
|
|
||||
|
const headers = { |
||||
|
'Content-Type': 'application/x-www-form-urlencoded' |
||||
|
}; |
||||
|
if (csrfToken && csrfHeader) { |
||||
|
headers[csrfHeader] = csrfToken; |
||||
|
} |
||||
|
|
||||
|
fetch(contextPath + 'gcctapaldetailsmanagement/api/login', { |
||||
|
method: 'POST', |
||||
|
headers: headers, |
||||
|
body: urlParams |
||||
|
}) |
||||
|
.then(response => response.json()) |
||||
|
.then(data => { |
||||
|
if (data.result) { |
||||
|
alert("username: " + data.usrName + "usrPass:" + data.password); |
||||
|
sessionStorage.setItem("tap_usrName", data.usrName); |
||||
|
window.location.href = contextPath + 'gcctapaldetailsmanagement/dashboard'; |
||||
|
} else { |
||||
|
submitBtn.disabled = false; |
||||
|
submitBtn.value = 'Login'; |
||||
|
errorText.textContent = data.error || "Authentication failed."; |
||||
|
errorBox.style.display = "block"; |
||||
|
} |
||||
|
}) |
||||
|
.catch(err => { |
||||
|
console.error("Login Error:", err); |
||||
|
submitBtn.disabled = false; |
||||
|
submitBtn.value = 'Login'; |
||||
|
errorText.textContent = "Network error. Please try again later."; |
||||
|
errorBox.style.display = "block"; |
||||
|
}); |
||||
|
} |
||||
|
</script> |
||||
|
</body> |
||||
|
|
||||
|
</html> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue