-
BINcd_waste_docs/cdwaste_aadhar/10_Race.jpg
-
BINcd_waste_docs/cdwaste_aadhar/11_Sample1.jpg
-
BINcd_waste_docs/cdwaste_aadhar/12_pexels-mike-jones-9461451.jpg
-
BINcd_waste_docs/cdwaste_aadhar/1_images.jpeg
-
BINcd_waste_docs/cdwaste_aadhar/2_images.jpeg
-
BINcd_waste_docs/cdwaste_aadhar/3_Race.jpg
-
BINcd_waste_docs/cdwaste_aadhar/4_Race.jpg
-
BINcd_waste_docs/cdwaste_aadhar/5_Race.jpg
-
BINcd_waste_docs/cdwaste_aadhar/6_Race.jpg
-
BINcd_waste_docs/cdwaste_aadhar/7_Race.jpg
-
BINcd_waste_docs/cdwaste_aadhar/8_Sample1.jpg
-
BINcd_waste_docs/cdwaste_aadhar/9_Sample1.jpg
-
BINcd_waste_docs/cdwaste_leasedoc/12_pexels-cottonbro-10034377.jpg
-
BINcd_waste_docs/cdwaste_leasedoc/1_images.jpeg
-
BINcd_waste_docs/cdwaste_leasedoc/2_images.jpeg
-
BINcd_waste_docs/cdwaste_rcbookdoc/10_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/11_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/12_pexels-mike-jones-9461451.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/1_images.jpeg
-
BINcd_waste_docs/cdwaste_rcbookdoc/2_images.jpeg
-
BINcd_waste_docs/cdwaste_rcbookdoc/3_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/4_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/5_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/6_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/7_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/8_Sample1.jpg
-
BINcd_waste_docs/cdwaste_rcbookdoc/9_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/10_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/11_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/12_pexels-mike-jones-9461451.jpg
-
BINcd_waste_docs/cdwaste_userphoto/1_images.jpeg
-
BINcd_waste_docs/cdwaste_userphoto/2_images.jpeg
-
BINcd_waste_docs/cdwaste_userphoto/3_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/4_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/5_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/6_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/7_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/8_Sample1.jpg
-
BINcd_waste_docs/cdwaste_userphoto/9_Sample1.jpg
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.08 PM.jpeg
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/aa.jpg
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/booking.png
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/calendar.png
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/id-card.png
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/ima.jpg
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/lockers.png
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/man.png
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/schedule.png
-
BINcdwastecollectordocuments/cdwaste_adhaar_copy/shower.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-08-24 at 12.49.58 PM.jpeg
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-12 at 9.54.20 PM.jpeg
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/booking.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/calendar.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/ima.jpg
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/lockers.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/plus.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/portable-toilet.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/received-card.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/search.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/shower.png
-
BINcdwastecollectordocuments/cdwaste_rcbook_copy/wardrobe.png
-
48pom.xml
-
61src/main/java/com/volunteersregistration/config/AppConfigur.java
-
11src/main/java/com/volunteersregistration/config/AppConstants.java
-
24src/main/java/com/volunteersregistration/config/DataSourceConfig.java
-
50src/main/java/com/volunteersregistration/config/QRCodeGenerator.java
-
42src/main/java/com/volunteersregistration/config/UserSession.java
-
43src/main/java/com/volunteersregistration/config/WebConfig.java
-
132src/main/java/com/volunteersregistration/controller/ApiController.java
-
111src/main/java/com/volunteersregistration/controller/VolunteerController.java
-
65src/main/java/com/volunteersregistration/entity/Category.java
-
43src/main/java/com/volunteersregistration/entity/LoginDetail.java
-
51src/main/java/com/volunteersregistration/entity/SubCategory.java
-
402src/main/java/com/volunteersregistration/entity/VolunteerInformation.java
-
19src/main/java/com/volunteersregistration/repository/CompanyInfoRepo.java
-
12src/main/java/com/volunteersregistration/repository/LoginDetailRepo.java
-
19src/main/java/com/volunteersregistration/repository/NgoInfoRepo.java
-
17src/main/java/com/volunteersregistration/repository/VolunteerRegistrationRepo.java
-
90src/main/java/com/volunteersregistration/service/Registrationservice.java
-
30src/main/java/com/volunteersregistration/service/VolunteerRegistrationService.java
-
521src/main/java/com/volunteersregistration/wasteCollector/controller/ApiController.java
-
173src/main/java/com/volunteersregistration/wasteCollector/controller/MainController.java
-
73src/main/java/com/volunteersregistration/wasteCollector/entity/Amount.java
-
59src/main/java/com/volunteersregistration/wasteCollector/entity/Cdlicense.java
-
119src/main/java/com/volunteersregistration/wasteCollector/entity/Orderslogs.java
-
112src/main/java/com/volunteersregistration/wasteCollector/entity/Payments.java
-
281src/main/java/com/volunteersregistration/wasteCollector/entity/WasteRegistration.java
-
17src/main/java/com/volunteersregistration/wasteCollector/repository/CdlicenseRepository.java
-
12src/main/java/com/volunteersregistration/wasteCollector/repository/OderLogsRepo.java
-
11src/main/java/com/volunteersregistration/wasteCollector/repository/PaymentsRepo.java
-
123src/main/java/com/volunteersregistration/wasteCollector/repository/WasteRegistrationRepo.java
-
164src/main/java/com/volunteersregistration/wasteCollector/service/WasteRegistrationService.java
-
35src/main/resources/application-dev.properties
-
36src/main/resources/application-prod.properties
-
14src/main/resources/application.properties
-
65src/main/resources/static/assets/_js/main/app.js
|
After Width: 728 | Height: 469 | Size: 79 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 4000 | Height: 6000 | Size: 2.1 MiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 728 | Height: 469 | Size: 79 KiB |
|
After Width: 728 | Height: 469 | Size: 79 KiB |
|
After Width: 728 | Height: 469 | Size: 79 KiB |
|
After Width: 728 | Height: 469 | Size: 79 KiB |
|
After Width: 728 | Height: 469 | Size: 79 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 2618 | Height: 3927 | Size: 740 KiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 4000 | Height: 6000 | Size: 2.1 MiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 4000 | Height: 6000 | Size: 2.1 MiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 276 | Height: 183 | Size: 8.8 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
After Width: 1792 | Height: 1792 | Size: 500 KiB |
|
Before Width: 1280 | Height: 720 | Size: 119 KiB |
|
Before Width: 1280 | Height: 720 | Size: 179 KiB |
|
Before Width: 1280 | Height: 720 | Size: 129 KiB |
|
Before Width: 200 | Height: 180 | Size: 22 KiB |
|
Before Width: 512 | Height: 512 | Size: 35 KiB |
|
Before Width: 512 | Height: 512 | Size: 22 KiB |
|
Before Width: 512 | Height: 512 | Size: 14 KiB |
|
Before Width: 320 | Height: 180 | Size: 15 KiB |
|
Before Width: 512 | Height: 512 | Size: 12 KiB |
|
Before Width: 512 | Height: 512 | Size: 33 KiB |
|
Before Width: 512 | Height: 512 | Size: 28 KiB |
|
Before Width: 512 | Height: 512 | Size: 40 KiB |
|
Before Width: 738 | Height: 1600 | Size: 141 KiB |
|
Before Width: 1080 | Height: 1187 | Size: 150 KiB |
|
Before Width: 1280 | Height: 720 | Size: 119 KiB |
|
Before Width: 1280 | Height: 720 | Size: 179 KiB |
|
Before Width: 512 | Height: 512 | Size: 35 KiB |
|
Before Width: 512 | Height: 512 | Size: 22 KiB |
|
Before Width: 320 | Height: 180 | Size: 15 KiB |
|
Before Width: 512 | Height: 512 | Size: 12 KiB |
|
Before Width: 512 | Height: 512 | Size: 25 KiB |
|
Before Width: 512 | Height: 512 | Size: 18 KiB |
|
Before Width: 512 | Height: 512 | Size: 13 KiB |
|
Before Width: 512 | Height: 512 | Size: 30 KiB |
|
Before Width: 512 | Height: 512 | Size: 40 KiB |
|
Before Width: 512 | Height: 512 | Size: 20 KiB |
@ -0,0 +1,61 @@ |
|||||
|
package com.volunteersregistration.config; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Component |
||||
|
@ConfigurationProperties(prefix = "app") |
||||
|
public class AppConfigur { |
||||
|
|
||||
|
private String title; |
||||
|
private String baseUrl; |
||||
|
private String getOtpUrl; |
||||
|
private String erpUrl; |
||||
|
|
||||
|
@Value("${payment.razorpay.my_key_id}") |
||||
|
private String keyId; |
||||
|
|
||||
|
public String getTitle() { |
||||
|
return title; |
||||
|
} |
||||
|
|
||||
|
public void setTitle(String title) { |
||||
|
this.title = title; |
||||
|
} |
||||
|
|
||||
|
public String getBaseUrl() { |
||||
|
return baseUrl; |
||||
|
} |
||||
|
|
||||
|
public void setBaseUrl(String baseUrl) { |
||||
|
this.baseUrl = baseUrl; |
||||
|
} |
||||
|
|
||||
|
public String getGetOtpUrl() { |
||||
|
return getOtpUrl; |
||||
|
} |
||||
|
|
||||
|
public void setGetOtpUrl(String getOtpUrl) { |
||||
|
this.getOtpUrl = getOtpUrl; |
||||
|
} |
||||
|
|
||||
|
public String getErpUrl() { |
||||
|
return erpUrl; |
||||
|
} |
||||
|
|
||||
|
public void setErpUrl(String erpUrl) { |
||||
|
this.erpUrl = erpUrl; |
||||
|
} |
||||
|
|
||||
|
public String getKeyId() { |
||||
|
return keyId; |
||||
|
} |
||||
|
|
||||
|
public void setKeyId(String keyId) { |
||||
|
this.keyId = keyId; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.volunteersregistration.config; |
||||
|
|
||||
|
public final class AppConstants { |
||||
|
// public static String key_id="rzp_live_ySI5Ns54Y7qOcJ"; |
||||
|
// public static String key_secret="Nwf1TjhUtaskof8vePkRR8Sb"; |
||||
|
|
||||
|
|
||||
|
//uncomment for testing payment |
||||
|
public static String key_id="rzp_test_tDkHFEqWXmuEi8"; |
||||
|
public static String key_secret="cBQUjMcKZ4J6vmOKSyNZ92py"; |
||||
|
} |
||||
@ -1,24 +0,0 @@ |
|||||
package com.volunteersregistration.config; |
|
||||
|
|
||||
import javax.sql.DataSource; |
|
||||
|
|
||||
import org.springframework.context.annotation.Bean; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource; |
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement; |
|
||||
|
|
||||
@Configuration |
|
||||
@EnableTransactionManagement |
|
||||
public class DataSourceConfig { |
|
||||
|
|
||||
//////////////////////////////(For C & D Waste Collectors Registration ) //////////////////////// |
|
||||
@Bean(name = "volunteers") |
|
||||
public DataSource mysql1913CDwasteDataSource() { |
|
||||
DriverManagerDataSource dataSource = new DriverManagerDataSource(); |
|
||||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
|
||||
dataSource.setUrl("jdbc:mysql://localhost:3306/volunteer"); |
|
||||
dataSource.setUsername("root"); |
|
||||
dataSource.setPassword("root"); |
|
||||
return dataSource; |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,50 @@ |
|||||
|
package com.volunteersregistration.config; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import com.google.zxing.BarcodeFormat; |
||||
|
import com.google.zxing.EncodeHintType; |
||||
|
import com.google.zxing.WriterException; |
||||
|
import com.google.zxing.client.j2se.MatrixToImageWriter; |
||||
|
import com.google.zxing.common.BitMatrix; |
||||
|
import com.google.zxing.qrcode.QRCodeWriter; |
||||
|
|
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.util.Base64; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public class QRCodeGenerator { |
||||
|
|
||||
|
public static String generateQRCode(String baseUrl, String refNum) throws WriterException, IOException { |
||||
|
int width = 100; // width of the QR code image |
||||
|
int height = 100; // height of the QR code image |
||||
|
String format = "png"; // format of the QR code image |
||||
|
String charset = "UTF-8"; // character set used to encode the data |
||||
|
|
||||
|
// The URL to be embedded in the QR code |
||||
|
String data = baseUrl + "/viewidcard?register_id=" + refNum; |
||||
|
|
||||
|
// create the QR code writer and hints |
||||
|
QRCodeWriter qrCodeWriter = new QRCodeWriter(); |
||||
|
Map<EncodeHintType, Object> hints = new HashMap<>(); |
||||
|
hints.put(EncodeHintType.CHARACTER_SET, charset); |
||||
|
|
||||
|
// generate the QR code matrix |
||||
|
BitMatrix matrix = qrCodeWriter.encode(data, BarcodeFormat.QR_CODE, width, height, hints); |
||||
|
|
||||
|
// create the QR code image as a byte array |
||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
||||
|
MatrixToImageWriter.writeToStream(matrix, format, baos); |
||||
|
byte[] imageBytes = baos.toByteArray(); |
||||
|
|
||||
|
// encode the image data in base64 format |
||||
|
// Return the QR code image as a Base64 string with the correct data URI prefix |
||||
|
return "data:image/png;base64," + Base64.getEncoder().encodeToString(imageBytes); |
||||
|
|
||||
|
// Fixed return statement |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
package com.volunteersregistration.config; |
||||
|
|
||||
|
import org.springframework.context.annotation.Scope; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.context.WebApplicationContext; |
||||
|
import org.springframework.context.annotation.ScopedProxyMode; |
||||
|
|
||||
|
@Component |
||||
|
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS) |
||||
|
public class UserSession { |
||||
|
private Integer userId; |
||||
|
private long mobNo; |
||||
|
private String userType; |
||||
|
private String dispayName; |
||||
|
public Integer getUserId() { |
||||
|
return userId; |
||||
|
} |
||||
|
public void setUserId(Integer userId) { |
||||
|
this.userId = userId; |
||||
|
} |
||||
|
public long getMobNo() { |
||||
|
return mobNo; |
||||
|
} |
||||
|
public void setMobNo(long mobNo) { |
||||
|
this.mobNo = mobNo; |
||||
|
} |
||||
|
public String getUserType() { |
||||
|
return userType; |
||||
|
} |
||||
|
public void setUserType(String userType) { |
||||
|
this.userType = userType; |
||||
|
} |
||||
|
public String getDispayName() { |
||||
|
return dispayName; |
||||
|
} |
||||
|
public void setDispayName(String dispayName) { |
||||
|
this.dispayName = dispayName; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
package com.volunteersregistration.config; |
||||
|
|
||||
|
import java.io.File; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
|
||||
|
@Configuration |
||||
|
public class WebConfig implements WebMvcConfigurer { |
||||
|
|
||||
|
|
||||
|
@Value("${file.upload.directory}") |
||||
|
private String uploadDirectory; |
||||
|
|
||||
|
@Value("${file.aadhar.fullpath}") |
||||
|
private String aadharFullPath; |
||||
|
|
||||
|
@Value("${file.leasedoc.fullpath}") |
||||
|
private String leaseDocFullPath; |
||||
|
|
||||
|
@Value("${file.rcbookdoc.fullpath}") |
||||
|
private String rcbookDocFullPath; |
||||
|
|
||||
|
@Value("${file.userphoto.fullpath}") |
||||
|
private String userPhotoFullPath; |
||||
|
|
||||
|
@Override |
||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
||||
|
registry.addResourceHandler("/cd_waste_docs/cdwaste_aadhar/**") |
||||
|
.addResourceLocations("file:" + uploadDirectory + "/cdwaste_aadhar/"); |
||||
|
registry.addResourceHandler("/cd_waste_docs/cdwaste_leasedoc/**") |
||||
|
.addResourceLocations("file:" + uploadDirectory + "/cdwaste_leasedoc/"); |
||||
|
registry.addResourceHandler("/cd_waste_docs/cdwaste_rcbookdoc/**") |
||||
|
.addResourceLocations("file:" + uploadDirectory + "/cdwaste_rcbookdoc/"); |
||||
|
registry.addResourceHandler("/cd_waste_docs/cdwaste_userphoto/**") |
||||
|
.addResourceLocations("file:" + uploadDirectory + "/cdwaste_userphoto/"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -1,75 +1,139 @@ |
|||||
package com.volunteersregistration.controller; |
package com.volunteersregistration.controller; |
||||
|
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
|
||||
|
|
||||
import org.springframework.core.env.Environment; |
import org.springframework.core.env.Environment; |
||||
|
|
||||
import org.springframework.http.HttpStatus; |
import org.springframework.http.HttpStatus; |
||||
import org.springframework.http.ResponseEntity; |
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
import org.springframework.web.multipart.MultipartFile; |
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
import com.volunteersregistration.service.Registrationservice; |
|
||||
|
import com.volunteersregistration.config.AppConfigur; |
||||
|
import com.volunteersregistration.config.UserSession; |
||||
|
import com.volunteersregistration.entity.LoginDetail; |
||||
|
|
||||
|
import com.volunteersregistration.repository.LoginDetailRepo; |
||||
|
|
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
|
||||
import java.io.IOException; |
import java.io.IOException; |
||||
import java.nio.file.Files; |
import java.nio.file.Files; |
||||
import java.nio.file.Path; |
import java.nio.file.Path; |
||||
import java.nio.file.Paths; |
import java.nio.file.Paths; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.ArrayList; |
||||
import java.util.Collections; |
import java.util.Collections; |
||||
|
import java.util.HashMap; |
||||
import java.util.List; |
import java.util.List; |
||||
import java.util.Map; |
import java.util.Map; |
||||
|
import java.util.Random; |
||||
|
|
||||
@RestController |
|
||||
@RequestMapping("/gcc/api/registration") |
|
||||
|
@RestController("volunteerapicontroller") |
||||
|
@RequestMapping("/volunteer/api/registration") |
||||
public class ApiController { |
public class ApiController { |
||||
|
|
||||
|
@Autowired |
||||
|
private HttpSession session; |
||||
@Autowired |
@Autowired |
||||
private Environment environment; |
private Environment environment; |
||||
|
|
||||
private final Registrationservice registrationService; |
|
||||
|
@Autowired |
||||
|
private LoginDetailRepo logindetailrepo; |
||||
|
|
||||
|
@Autowired |
||||
|
private UserSession usersession; |
||||
|
@Autowired |
||||
|
private AppConfigur appConfig; |
||||
|
|
||||
|
|
||||
public ApiController(Registrationservice registrationService) { |
|
||||
this.registrationService = registrationService; |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
//for login |
||||
|
@GetMapping(value = "/login") |
||||
|
public String login(HttpServletRequest request, @RequestParam String uname, @RequestParam String upass) { |
||||
|
LoginDetail ld = logindetailrepo.checkUser(Long.parseLong(uname), upass); |
||||
|
if (ld != null) { |
||||
|
session.setAttribute("userId", ld.getId()); // Store user in session |
||||
|
session.setAttribute("mobNo", ld.getMobileno()); |
||||
|
session.setAttribute("userType", ld.getUsertype()); |
||||
|
|
||||
|
return ld.getUsertype(); // Return user type to redirect appropriately |
||||
|
} else { |
||||
|
return "Error"; // Return error if login fails |
||||
|
} |
||||
} |
} |
||||
|
|
||||
@PostMapping("/register") |
|
||||
public ResponseEntity<List<Map<String, Object>>> registerCollector( |
|
||||
@RequestParam("name") String name, |
|
||||
@RequestParam("mobileNo") String mobileNo, |
|
||||
@RequestParam("address") String address, |
|
||||
@RequestParam("adhaar") MultipartFile adhaarFile, |
|
||||
@RequestParam("vehicleRcBook") MultipartFile vehicleRcBookFile) { |
|
||||
|
@GetMapping(value = "/sendOTP") |
||||
|
public String sendOtp(HttpServletRequest request, @RequestParam String mobile,@RequestParam String purpose) { |
||||
|
String MobileNo=mobile; |
||||
|
System.out.print("\n MobileNo---:"+mobile); |
||||
|
Random rand = new Random(); |
||||
|
int otp = rand.nextInt(90000) + 10000; |
||||
|
System.out.print("\n otp---:"+otp); |
||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); |
||||
|
LocalDateTime now = LocalDateTime.now(); |
||||
|
System.out.println(dtf.format(now)); |
||||
|
|
||||
|
String generatedToken = "Welcome to GCC "+otp+" is your OTP for gcc QR System"; |
||||
|
// String key="qxg4mklD"; |
||||
|
String key="pfTEYN6H"; |
||||
|
String urlString= appConfig.getGetOtpUrl()+"from=GCCCRP&key="+key+"&sender=GCCCRP&to="+MobileNo+"&body="+generatedToken+"&entityid=1401572690000011081&templateid=1407168250479102852"; |
||||
|
// String urlString=appConfig.getGetOtpUrl()+"user=GCCtrans&authkey=92kOC1RBGBIws&sender=GCCCRP&mobile="+MobileNo+"&text="+generatedToken+"&rpt=1&summary=1&output=json&entityid=1401572690000011081&templateid=1407168250479102852"; |
||||
|
System.out.print("\n urlString---: "+urlString); |
||||
|
String bodyMessage = ""; |
||||
try { |
try { |
||||
// Save files to specified folders |
|
||||
String adhaarFolder = environment.getProperty("cdwaste_adhaar_foldername"); |
|
||||
String vehicleRcFolder = environment.getProperty("cdwaste_rc_foldername"); |
|
||||
|
RestTemplate restTemplate = new RestTemplate(); |
||||
|
String Response = restTemplate.getForObject(urlString, String.class); |
||||
|
bodyMessage=Response; |
||||
|
System.out.println("\n bodyMessage"+bodyMessage); |
||||
|
|
||||
// Create directories if they do not exist |
|
||||
Files.createDirectories(Paths.get(adhaarFolder)); |
|
||||
Files.createDirectories(Paths.get(vehicleRcFolder)); |
|
||||
|
System.out.println("OTP sent successfully!"); |
||||
|
|
||||
// Define file paths |
|
||||
Path adhaarPath = Paths.get(adhaarFolder, adhaarFile.getOriginalFilename()); |
|
||||
Path vehicleRcPath = Paths.get(vehicleRcFolder, vehicleRcBookFile.getOriginalFilename()); |
|
||||
|
} catch (Exception e) { |
||||
|
System.out.print("ERROR---: "+e); |
||||
|
bodyMessage = "Error"; |
||||
|
} |
||||
|
HttpSession session = request.getSession(); |
||||
|
session.setAttribute("otp", otp); |
||||
|
return bodyMessage; |
||||
|
|
||||
// Save files |
|
||||
adhaarFile.transferTo(adhaarPath); |
|
||||
vehicleRcBookFile.transferTo(vehicleRcPath); |
|
||||
|
} |
||||
|
|
||||
// Now call the service to save the registration data |
|
||||
List<Map<String, Object>> result = registrationService.saveRegistration(name, mobileNo, address, adhaarFile, vehicleRcBookFile); |
|
||||
|
@GetMapping(value = "/verifyOTP") |
||||
|
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
||||
|
HttpSession session = request.getSession(); |
||||
|
try { |
||||
|
Integer session_otp = (Integer) session.getAttribute("otp"); |
||||
|
System.out.println("session_otp---:" + session_otp); |
||||
|
Integer entered_otp = Integer.parseInt(otp); |
||||
|
|
||||
if (result.isEmpty()) { |
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|
||||
.body(Collections.singletonList(Map.of("status", "error", "message", "Error registering collector!"))); |
|
||||
|
if (session_otp != null && session_otp.equals(entered_otp)) { |
||||
|
System.out.println("Entered OTP Correct"); |
||||
|
session.setAttribute("verifiedotp", "success"); |
||||
|
return "Success"; |
||||
|
} else { |
||||
|
System.out.println("Incorrect OTP. Please enter correct OTPs."); |
||||
|
session.setAttribute("verifiedotp", "error"); |
||||
|
return "Error"; |
||||
} |
} |
||||
return ResponseEntity.ok(result); |
|
||||
} catch (IOException e) { |
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|
||||
.body(Collections.singletonList(Map.of("status", "error", "message", "Error uploading files: " + e.getMessage()))); |
|
||||
|
} catch (NumberFormatException e) { |
||||
|
System.out.println("Invalid OTP format: " + otp); |
||||
|
return "Error"; |
||||
|
} catch (Exception e) { |
||||
|
System.out.println("Error verifying OTP: " + e.getMessage()); |
||||
|
return "Error"; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
} |
} |
||||
@ -1,29 +1,124 @@ |
|||||
package com.volunteersregistration.controller; |
package com.volunteersregistration.controller; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.stereotype.Controller; |
import org.springframework.stereotype.Controller; |
||||
import org.springframework.ui.Model; |
import org.springframework.ui.Model; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
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.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
|
||||
|
import com.volunteersregistration.config.UserSession; |
||||
|
import com.volunteersregistration.service.VolunteerRegistrationService; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
|
||||
|
|
||||
|
|
||||
@Controller |
@Controller |
||||
@RequestMapping("/volunteer") |
@RequestMapping("/volunteer") |
||||
public class VolunteerController { |
public class VolunteerController { |
||||
|
|
||||
@GetMapping(value={"/","","/index"}) |
|
||||
public String register(@RequestParam(required = false) String ref, Model model){ |
|
||||
System.out.println("indesx page....."+ ref); |
|
||||
model.addAttribute("ref",ref); |
|
||||
return "index"; |
|
||||
|
@Autowired |
||||
|
private HttpSession session; |
||||
|
|
||||
|
@Autowired |
||||
|
private UserSession usersession; |
||||
|
@Autowired |
||||
|
public VolunteerRegistrationService volunteerRegistrationService; |
||||
|
|
||||
|
@GetMapping(value = { "/", "", "/index" }) |
||||
|
public String register(@RequestParam(required = false) String ref, Model model) { |
||||
|
System.out.println("indesx page....." + ref); |
||||
|
model.addAttribute("ref", ref); |
||||
|
return "index"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// Check session and redirect to login if user is not logged in |
||||
|
private boolean isLoggedIn() { |
||||
|
return session.getAttribute("userId") != null; // Check if userId is in session store the user type if the user type not quals to kyn n s pls logout |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = {"/kynreport"}) |
||||
|
public String kynreport(Model model, HttpServletRequest request) { |
||||
|
if (!isLoggedIn()) { |
||||
|
return "redirect:/volunteer/kynreportlogin"; // Redirect to login if not logged in |
||||
|
} |
||||
|
return "kynreport"; // Render page if logged in |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = {"/allreports"}) |
||||
|
public String allreports(Model model, HttpServletRequest request) { |
||||
|
if (!isLoggedIn()) { |
||||
|
return "redirect:/volunteer/kynreportlogin"; // Redirect to login if not logged in |
||||
|
} |
||||
|
return "allreports"; // Render page if logged in |
||||
} |
} |
||||
|
|
||||
@GetMapping(value={"/wastecollectors"}) |
|
||||
public String wastecollectors(Model model){ |
|
||||
|
|
||||
return "wastecollectors"; |
|
||||
|
@PostMapping(value = {"/allreports"}) |
||||
|
public String allreports( |
||||
|
@RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, |
||||
|
@RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate, |
||||
|
@RequestParam("category") int category, |
||||
|
Model model) { |
||||
|
|
||||
|
if (!isLoggedIn()) { |
||||
|
return "redirect:/volunteer/kynreportlogin"; |
||||
|
} |
||||
|
|
||||
|
LocalDateTime fromDateTime = fromDate.atStartOfDay(); |
||||
|
LocalDateTime toDateTime = toDate.atTime(23, 59, 59); |
||||
|
String fromDateString = fromDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
String toDateString = toDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
List<Map<String, Object>> alldata = volunteerRegistrationService.getAllReport(fromDateString, toDateString, category); |
||||
|
|
||||
|
model.addAttribute("alldata", alldata); |
||||
|
model.addAttribute("category", category); |
||||
|
model.addAttribute("fromdate", fromDate); |
||||
|
model.addAttribute("todate", toDate); |
||||
|
return "allreports"; |
||||
} |
} |
||||
|
|
||||
|
@PostMapping(value = {"/kynreport"}) |
||||
|
public String kynreport( |
||||
|
@RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, |
||||
|
@RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate, |
||||
|
@RequestParam("category") int category, |
||||
|
Model model) { |
||||
|
|
||||
|
if (!isLoggedIn()) { |
||||
|
return "redirect:/volunteer/kynreportlogin"; |
||||
|
} |
||||
|
|
||||
|
LocalDateTime fromDateTime = fromDate.atStartOfDay(); |
||||
|
LocalDateTime toDateTime = toDate.atTime(23, 59, 59); |
||||
|
String fromDateString = fromDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
String toDateString = toDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
|
||||
|
List<Map<String, Object>> reportData = volunteerRegistrationService.getKynReport(fromDateString, toDateString, category); |
||||
|
|
||||
|
model.addAttribute("fromdate", fromDate); |
||||
|
model.addAttribute("todate", toDate); |
||||
|
model.addAttribute("reportData", reportData); |
||||
|
model.addAttribute("category", category); |
||||
|
return "kynreport"; |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = {"/kynreportlogin"}) |
||||
|
public String kynreportlogin(Model model) { |
||||
|
return "kynreportlogin"; |
||||
|
} |
||||
|
|
||||
|
|
||||
} |
} |
||||
@ -1,65 +0,0 @@ |
|||||
//package com.volunteersregistration.entity; |
|
||||
// |
|
||||
//import com.fasterxml.jackson.annotation.JsonIgnore; |
|
||||
//import jakarta.persistence.*; |
|
||||
// |
|
||||
//import java.util.ArrayList; |
|
||||
//import java.util.List; |
|
||||
// |
|
||||
//@Entity |
|
||||
//public class Category { |
|
||||
// |
|
||||
// @Id |
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY) |
|
||||
// private int cat_id; |
|
||||
// |
|
||||
// @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "category", orphanRemoval = true) |
|
||||
// private List<SubCategory> subCategory = new ArrayList<>(); |
|
||||
// |
|
||||
// private String name; |
|
||||
// private String catCode; |
|
||||
// |
|
||||
// // Add helper methods to synchronize both sides of the relationship |
|
||||
// public void addSubCategory(SubCategory subCategory) { |
|
||||
// this.subCategory.add(subCategory); |
|
||||
// subCategory.setCategory(this); // Synchronize relationship |
|
||||
// } |
|
||||
// |
|
||||
// public void removeSubCategory(SubCategory subCategory) { |
|
||||
// this.subCategory.remove(subCategory); |
|
||||
// subCategory.setCategory(null); // Break the relationship |
|
||||
// } |
|
||||
// |
|
||||
// // Getters and Setters |
|
||||
// public int getCat_id() { |
|
||||
// return cat_id; |
|
||||
// } |
|
||||
// |
|
||||
// public void setCat_id(int cat_id) { |
|
||||
// this.cat_id = cat_id; |
|
||||
// } |
|
||||
// |
|
||||
// public List<SubCategory> getSubCategory() { |
|
||||
// return subCategory; |
|
||||
// } |
|
||||
// |
|
||||
// public void setSubCategory(List<SubCategory> subCategory) { |
|
||||
// this.subCategory = subCategory; |
|
||||
// } |
|
||||
// |
|
||||
// public String getName() { |
|
||||
// return name; |
|
||||
// } |
|
||||
// |
|
||||
// public void setName(String name) { |
|
||||
// this.name = name; |
|
||||
// } |
|
||||
// |
|
||||
// public String getCatCode() { |
|
||||
// return catCode; |
|
||||
// } |
|
||||
// |
|
||||
// public void setCatCode(String catCode) { |
|
||||
// this.catCode = catCode; |
|
||||
// } |
|
||||
//} |
|
||||
@ -0,0 +1,43 @@ |
|||||
|
package com.volunteersregistration.entity; |
||||
|
|
||||
|
import jakarta.annotation.Generated; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
|
||||
|
@Entity |
||||
|
public class LoginDetail { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
private int id; |
||||
|
private long mobileno; |
||||
|
private String pin; |
||||
|
private String usertype; |
||||
|
public int getId() { |
||||
|
return id; |
||||
|
} |
||||
|
public void setId(int id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
public long getMobileno() { |
||||
|
return mobileno; |
||||
|
} |
||||
|
public void setMobileno(long mobileno) { |
||||
|
this.mobileno = mobileno; |
||||
|
} |
||||
|
public String getPin() { |
||||
|
return pin; |
||||
|
} |
||||
|
public void setPin(String pin) { |
||||
|
this.pin = pin; |
||||
|
} |
||||
|
public String getUsertype() { |
||||
|
return usertype; |
||||
|
} |
||||
|
public void setUsertype(String usertype) { |
||||
|
this.usertype = usertype; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,51 +0,0 @@ |
|||||
//package com.volunteersregistration.entity; |
|
||||
// |
|
||||
//import com.fasterxml.jackson.annotation.JsonIgnore; |
|
||||
//import jakarta.persistence.*; |
|
||||
// |
|
||||
//@Entity |
|
||||
//public class SubCategory { |
|
||||
// @Id |
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY) |
|
||||
// private int sub_id; |
|
||||
// |
|
||||
// private String desc; |
|
||||
// private String subCatCode; |
|
||||
// |
|
||||
// @ManyToOne(fetch = FetchType.LAZY) |
|
||||
// @JoinColumn(name = "cat_id") // Specify the join column for clarity |
|
||||
// private Category category; |
|
||||
// |
|
||||
// // Getters and Setters |
|
||||
// public int getSub_id() { |
|
||||
// return sub_id; |
|
||||
// } |
|
||||
// |
|
||||
// public void setSub_id(int sub_id) { |
|
||||
// this.sub_id = sub_id; |
|
||||
// } |
|
||||
// |
|
||||
// public String getDesc() { |
|
||||
// return desc; |
|
||||
// } |
|
||||
// |
|
||||
// public void setDesc(String desc) { |
|
||||
// this.desc = desc; |
|
||||
// } |
|
||||
// |
|
||||
// public String getSubCatCode() { |
|
||||
// return subCatCode; |
|
||||
// } |
|
||||
// |
|
||||
// public void setSubCatCode(String subCatCode) { |
|
||||
// this.subCatCode = subCatCode; |
|
||||
// } |
|
||||
// |
|
||||
// public Category getCategory() { |
|
||||
// return category; |
|
||||
// } |
|
||||
// |
|
||||
// public void setCategory(Category category) { |
|
||||
// this.category = category; |
|
||||
// } |
|
||||
//} |
|
||||
@ -1,9 +1,26 @@ |
|||||
package com.volunteersregistration.repository; |
package com.volunteersregistration.repository; |
||||
|
|
||||
import com.volunteersregistration.entity.CorporateInformation; |
import com.volunteersregistration.entity.CorporateInformation; |
||||
|
import com.volunteersregistration.entity.VolunteerInformation; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
import org.springframework.data.jpa.repository.JpaRepository; |
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
import org.springframework.data.repository.query.Param; |
||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||
|
|
||||
@Repository |
@Repository |
||||
public interface CompanyInfoRepo extends JpaRepository<CorporateInformation,Integer> { |
|
||||
|
public interface CompanyInfoRepo extends JpaRepository<CorporateInformation, Integer> { |
||||
|
@Query(value = "SELECT * FROM corporate_information c " + "WHERE c.refer_by = :referBy " |
||||
|
+ "AND DATE(c.cdate) >= :fromDate " + "AND DATE(c.cdate) < :toDate", nativeQuery = true) |
||||
|
List<Map<String, Object>> findByReferByAndDateRange(@Param("referBy") String referBy, |
||||
|
@Param("fromDate") String fromDate, @Param("toDate") String toDate); |
||||
|
|
||||
|
@Query(value = "SELECT * FROM corporate_information c " + "WHERE DATE(c.cdate) >= :fromDate " |
||||
|
+ "AND DATE(c.cdate) < :toDate", nativeQuery = true) |
||||
|
List<Map<String, Object>> findByDateRange(@Param("fromDate") String fromDate, @Param("toDate") String toDate); |
||||
} |
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.volunteersregistration.repository; |
||||
|
|
||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
|
||||
|
import com.volunteersregistration.entity.LoginDetail; |
||||
|
|
||||
|
public interface LoginDetailRepo extends JpaRepository<LoginDetail, Integer> { |
||||
|
@Query(value = "SELECT * FROM login_detail WHERE mobileno= :mobileno and pin=:pin",nativeQuery = true) |
||||
|
LoginDetail checkUser(long mobileno,String pin); |
||||
|
|
||||
|
} |
||||
@ -1,10 +1,27 @@ |
|||||
package com.volunteersregistration.repository; |
package com.volunteersregistration.repository; |
||||
|
|
||||
import com.volunteersregistration.entity.NgoInformation; |
import com.volunteersregistration.entity.NgoInformation; |
||||
|
import com.volunteersregistration.entity.VolunteerInformation; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
import org.springframework.data.jpa.repository.JpaRepository; |
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
import org.springframework.data.repository.query.Param; |
||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||
|
|
||||
@Repository |
@Repository |
||||
public interface NgoInfoRepo extends JpaRepository<NgoInformation,Integer> { |
|
||||
|
public interface NgoInfoRepo extends JpaRepository<NgoInformation, Integer> { |
||||
|
@Query(value = "SELECT * FROM ngo_information n " + "WHERE n.refer_by = :referBy " |
||||
|
+ "AND DATE(n.cdate) >= :fromDate " + "AND DATE(n.cdate) < :toDate", nativeQuery = true) |
||||
|
List<Map<String, Object>> findByReferByAndDateRange(@Param("referBy") String referBy, |
||||
|
@Param("fromDate") String fromDate, @Param("toDate") String toDate); |
||||
|
|
||||
|
@Query(value = "SELECT * FROM ngo_information n " + "WHERE DATE(n.cdate) >= :fromDate " |
||||
|
+ "AND DATE(n.cdate) < :toDate", nativeQuery = true) |
||||
|
List<Map<String, Object>> findByDateRange(@Param("fromDate") String fromDate, @Param("toDate") String toDate); |
||||
|
|
||||
} |
} |
||||
@ -1,9 +1,26 @@ |
|||||
package com.volunteersregistration.repository; |
package com.volunteersregistration.repository; |
||||
|
|
||||
import com.volunteersregistration.entity.VolunteerInformation; |
import com.volunteersregistration.entity.VolunteerInformation; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
import org.springframework.data.jpa.repository.JpaRepository; |
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
import org.springframework.data.repository.query.Param; |
||||
import org.springframework.stereotype.Repository; |
import org.springframework.stereotype.Repository; |
||||
|
|
||||
@Repository |
@Repository |
||||
public interface VolunteerRegistrationRepo extends JpaRepository<VolunteerInformation, Integer> { |
public interface VolunteerRegistrationRepo extends JpaRepository<VolunteerInformation, Integer> { |
||||
|
@Query(value = "SELECT * FROM volunteer_information v " + "WHERE v.refer_by = :referBy " |
||||
|
+ "AND DATE(v.cdate) >= :fromDate " + "AND DATE(v.cdate) < :toDate", nativeQuery = true) |
||||
|
List<Map<String, Object>> findByReferByAndDateRange(@Param("referBy") String referBy, |
||||
|
@Param("fromDate") String fromDate, @Param("toDate") String toDate); |
||||
|
|
||||
|
@Query(value = "SELECT * FROM volunteer_information v " + "WHERE DATE(v.cdate) >= :fromDate " |
||||
|
+ "AND DATE(v.cdate) < :toDate", nativeQuery = true) |
||||
|
List<Map<String, Object>> findByDateRange(@Param("fromDate") String fromDate, @Param("toDate") String toDate); |
||||
|
|
||||
} |
} |
||||
@ -1,90 +0,0 @@ |
|||||
package com.volunteersregistration.service; |
|
||||
|
|
||||
import java.io.File; |
|
||||
import java.io.IOException; |
|
||||
import java.util.ArrayList; |
|
||||
import java.util.HashMap; |
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
import java.util.UUID; |
|
||||
|
|
||||
import javax.sql.DataSource; |
|
||||
|
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.beans.factory.annotation.Qualifier; |
|
||||
import org.springframework.core.env.Environment; |
|
||||
import org.springframework.jdbc.core.JdbcTemplate; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
import org.springframework.web.multipart.MultipartFile; |
|
||||
|
|
||||
@Service |
|
||||
public class Registrationservice { |
|
||||
|
|
||||
@Autowired |
|
||||
private JdbcTemplate jdbcTemplate; |
|
||||
|
|
||||
@Autowired |
|
||||
private Environment environment; |
|
||||
|
|
||||
@Autowired |
|
||||
public void setDataSource(@Qualifier("volunteers") DataSource dataSource) { |
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|
||||
} |
|
||||
|
|
||||
public List<Map<String, Object>> saveRegistration(String name, String mobileNo, String address, MultipartFile adhaarFile, MultipartFile vehicleRcBookFile) throws IOException { |
|
||||
|
|
||||
// Define directory paths from application.properties |
|
||||
String adhaarDir = environment.getProperty("cdwaste_adhaar_foldername"); |
|
||||
String rcBookDir = environment.getProperty("cdwaste_rc_foldername"); |
|
||||
|
|
||||
// Ensure directories exist |
|
||||
File adhaarFolder = new File(adhaarDir); |
|
||||
File rcBookFolder = new File(rcBookDir); |
|
||||
|
|
||||
if (!adhaarFolder.exists()) { |
|
||||
adhaarFolder.mkdirs(); |
|
||||
} |
|
||||
if (!rcBookFolder.exists()) { |
|
||||
rcBookFolder.mkdirs(); |
|
||||
} |
|
||||
|
|
||||
// Generate unique file names to avoid overwriting existing files |
|
||||
String adhaarFileName = adhaarFile.getOriginalFilename(); |
|
||||
String rcBookFileName = vehicleRcBookFile.getOriginalFilename(); |
|
||||
|
|
||||
// Paths where files will be stored |
|
||||
String adhaarFilePath = adhaarFolder.getAbsolutePath() + File.separator + adhaarFileName; |
|
||||
String rcBookFilePath = rcBookFolder.getAbsolutePath() + File.separator + rcBookFileName; |
|
||||
|
|
||||
// Save the files to the specified directories |
|
||||
adhaarFile.transferTo(new File(adhaarFilePath)); |
|
||||
vehicleRcBookFile.transferTo(new File(rcBookFilePath)); |
|
||||
|
|
||||
// File URLs to be saved in the database (adjust as per your URL structure) |
|
||||
String adhaarUrl = "/uploads/" + adhaarFileName; |
|
||||
String rcBookUrl = "/uploads/" + rcBookFileName; |
|
||||
|
|
||||
// SQL INSERT query (saving URLs) |
|
||||
String sqlQuery = "INSERT INTO registration (name, mobile_no, address, adhaar, vehicle_rc_book) VALUES (?, ?, ?, ?, ?)"; |
|
||||
int rowsAffected = jdbcTemplate.update(sqlQuery, name, mobileNo, address, adhaarUrl, rcBookUrl); |
|
||||
|
|
||||
// Prepare the response |
|
||||
List<Map<String, Object>> response = new ArrayList<>(); |
|
||||
Map<String, Object> result = new HashMap<>(); |
|
||||
|
|
||||
if (rowsAffected > 0) { |
|
||||
result.put("status", "success"); |
|
||||
result.put("message", "Collector registered successfully!"); |
|
||||
} else { |
|
||||
result.put("status", "error"); |
|
||||
result.put("message", "No rows affected. Registration failed!"); |
|
||||
} |
|
||||
|
|
||||
response.add(result); |
|
||||
return response; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,521 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.controller; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.security.SecureRandom; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Optional; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
import org.json.JSONObject; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.core.env.Environment; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
import com.google.zxing.WriterException; |
||||
|
import com.razorpay.Order; |
||||
|
import com.razorpay.RazorpayClient; |
||||
|
import com.razorpay.RazorpayException; |
||||
|
import com.volunteersregistration.config.AppConfigur; |
||||
|
import com.volunteersregistration.config.AppConstants; |
||||
|
import com.volunteersregistration.config.QRCodeGenerator; |
||||
|
import com.volunteersregistration.config.UserSession; |
||||
|
import com.volunteersregistration.entity.LoginDetail; |
||||
|
import com.volunteersregistration.repository.LoginDetailRepo; |
||||
|
import com.volunteersregistration.wasteCollector.entity.Cdlicense; |
||||
|
import com.volunteersregistration.wasteCollector.entity.Orderslogs; |
||||
|
import com.volunteersregistration.wasteCollector.entity.Payments; |
||||
|
import com.volunteersregistration.wasteCollector.entity.WasteRegistration; |
||||
|
import com.volunteersregistration.wasteCollector.entity.WasteRegistration.Application_status; |
||||
|
import com.volunteersregistration.wasteCollector.repository.CdlicenseRepository; |
||||
|
import com.volunteersregistration.wasteCollector.repository.OderLogsRepo; |
||||
|
import com.volunteersregistration.wasteCollector.repository.PaymentsRepo; |
||||
|
//import com.volunteersregistration.service.WasteRegistrationService; |
||||
|
import com.volunteersregistration.wasteCollector.repository.WasteRegistrationRepo; |
||||
|
import com.volunteersregistration.wasteCollector.service.WasteRegistrationService; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/volunteer/wastecollectors/api") |
||||
|
public class ApiController { |
||||
|
|
||||
|
@Autowired |
||||
|
private HttpSession session; |
||||
|
|
||||
|
@Autowired |
||||
|
private Environment environment; |
||||
|
|
||||
|
@Autowired |
||||
|
private LoginDetailRepo logindetailrepo; |
||||
|
|
||||
|
@Autowired |
||||
|
private UserSession usersession; |
||||
|
|
||||
|
@Autowired |
||||
|
private AppConfigur appConfig; |
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
private WasteRegistrationRepo wasteregistrationrepo; |
||||
|
|
||||
|
@Autowired |
||||
|
private WasteRegistrationService registrationService; |
||||
|
|
||||
|
@Autowired |
||||
|
private OderLogsRepo oderlogrepo; |
||||
|
|
||||
|
@Autowired |
||||
|
private PaymentsRepo paymentsrepo; |
||||
|
|
||||
|
@Autowired |
||||
|
private CdlicenseRepository cdlicenserepo; |
||||
|
|
||||
|
// public ApiController(WasteRegistrationService registrationService,WasteRegistrationRepo wasteregistrationrepo) { |
||||
|
// this.registrationService = registrationService; |
||||
|
// this.wasteregistrationrepo = wasteregistrationrepo; |
||||
|
// } |
||||
|
// |
||||
|
@PostMapping("/register") |
||||
|
public ResponseEntity<String> registerWasteCollector( |
||||
|
@RequestParam("name") String name, |
||||
|
@RequestParam("mobileNo") String mobileNo, |
||||
|
@RequestParam("address") String address, |
||||
|
@RequestParam("adhaar") MultipartFile adhaarFile, |
||||
|
@RequestParam("vehicletype") String vehicletype, |
||||
|
@RequestParam(value = "leasedocFile", required = false) MultipartFile leasedocFile, |
||||
|
@RequestParam("userphoto") MultipartFile userPhotoFile, |
||||
|
@RequestParam(value = "rcbook") MultipartFile rcbookFile, |
||||
|
@RequestParam("vehicle_num") String vehicle_num |
||||
|
|
||||
|
) { |
||||
|
|
||||
|
try { |
||||
|
// Check if vehicle_num already exists |
||||
|
Optional<WasteRegistration> existingVehicle = wasteregistrationrepo.findByVehicleNum(vehicle_num); |
||||
|
|
||||
|
if (existingVehicle.isPresent()) { |
||||
|
WasteRegistration registrations = existingVehicle.get(); |
||||
|
Application_status applicationStatus = registrations.getApplicationstatus(); |
||||
|
|
||||
|
|
||||
|
Long registerId = registrations.getRegister_id(); |
||||
|
|
||||
|
// Check the application status and return an appropriate message |
||||
|
if (applicationStatus == Application_status.PENDING) { |
||||
|
return ResponseEntity.ok("pending"); |
||||
|
} else if (applicationStatus == Application_status.APPROVED) { |
||||
|
return ResponseEntity.ok("approved"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
SecureRandom secureRandom = new SecureRandom(); |
||||
|
|
||||
|
// Get the current date and time |
||||
|
LocalDateTime now = LocalDateTime.now(); |
||||
|
|
||||
|
// Format the date to extract year, month, day, and seconds |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddss"); // Year (2 digits), Month, Day, Seconds |
||||
|
String dateTimePart = now.format(formatter); // Example: "24102345" for 2024-10-23 and 45 seconds |
||||
|
|
||||
|
// Generate a random 2-digit number to fill the remaining digits |
||||
|
int randomPart = secureRandom.nextInt(9000) + 1000;// Generates a 4-digit number between 0 and 99 |
||||
|
|
||||
|
// Combine the dateTimePart and randomPart to form the 10-digit number |
||||
|
String randomNumber = dateTimePart + String.format("%02d",randomPart); |
||||
|
|
||||
|
// Create WasteRegistration object |
||||
|
WasteRegistration registration = new WasteRegistration(); |
||||
|
registration.setName(name); |
||||
|
registration.setMobileNo(mobileNo); |
||||
|
registration.setAddress(address); |
||||
|
registration.setVehicletype(vehicletype); |
||||
|
registration.setVehicle_num(vehicle_num); |
||||
|
registration.setReference_num(randomNumber); |
||||
|
|
||||
|
// Set current date and time for cdate |
||||
|
registration.setCdate(LocalDateTime.now()); |
||||
|
|
||||
|
// Call service method to save the form data |
||||
|
registrationService.saveWasteRegistration(registration, adhaarFile, leasedocFile, userPhotoFile,rcbookFile); |
||||
|
|
||||
|
String register_id=String.valueOf(registration.getRegister_id()); |
||||
|
return ResponseEntity.ok(register_id); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body("Error registering waste collector: " + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//for login |
||||
|
@GetMapping(value = "/login") |
||||
|
public String login(HttpServletRequest request, @RequestParam String uname, @RequestParam String upass) { |
||||
|
LoginDetail ld = logindetailrepo.checkUser(Long.parseLong(uname), upass); |
||||
|
if (ld != null) { |
||||
|
session.setAttribute("userId", ld.getId()); // Store user in session |
||||
|
session.setAttribute("mobNo", ld.getMobileno()); |
||||
|
session.setAttribute("userType", ld.getUsertype()); |
||||
|
|
||||
|
return ld.getUsertype(); // Return user type to redirect appropriately |
||||
|
} else { |
||||
|
return "Error"; // Return error if login fails |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping(value = "/sendOTP") |
||||
|
public String sendOtp(HttpServletRequest request, @RequestParam String mobile) { |
||||
|
|
||||
|
// Create an ObjectMapper instance |
||||
|
ObjectMapper objectMapper = new ObjectMapper(); |
||||
|
|
||||
|
// Check if mobile number is already registered |
||||
|
List<WasteRegistration> registrations = wasteregistrationrepo.findByMobileNo(mobile); |
||||
|
|
||||
|
// Create a response map |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
if (registrations.isEmpty()) { |
||||
|
// If mobile number is not registered |
||||
|
response.put("status", "NOT_REGISTERED"); |
||||
|
response.put("mobile", mobile); // Return the mobile number |
||||
|
try { |
||||
|
return objectMapper.writeValueAsString(response); // Use the instance to convert map to JSON string |
||||
|
} catch (Exception e) { |
||||
|
// Handle JSON conversion error |
||||
|
return "{\"status\": \"ERROR\", \"message\": \"Could not convert response to JSON.\"}"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
String MobileNo=mobile; |
||||
|
System.out.print("\n MobileNo---:"+mobile); |
||||
|
Random rand = new Random(); |
||||
|
int otp = rand.nextInt(90000) + 10000; |
||||
|
System.out.print("\n otp---:"+otp); |
||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm"); |
||||
|
LocalDateTime now = LocalDateTime.now(); |
||||
|
System.out.println(dtf.format(now)); |
||||
|
//String generatedToken = "Welcome to GCC! Your OTP for C%26D waste collectors Registration process is "+otp; |
||||
|
|
||||
|
//String generatedToken = "Welcome to GCC "+otp+" is your OTP for gcc QR System"; |
||||
|
|
||||
|
String generatedToken = "Welcome to GCC! Your OTP for C and D waste collectors Registration process is " + otp; |
||||
|
// String key="qxg4mklD"; |
||||
|
String key="pfTEYN6H"; |
||||
|
String urlString= appConfig.getGetOtpUrl()+"from=GCCCRP&key="+key+"&sender=GCCCRP&to="+MobileNo+"&body="+generatedToken+"&entityid=1401572690000011081&templateid=1407172967243483268"; |
||||
|
|
||||
|
|
||||
|
//String urlString = "https://tmegov.onex-aura.com/api/sms?from=GCCCRP&key=pfTEYN6H&sender=GCCCRP&to=9360777472&body=Welcome%20to%20GCC!%20Your%20OTP%20for%20C%26D%20waste%20collectors%20Registration%20process%20is%20"+otp+"&entityid=1401572690000011081&templateid=1407172959127552127"; |
||||
|
//String urlString= appConfig.getGetOtpUrl()+"from=GCCCRP&key="+key+"&sender=GCCCRP&to="+MobileNo+"&body="+generatedToken+"&entityid=1401572690000011081&templateid=1407168250479102852"; |
||||
|
// String urlString=appConfig.getGetOtpUrl()+"user=GCCtrans&authkey=92kOC1RBGBIws&sender=GCCCRP&mobile="+MobileNo+"&text="+generatedToken+"&rpt=1&summary=1&output=json&entityid=1401572690000011081&templateid=1407168250479102852"; |
||||
|
System.out.print("\n urlString---: "+urlString); |
||||
|
String bodyMessage = ""; |
||||
|
try { |
||||
|
RestTemplate restTemplate = new RestTemplate(); |
||||
|
String Response = restTemplate.getForObject(urlString, String.class); |
||||
|
bodyMessage=Response; |
||||
|
System.out.println("\n bodyMessage"+bodyMessage); |
||||
|
|
||||
|
System.out.println("OTP sent successfully!"); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
System.out.print("ERROR---: "+e); |
||||
|
bodyMessage = "Error"; |
||||
|
} |
||||
|
HttpSession session = request.getSession(); |
||||
|
session.setAttribute("otp", otp); |
||||
|
return bodyMessage; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/verifyOTP") |
||||
|
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
||||
|
HttpSession session = request.getSession(); |
||||
|
try { |
||||
|
Integer session_otp = (Integer) session.getAttribute("otp"); |
||||
|
System.out.println("session_otp---:" + session_otp); |
||||
|
Integer entered_otp = Integer.parseInt(otp); |
||||
|
|
||||
|
if (session_otp != null && session_otp.equals(entered_otp)) { |
||||
|
System.out.println("Entered OTP Correct"); |
||||
|
session.setAttribute("verifiedotp", "success"); |
||||
|
return "Success"; |
||||
|
} else { |
||||
|
System.out.println("Incorrect OTP. Please enter correct OTPs."); |
||||
|
session.setAttribute("verifiedotp", "error"); |
||||
|
return "Error"; |
||||
|
} |
||||
|
} catch (NumberFormatException e) { |
||||
|
System.out.println("Invalid OTP format: " + otp); |
||||
|
return "Error"; |
||||
|
} catch (Exception e) { |
||||
|
System.out.println("Error verifying OTP: " + e.getMessage()); |
||||
|
return "Error"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/findIdByMobileNo") |
||||
|
public String findIdByMobileNo(@RequestParam String mobileNumber) |
||||
|
{ |
||||
|
List<String> registerIds = wasteregistrationrepo.getIdByMobileno(mobileNumber); |
||||
|
if (!registerIds.isEmpty()) { |
||||
|
return registerIds.get(0); // Return the first register_id |
||||
|
} else { |
||||
|
return null; // Handle cases where no register_id is found |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@PostMapping("/accept") |
||||
|
public ResponseEntity<Map<String, String>> acceptuserById(@RequestParam("registerId") Long registerId) { |
||||
|
int rowsAffected = registrationService.updateUseraccept(registerId); |
||||
|
|
||||
|
// Fetch the WasteRegistration entity by registerId to get cdate |
||||
|
WasteRegistration waste = wasteregistrationrepo.findByRegisterId(registerId); |
||||
|
if (waste == null) { |
||||
|
Map<String, String> errorResponse = new HashMap<>(); |
||||
|
errorResponse.put("status", "error"); |
||||
|
errorResponse.put("message", "No WasteRegistration found for RegisterId: " + registerId); |
||||
|
return ResponseEntity.ok(errorResponse); |
||||
|
} |
||||
|
|
||||
|
// Get the creation date (cdate) from the retrieved WasteRegistration |
||||
|
LocalDateTime cdate = waste.getCdate(); |
||||
|
|
||||
|
// Extract the year from cdate for firstnum |
||||
|
int firstnum = cdate.getYear(); |
||||
|
|
||||
|
Cdlicense cdlicense= new Cdlicense(); |
||||
|
|
||||
|
cdlicense.setCdate(LocalDateTime.now()); |
||||
|
cdlicense.setRegister_id(registerId); |
||||
|
|
||||
|
String formattedRegisterId = String.format("%05d", registerId); |
||||
|
cdlicense.setLicense_num(firstnum + "/" + formattedRegisterId); |
||||
|
|
||||
|
cdlicenserepo.save(cdlicense); |
||||
|
|
||||
|
Map<String, String> response = new HashMap<>(); |
||||
|
if (rowsAffected > 0) { |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Approved RegisterId: " + registerId + " Successfully!"); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "No records were updated."); |
||||
|
} |
||||
|
return ResponseEntity.ok(response); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/reject") |
||||
|
public ResponseEntity<Map<String, String>> rejectuserById(@RequestParam("registerId") Long registerId,@RequestParam("reason")String reason) { |
||||
|
int rowsAffected = registrationService.updateUserreject(reason,registerId); |
||||
|
|
||||
|
Map<String, String> response = new HashMap<>(); |
||||
|
if (rowsAffected > 0) { |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Rejected RegisterId: " + registerId + " Successfully!"); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "No records were updated."); |
||||
|
} |
||||
|
return ResponseEntity.ok(response); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/generateQRCode") |
||||
|
public ResponseEntity<String> generateQRCodeForUser(@RequestParam("registerId") String registerId) { |
||||
|
try { |
||||
|
// Base URL and full URL construction |
||||
|
// String baseUrl = "https://gccservices.chennaicorporation.gov.in/volunteer/wastecollectors"; |
||||
|
|
||||
|
String baseUrl ="http://localhost:8071/volunteer/wastecollectors"; |
||||
|
|
||||
|
String refNum=wasteregistrationrepo.getreferencenumbyid(registerId); |
||||
|
|
||||
|
String fullUrl = baseUrl + "/viewidcard?register_id=" + refNum; // Full URL |
||||
|
|
||||
|
// Log the generated full URL for debugging |
||||
|
System.out.println("Generated Full URL for QR Code: " + baseUrl); |
||||
|
|
||||
|
// Generate the QR code with the full URL |
||||
|
String qrCodeImage = QRCodeGenerator.generateQRCode(baseUrl, refNum); |
||||
|
String dataUri = qrCodeImage; // Encode QR code image as Base64 |
||||
|
|
||||
|
// Return the QR code image as a Base64 string |
||||
|
return ResponseEntity.ok(dataUri); |
||||
|
} catch (WriterException | IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body("Error generating QR code"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping("/getuserbyid") |
||||
|
@ResponseBody |
||||
|
public ResponseEntity<List<Map<String, Object>>> getUserDetails(@RequestParam("registerId") Long registerId) { |
||||
|
// Assuming a service method to fetch the data by register_id |
||||
|
List<Map<String, Object>> userDetails = registrationService.getUserDetailsById(registerId); |
||||
|
System.out.println(userDetails); |
||||
|
return ResponseEntity.ok(userDetails); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getuserdetails") |
||||
|
@ResponseBody |
||||
|
public ResponseEntity<List<Map<String, Object>>> getUserDetails() { |
||||
|
// Assuming a service method to fetch the data by register_id |
||||
|
List<Map<String, Object>> userDetails = registrationService.getUserDetails(); |
||||
|
System.out.println(userDetails); |
||||
|
return ResponseEntity.ok(userDetails); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/approvedlist") |
||||
|
@ResponseBody |
||||
|
public ResponseEntity<List<Map<String, Object>>> viewapprovedList() { |
||||
|
// Assuming a service method to fetch the data by register_id |
||||
|
List<Map<String, Object>> approvedDetails = registrationService.viewapprovedList(); |
||||
|
System.out.println(approvedDetails); |
||||
|
return ResponseEntity.ok(approvedDetails); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/rejectedlist") |
||||
|
@ResponseBody |
||||
|
public ResponseEntity<List<Map<String, Object>>> viewRejectedList() { |
||||
|
// Assuming a service method to fetch the data by register_id |
||||
|
List<Map<String, Object>> rejectedDetails = registrationService.viewRejectedList(); |
||||
|
System.out.println(rejectedDetails); |
||||
|
return ResponseEntity.ok(rejectedDetails); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@PostMapping("/create_order") |
||||
|
@ResponseBody |
||||
|
public String createOrder(@RequestBody Map<String,Object> data,HttpServletRequest request) throws RazorpayException { |
||||
|
|
||||
|
System.out.println("key ID :-----"+appConfig.getKeyId()); |
||||
|
long reg_id= Long.parseLong(data.get("id")+""); |
||||
|
Optional<WasteRegistration> byId = wasteregistrationrepo.findById(reg_id); |
||||
|
if(byId.isPresent()) { |
||||
|
WasteRegistration waste = byId.get(); |
||||
|
|
||||
|
if(waste.getApplicationstatus() == WasteRegistration.Application_status.PENDING) { |
||||
|
int amount=registrationService.getamount(); |
||||
|
System.out.println(" amount :-----"+amount); |
||||
|
//To enable testing mode in appConstants if required for testing & development |
||||
|
var client = new RazorpayClient(AppConstants.key_id,AppConstants.key_secret); |
||||
|
JSONObject options = new JSONObject(); |
||||
|
options.put("amount", amount*100); |
||||
|
options.put("currency", "INR"); |
||||
|
// options.put("receipt","Pet_ID/"+pet_id); |
||||
|
Order od=client.orders.create( options); |
||||
|
Orderslogs or = new Orderslogs(); |
||||
|
or.setOrder_id(od.get("id")); |
||||
|
or.setOrder_info(od.toString()); |
||||
|
//or.setUniqueid(pet_id); |
||||
|
or.setUpdated_date(LocalDateTime.now()); |
||||
|
or.setReceipt_id(String.valueOf(reg_id)); |
||||
|
or.setWasteRegistration(waste); |
||||
|
Orderslogs order = oderlogrepo.save(or); |
||||
|
System.out.println(od); |
||||
|
request.setAttribute("orderId", order.getId()); |
||||
|
return od.toString(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return "error"; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
@PostMapping("/Confirm") |
||||
|
public ResponseEntity<?> updateOrder(@RequestBody Map<String,Object> data,HttpServletRequest request){ |
||||
|
|
||||
|
System.out.println("confirm:--------------------:"+data.get("payment_id").toString()); |
||||
|
|
||||
|
long reg_id= Long.parseLong(data.get("id")+""); |
||||
|
|
||||
|
System.out.println("reg_id--------------------------:"+reg_id); |
||||
|
Optional<WasteRegistration> byId = wasteregistrationrepo.findById(reg_id); |
||||
|
int orderId = 0; |
||||
|
Orderslogs order= null; |
||||
|
try { |
||||
|
|
||||
|
orderId = (int)request.getAttribute("orderId"); |
||||
|
System.out.println("orderId:-----------"+orderId); |
||||
|
|
||||
|
|
||||
|
}catch(Exception e) { |
||||
|
orderId =1; |
||||
|
} |
||||
|
if(byId.isPresent()) { |
||||
|
System.out.println("update........................."+byId.get().getRegister_id()); |
||||
|
WasteRegistration waste = byId.get(); |
||||
|
Optional<Orderslogs> byId2 = oderlogrepo.findById(orderId); |
||||
|
Orderslogs orderid =byId2.get(); |
||||
|
|
||||
|
int amount=registrationService.getamount(); |
||||
|
|
||||
|
String pay_id= data.get("payment_id").toString(); |
||||
|
String order_id=data.get("order_id").toString(); |
||||
|
String status=data.get("status").toString(); |
||||
|
|
||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); |
||||
|
LocalDateTime now = LocalDateTime.now(); |
||||
|
System.out.println(data); |
||||
|
|
||||
|
Payments pay = new Payments(); |
||||
|
pay.setAmountReceived(amount); |
||||
|
pay.setTransactionId(pay_id); |
||||
|
pay.setCdate(now); |
||||
|
pay.setPaymentStatus(status); |
||||
|
// pay.setWasteRegistration(waste); |
||||
|
// pay.setOrderslogs(orderid); |
||||
|
pay.setWaste_registration_id(reg_id); |
||||
|
|
||||
|
|
||||
|
Thread payThred= new Thread(() -> { |
||||
|
paymentsrepo.save(pay); |
||||
|
}); |
||||
|
payThred.start(); |
||||
|
|
||||
|
waste.setPaymentstatus(WasteRegistration.Payment_status.COMPLETED); |
||||
|
wasteregistrationrepo.save(waste); |
||||
|
|
||||
|
return ResponseEntity.ok(Map.of("msg","updated")); |
||||
|
|
||||
|
} |
||||
|
return ResponseEntity.ok(Map.of("error","not_updated")); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getrefno") |
||||
|
public ResponseEntity<String> getreferencenumbyid(@RequestParam("register_id") String register_id) { |
||||
|
|
||||
|
String refnum=registrationService.getreferencenumbyid(register_id); |
||||
|
return ResponseEntity.ok(refnum); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,173 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.controller; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Optional; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
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 com.volunteersregistration.config.UserSession; |
||||
|
|
||||
|
import com.volunteersregistration.service.VolunteerRegistrationService; |
||||
|
import com.volunteersregistration.wasteCollector.entity.WasteRegistration; |
||||
|
import com.volunteersregistration.wasteCollector.entity.WasteRegistration.Application_status; |
||||
|
import com.volunteersregistration.wasteCollector.repository.CdlicenseRepository; |
||||
|
import com.volunteersregistration.wasteCollector.repository.WasteRegistrationRepo; |
||||
|
import com.volunteersregistration.wasteCollector.service.WasteRegistrationService; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpSession; |
||||
|
|
||||
|
@Controller |
||||
|
@RequestMapping("/volunteer/wastecollectors") |
||||
|
public class MainController { |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
private HttpSession session; |
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
public VolunteerRegistrationService volunteerRegistrationService; |
||||
|
|
||||
|
@Autowired |
||||
|
private WasteRegistrationRepo registrationRepo; |
||||
|
|
||||
|
@Autowired |
||||
|
private WasteRegistrationService registrationService; |
||||
|
|
||||
|
@Autowired |
||||
|
private CdlicenseRepository cdlicenserepo; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping(value = { "/", "", "/index" }) |
||||
|
public String index(Model model) { |
||||
|
|
||||
|
return "modules/wastecollectors/index"; |
||||
|
} |
||||
|
|
||||
|
// Register pages of C & D Waste Pages |
||||
|
@GetMapping("/register") |
||||
|
public String wastecollectorsregister(Model model) { |
||||
|
|
||||
|
return "modules/wastecollectors/register"; |
||||
|
} |
||||
|
|
||||
|
// Status pages of C & D Waste Pages |
||||
|
@GetMapping("/status") |
||||
|
public String wastecollectorsstatus(Model model) { |
||||
|
|
||||
|
return "modules/wastecollectors/otp"; |
||||
|
} |
||||
|
|
||||
|
// User pages of C & D Waste Pages |
||||
|
@GetMapping("/userdetail") |
||||
|
public String wastecollectorsnew(Model model, @RequestParam("register_id") String reference_num) { |
||||
|
|
||||
|
WasteRegistration refnum=registrationRepo.findByReferenceNum(reference_num); |
||||
|
if (refnum == null) { |
||||
|
// If not found, add a message to the model and return a specific view |
||||
|
model.addAttribute("message", "Sorry, your details not found..."); |
||||
|
return "modules/wastecollectors/noidcard"; // A different page to show the message |
||||
|
} |
||||
|
|
||||
|
String mobile_num=registrationRepo.getmobilenumByRefnum(reference_num); |
||||
|
List<Map<String,Object>> userdetails=registrationRepo.getlistbymobileno(mobile_num); |
||||
|
int amount=registrationService.getamount(); |
||||
|
|
||||
|
model.addAttribute("userdetails", userdetails); |
||||
|
model.addAttribute("amount", amount); |
||||
|
|
||||
|
return "modules/wastecollectors/userdetail"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/viewreceipt") |
||||
|
public String viewreceipt(Model model,@RequestParam("register_id") String reference_num) |
||||
|
{ |
||||
|
WasteRegistration refnum=registrationRepo.findByReferenceNum(reference_num); |
||||
|
if (refnum == null) { |
||||
|
// If not found, add a message to the model and return a specific view |
||||
|
model.addAttribute("message", "Sorry, your details not found..."); |
||||
|
return "modules/wastecollectors/noidcard"; // A different page to show the message |
||||
|
} |
||||
|
|
||||
|
String register_id=registrationRepo.getregisterIdbyref(reference_num); |
||||
|
List<Map<String, Object>> payment = registrationRepo.viewPaymentDetails(register_id); |
||||
|
|
||||
|
// Check if payment exists and if the payment status is PAID |
||||
|
if (payment == null || payment.isEmpty() || !payment.get(0).get("payment_status").toString().equalsIgnoreCase("PAID")) { |
||||
|
// If payment is not completed, show a message |
||||
|
model.addAttribute("message", "Sorry, your payment has not been completed."); |
||||
|
return "modules/wastecollectors/noidcard"; |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> user=registrationRepo.viewUserDetails(reference_num); |
||||
|
model.addAttribute("user", user); |
||||
|
|
||||
|
model.addAttribute("payment", payment); |
||||
|
|
||||
|
return "modules/wastecollectors/receipt"; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/viewidcard") |
||||
|
public String viewidcard(Model model, @RequestParam("register_id") String reference_num) { |
||||
|
|
||||
|
WasteRegistration refnum=registrationRepo.findByReferenceNum(reference_num); |
||||
|
if (refnum == null) { |
||||
|
// If not found, add a message to the model and return a specific view |
||||
|
model.addAttribute("message", "Sorry, your details not found..."); |
||||
|
return "modules/wastecollectors/noidcard"; // A different page to show the message |
||||
|
} |
||||
|
|
||||
|
// Fetch the register_id based on reference_num |
||||
|
String register_id = registrationRepo.getregisterIdbyref(reference_num); |
||||
|
|
||||
|
// Fetch payment details |
||||
|
List<Map<String, Object>> payment = registrationRepo.viewPaymentDetails(register_id); |
||||
|
|
||||
|
// Check if payment exists and if the payment status is PAID |
||||
|
if (payment == null || payment.isEmpty() || !payment.get(0).get("payment_status").toString().equalsIgnoreCase("PAID")) { |
||||
|
// If payment is not completed, show a message |
||||
|
model.addAttribute("message", "Sorry, your payment has not been completed."); |
||||
|
return "modules/wastecollectors/noidcard"; |
||||
|
} |
||||
|
|
||||
|
// Fetch the application status |
||||
|
WasteRegistration registration = registrationRepo.findByReferenceNum(reference_num); |
||||
|
|
||||
|
// Check if the application status is APPROVED |
||||
|
if (registration == null || registration.getApplicationstatus() != WasteRegistration.Application_status.APPROVED) { |
||||
|
// If the application is not approved, show a message |
||||
|
model.addAttribute("message", "Sorry, your application may be in process."); |
||||
|
return "modules/wastecollectors/noidcard"; |
||||
|
} |
||||
|
|
||||
|
// Proceed if both conditions (APPROVED and PAID) are satisfied |
||||
|
List<Map<String, Object>> identity = registrationService.viewIdDetails(register_id); |
||||
|
model.addAttribute("identity", identity); |
||||
|
|
||||
|
String licensenum = cdlicenserepo.findlicensenumber(register_id); |
||||
|
model.addAttribute("licensenum", licensenum); |
||||
|
|
||||
|
return "modules/wastecollectors/idcard"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
//List<Map<String,Object>> userdetails=registrationRepo.getAllById(register_id); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.entity; |
||||
|
|
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.PrePersist; |
||||
|
import jakarta.persistence.Table; |
||||
|
import jakarta.persistence.Temporal; |
||||
|
import jakarta.persistence.TemporalType; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name = "cd_amount") |
||||
|
public class Amount { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
private int id; |
||||
|
|
||||
|
private double amount; |
||||
|
|
||||
|
@Temporal(TemporalType.TIMESTAMP) // Set this field to store as TIMESTAMP |
||||
|
private Date cdate; |
||||
|
|
||||
|
private int isactive = 1; |
||||
|
|
||||
|
private int isdelete = 0; |
||||
|
|
||||
|
// Getters and Setters |
||||
|
|
||||
|
public int getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(int id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public double getAmount() { |
||||
|
return amount; |
||||
|
} |
||||
|
|
||||
|
public void setAmount(double amount) { |
||||
|
this.amount = amount; |
||||
|
} |
||||
|
|
||||
|
public Date getCdate() { |
||||
|
return cdate; |
||||
|
} |
||||
|
|
||||
|
public void setCdate(Date cdate) { |
||||
|
this.cdate = cdate; |
||||
|
} |
||||
|
|
||||
|
public int getIsactive() { |
||||
|
return isactive; |
||||
|
} |
||||
|
|
||||
|
public void setIsactive(int isactive) { |
||||
|
this.isactive = isactive; |
||||
|
} |
||||
|
|
||||
|
public int getIsdelete() { |
||||
|
return isdelete; |
||||
|
} |
||||
|
|
||||
|
public void setIsdelete(int isdelete) { |
||||
|
this.isdelete = isdelete; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,59 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.entity; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import jakarta.persistence.Column; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.Table; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name = "cdlicense") |
||||
|
public class Cdlicense |
||||
|
{ |
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
private Long id; |
||||
|
|
||||
|
private String license_num; |
||||
|
|
||||
|
private LocalDateTime cdate; |
||||
|
|
||||
|
@Column(name = "register_id") |
||||
|
private long register_id; |
||||
|
|
||||
|
public Long getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(Long id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getLicense_num() { |
||||
|
return license_num; |
||||
|
} |
||||
|
|
||||
|
public void setLicense_num(String license_num) { |
||||
|
this.license_num = license_num; |
||||
|
} |
||||
|
|
||||
|
public LocalDateTime getCdate() { |
||||
|
return cdate; |
||||
|
} |
||||
|
|
||||
|
public void setCdate(LocalDateTime cdate) { |
||||
|
this.cdate = cdate; |
||||
|
} |
||||
|
|
||||
|
public long getRegister_id() { |
||||
|
return register_id; |
||||
|
} |
||||
|
|
||||
|
public void setRegister_id(long register_id) { |
||||
|
this.register_id = register_id; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,119 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.entity; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
|
||||
|
import jakarta.persistence.CascadeType; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.FetchType; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.JoinColumn; |
||||
|
import jakarta.persistence.ManyToOne; |
||||
|
import jakarta.persistence.OneToMany; |
||||
|
import jakarta.persistence.OneToOne; |
||||
|
import jakarta.persistence.Table; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name="order_logs") |
||||
|
public class Orderslogs { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
private int id; |
||||
|
|
||||
|
private String order_id; |
||||
|
|
||||
|
//private int uniqueid; |
||||
|
|
||||
|
private String order_info; |
||||
|
|
||||
|
public String getOrder_info() { |
||||
|
return order_info; |
||||
|
} |
||||
|
|
||||
|
public void setOrder_info(String order_info) { |
||||
|
this.order_info = order_info; |
||||
|
} |
||||
|
|
||||
|
private String payment_status; |
||||
|
|
||||
|
private String receipt_id; |
||||
|
|
||||
|
private LocalDateTime updated_date; |
||||
|
|
||||
|
@ManyToOne |
||||
|
@JoinColumn(name = "waste_registration_id") |
||||
|
private WasteRegistration wasteRegistration; // ManyToOne relationship to WasteRegistration |
||||
|
|
||||
|
/* |
||||
|
* @OneToOne(mappedBy = "orderslogs", cascade = CascadeType.ALL) private |
||||
|
* Payments payment; |
||||
|
*/ |
||||
|
|
||||
|
public int getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(int id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getOrder_id() { |
||||
|
return order_id; |
||||
|
} |
||||
|
|
||||
|
public void setOrder_id(String order_id) { |
||||
|
this.order_id = order_id; |
||||
|
} |
||||
|
|
||||
|
// public int getUniqueid() { |
||||
|
// return uniqueid; |
||||
|
// } |
||||
|
// |
||||
|
// public void setUniqueid(int uniqueid) { |
||||
|
// this.uniqueid = uniqueid; |
||||
|
// } |
||||
|
|
||||
|
public String getPayment_status() { |
||||
|
return payment_status; |
||||
|
} |
||||
|
|
||||
|
public void setPayment_status(String payment_status) { |
||||
|
this.payment_status = payment_status; |
||||
|
} |
||||
|
|
||||
|
public String getReceipt_id() { |
||||
|
return receipt_id; |
||||
|
} |
||||
|
|
||||
|
public void setReceipt_id(String receipt_id) { |
||||
|
this.receipt_id = receipt_id; |
||||
|
} |
||||
|
|
||||
|
public LocalDateTime getUpdated_date() { |
||||
|
return updated_date; |
||||
|
} |
||||
|
|
||||
|
public void setUpdated_date(LocalDateTime updated_date) { |
||||
|
this.updated_date = updated_date; |
||||
|
} |
||||
|
|
||||
|
public WasteRegistration getWasteRegistration() { |
||||
|
return wasteRegistration; |
||||
|
} |
||||
|
|
||||
|
public void setWasteRegistration(WasteRegistration wasteRegistration) { |
||||
|
this.wasteRegistration = wasteRegistration; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* public Payments getPayment() { return payment; } |
||||
|
* |
||||
|
* public void setPayment(Payments payment) { this.payment = payment; } |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,112 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.entity; |
||||
|
|
||||
|
|
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
|
||||
|
import jakarta.persistence.CascadeType; |
||||
|
import jakarta.persistence.Column; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.FetchType; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.JoinColumn; |
||||
|
import jakarta.persistence.ManyToOne; |
||||
|
import jakarta.persistence.OneToMany; |
||||
|
import jakarta.persistence.OneToOne; |
||||
|
import jakarta.persistence.Table; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name = "payments") |
||||
|
public class Payments { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
private Long payment_id; |
||||
|
|
||||
|
@Column(name = "amount_received") // map to the correct column name |
||||
|
private double amountReceived; |
||||
|
|
||||
|
@Column(name = "transaction_id") // map to the correct column name |
||||
|
private String transactionId; |
||||
|
|
||||
|
@Column(name = "payment_status") // map to the correct column name |
||||
|
private String paymentStatus; |
||||
|
|
||||
|
@Column(name = "cdate") // map to the correct column name |
||||
|
private LocalDateTime cdate; |
||||
|
|
||||
|
private long waste_registration_id; |
||||
|
|
||||
|
|
||||
|
public Long getPayment_id() { |
||||
|
return payment_id; |
||||
|
} |
||||
|
|
||||
|
public void setPayment_id(Long payment_id) { |
||||
|
this.payment_id = payment_id; |
||||
|
} |
||||
|
|
||||
|
public double getAmountReceived() { |
||||
|
return amountReceived; |
||||
|
} |
||||
|
|
||||
|
public void setAmountReceived(double amountReceived) { |
||||
|
this.amountReceived = amountReceived; |
||||
|
} |
||||
|
|
||||
|
public String getTransactionId() { |
||||
|
return transactionId; |
||||
|
} |
||||
|
|
||||
|
public void setTransactionId(String transactionId) { |
||||
|
this.transactionId = transactionId; |
||||
|
} |
||||
|
|
||||
|
public String getPaymentStatus() { |
||||
|
return paymentStatus; |
||||
|
} |
||||
|
|
||||
|
public void setPaymentStatus(String paymentStatus) { |
||||
|
this.paymentStatus = paymentStatus; |
||||
|
} |
||||
|
|
||||
|
public LocalDateTime getCdate() { |
||||
|
return cdate; |
||||
|
} |
||||
|
|
||||
|
public void setCdate(LocalDateTime cdate) { |
||||
|
this.cdate = cdate; |
||||
|
} |
||||
|
|
||||
|
public long getWaste_registration_id() { |
||||
|
return waste_registration_id; |
||||
|
} |
||||
|
|
||||
|
public void setWaste_registration_id(long waste_registration_id) { |
||||
|
this.waste_registration_id = waste_registration_id; |
||||
|
} |
||||
|
|
||||
|
// public WasteRegistration getWasteRegistration() { |
||||
|
// return wasteRegistration; |
||||
|
// } |
||||
|
// |
||||
|
// public void setWasteRegistration(WasteRegistration wasteRegistration) { |
||||
|
// this.wasteRegistration = wasteRegistration; |
||||
|
// } |
||||
|
// |
||||
|
// public Orderslogs getOrderslogs() { |
||||
|
// return orderslogs; |
||||
|
// } |
||||
|
// |
||||
|
// public void setOrderslogs(Orderslogs orderslogs) { |
||||
|
// this.orderslogs = orderslogs; |
||||
|
// } |
||||
|
// |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,281 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.entity; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
|
||||
|
import jakarta.persistence.CascadeType; |
||||
|
import jakarta.persistence.Column; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.EnumType; |
||||
|
import jakarta.persistence.Enumerated; |
||||
|
import jakarta.persistence.FetchType; |
||||
|
import jakarta.persistence.GeneratedValue; |
||||
|
import jakarta.persistence.GenerationType; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.OneToMany; |
||||
|
import jakarta.persistence.Table; |
||||
|
import jakarta.persistence.Transient; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name = "waste_collectors_registration") |
||||
|
public class WasteRegistration { |
||||
|
|
||||
|
@Id |
||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||
|
private Long register_id; |
||||
|
|
||||
|
public enum Application_status { |
||||
|
PENDING,APPROVED,REJECTED |
||||
|
} |
||||
|
|
||||
|
public enum Payment_status{ |
||||
|
PENDING,COMPLETED |
||||
|
} |
||||
|
|
||||
|
private String name; |
||||
|
|
||||
|
@Column(name="vehicle_num") |
||||
|
private String vehicle_num; |
||||
|
|
||||
|
@Column(name = "mobile_no") |
||||
|
private String mobileNo; |
||||
|
|
||||
|
private String address; |
||||
|
|
||||
|
private String acceptedby; |
||||
|
|
||||
|
private LocalDateTime accepteddate; |
||||
|
|
||||
|
private String reason; |
||||
|
|
||||
|
private String adhaarurl; |
||||
|
private String leasedocurl; |
||||
|
private String userPhotourl; |
||||
|
private String rcbookurl; |
||||
|
|
||||
|
@Transient |
||||
|
private MultipartFile adhaar; |
||||
|
|
||||
|
@Transient |
||||
|
private MultipartFile leasedoc; |
||||
|
|
||||
|
@Transient |
||||
|
private MultipartFile rcbook; |
||||
|
|
||||
|
|
||||
|
@Transient |
||||
|
private MultipartFile userPhoto; |
||||
|
|
||||
|
private LocalDateTime cdate; |
||||
|
|
||||
|
private String vehicletype; |
||||
|
|
||||
|
@Column(name="reference_num") |
||||
|
private String reference_num; |
||||
|
|
||||
|
|
||||
|
|
||||
|
public String getReference_num() { |
||||
|
return reference_num; |
||||
|
} |
||||
|
|
||||
|
public void setReference_num(String reference_num) { |
||||
|
this.reference_num = reference_num; |
||||
|
} |
||||
|
|
||||
|
@Column(name="application_status") |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
private Application_status applicationstatus = Application_status.PENDING; |
||||
|
|
||||
|
@Column(name="payment_status") |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
private Payment_status paymentstatus=Payment_status.PENDING; |
||||
|
|
||||
|
public Payment_status getPaymentstatus() { |
||||
|
return paymentstatus; |
||||
|
} |
||||
|
|
||||
|
public void setPaymentstatus(Payment_status paymentstatus) { |
||||
|
this.paymentstatus = paymentstatus; |
||||
|
} |
||||
|
|
||||
|
@Column(name = "isactive",nullable = false) |
||||
|
private int isActive=1; |
||||
|
|
||||
|
@Column(name = "isdelete",nullable = false) |
||||
|
private int isDelete=0; |
||||
|
|
||||
|
public Long getRegister_id() { |
||||
|
return register_id; |
||||
|
} |
||||
|
|
||||
|
public void setRegister_id(Long register_id) { |
||||
|
this.register_id = register_id; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public String getVehicle_num() { |
||||
|
return vehicle_num; |
||||
|
} |
||||
|
|
||||
|
public void setVehicle_num(String vehicle_num) { |
||||
|
this.vehicle_num = vehicle_num; |
||||
|
} |
||||
|
|
||||
|
public String getMobileNo() { |
||||
|
return mobileNo; |
||||
|
} |
||||
|
|
||||
|
public void setMobileNo(String mobileNo) { |
||||
|
this.mobileNo = mobileNo; |
||||
|
} |
||||
|
|
||||
|
public String getAddress() { |
||||
|
return address; |
||||
|
} |
||||
|
|
||||
|
public void setAddress(String address) { |
||||
|
this.address = address; |
||||
|
} |
||||
|
|
||||
|
public String getAcceptedby() { |
||||
|
return acceptedby; |
||||
|
} |
||||
|
|
||||
|
public void setAcceptedby(String acceptedby) { |
||||
|
this.acceptedby = acceptedby; |
||||
|
} |
||||
|
|
||||
|
public LocalDateTime getAccepteddate() { |
||||
|
return accepteddate; |
||||
|
} |
||||
|
|
||||
|
public void setAccepteddate(LocalDateTime accepteddate) { |
||||
|
this.accepteddate = accepteddate; |
||||
|
} |
||||
|
|
||||
|
public String getReason() { |
||||
|
return reason; |
||||
|
} |
||||
|
|
||||
|
public void setReason(String reason) { |
||||
|
this.reason = reason; |
||||
|
} |
||||
|
|
||||
|
public String getAdhaarurl() { |
||||
|
return adhaarurl; |
||||
|
} |
||||
|
|
||||
|
public void setAdhaarurl(String adhaarurl) { |
||||
|
this.adhaarurl = adhaarurl; |
||||
|
} |
||||
|
|
||||
|
public String getLeasedocurl() { |
||||
|
return leasedocurl; |
||||
|
} |
||||
|
|
||||
|
public void setLeasedocurl(String leasedocurl) { |
||||
|
this.leasedocurl = leasedocurl; |
||||
|
} |
||||
|
|
||||
|
public String getUserPhotourl() { |
||||
|
return userPhotourl; |
||||
|
} |
||||
|
|
||||
|
public void setUserPhotourl(String userPhotourl) { |
||||
|
this.userPhotourl = userPhotourl; |
||||
|
} |
||||
|
|
||||
|
public String getRcbookurl() { |
||||
|
return rcbookurl; |
||||
|
} |
||||
|
|
||||
|
public void setRcbookurl(String rcbookurl) { |
||||
|
this.rcbookurl = rcbookurl; |
||||
|
} |
||||
|
|
||||
|
public MultipartFile getAdhaar() { |
||||
|
return adhaar; |
||||
|
} |
||||
|
|
||||
|
public void setAdhaar(MultipartFile adhaar) { |
||||
|
this.adhaar = adhaar; |
||||
|
} |
||||
|
|
||||
|
public MultipartFile getLeasedoc() { |
||||
|
return leasedoc; |
||||
|
} |
||||
|
|
||||
|
public void setLeasedoc(MultipartFile leasedoc) { |
||||
|
this.leasedoc = leasedoc; |
||||
|
} |
||||
|
|
||||
|
public MultipartFile getRcbook() { |
||||
|
return rcbook; |
||||
|
} |
||||
|
|
||||
|
public void setRcbook(MultipartFile rcbook) { |
||||
|
this.rcbook = rcbook; |
||||
|
} |
||||
|
|
||||
|
public MultipartFile getUserPhoto() { |
||||
|
return userPhoto; |
||||
|
} |
||||
|
|
||||
|
public void setUserPhoto(MultipartFile userPhoto) { |
||||
|
this.userPhoto = userPhoto; |
||||
|
} |
||||
|
|
||||
|
public LocalDateTime getCdate() { |
||||
|
return cdate; |
||||
|
} |
||||
|
|
||||
|
public void setCdate(LocalDateTime cdate) { |
||||
|
this.cdate = cdate; |
||||
|
} |
||||
|
|
||||
|
public String getVehicletype() { |
||||
|
return vehicletype; |
||||
|
} |
||||
|
|
||||
|
public void setVehicletype(String vehicletype) { |
||||
|
this.vehicletype = vehicletype; |
||||
|
} |
||||
|
|
||||
|
public Application_status getApplicationstatus() { |
||||
|
return applicationstatus; |
||||
|
} |
||||
|
|
||||
|
public void setApplicationstatus(Application_status applicationstatus) { |
||||
|
this.applicationstatus = applicationstatus; |
||||
|
} |
||||
|
|
||||
|
public int getIsActive() { |
||||
|
return isActive; |
||||
|
} |
||||
|
|
||||
|
public void setIsActive(int isActive) { |
||||
|
this.isActive = isActive; |
||||
|
} |
||||
|
|
||||
|
public int getIsDelete() { |
||||
|
return isDelete; |
||||
|
} |
||||
|
|
||||
|
public void setIsDelete(int isDelete) { |
||||
|
this.isDelete = isDelete; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.repository; |
||||
|
|
||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
import org.springframework.data.repository.query.Param; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import com.volunteersregistration.wasteCollector.entity.Cdlicense; |
||||
|
|
||||
|
@Repository |
||||
|
public interface CdlicenseRepository extends JpaRepository<Cdlicense, Long> |
||||
|
{ |
||||
|
@Query(value="SELECT license_num\r\n" |
||||
|
+ "FROM cdlicense\r\n" |
||||
|
+ "where register_id=:register_id", nativeQuery = true) |
||||
|
String findlicensenumber(@Param("register_id") String register_id); |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.repository; |
||||
|
|
||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import com.volunteersregistration.wasteCollector.entity.Orderslogs; |
||||
|
|
||||
|
@Repository |
||||
|
public interface OderLogsRepo extends JpaRepository<Orderslogs,Integer> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.repository; |
||||
|
|
||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import com.volunteersregistration.wasteCollector.entity.Payments; |
||||
|
|
||||
|
@Repository |
||||
|
public interface PaymentsRepo extends JpaRepository<Payments, Long> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,123 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.repository; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Optional; |
||||
|
|
||||
|
import org.springframework.data.jpa.repository.JpaRepository; |
||||
|
import org.springframework.data.jpa.repository.Modifying; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
import org.springframework.data.repository.query.Param; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
|
||||
|
|
||||
|
import com.volunteersregistration.wasteCollector.entity.WasteRegistration; |
||||
|
|
||||
|
|
||||
|
@Repository |
||||
|
public interface WasteRegistrationRepo extends JpaRepository<WasteRegistration, Long> { |
||||
|
|
||||
|
@Query(value = "SELECT * FROM waste_collectors_registration WHERE vehicle_num = :vehicle_num", nativeQuery = true) |
||||
|
Optional<WasteRegistration> findByVehicleNum(@Param("vehicle_num") String vehicle_num); |
||||
|
|
||||
|
@Query(value = "SELECT * FROM waste_collectors_registration WHERE reference_num = :reference_num", nativeQuery = true) |
||||
|
WasteRegistration findByReferenceNum(@Param("reference_num") String reference_num); |
||||
|
|
||||
|
|
||||
|
List<WasteRegistration> findByMobileNo(String mobileNo); // Use mobileNo here |
||||
|
|
||||
|
@Query("SELECT w FROM WasteRegistration w WHERE w.register_id = :registerId") |
||||
|
WasteRegistration findByRegisterId(@Param("registerId") Long registerId); |
||||
|
|
||||
|
|
||||
|
@Transactional |
||||
|
@Query(value = "select register_id FROM waste_collectors_registration where mobile_no=:mobileNumber", nativeQuery = true) |
||||
|
List<String> getIdByMobileno(@Param("mobileNumber") String mobileNumber); |
||||
|
|
||||
|
@Transactional |
||||
|
@Query(value = "select *\r\n" |
||||
|
+ "FROM waste_collectors_registration\r\n" |
||||
|
+ "where register_id=:register_id", nativeQuery = true) |
||||
|
List<Map<String,Object>> getAllById(@Param("register_id") String register_id); |
||||
|
|
||||
|
@Query(value = "SELECT * FROM waste_collectors_registration where application_status='PENDING'", nativeQuery = true) |
||||
|
List<Map<String, Object>> viewPendingList(); |
||||
|
|
||||
|
|
||||
|
@Query(value = "SELECT *, " + |
||||
|
"CONCAT(:baseUrl, adhaarurl) as adhaarurl, " + |
||||
|
"CONCAT(:baseUrl, user_photourl) as user_photourl, " + |
||||
|
"CONCAT(:baseUrl, rcbookurl) as rcbookurl, " + |
||||
|
"CONCAT(:baseUrl, leasedocurl) as leasedocurl " + |
||||
|
"FROM waste_collectors_registration " + |
||||
|
"WHERE register_id = :registerId", |
||||
|
nativeQuery = true) |
||||
|
List<Map<String, Object>> findUserDetailsById(@Param("registerId") Long registerId, @Param("baseUrl") String baseUrl); |
||||
|
|
||||
|
@Modifying |
||||
|
@Transactional |
||||
|
@Query(value = "UPDATE waste_collectors_registration SET application_status='APPROVED',acceptedby='OFFICER', accepteddate=NOW(),reason='Valid_Documents" |
||||
|
+ "' WHERE register_id=:register_id", nativeQuery = true) |
||||
|
int updateUseraccept(@Param("register_id") Long register_id); |
||||
|
|
||||
|
@Modifying |
||||
|
@Transactional |
||||
|
@Query(value = "UPDATE waste_collectors_registration SET application_status='REJECTED',acceptedby='OFFICER', accepteddate=NOW(),reason=:reason WHERE register_id=:register_id", nativeQuery = true) |
||||
|
int updateUserreject(@Param("reason") String reason,@Param("register_id") Long register_id); |
||||
|
|
||||
|
@Query(value = "SELECT amount \r\n" |
||||
|
+ "FROM cd_amount\r\n" |
||||
|
+ "where isactive='1' and isdelete='0'", nativeQuery = true) |
||||
|
int getamount(); |
||||
|
|
||||
|
@Query(value="SELECT register_id,name,address,mobile_no,vehicletype,cdate,accepteddate,vehicle_num \r\n" |
||||
|
+ "FROM waste_collectors_registration\r\n" |
||||
|
+ "where reference_num=:reference_num", nativeQuery = true) |
||||
|
List<Map<String, Object>> viewUserDetails(@Param("reference_num") String reference_num); |
||||
|
|
||||
|
@Query(value="SELECT transaction_id,amount_received,cdate,payment_status \r\n" |
||||
|
+ "FROM payments\r\n" |
||||
|
+ "where waste_registration_id=:register_id", nativeQuery = true) |
||||
|
List<Map<String, Object>> viewPaymentDetails(@Param("register_id") String register_id); |
||||
|
|
||||
|
//DataTable for User Details view Button |
||||
|
@Query(value = "SELECT name, mobile_no, address,register_id FROM waste_collectors_registration where application_status='PENDING' and payment_status='COMPLETED'", nativeQuery = true) |
||||
|
List<Map<String, Object>> findUserDetails(); |
||||
|
|
||||
|
@Query(value = "SELECT name, vehicle_num,vehicletype,register_id,CONCAT(:baseUrl,user_photourl) as user_photourl FROM waste_collectors_registration where register_id=:register_id ", nativeQuery = true) |
||||
|
List<Map<String, Object>> viewIdDetails(@Param("register_id") String register_id,String baseUrl); |
||||
|
|
||||
|
@Query(value = "SELECT register_id, name, mobile_no, acceptedby, accepteddate, address, vehicletype , vehicle_num FROM waste_collectors_registration WHERE application_status = 'APPROVED'", nativeQuery = true) |
||||
|
List<Map<String, Object>> approvedDetails(); |
||||
|
|
||||
|
@Query(value = "SELECT register_id, name, mobile_no, acceptedby, accepteddate, address, vehicletype , vehicle_num, reason FROM waste_collectors_registration WHERE application_status = 'REJECTED'", nativeQuery = true) |
||||
|
List<Map<String, Object>> rejectedDetails(); |
||||
|
|
||||
|
@Query(value="select mobile_no\r\n" |
||||
|
+ "from waste_collectors_registration\r\n" |
||||
|
+ "where reference_num=:reference_num",nativeQuery = true) |
||||
|
String getmobilenumByRefnum(String reference_num); |
||||
|
|
||||
|
@Query(value="select register_id,name,address,mobile_no,vehicle_num,cdate,application_status,payment_status,reason,accepteddate,reference_num\r\n" |
||||
|
+ "from waste_collectors_registration\r\n" |
||||
|
+ "where mobile_no=:mobile_no",nativeQuery = true) |
||||
|
List<Map<String, Object>> getlistbymobileno(@Param("mobile_no") String mobile_no); |
||||
|
|
||||
|
|
||||
|
@Query(value="select reference_num\r\n" |
||||
|
+ "from waste_collectors_registration\r\n" |
||||
|
+ "where register_id=:register_id",nativeQuery = true) |
||||
|
String getreferencenumbyid(@Param("register_id") String register_id); |
||||
|
|
||||
|
|
||||
|
@Query(value="select register_id\r\n" |
||||
|
+ "from waste_collectors_registration\r\n" |
||||
|
+ "where reference_num=:reference_num",nativeQuery = true) |
||||
|
String getregisterIdbyref(@Param("reference_num") String reference_num); |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,164 @@ |
|||||
|
package com.volunteersregistration.wasteCollector.service; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.core.env.Environment; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
|
||||
|
import com.volunteersregistration.wasteCollector.entity.WasteRegistration; |
||||
|
//import com.volunteersregistration.entity.WasteRegistration; |
||||
|
//import com.volunteersregistration.repository.WasteRegistrationRepo; |
||||
|
import com.volunteersregistration.wasteCollector.repository.WasteRegistrationRepo; |
||||
|
|
||||
|
import java.io.File; |
||||
|
import java.io.FileOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.nio.file.*; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Optional; |
||||
|
|
||||
|
@Service |
||||
|
public class WasteRegistrationService{ |
||||
|
|
||||
|
@Autowired |
||||
|
private WasteRegistrationRepo registrationRepo; |
||||
|
|
||||
|
@Value("${file.aadhar.upload.directory}") |
||||
|
private String aadharUploadDirectory; |
||||
|
|
||||
|
@Value("${file.leasedoc.upload.directory}") |
||||
|
private String leaseDocUploadDirectory; |
||||
|
|
||||
|
@Value("${file.rcbookdoc.upload.directory}") |
||||
|
private String rcbookDocUploadDirectory; |
||||
|
|
||||
|
|
||||
|
@Value("${file.userphoto.upload.directory}") |
||||
|
private String userPhotoUploadDirectory; |
||||
|
|
||||
|
@Value("${file.aadhar.fullpath}") |
||||
|
private String aadharFullPath; |
||||
|
|
||||
|
@Value("${file.leasedoc.fullpath}") |
||||
|
private String leaseDocFullPath; |
||||
|
|
||||
|
@Value("${file.rcbookdoc.fullpath}") |
||||
|
private String rcbookDocFullPath; |
||||
|
|
||||
|
@Value("${file.userphoto.fullpath}") |
||||
|
private String userPhotoFullPath; |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
private Environment environment; |
||||
|
|
||||
|
@Value("${app.baseUrl}") |
||||
|
private String baseUrl; |
||||
|
|
||||
|
public WasteRegistration saveWasteRegistration(WasteRegistration registration, MultipartFile aadhaar, MultipartFile leasedoc, MultipartFile userPhoto,MultipartFile rcbook) { |
||||
|
// Save the user registration first |
||||
|
|
||||
|
WasteRegistration savedRegistration = registrationRepo.save(registration); |
||||
|
|
||||
|
// Save Aadhaar file if present |
||||
|
if (aadhaar != null && !aadhaar.isEmpty()) { |
||||
|
String fileName = savedRegistration.getRegister_id() + "_" + aadhaar.getOriginalFilename(); |
||||
|
String filePath = aadharUploadDirectory + "/" + fileName; |
||||
|
saveFile(aadhaar, filePath); |
||||
|
savedRegistration.setAdhaarurl(aadharFullPath + "cdwaste_aadhar/" + fileName); |
||||
|
} |
||||
|
|
||||
|
// Save Vehicle Document if present |
||||
|
if (leasedoc != null && !leasedoc.isEmpty()) { |
||||
|
String fileName = savedRegistration.getRegister_id() + "_" + leasedoc.getOriginalFilename(); |
||||
|
String filePath = leaseDocUploadDirectory + "/" + fileName; |
||||
|
saveFile(leasedoc, filePath); |
||||
|
savedRegistration.setLeasedocurl(leaseDocFullPath+ "cdwaste_leasedoc/"+fileName); |
||||
|
} |
||||
|
|
||||
|
if (rcbook != null && !rcbook.isEmpty()) { |
||||
|
String fileName = savedRegistration.getRegister_id() + "_" + rcbook.getOriginalFilename(); |
||||
|
String filePath = rcbookDocUploadDirectory + "/" + fileName; |
||||
|
saveFile(rcbook, filePath); |
||||
|
savedRegistration.setRcbookurl(rcbookDocFullPath+ "cdwaste_rcbookdoc/"+fileName); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// Save User Photo if present |
||||
|
if (userPhoto != null && !userPhoto.isEmpty()) { |
||||
|
String fileName = savedRegistration.getRegister_id() + "_" + userPhoto.getOriginalFilename(); |
||||
|
String filePath = userPhotoUploadDirectory + "/" + fileName; |
||||
|
saveFile(userPhoto, filePath); |
||||
|
savedRegistration.setUserPhotourl(userPhotoFullPath + "cdwaste_userphoto/" + fileName); |
||||
|
} |
||||
|
|
||||
|
// Save the updated WasteRegistration with file paths |
||||
|
return registrationRepo.save(savedRegistration); |
||||
|
} |
||||
|
|
||||
|
private void saveFile(MultipartFile file, String filePath) { |
||||
|
File targetFile = new File(filePath); |
||||
|
// Create directories if they don't exist |
||||
|
targetFile.getParentFile().mkdirs(); |
||||
|
try (FileOutputStream fos = new FileOutputStream(targetFile)) { |
||||
|
fos.write(file.getBytes()); |
||||
|
} catch (IOException e) { |
||||
|
throw new RuntimeException("Error saving file: " + filePath, e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public List<Map<String,Object>> viewPendingList() { |
||||
|
// Call repository to get the filtered list based on the parameters |
||||
|
return registrationRepo.viewPendingList(); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getUserDetails() { |
||||
|
return registrationRepo.findUserDetails(); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getUserDetailsById(Long registerId) { |
||||
|
System.out.println("baseUrl:---"+baseUrl); |
||||
|
return registrationRepo.findUserDetailsById(registerId,baseUrl); |
||||
|
} |
||||
|
|
||||
|
public int updateUseraccept(Long registerId) { |
||||
|
return registrationRepo.updateUseraccept(registerId); |
||||
|
} |
||||
|
|
||||
|
public int updateUserreject(String reason,Long registerId) { |
||||
|
return registrationRepo.updateUserreject(reason,registerId); |
||||
|
} |
||||
|
|
||||
|
public int getamount() |
||||
|
{ |
||||
|
return registrationRepo.getamount(); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> viewIdDetails(String registerId) |
||||
|
{ |
||||
|
return registrationRepo.viewIdDetails(registerId,baseUrl); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> viewapprovedList() { |
||||
|
return registrationRepo.approvedDetails(); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> viewRejectedList() { |
||||
|
return registrationRepo.rejectedDetails(); |
||||
|
} |
||||
|
|
||||
|
public String getreferencenumbyid(String register_id) |
||||
|
{ |
||||
|
return registrationRepo.getreferencenumbyid(register_id); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
spring.application.name=volunteersregistration |
||||
|
|
||||
|
spring.datasource.url=jdbc:mysql://localhost:3306/volunteer |
||||
|
spring.datasource.username=root |
||||
|
spring.datasource.password=Anto |
||||
|
spring.jpa.hibernate.ddl-auto=update |
||||
|
spring.jpa.show-sql=true |
||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
||||
|
server.port=8071 |
||||
|
|
||||
|
server.servlet.session.timeout=1m |
||||
|
|
||||
|
spring.servlet.multipart.max-file-size=20MB |
||||
|
spring.servlet.multipart.max-request-size=100MB |
||||
|
|
||||
|
app.baseUrl=http://localhost:8071 |
||||
|
app.getOtpUrl=https://tmegov.onex-aura.com/api/sms? |
||||
|
app.title=GREATER CHENNAI CORPORATION - volunteers |
||||
|
app.erpUrl=https://erp.chennaicorporation.gov.in/pgr/external/mobileservice? |
||||
|
|
||||
|
|
||||
|
file.upload.directory=${user.dir}/cd_waste_docs |
||||
|
file.aadhar.upload.directory=${user.dir}/cd_waste_docs/cdwaste_aadhar |
||||
|
file.leasedoc.upload.directory=${user.dir}/cd_waste_docs/cdwaste_leasedoc |
||||
|
file.rcbookdoc.upload.directory=${user.dir}/cd_waste_docs/cdwaste_rcbookdoc |
||||
|
file.userphoto.upload.directory=${user.dir}/cd_waste_docs/cdwaste_userphoto |
||||
|
|
||||
|
file.fullpath=/ |
||||
|
file.aadhar.fullpath=/cd_waste_docs/ |
||||
|
file.leasedoc.fullpath=/cd_waste_docs/ |
||||
|
file.rcbookdoc.fullpath=/cd_waste_docs/ |
||||
|
file.userphoto.fullpath=/cd_waste_docs/ |
||||
|
|
||||
|
#testing key |
||||
|
payment.razorpay.my_key_id=rzp_test_tDkHFEqWXmuEi8 |
||||
@ -0,0 +1,36 @@ |
|||||
|
spring.application.name=volunteersregistration |
||||
|
|
||||
|
spring.datasource.url=jdbc:mysql://localhost:3306/volunteer |
||||
|
spring.datasource.username=root |
||||
|
spring.datasource.password=gccroot |
||||
|
spring.jpa.hibernate.ddl-auto=update |
||||
|
spring.jpa.show-sql=true |
||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
||||
|
server.port=8071 |
||||
|
|
||||
|
server.servlet.session.timeout=1m |
||||
|
|
||||
|
spring.servlet.multipart.max-file-size=30MB |
||||
|
spring.servlet.multipart.max-request-size=120MB |
||||
|
|
||||
|
app.baseUrl=https://gccservices.chennaicorporation.gov.in/volunteer |
||||
|
app.getOtpUrl=https://tmegov.onex-aura.com/api/sms? |
||||
|
app.title=GREATER CHENNAI CORPORATION - volunteers |
||||
|
app.erpUrl=https://erp.chennaicorporation.gov.in/pgr/external/mobileservice? |
||||
|
|
||||
|
|
||||
|
file.upload.directory=${user.dir}/cd_waste_docs |
||||
|
file.aadhar.upload.directory=${user.dir}/cd_waste_docs/cdwaste_aadhar |
||||
|
file.leasedoc.upload.directory=${user.dir}/cd_waste_docs/cdwaste_leasedoc |
||||
|
file.rcbookdoc.upload.directory=${user.dir}/cd_waste_docs/cdwaste_rcbookdoc |
||||
|
file.userphoto.upload.directory=${user.dir}/cd_waste_docs/cdwaste_userphoto |
||||
|
|
||||
|
file.fullpath=/ |
||||
|
file.aadhar.fullpath=/cd_waste_docs/ |
||||
|
file.leasedoc.fullpath=/cd_waste_docs/ |
||||
|
file.rcbookdoc.fullpath=/cd_waste_docs/ |
||||
|
file.userphoto.fullpath=/cd_waste_docs/ |
||||
|
|
||||
|
|
||||
|
#live key |
||||
|
payment.razorpay.my_key_id=rzp_live_ySI5Ns54Y7qOcJ |
||||
@ -1,13 +1 @@ |
|||||
spring.application.name=volunteersregistration |
|
||||
|
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/volunteer |
|
||||
spring.datasource.username=root |
|
||||
spring.datasource.password=root |
|
||||
spring.jpa.hibernate.ddl-auto=update |
|
||||
spring.jpa.show-sql=true |
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
|
||||
server.port=8071 |
|
||||
|
|
||||
#//////// For C&D Waste Collector Project////////////////// |
|
||||
cdwaste_adhaar_foldername=cdwastecollectordocuments/cdwaste_adhaar_copy |
|
||||
cdwaste_rc_foldername=cdwastecollectordocuments/cdwaste_rcbook_copy |
|
||||
|
spring.profiles.active=dev |
||||
@ -0,0 +1,65 @@ |
|||||
|
/* |
||||
|
* Document : app.js |
||||
|
* Author : pixelcave |
||||
|
* Description: Main entry point |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
// Import required modules
|
||||
|
import Template from './modules/template'; |
||||
|
|
||||
|
// App extends Template
|
||||
|
export default class App extends Template { |
||||
|
/* |
||||
|
* Auto called when creating a new instance |
||||
|
* |
||||
|
*/ |
||||
|
constructor() { |
||||
|
super(); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Here you can override or extend any function you want from Template class |
||||
|
* if you would like to change/extend/remove the default functionality. |
||||
|
* |
||||
|
* This way it will be easier for you to update the module files if a new update |
||||
|
* is released since all your changes will be in here overriding the original ones. |
||||
|
* |
||||
|
* Let's have a look at the _uiInit() function, the one that runs the first time |
||||
|
* we create an instance of Template class or App class which extends it. This function |
||||
|
* inits all vital functionality but you can change it to fit your own needs. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
* EXAMPLE #1 - Removing default functionality by making it empty |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
// _uiInit() {}
|
||||
|
|
||||
|
|
||||
|
/* |
||||
|
* EXAMPLE #2 - Extending default functionality with additional code |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
// _uiInit() {
|
||||
|
// // Call original function
|
||||
|
// super._uiInit();
|
||||
|
//
|
||||
|
// // Your extra JS code afterwards
|
||||
|
// }
|
||||
|
|
||||
|
/* |
||||
|
* EXAMPLE #3 - Replacing default functionality by writing your own code |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
// _uiInit() {
|
||||
|
// // Your own JS code without ever calling the original function's code
|
||||
|
// }
|
||||
|
} |
||||
|
|
||||
|
// Create a new instance of App
|
||||
|
window.Dashmix = new App(); |
||||