├── .idea
├── .gitignore
├── vcs.xml
├── encodings.xml
├── misc.xml
└── workspace.xml
├── src
└── main
│ ├── java
│ └── edu
│ │ └── icet
│ │ ├── repository
│ │ ├── CourseRepository.java
│ │ ├── ProgramRepository.java
│ │ ├── FacultyRepository.java
│ │ ├── LecturerRepository.java
│ │ └── RegisterRepository.java
│ │ ├── dto
│ │ ├── Email.java
│ │ ├── MessageRequest.java
│ │ ├── MessageResponse.java
│ │ ├── PayDetails.java
│ │ ├── Course.java
│ │ ├── Program.java
│ │ ├── Faculty.java
│ │ ├── Lecturer.java
│ │ └── Register.java
│ │ ├── Main.java
│ │ ├── config
│ │ ├── Config.java
│ │ └── PaypalConfig.java
│ │ ├── service
│ │ ├── CourseService.java
│ │ ├── ProgramService.java
│ │ ├── FacultyService.java
│ │ ├── RegisterService.java
│ │ ├── LecturerService.java
│ │ ├── EmailSenderService.java
│ │ ├── PaypalService.java
│ │ └── impl
│ │ │ ├── CourseServiceImpl.java
│ │ │ ├── FacultyServiceImpl.java
│ │ │ ├── LecturerServiceImpl.java
│ │ │ ├── RegisterServiceImpl.java
│ │ │ └── ProgramServiceImpl.java
│ │ ├── entity
│ │ ├── FacultyEntity.java
│ │ ├── ProgramEntity.java
│ │ ├── LecturerEntity.java
│ │ ├── CourseEntity.java
│ │ └── RegisterEntity.java
│ │ └── controller
│ │ ├── EmailSenderController.java
│ │ ├── PaypalController.java
│ │ ├── ChatController.java
│ │ ├── CoursesController.java
│ │ ├── ProgramController.java
│ │ ├── FacultyController.java
│ │ ├── RegisterController.java
│ │ └── LecturerController.java
│ └── resources
│ └── application.yml
├── .gitignore
├── LICENSE.md
├── pom.xml
└── README.md
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/repository/CourseRepository.java:
--------------------------------------------------------------------------------
1 | package edu.icet.repository;
2 |
3 | import edu.icet.entity.CourseEntity;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | public interface CourseRepository extends JpaRepository {
7 |
8 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/repository/ProgramRepository.java:
--------------------------------------------------------------------------------
1 | package edu.icet.repository;
2 |
3 | import edu.icet.entity.ProgramEntity;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | public interface ProgramRepository extends JpaRepository {
7 | }
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/Email.java:
--------------------------------------------------------------------------------
1 |
2 | package edu.icet.dto;
3 |
4 | import lombok.*;
5 |
6 | @Setter
7 | @Getter
8 | @Data
9 | @ToString
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class Email {
13 | private String email;
14 | private String password;
15 |
16 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/Main.java:
--------------------------------------------------------------------------------
1 | package edu.icet;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class Main {
8 | public static void main(String[] args) {
9 | SpringApplication.run(Main.class);
10 | }
11 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/MessageRequest.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | @NoArgsConstructor
9 | @AllArgsConstructor
10 | @ToString
11 | @Data
12 | public class MessageRequest {
13 | private String message;
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/MessageResponse.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | @Data
9 | @NoArgsConstructor
10 | @ToString
11 | @AllArgsConstructor
12 | public class MessageResponse {
13 | private String responseMessage;
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/repository/FacultyRepository.java:
--------------------------------------------------------------------------------
1 | package edu.icet.repository;
2 |
3 | import edu.icet.entity.FacultyEntity;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | @Repository
8 | public interface FacultyRepository extends JpaRepository {
9 |
10 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/config/Config.java:
--------------------------------------------------------------------------------
1 | package edu.icet.config;
2 |
3 | import org.modelmapper.ModelMapper;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | @Configuration
8 | public class Config{
9 | @Bean
10 | public ModelMapper getMapper(){
11 | return new ModelMapper();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/repository/LecturerRepository.java:
--------------------------------------------------------------------------------
1 | package edu.icet.repository;
2 |
3 | import edu.icet.entity.LecturerEntity;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.List;
7 |
8 | public interface LecturerRepository extends JpaRepository {
9 | List findByFaculty(String faculty);
10 | List findByLecturerNameContainingIgnoreCase(String lecturerName);
11 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/PayDetails.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 |
9 | @Data
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | @ToString
13 |
14 | public class PayDetails {
15 | private double price;
16 | private String currency;
17 | private String method;
18 | private String intent;
19 | private String description;
20 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/CourseService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import edu.icet.dto.Course;
4 | import org.springframework.web.multipart.MultipartFile;
5 |
6 | import java.util.List;
7 |
8 | public interface CourseService {
9 | List getAll();
10 | void addCourse(Course course, MultipartFile imageFile);
11 | Course searchCourseById(Long id);
12 | void deleteCourseById(Long id);
13 | void updateCourseById(Course course, MultipartFile imageFile);
14 |
15 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/repository/RegisterRepository.java:
--------------------------------------------------------------------------------
1 | package edu.icet.repository;
2 |
3 |
4 | import edu.icet.entity.RegisterEntity;
5 | import org.springframework.data.domain.Pageable;
6 | import org.springframework.data.jpa.repository.JpaRepository;
7 |
8 | import java.util.List;
9 |
10 | public interface RegisterRepository extends JpaRepository {
11 | RegisterEntity findByEmail(String email);
12 | List findByOrderByCreatedDateDesc(Pageable pageable);
13 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/ProgramService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import edu.icet.dto.Program;
4 | import org.springframework.web.multipart.MultipartFile;
5 |
6 | import java.util.List;
7 |
8 | public interface ProgramService {
9 | List getAllProgram();
10 | void addProgram(Program program, MultipartFile imageFile);
11 | void updateProgramById(Program program, MultipartFile imageFile);
12 | void deleteProgramById(Long id);
13 | Program searchProgramById(Long id);
14 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/FacultyService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import edu.icet.dto.Faculty;
4 | import org.springframework.web.multipart.MultipartFile;
5 |
6 | import java.io.IOException;
7 | import java.util.List;
8 |
9 | public interface FacultyService {
10 | List getAll();
11 | void addFaculty(Faculty faculty, MultipartFile imageFile) throws IOException;
12 | Faculty searchFacultyById(Long id);
13 | void deleteFacultyById(Long id);
14 | void updateFacultyById(Faculty faculty, MultipartFile imageFile) throws IOException;
15 |
16 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/Course.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import lombok.ToString;
7 |
8 | @Data
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | @ToString
12 | public class Course {
13 | private Long courseId;
14 | private String courseName;
15 | private String subjects;
16 | private Double courseFee;
17 | private String fulDetails;
18 | private String description;
19 | private String courseImageName;
20 | private String courseImageType;
21 | private byte[] courseImageData;
22 |
23 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/Program.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.time.LocalDateTime;
8 | @Data
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | public class Program {
12 | private Long programId;
13 | private String programName;
14 | private String programMission;
15 | private String programDetails;
16 | private String programVenue;
17 | private LocalDateTime programDateTime;
18 | private String programImageName;
19 | private String programImageType;
20 | private byte[] programImageData;
21 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/Faculty.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import edu.icet.entity.FacultyEntity;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import lombok.ToString;
8 |
9 | @Data
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | @ToString
13 | public class Faculty {
14 | private Long facultyId;
15 | private String name;
16 | private String description;
17 | private String specializations;
18 | private String icon;
19 | private FacultyEntity faculty;
20 | private String facImageName;
21 | private String faImageType;
22 | private byte[] facImageData;
23 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea/modules.xml
8 | .idea/jarRepositories.xml
9 | .idea/compiler.xml
10 | .idea/libraries/
11 | *.iws
12 | *.iml
13 | *.ipr
14 |
15 | ### Eclipse ###
16 | .apt_generated
17 | .classpath
18 | .factorypath
19 | .project
20 | .settings
21 | .springBeans
22 | .sts4-cache
23 |
24 | ### NetBeans ###
25 | /nbproject/private/
26 | /nbbuild/
27 | /dist/
28 | /nbdist/
29 | /.nb-gradle/
30 | build/
31 | !**/src/main/**/build/
32 | !**/src/test/**/build/
33 |
34 | ### VS Code ###
35 | .vscode/
36 |
37 | ### Mac OS ###
38 | .DS_Store
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/Lecturer.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import edu.icet.entity.FacultyEntity;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | public class Lecturer {
12 | private Long lecturer_id;
13 | private String lecturerName;
14 | private String lecturerExperience;
15 | private String lecturerDegrees;
16 | private FacultyEntity facultyEntity;
17 | private String learnSubjects;
18 | private String faculty;
19 | private String lecturerImageName;
20 | private String lecturerImageType;
21 | private byte[] lecturerImageData;
22 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/RegisterService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import edu.icet.dto.Register;
4 | import edu.icet.entity.RegisterEntity;
5 | import org.springframework.web.multipart.MultipartFile;
6 |
7 | import java.io.IOException;
8 | import java.util.List;
9 |
10 | public interface RegisterService {
11 |
12 | List getAll();
13 | void addUser(Register user, MultipartFile imageFile) throws IOException;
14 | Register searchUserById(Long id);
15 | void deleteUserById(Long id);
16 | RegisterEntity findByEmail(String email);
17 | void updateUserById(Register user, MultipartFile imageFile) throws IOException;
18 | List getLastUsers(int count);
19 |
20 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/LecturerService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import edu.icet.dto.Lecturer;
4 | import edu.icet.entity.LecturerEntity;
5 | import org.springframework.web.multipart.MultipartFile;
6 |
7 | import java.io.IOException;
8 | import java.util.List;
9 |
10 | public interface LecturerService {
11 | List getAllLecturer();
12 | void addLecturer(Lecturer lecturer, MultipartFile imageFile) throws IOException;
13 | Lecturer searchLecturerById(Long id);
14 | void deleteLecturerById(Long id);
15 | void updateLecturerById(Lecturer lecturer, MultipartFile imageFile) throws IOException;
16 | List searchLecturerByFaculty(String faculty);
17 | List searchLecturerByName(String lecturerName);
18 |
19 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/entity/FacultyEntity.java:
--------------------------------------------------------------------------------
1 | package edu.icet.entity;
2 |
3 |
4 | import jakarta.persistence.*;
5 | import jakarta.transaction.Transactional;
6 | import lombok.AllArgsConstructor;
7 | import lombok.Data;
8 | import lombok.NoArgsConstructor;
9 |
10 | @Data
11 | @Transactional
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | @Entity
15 | @Table(name = "faculty")
16 | public class FacultyEntity {
17 |
18 | @Id
19 | @GeneratedValue(strategy = GenerationType.IDENTITY)
20 | @Column(name = "faculty_id")
21 | private Long facultyId;
22 |
23 | private String name;
24 | private String description;
25 | private String specializations;
26 | private String icon;
27 | private String facImageName;
28 | private String facImageType;
29 |
30 | @Lob
31 | @Column(name = "fac_image_data", columnDefinition = "BLOB")
32 | private byte[] facImageData;
33 |
34 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/entity/ProgramEntity.java:
--------------------------------------------------------------------------------
1 | package edu.icet.entity;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import java.time.LocalDateTime;
9 |
10 | @Data
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Entity
14 | @Table(name = "programs")
15 | public class ProgramEntity {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.IDENTITY)
19 | private Long programId;
20 |
21 | private String programName;
22 | private String programMission;
23 | private String programDetails;
24 | private String programVenue;
25 | private LocalDateTime programDateTime;
26 |
27 | private String programImageName;
28 | private String programImageType;
29 |
30 | @Lob
31 | @Column(name = "imageData", columnDefinition = "BLOB")
32 | private byte[] programImageData;
33 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/entity/LecturerEntity.java:
--------------------------------------------------------------------------------
1 | package edu.icet.entity;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | @Entity
12 | @Table(name = "lecturer")
13 | public class LecturerEntity {
14 | @Id
15 | @GeneratedValue(strategy = GenerationType.IDENTITY)
16 | @Column(name = "lecturer_id")
17 | private Long lecturer_id;
18 |
19 | private String lecturerName;
20 | private String lecturerExperience;
21 | private String lecturerDegrees;
22 | private String learnSubjects;
23 | private String faculty;
24 |
25 | private String lecturerImageName;
26 | private String lecturerImageType;
27 |
28 | @Lob
29 | @Column(name = "lecturer_image_data", columnDefinition = "BLOB")
30 | private byte[] lecturerImageData;
31 |
32 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/EmailSenderService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.mail.SimpleMailMessage;
5 | import org.springframework.mail.javamail.JavaMailSender;
6 | import org.springframework.stereotype.Service;
7 |
8 | @Service
9 | public class EmailSenderService {
10 | @Autowired
11 | private JavaMailSender mailSender;
12 |
13 | public void sendEmail(String toEmail,
14 | String subject,
15 | String body) {
16 | SimpleMailMessage message = new SimpleMailMessage();
17 | message.setFrom("chathupachamika765@gmail.com");
18 | message.setTo(toEmail);
19 | message.setText(body);
20 | message.setSubject(subject);
21 | mailSender.send(message);
22 | System.out.println("Mail sent successfully.");
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/entity/CourseEntity.java:
--------------------------------------------------------------------------------
1 | package edu.icet.entity;
2 |
3 | import jakarta.persistence.*;
4 | import jakarta.transaction.Transactional;
5 | import lombok.AllArgsConstructor;
6 | import lombok.Data;
7 | import lombok.NoArgsConstructor;
8 |
9 | @Data
10 | @Transactional
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Entity
14 | @Table(name = "course")
15 | public class CourseEntity {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.IDENTITY)
19 | @Column(name = "course_id")
20 | private Long courseId;
21 |
22 | private String courseName;
23 | private String subjects;
24 | private Double courseFee;
25 | private String description;
26 | private String fulDetails;
27 | private String courseImageName;
28 | private String courseImageType;
29 |
30 | @Lob
31 | @Column(name = "course_image_data", columnDefinition = "BLOB")
32 | private byte[] courseImageData;
33 |
34 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/dto/Register.java:
--------------------------------------------------------------------------------
1 | package edu.icet.dto;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 | import lombok.ToString;
8 |
9 | import java.util.Date;
10 |
11 | @Data
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | @ToString
15 | public class Register {
16 |
17 | private Long reg_id;
18 | private String program;
19 | private String title;
20 | private String referral;
21 | private String shortName;
22 | private String fullName;
23 | private Date dob;
24 | private String country;
25 | private String passport;
26 | private String mobile;
27 | private String email;
28 | private String address;
29 | private String username;
30 | private Faculty faculty;
31 | private String password;
32 | private String imageName;
33 | private String imageType;
34 | private byte[] imageData;
35 |
36 |
37 | }
--------------------------------------------------------------------------------
/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 9090
3 |
4 | paypal:
5 | mode: sandbox
6 | client:
7 | id: AXF3IX8bmXTk3ogAOySIZrRb0S9tTRJGQmcwC9_0m-KucXXWzjF4uD412FAWK1lWoXWdO4LxBgDvtU9U
8 | secret: ECB-vp_BI3nCivfdO3RU2eIgcKKpW_-ONEQmlwLGHbdFYQ3VaMHXfFVgc3bMGLw5XiOHBh-wMX08mChZ
9 |
10 | spring:
11 | datasource:
12 | url: jdbc:mysql://localhost:3306/campus
13 | username: root
14 | password: 1234
15 |
16 | jpa:
17 | hibernate:
18 | ddl-auto: update
19 |
20 | mail:
21 | host: smtp.gmail.com
22 | port: 587
23 | username: chathupachamika765@gmail.com
24 | password: hzwwtarfzjoxedqc
25 | properties:
26 | mail:
27 | smtp:
28 | auth: true
29 | starttls:
30 | enable: true
31 |
32 | ai:
33 | api:
34 | url: https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent
35 | key: AIzaSyBn7-BNPtxDzD-OXB_sqRzOve-z9NNBc7Y
36 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [YEAR] [YOUR NAME]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/entity/RegisterEntity.java:
--------------------------------------------------------------------------------
1 | package edu.icet.entity;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.*;
5 |
6 | import java.time.LocalDateTime;
7 | import java.util.Date;
8 |
9 | @Data
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | @ToString
13 | @Entity
14 | @Table(name = "registered_guys")
15 | public class RegisterEntity {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.IDENTITY)
19 | private Long reg_id;
20 | private String program;
21 | private String title;
22 | private String referral;
23 | private String shortName;
24 | private String fullName;
25 | private Date dob;
26 | private String country;
27 | private String passport;
28 | private String mobile;
29 | private String email;
30 | private String address;
31 | private String username;
32 | private String password;
33 |
34 | @Column(name = "created_date")
35 | private LocalDateTime createdDate;
36 |
37 | private String imageName;
38 | private String imageType;
39 |
40 | @Lob
41 | @Column(name = "imageData", columnDefinition = "BLOB")
42 | private byte[] imageData;
43 |
44 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/controller/EmailSenderController.java:
--------------------------------------------------------------------------------
1 | package edu.icet.controller;
2 |
3 | import edu.icet.dto.Email;
4 | import edu.icet.entity.RegisterEntity;
5 | import edu.icet.service.EmailSenderService;
6 | import edu.icet.service.RegisterService;
7 | import lombok.RequiredArgsConstructor;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | @CrossOrigin
11 | @RestController
12 | @RequestMapping("/forgot-password")
13 | @RequiredArgsConstructor
14 | public class EmailSenderController {
15 |
16 | private final EmailSenderService service;
17 | private final RegisterService registerService;
18 |
19 | @PostMapping("/post")
20 | public String sendForgotPasswordEmail(@RequestBody Email request) {
21 | RegisterEntity user = registerService.findByEmail(request.getEmail());
22 | if (user != null) {
23 | String subject = "Password Reset Request - Your Password: " + user.getPassword();
24 | String body = "Click the link to reset your password.";
25 | service.sendEmail(request.getEmail(), subject, body);
26 | return "Password reset email sent successfully.";
27 | }
28 | return "Email not found.";
29 | }
30 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/config/PaypalConfig.java:
--------------------------------------------------------------------------------
1 |
2 | package edu.icet.config;
3 |
4 | import com.paypal.base.rest.APIContext;
5 | import com.paypal.base.rest.OAuthTokenCredential;
6 | import com.paypal.base.rest.PayPalRESTException;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.context.annotation.Configuration;
10 |
11 | import java.util.HashMap;
12 | import java.util.Map;
13 |
14 | @Configuration
15 | public class PaypalConfig {
16 | @Value("${paypal.client.id}")
17 | private String clientId;
18 | @Value("${paypal.client.secret}")
19 | private String clientSecret;
20 | @Value("${paypal.mode}")
21 | private String mode;
22 |
23 | @Bean
24 | public Map paypalSDKConfig(){
25 | Map configMap=new HashMap<>();
26 | configMap.put("mode",mode);
27 | return configMap;
28 | }
29 |
30 | @Bean
31 | public OAuthTokenCredential oAuthTokenCredential(){
32 | return new OAuthTokenCredential(clientId, clientSecret, paypalSDKConfig());
33 | }
34 |
35 | @Bean
36 | public APIContext apiContext() throws PayPalRESTException{
37 | APIContext context = new APIContext(oAuthTokenCredential().getAccessToken());
38 | context.setConfigurationMap(paypalSDKConfig());
39 | return context;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/PaypalService.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service;
2 |
3 | import com.paypal.api.payments.*;
4 | import com.paypal.base.rest.APIContext;
5 | import com.paypal.base.rest.PayPalRESTException;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.math.BigDecimal;
10 | import java.math.RoundingMode;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | @Service
15 | public class PaypalService {
16 |
17 | @Autowired
18 | private APIContext apiContext;
19 |
20 | public Payment createPayment(
21 | Double total,
22 | String currency,
23 | String method,
24 | String intent,
25 | String description,
26 | String cancelUrl,
27 | String successUrl) throws PayPalRESTException {
28 | Amount amount = new Amount();
29 | amount.setCurrency(currency);
30 | total = new BigDecimal(total).setScale(2, RoundingMode.HALF_UP).doubleValue();
31 | amount.setTotal(String.format("%.2f", total));
32 |
33 | Transaction transaction = new Transaction();
34 | transaction.setDescription(description);
35 | transaction.setAmount(amount);
36 |
37 | List transactions = new ArrayList<>();
38 | transactions.add(transaction);
39 |
40 | Payer payer = new Payer();
41 | payer.setPaymentMethod(method.toString());
42 |
43 | Payment payment = new Payment();
44 | payment.setIntent(intent.toString());
45 | payment.setPayer(payer);
46 | payment.setTransactions(transactions);
47 | RedirectUrls redirectUrls = new RedirectUrls();
48 | redirectUrls.setCancelUrl(cancelUrl);
49 | redirectUrls.setReturnUrl(successUrl);
50 | payment.setRedirectUrls(redirectUrls);
51 | return payment.create(apiContext);
52 | }
53 |
54 | public Payment executePayment(String paymentId, String payerId) throws PayPalRESTException{
55 | Payment payment = new Payment();
56 | payment.setId(paymentId);
57 | PaymentExecution paymentExecute = new PaymentExecution();
58 | paymentExecute.setPayerId(payerId);
59 | return payment.execute(apiContext, paymentExecute);
60 | }
61 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/impl/CourseServiceImpl.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service.impl;
2 |
3 | import edu.icet.dto.Course;
4 | import edu.icet.entity.CourseEntity;
5 | import edu.icet.repository.CourseRepository;
6 | import edu.icet.service.CourseService;
7 | import lombok.RequiredArgsConstructor;
8 | import org.modelmapper.ModelMapper;
9 | import org.springframework.stereotype.Service;
10 | import org.springframework.web.multipart.MultipartFile;
11 |
12 | import java.io.IOException;
13 | import java.util.List;
14 | import java.util.stream.Collectors;
15 |
16 | @Service
17 | @RequiredArgsConstructor
18 | public class CourseServiceImpl implements CourseService {
19 |
20 | private final CourseRepository repository;
21 | private final ModelMapper mapper;
22 |
23 | @Override
24 | public List getAll() {
25 | return repository.findAll().stream()
26 | .map(courseEntity -> mapper.map(courseEntity, Course.class))
27 | .collect(Collectors.toList());
28 | }
29 |
30 | @Override
31 | public void addCourse(Course course, MultipartFile imageFile) {
32 | try {
33 | CourseEntity courseEntity = mapper.map(course, CourseEntity.class);
34 | courseEntity.setCourseImageData(imageFile.getBytes());
35 | repository.save(courseEntity);
36 | } catch (IOException e) {
37 | e.printStackTrace();
38 | }
39 | }
40 |
41 | @Override
42 | public Course searchCourseById(Long id) {
43 | return repository.findById(id)
44 | .map(courseEntity -> mapper.map(courseEntity, Course.class))
45 | .orElse(null);
46 | }
47 |
48 | @Override
49 | public void deleteCourseById(Long id) {
50 | repository.deleteById(id);
51 | }
52 |
53 | @Override
54 | public void updateCourseById(Course course, MultipartFile imageFile) {
55 | try {
56 | CourseEntity existingCourse = repository.findById(course.getCourseId()).orElse(null);
57 | if (existingCourse != null) {
58 | mapper.map(course, existingCourse);
59 | if (imageFile != null && !imageFile.isEmpty()) {
60 | existingCourse.setCourseImageData(imageFile.getBytes());
61 | }
62 | repository.save(existingCourse);
63 | }
64 | } catch (IOException e) {
65 | e.printStackTrace();
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | new
9 | 1.0-SNAPSHOT
10 |
11 |
12 | org.springframework.boot
13 | spring-boot-starter-parent
14 | 3.3.5
15 |
16 |
17 | 23
18 | 23
19 | UTF-8
20 |
21 |
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-mail
26 |
27 |
28 |
29 | com.fasterxml.jackson.core
30 | jackson-databind
31 | 2.15.2
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-thymeleaf
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-devtools
41 | runtime
42 | true
43 |
44 |
45 | com.paypal.sdk
46 | rest-api-sdk
47 | 1.4.2
48 |
49 |
50 | org.springframework.boot
51 | spring-boot-starter-web
52 |
53 |
54 | org.projectlombok
55 | lombok
56 | 1.18.34
57 | provided
58 |
59 |
60 | org.modelmapper
61 | modelmapper
62 | 3.2.1
63 |
64 |
65 | com.mysql
66 | mysql-connector-j
67 | 9.1.0
68 |
69 |
70 | org.springframework.boot
71 | spring-boot-starter-data-jpa
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/controller/PaypalController.java:
--------------------------------------------------------------------------------
1 | package edu.icet.controller;
2 |
3 | import com.paypal.api.payments.Links;
4 | import com.paypal.api.payments.Payment;
5 | import com.paypal.base.rest.PayPalRESTException;
6 | import edu.icet.dto.PayDetails;
7 | import edu.icet.service.PaypalService;
8 | import lombok.RequiredArgsConstructor;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.http.ResponseEntity;
11 | import org.springframework.web.bind.annotation.*;
12 |
13 | import java.util.Map;
14 |
15 | @RestController
16 | @RequestMapping("/payment")
17 | @RequiredArgsConstructor
18 | @CrossOrigin()
19 | public class PaypalController {
20 |
21 | @Autowired
22 | private PaypalService service;
23 |
24 | private static final String SUCCESS_URL = "pay/success";
25 | private static final String CANCEL_URL = "pay/cancel";
26 |
27 | @PostMapping("/pay")
28 | public ResponseEntity> payment(@RequestBody PayDetails payDetails) {
29 | try {
30 | Payment payment = service.createPayment(
31 | payDetails.getPrice(),
32 | payDetails.getCurrency(),
33 | payDetails.getMethod(),
34 | payDetails.getIntent(),
35 | payDetails.getDescription(),
36 | "http://localhost:8080/" + CANCEL_URL,
37 | "http://localhost:8080/" + SUCCESS_URL
38 | );
39 | for (Links link : payment.getLinks()) {
40 | if ("approval_url".equals(link.getRel())) {
41 | return ResponseEntity.ok().body(Map.of("redirectUrl", link.getHref()));
42 | }
43 | }
44 | } catch (PayPalRESTException e) {
45 | return ResponseEntity.status(500).body(Map.of("error", "Payment initiation failed", "details", e.getMessage()));
46 | }
47 | return ResponseEntity.status(500).body(Map.of("error", "Unknown error occurred"));
48 | }
49 |
50 | @GetMapping(value = CANCEL_URL)
51 | public ResponseEntity> cancelPay() {
52 | return ResponseEntity.ok().body(Map.of("status", "cancelled", "message", "Payment was cancelled by the user."));
53 | }
54 |
55 | @GetMapping(value = SUCCESS_URL)
56 | public ResponseEntity> successPay(@RequestParam("paymentId") String paymentId, @RequestParam("PayerID") String payerId) {
57 | try {
58 | Payment payment = service.executePayment(paymentId, payerId);
59 | if ("approved".equals(payment.getState())) {
60 | return ResponseEntity.ok().body(Map.of("status", "approved", "paymentDetails", payment.toJSON()));
61 | }
62 | } catch (PayPalRESTException e) {
63 | return ResponseEntity.status(500).body(Map.of("error", "Payment execution failed", "details", e.getMessage()));
64 | }
65 | return ResponseEntity.status(400).body(Map.of("error", "Payment was not approved"));
66 | }
67 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/controller/ChatController.java:
--------------------------------------------------------------------------------
1 | package edu.icet.controller;
2 |
3 | import com.fasterxml.jackson.databind.JsonNode;
4 | import com.fasterxml.jackson.databind.ObjectMapper;
5 | import edu.icet.dto.MessageRequest;
6 | import edu.icet.dto.MessageResponse;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.http.ResponseEntity;
9 | import org.springframework.web.bind.annotation.*;
10 | import org.springframework.web.client.RestTemplate;
11 |
12 | @CrossOrigin
13 | @RestController
14 | @RequestMapping("/api/chat")
15 | public class ChatController {
16 |
17 | @Value("${ai.api.url}")
18 | private String aiApiUrl;
19 |
20 | @Value("${ai.api.key}")
21 | private String apiKey;
22 |
23 | @PostMapping("/sendMessage")
24 | public ResponseEntity sendMessage(@RequestBody MessageRequest request) {
25 | try {
26 | RestTemplate restTemplate = new RestTemplate();
27 | String fullUrl = aiApiUrl + "?key=" + apiKey;
28 |
29 | var aiRequest = """
30 | {
31 | "contents": [
32 | { "parts": [{ "text": "%s" }] }
33 | ]
34 | }
35 | """.formatted(request.getMessage());
36 |
37 | var headers = new org.springframework.http.HttpHeaders();
38 | headers.set("Content-Type", "application/json");
39 |
40 | var entity = new org.springframework.http.HttpEntity<>(aiRequest, headers);
41 | var aiResponse = restTemplate.postForEntity(fullUrl, entity, String.class);
42 |
43 | String aiText = "Sorry, something went wrong.";
44 | if (aiResponse.getStatusCode().is2xxSuccessful()) {
45 | var body = aiResponse.getBody();
46 | assert body != null;
47 | aiText = parseAiResponse(body);
48 | }
49 | return ResponseEntity.ok(new MessageResponse(aiText));
50 |
51 | } catch (Exception ex) {
52 | ex.printStackTrace();
53 | return ResponseEntity.status(500).body(new MessageResponse("An error occurred while processing your request."));
54 | }
55 | }
56 |
57 | private String parseAiResponse(String responseBody) {
58 | try {
59 | ObjectMapper mapper = new ObjectMapper();
60 | JsonNode root = mapper.readTree(responseBody);
61 | JsonNode candidates = root.path("candidates");
62 | if (candidates.isArray() && candidates.size() > 0) {
63 | JsonNode content = candidates.get(0).path("content");
64 | JsonNode parts = content.path("parts");
65 | if (parts.isArray() && parts.size() > 0) {
66 | return parts.get(0).path("text").asText();
67 | }
68 | }
69 | } catch (Exception e) {
70 | e.printStackTrace();
71 | }
72 | return "Sorry, I encountered an error parsing the response.";
73 | }
74 | }
--------------------------------------------------------------------------------
/src/main/java/edu/icet/service/impl/FacultyServiceImpl.java:
--------------------------------------------------------------------------------
1 | package edu.icet.service.impl;
2 |
3 | import edu.icet.dto.Faculty;
4 | import edu.icet.entity.FacultyEntity;
5 | import edu.icet.repository.FacultyRepository;
6 | import edu.icet.service.FacultyService;
7 | import jakarta.persistence.EntityNotFoundException;
8 | import lombok.RequiredArgsConstructor;
9 | import org.modelmapper.ModelMapper;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Service;
12 | import org.springframework.web.multipart.MultipartFile;
13 |
14 | import java.io.IOException;
15 | import java.util.List;
16 | import java.util.Optional;
17 | import java.util.stream.Collectors;
18 |
19 | @Service
20 | @RequiredArgsConstructor
21 | public class FacultyServiceImpl implements FacultyService {
22 | @Autowired
23 | private final FacultyRepository repository;
24 | private final ModelMapper mapper;
25 |
26 | @Override
27 | public List getAll() {
28 | return repository.findAll().stream()
29 | .map(entity -> mapper.map(entity, Faculty.class))
30 | .collect(Collectors.toList());
31 | }
32 |
33 | @Override
34 | public void addFaculty(Faculty faculty, MultipartFile imageFile) throws IOException {
35 | if (imageFile != null && !imageFile.isEmpty()) {
36 | faculty.setFacImageName(imageFile.getOriginalFilename());
37 | faculty.setFaImageType(imageFile.getContentType());
38 | faculty.setFacImageData(imageFile.getBytes());
39 | }
40 | FacultyEntity entity = mapper.map(faculty, FacultyEntity.class);
41 | repository.save(entity);
42 | }
43 |
44 | @Override
45 | public Faculty searchFacultyById(Long id) {
46 | return repository.findById(id)
47 | .map(entity -> mapper.map(entity, Faculty.class))
48 | .orElse(null);
49 | }
50 |
51 | @Override
52 | public void deleteFacultyById(Long id) {
53 | if (repository.existsById(id)) {
54 | repository.deleteById(id);
55 | }
56 | }
57 |
58 | @Override
59 | public void updateFacultyById(Faculty faculty, MultipartFile imageFile) throws IOException {
60 | Optional existingEntityOpt = repository.findById(faculty.getFacultyId());
61 |
62 | if (existingEntityOpt.isPresent()) {
63 | FacultyEntity existingEntity = existingEntityOpt.get();
64 |
65 | existingEntity.setName(faculty.getName());
66 | existingEntity.setDescription(faculty.getDescription());
67 | existingEntity.setSpecializations(faculty.getSpecializations());
68 | existingEntity.setIcon(faculty.getIcon());
69 |
70 | if (imageFile != null && !imageFile.isEmpty()) {
71 | existingEntity.setFacImageName(imageFile.getOriginalFilename());
72 | existingEntity.setFacImageType(imageFile.getContentType());
73 | existingEntity.setFacImageData(imageFile.getBytes());
74 | }
75 | repository.save(existingEntity);
76 | } else {
77 | throw new EntityNotFoundException("Faculty with ID " + faculty.getFacultyId() + " not found");
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/edu/icet/controller/CoursesController.java:
--------------------------------------------------------------------------------
1 | package edu.icet.controller;
2 |
3 | import edu.icet.dto.Course;
4 | import edu.icet.service.CourseService;
5 | import jakarta.persistence.EntityNotFoundException;
6 | import lombok.RequiredArgsConstructor;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.http.HttpStatus;
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 | import org.springframework.web.multipart.MultipartFile;
12 |
13 | import java.util.HashMap;
14 | import java.util.List;
15 | import java.util.Map;
16 | @CrossOrigin
17 | @RestController
18 | @RequestMapping("/course")
19 | @RequiredArgsConstructor
20 | public class CoursesController {
21 | @Autowired
22 | private final CourseService service;
23 |
24 | @GetMapping("/get-all")
25 | public ResponseEntity> getCourse() {
26 | return ResponseEntity.ok(service.getAll());
27 | }
28 |
29 | @PostMapping("/add-user")
30 | @ResponseStatus(HttpStatus.CREATED)
31 | public ResponseEntity