├── .idea ├── .gitignore ├── compiler.xml ├── encodings.xml ├── jarRepositories.xml ├── microservice-project.iml ├── misc.xml ├── modules.xml └── vcs.xml ├── .vscode └── settings.json ├── NOTES.md ├── README.md ├── api-gateway ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── api_gateway │ │ │ ├── ApiGatewayApplication.java │ │ │ ├── UserClient.java │ │ │ ├── UserService.java │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ ├── AuthenticationFilter.java │ │ │ ├── CorsConfig.java │ │ │ └── WebClientConfig.java │ │ │ └── dto │ │ │ ├── ApiResponse.java │ │ │ ├── AuthenticationRequest.java │ │ │ ├── AuthenticationResponse.java │ │ │ └── UserDTO.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── api_gateway │ └── ApiGatewayApplicationTests.java ├── client ├── .editorconfig ├── .gitignore ├── .vscode │ ├── extensions.json │ ├── launch.json │ └── tasks.json ├── README.md ├── angular.json ├── package-lock.json ├── package.json ├── public │ └── favicon.ico ├── server.ts ├── src │ ├── app │ │ ├── admin │ │ │ ├── admin.module.ts │ │ │ └── admin.routes.ts │ │ ├── apiresponse.spec.ts │ │ ├── apiresponse.ts │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.config.server.ts │ │ ├── app.config.ts │ │ ├── app.routes.ts │ │ ├── components │ │ │ ├── company-list │ │ │ │ ├── company-list.component.css │ │ │ │ ├── company-list.component.html │ │ │ │ ├── company-list.component.spec.ts │ │ │ │ └── company-list.component.ts │ │ │ ├── contact │ │ │ │ ├── contact.component.css │ │ │ │ ├── contact.component.html │ │ │ │ ├── contact.component.spec.ts │ │ │ │ └── contact.component.ts │ │ │ ├── create-profile │ │ │ │ ├── create-profile.component.css │ │ │ │ ├── create-profile.component.html │ │ │ │ ├── create-profile.component.spec.ts │ │ │ │ └── create-profile.component.ts │ │ │ ├── home │ │ │ │ ├── home.component.css │ │ │ │ ├── home.component.html │ │ │ │ ├── home.component.spec.ts │ │ │ │ └── home.component.ts │ │ │ ├── job-details │ │ │ │ ├── job-details.component.css │ │ │ │ ├── job-details.component.html │ │ │ │ ├── job-details.component.spec.ts │ │ │ │ └── job-details.component.ts │ │ │ ├── job-list │ │ │ │ ├── job-list.component.css │ │ │ │ ├── job-list.component.html │ │ │ │ ├── job-list.component.spec.ts │ │ │ │ └── job-list.component.ts │ │ │ ├── login │ │ │ │ ├── login.component.css │ │ │ │ ├── login.component.html │ │ │ │ ├── login.component.spec.ts │ │ │ │ └── login.component.ts │ │ │ ├── navbar │ │ │ │ ├── navbar.component.css │ │ │ │ ├── navbar.component.html │ │ │ │ ├── navbar.component.spec.ts │ │ │ │ └── navbar.component.ts │ │ │ ├── notification │ │ │ │ ├── notification.component.css │ │ │ │ ├── notification.component.html │ │ │ │ ├── notification.component.spec.ts │ │ │ │ └── notification.component.ts │ │ │ ├── post-project │ │ │ │ ├── post-project.component.css │ │ │ │ ├── post-project.component.html │ │ │ │ ├── post-project.component.spec.ts │ │ │ │ └── post-project.component.ts │ │ │ ├── profile-list │ │ │ │ ├── profile-list.component.css │ │ │ │ ├── profile-list.component.html │ │ │ │ ├── profile-list.component.spec.ts │ │ │ │ └── profile-list.component.ts │ │ │ ├── profile-user │ │ │ │ ├── profile-user.component.css │ │ │ │ ├── profile-user.component.html │ │ │ │ ├── profile-user.component.spec.ts │ │ │ │ └── profile-user.component.ts │ │ │ ├── profile │ │ │ │ ├── profile.component.css │ │ │ │ ├── profile.component.html │ │ │ │ ├── profile.component.spec.ts │ │ │ │ └── profile.component.ts │ │ │ ├── project-list │ │ │ │ ├── project-list.component.css │ │ │ │ ├── project-list.component.html │ │ │ │ ├── project-list.component.spec.ts │ │ │ │ └── project-list.component.ts │ │ │ ├── register │ │ │ │ ├── register.component.css │ │ │ │ ├── register.component.html │ │ │ │ ├── register.component.spec.ts │ │ │ │ └── register.component.ts │ │ │ └── user │ │ │ │ ├── user.component.css │ │ │ │ ├── user.component.html │ │ │ │ ├── user.component.spec.ts │ │ │ │ └── user.component.ts │ │ ├── layouts │ │ │ ├── admin-layout │ │ │ │ ├── admin-layout.component.css │ │ │ │ ├── admin-layout.component.html │ │ │ │ ├── admin-layout.component.spec.ts │ │ │ │ └── admin-layout.component.ts │ │ │ ├── company-list │ │ │ │ ├── company-list.component.css │ │ │ │ ├── company-list.component.html │ │ │ │ ├── company-list.component.spec.ts │ │ │ │ └── company-list.component.ts │ │ │ ├── navbar │ │ │ │ ├── navbar.component.css │ │ │ │ ├── navbar.component.html │ │ │ │ ├── navbar.component.spec.ts │ │ │ │ └── navbar.component.ts │ │ │ ├── project-list │ │ │ │ ├── project-list.component.css │ │ │ │ ├── project-list.component.html │ │ │ │ ├── project-list.component.spec.ts │ │ │ │ └── project-list.component.ts │ │ │ └── user-list │ │ │ │ ├── user-list.component.css │ │ │ │ ├── user-list.component.html │ │ │ │ ├── user-list.component.spec.ts │ │ │ │ └── user-list.component.ts │ │ ├── manager-router │ │ │ ├── manager.module.ts │ │ │ └── manager.routes.ts │ │ ├── manager │ │ │ ├── apply-layout │ │ │ │ ├── apply-layout.component.css │ │ │ │ ├── apply-layout.component.html │ │ │ │ ├── apply-layout.component.spec.ts │ │ │ │ └── apply-layout.component.ts │ │ │ ├── company │ │ │ │ ├── company.component.css │ │ │ │ ├── company.component.html │ │ │ │ ├── company.component.spec.ts │ │ │ │ └── company.component.ts │ │ │ ├── emloyee-layout │ │ │ │ ├── emloyee-layout.component.css │ │ │ │ ├── emloyee-layout.component.html │ │ │ │ ├── emloyee-layout.component.spec.ts │ │ │ │ └── emloyee-layout.component.ts │ │ │ ├── hr-layout │ │ │ │ ├── hr-layout.component.css │ │ │ │ ├── hr-layout.component.html │ │ │ │ ├── hr-layout.component.spec.ts │ │ │ │ └── hr-layout.component.ts │ │ │ ├── job-layout │ │ │ │ ├── job-layout.component.css │ │ │ │ ├── job-layout.component.html │ │ │ │ ├── job-layout.component.spec.ts │ │ │ │ └── job-layout.component.ts │ │ │ ├── manager-layout │ │ │ │ ├── manager-layout.component.css │ │ │ │ ├── manager-layout.component.html │ │ │ │ ├── manager-layout.component.spec.ts │ │ │ │ └── manager-layout.component.ts │ │ │ └── navabar │ │ │ │ ├── navabar.component.css │ │ │ │ ├── navabar.component.html │ │ │ │ ├── navabar.component.spec.ts │ │ │ │ └── navabar.component.ts │ │ ├── model │ │ │ ├── company.spec.ts │ │ │ ├── company.ts │ │ │ ├── contact.spec.ts │ │ │ ├── contact.ts │ │ │ ├── job.spec.ts │ │ │ ├── job.ts │ │ │ ├── notification.spec.ts │ │ │ ├── notification.ts │ │ │ ├── profile.spec.ts │ │ │ ├── profile.ts │ │ │ ├── project.spec.ts │ │ │ ├── project.ts │ │ │ ├── user.spec.ts │ │ │ └── user.ts │ │ ├── service │ │ │ ├── auth-interceptor.service.spec.ts │ │ │ ├── auth-interceptor.service.ts │ │ │ ├── company-service.service.spec.ts │ │ │ ├── company-service.service.ts │ │ │ ├── contact-service.service.spec.ts │ │ │ ├── contact-service.service.ts │ │ │ ├── image-service.service.spec.ts │ │ │ ├── image-service.service.ts │ │ │ ├── job-service.service.spec.ts │ │ │ ├── job-service.service.ts │ │ │ ├── notification-service.service.spec.ts │ │ │ ├── notification-service.service.ts │ │ │ ├── profile-service.service.spec.ts │ │ │ ├── profile-service.service.ts │ │ │ ├── project-service.service.spec.ts │ │ │ ├── project-service.service.ts │ │ │ ├── user-service.service.spec.ts │ │ │ └── user-service.service.ts │ │ └── template.html │ ├── index.html │ ├── main.server.ts │ ├── main.ts │ └── styles.css ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json ├── discovery-server ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── discovery_server │ │ │ └── DiscoveryServerApplication.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── example │ └── discovery_server │ └── DiscoveryServerApplicationTests.java ├── email-service ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── email_service │ │ │ ├── EmailServiceApplication.java │ │ │ ├── MailService.java │ │ │ ├── MailServiceImpl.java │ │ │ ├── config │ │ │ └── KafkaConfig.java │ │ │ ├── controller │ │ │ └── MailController.java │ │ │ ├── dto │ │ │ ├── ApiResponse.java │ │ │ ├── MailDTO.java │ │ │ ├── MessageDTO.java │ │ │ └── UserDTO.java │ │ │ ├── model │ │ │ └── Mail.java │ │ │ └── openfeign │ │ │ └── UserClient.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── email_service │ └── EmailServiceApplicationTests.java ├── image-service ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── image_service │ │ │ ├── ImageServiceApplication.java │ │ │ ├── config │ │ │ └── AppConfig.java │ │ │ ├── controller │ │ │ └── ImageController.java │ │ │ ├── dto │ │ │ ├── ApiResponse.java │ │ │ └── ImageDTO.java │ │ │ ├── exception │ │ │ ├── BadRequestException.java │ │ │ ├── CloudinaryException.java │ │ │ ├── CustomException.java │ │ │ ├── CustomizedResponseEntityExceptionHandler.java │ │ │ ├── Error.java │ │ │ └── ExceptionResponse.java │ │ │ ├── model │ │ │ └── Image.java │ │ │ ├── repository │ │ │ └── ImageRepository.java │ │ │ └── services │ │ │ ├── CloudinaryService.java │ │ │ ├── service │ │ │ └── ImageService.java │ │ │ └── serviceimpl │ │ │ └── ImageServiceImpl.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── image_service │ └── ImageServiceApplicationTests.java ├── manager-service ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── manager_service │ │ │ ├── ManagerServiceApplication.java │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ └── MongoConfig.java │ │ │ ├── controller │ │ │ ├── CompanyController.java │ │ │ └── JobController.java │ │ │ ├── dto │ │ │ ├── ApiResponse.java │ │ │ ├── AuthenticationRequest.java │ │ │ ├── AuthenticationResponse.java │ │ │ ├── BooleanDTO.java │ │ │ ├── CompanyDTO.java │ │ │ ├── ImageDTO.java │ │ │ ├── JobDTO.java │ │ │ ├── ProfileDTO.java │ │ │ └── UserDTO.java │ │ │ ├── exception │ │ │ ├── BadRequestException.java │ │ │ ├── CustomException.java │ │ │ ├── CustomizedResponseEntityExceptionHandler.java │ │ │ ├── Error.java │ │ │ └── ExceptionResponse.java │ │ │ ├── models │ │ │ ├── Company.java │ │ │ ├── Contact.java │ │ │ ├── Job.java │ │ │ └── TypeJob.java │ │ │ ├── openfeign │ │ │ ├── EmailClient.java │ │ │ ├── ImageClient.java │ │ │ ├── MessageDTO.java │ │ │ ├── NotificationClient.java │ │ │ ├── ProfileClient.java │ │ │ └── UserClient.java │ │ │ ├── repository │ │ │ ├── CompanyRepository.java │ │ │ └── JobRepository.java │ │ │ └── services │ │ │ ├── service │ │ │ ├── CompanyService.java │ │ │ └── JobService.java │ │ │ └── serviceimpl │ │ │ ├── CompanyServiceImpl.java │ │ │ └── JobServiceImpl.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── manager_service │ └── ManagerServiceApplicationTests.java ├── notification-service ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── notification_service │ │ │ ├── NotificationServiceApplication.java │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ └── KafkaConfig.java │ │ │ ├── controller │ │ │ └── NotificationController.java │ │ │ ├── dto │ │ │ ├── ApiResponse.java │ │ │ ├── MessageDTO.java │ │ │ ├── NotificationDTO.java │ │ │ └── UserDTO.java │ │ │ ├── exception │ │ │ ├── BadRequestException.java │ │ │ ├── CloudinaryException.java │ │ │ ├── CustomException.java │ │ │ ├── CustomizedResponseEntityExceptionHandler.java │ │ │ ├── Error.java │ │ │ └── ExceptionResponse.java │ │ │ ├── model │ │ │ └── Notification.java │ │ │ ├── openFeign │ │ │ └── UserClient.java │ │ │ ├── repository │ │ │ └── NotificationRepository.java │ │ │ └── services │ │ │ ├── service │ │ │ └── NotificationService.java │ │ │ └── serviceimpl │ │ │ └── NotificationServiceImpl.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── notification_service │ └── NotificationServiceApplicationTests.java ├── profile-service ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── profile_service │ │ │ ├── ProfileServiceApplication.java │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ ├── FeignClientConfig.java │ │ │ └── MongoConfig.java │ │ │ ├── controller │ │ │ └── ProfileController.java │ │ │ ├── dto │ │ │ ├── ApiResponse.java │ │ │ ├── BooleanDTO.java │ │ │ ├── ImageDTO.java │ │ │ ├── ProfileDTO.java │ │ │ └── UserDTO.java │ │ │ ├── exception │ │ │ ├── BadRequestException.java │ │ │ ├── CustomException.java │ │ │ ├── CustomizedResponseEntityExceptionHandler.java │ │ │ ├── Error.java │ │ │ └── ExceptionResponse.java │ │ │ ├── model │ │ │ ├── About.java │ │ │ ├── Contact.java │ │ │ ├── Profile.java │ │ │ └── TypeProfile.java │ │ │ ├── openFeign │ │ │ ├── ImageClient.java │ │ │ └── UserClient.java │ │ │ ├── repository │ │ │ └── ProfileRepository.java │ │ │ └── services │ │ │ ├── service │ │ │ └── ProfileService.java │ │ │ └── serviceImp │ │ │ └── ProfileServiceImp.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── profile_service │ └── ProfileServiceApplicationTests.java ├── project-service ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── baconbao │ │ │ └── project_service │ │ │ ├── ProjectServiceApplication.java │ │ │ ├── config │ │ │ └── AppConfig.java │ │ │ ├── controller │ │ │ └── ProjectController.java │ │ │ ├── dto │ │ │ ├── ApiResponse.java │ │ │ ├── ImageDTO.java │ │ │ ├── ProfileDTO.java │ │ │ ├── ProjectDTO.java │ │ │ └── UserDTO.java │ │ │ ├── exception │ │ │ ├── BadRequestException.java │ │ │ ├── CustomException.java │ │ │ ├── CustomizedResponseEntityExceptionHandler.java │ │ │ ├── Error.java │ │ │ └── ExceptionResponse.java │ │ │ ├── model │ │ │ └── Project.java │ │ │ ├── openFeign │ │ │ ├── ImageClient.java │ │ │ ├── ProfileClient.java │ │ │ ├── UserClient.java │ │ │ └── test.java │ │ │ ├── repository │ │ │ └── ProjectRepository.java │ │ │ └── services │ │ │ ├── service │ │ │ └── ProjectService.java │ │ │ └── serviceimpl │ │ │ └── ProjectServiceImpl.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── baconbao │ └── project_service │ └── ProjectServiceApplicationTests.java └── user-service ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── baconbao │ │ └── user_service │ │ ├── AuthService.java │ │ ├── UserServiceApplication.java │ │ ├── config │ │ ├── AppConfig.java │ │ ├── JwtAuthenticationFilter.java │ │ ├── ModelMapperConfig.java │ │ └── SecurityConfig.java │ │ ├── controller │ │ └── UserController.java │ │ ├── dto │ │ ├── ApiResponse.java │ │ ├── AuthenticationRequest.java │ │ ├── AuthenticationResponse.java │ │ └── UserDTO.java │ │ ├── exception │ │ ├── BadRequestException.java │ │ ├── CustomException.java │ │ ├── CustomJwtException.java │ │ ├── CustomizedResponseEntityExceptionHandler.java │ │ └── Error.java │ │ ├── model │ │ ├── Role.java │ │ └── User.java │ │ ├── repository │ │ └── UserRepository.java │ │ ├── security │ │ └── OurUserDetailsService.java │ │ ├── services │ │ ├── service │ │ │ └── UserService.java │ │ └── serviceImpl │ │ │ └── UserServiceImpl.java │ │ └── utils │ │ └── JwtTokenUtil.java └── resources │ ├── application.properties │ └── application.yml └── test └── java └── com └── baconbao └── user_service └── UserServiceApplicationTests.java /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 36 | 37 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/microservice-project.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 29 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.compile.nullAnalysis.mode": "automatic" 3 | } -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hoangjunss/microservice/188c17d75152c45181078b5db7ff2a0697fbd5db/NOTES.md -------------------------------------------------------------------------------- /api-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /api-gateway/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/ApiGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableFeignClients 10 | @EnableDiscoveryClient 11 | public class ApiGatewayApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ApiGatewayApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/UserClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway; 2 | 3 | import com.baconbao.api_gateway.dto.ApiResponse; 4 | import com.baconbao.api_gateway.dto.AuthenticationRequest; 5 | import com.baconbao.api_gateway.dto.AuthenticationResponse; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.service.annotation.PostExchange; 11 | import reactor.core.publisher.Mono; 12 | @FeignClient(name="user-service") 13 | public interface UserClient { 14 | @PostMapping("/auth/isValid") 15 | ApiResponse isValid(@RequestBody String token); 16 | } 17 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/UserService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway; 2 | 3 | import com.baconbao.api_gateway.dto.ApiResponse; 4 | import com.baconbao.api_gateway.dto.AuthenticationRequest; 5 | import com.baconbao.api_gateway.dto.AuthenticationResponse; 6 | import lombok.AccessLevel; 7 | import lombok.RequiredArgsConstructor; 8 | import lombok.experimental.FieldDefaults; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.core.ParameterizedTypeReference; 12 | import org.springframework.http.MediaType; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.web.reactive.function.client.WebClient; 15 | import reactor.core.publisher.Mono; 16 | import reactor.core.scheduler.Schedulers; 17 | 18 | @Service 19 | @RequiredArgsConstructor 20 | @Slf4j 21 | 22 | public class UserService { 23 | 24 | @Autowired 25 | private WebClient.Builder webClientBuilder; 26 | 27 | public Mono> isValid(String token) { 28 | return webClientBuilder.build() 29 | .post() 30 | .uri("http://localhost:8088/auth/isValid") 31 | .bodyValue(token) 32 | .retrieve() 33 | .bodyToMono(new ParameterizedTypeReference>() {}) 34 | ; 35 | } 36 | } -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 6 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | public HttpMessageConverters httpMessageConverters() { 13 | return new HttpMessageConverters(new MappingJackson2HttpMessageConverter()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.reactive.CorsWebFilter; 7 | import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; 8 | 9 | @Configuration 10 | public class CorsConfig { 11 | 12 | @Bean 13 | public CorsWebFilter corsWebFilter() { 14 | CorsConfiguration corsConfig = new CorsConfiguration(); 15 | corsConfig.addAllowedOrigin("http://localhost:4200"); 16 | corsConfig.addAllowedMethod("*"); 17 | corsConfig.addAllowedHeader("*"); 18 | corsConfig.setAllowCredentials(true); 19 | 20 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 21 | source.registerCorsConfiguration("/**", corsConfig); 22 | 23 | return new CorsWebFilter(source); 24 | } 25 | } -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/config/WebClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.reactive.function.client.WebClient; 6 | 7 | @Configuration 8 | public class WebClientConfig { 9 | 10 | @Bean 11 | public WebClient.Builder webClientBuilder() { 12 | return WebClient.builder(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ApiResponse { 7 | private boolean success; 8 | private String message; 9 | private T data; 10 | } 11 | -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/dto/AuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | 8 | @Data 9 | @Builder 10 | @JsonIgnoreProperties(ignoreUnknown = true) 11 | @JsonInclude(JsonInclude.Include.NON_NULL) 12 | public class AuthenticationRequest { 13 | private String name; 14 | private String email; 15 | private String role; 16 | private String token; 17 | private String password; 18 | } -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/dto/AuthenticationResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.dto; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | 9 | @Data 10 | @Builder 11 | public class AuthenticationResponse { 12 | private int statusCode; 13 | private String error; 14 | private String message; 15 | private String token; 16 | private String refreshToken; 17 | private String expirationTime; 18 | private boolean isVaild; 19 | private String role; 20 | } -------------------------------------------------------------------------------- /api-gateway/src/main/java/com/baconbao/api_gateway/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String role; 18 | } 19 | -------------------------------------------------------------------------------- /api-gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | eureka: 4 | client: 5 | serviceUrl: 6 | defaultZone: http://localhost:8671/eureka 7 | 8 | spring: 9 | application: 10 | name: api-gateway 11 | cloud: 12 | gateway: 13 | routes: 14 | - id: profile-service 15 | uri: lb://PROFILE-SERVICE 16 | predicates: 17 | - Path=/profile/** 18 | filters: 19 | - AuthenticationFilter 20 | - id: project-service 21 | uri: lb://PROJECT-SERVICE 22 | predicates: 23 | - Path=/project/** 24 | filters: 25 | - AuthenticationFilter 26 | - id: user-service 27 | uri: lb://USER-SERVICE 28 | predicates: 29 | - Path=/auth/** 30 | - id: profile-hr-service 31 | uri: lb://PROFILE-HR-SERVICE 32 | predicates: 33 | - Path=/profile-hr/** 34 | - id: notification-service 35 | uri: lb://NOTIFICATION-SERVICE 36 | predicates: 37 | - Path=/notification/** 38 | - id: manager-service 39 | uri: lb://MANAGER-SERVICE 40 | predicates: 41 | - Path=/manager/** 42 | filters: 43 | - AuthenticationFilter 44 | - id: image-service 45 | uri: lb://IMAGE-SERVICE 46 | predicates: 47 | - Path=/image/** 48 | 49 | -------------------------------------------------------------------------------- /api-gateway/src/test/java/com/baconbao/api_gateway/ApiGatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.api_gateway; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApiGatewayApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /client/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /client/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /client/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /client/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # Client 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.1.2. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. 28 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "client", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test", 10 | "serve:ssr:client": "node dist/client/server/server.mjs" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "^18.1.0", 15 | "@angular/common": "^18.1.0", 16 | "@angular/compiler": "^18.1.0", 17 | "@angular/core": "^18.1.0", 18 | "@angular/forms": "^18.1.0", 19 | "@angular/platform-browser": "^18.1.0", 20 | "@angular/platform-browser-dynamic": "^18.1.0", 21 | "@angular/platform-server": "^18.1.0", 22 | "@angular/router": "^18.1.0", 23 | "@angular/ssr": "^18.1.2", 24 | "express": "^4.18.2", 25 | "rxjs": "~7.8.0", 26 | "tslib": "^2.3.0", 27 | "zone.js": "~0.14.3" 28 | }, 29 | "devDependencies": { 30 | "@angular-devkit/build-angular": "^18.1.2", 31 | "@angular/cli": "^18.1.2", 32 | "@angular/compiler-cli": "^18.1.0", 33 | "@types/express": "^4.17.17", 34 | "@types/jasmine": "~5.1.0", 35 | "@types/node": "^18.18.0", 36 | "jasmine-core": "~5.1.0", 37 | "karma": "~6.4.0", 38 | "karma-chrome-launcher": "~3.2.0", 39 | "karma-coverage": "~2.2.0", 40 | "karma-jasmine": "~5.1.0", 41 | "karma-jasmine-html-reporter": "~2.1.0", 42 | "typescript": "~5.5.2" 43 | } 44 | } -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hoangjunss/microservice/188c17d75152c45181078b5db7ff2a0697fbd5db/client/public/favicon.ico -------------------------------------------------------------------------------- /client/server.ts: -------------------------------------------------------------------------------- 1 | import { APP_BASE_HREF } from '@angular/common'; 2 | import { CommonEngine } from '@angular/ssr'; 3 | import express from 'express'; 4 | import { fileURLToPath } from 'node:url'; 5 | import { dirname, join, resolve } from 'node:path'; 6 | import bootstrap from './src/main.server'; 7 | 8 | // The Express app is exported so that it can be used by serverless Functions. 9 | export function app(): express.Express { 10 | const server = express(); 11 | const serverDistFolder = dirname(fileURLToPath(import.meta.url)); 12 | const browserDistFolder = resolve(serverDistFolder, '../browser'); 13 | const indexHtml = join(serverDistFolder, 'index.server.html'); 14 | 15 | const commonEngine = new CommonEngine(); 16 | 17 | server.set('view engine', 'html'); 18 | server.set('views', browserDistFolder); 19 | 20 | // Example Express Rest API endpoints 21 | // server.get('/api/**', (req, res) => { }); 22 | // Serve static files from /browser 23 | server.get('**', express.static(browserDistFolder, { 24 | maxAge: '1y', 25 | index: 'index.html', 26 | })); 27 | 28 | // All regular routes use the Angular engine 29 | server.get('**', (req, res, next) => { 30 | const { protocol, originalUrl, baseUrl, headers } = req; 31 | 32 | commonEngine 33 | .render({ 34 | bootstrap, 35 | documentFilePath: indexHtml, 36 | url: `${protocol}://${headers.host}${originalUrl}`, 37 | publicPath: browserDistFolder, 38 | providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], 39 | }) 40 | .then((html) => res.send(html)) 41 | .catch((err) => next(err)); 42 | }); 43 | 44 | return server; 45 | } 46 | 47 | function run(): void { 48 | const port = process.env['PORT'] || 4000; 49 | 50 | // Start up the Node server 51 | const server = app(); 52 | server.listen(port, () => { 53 | console.log(`Node Express server listening on http://localhost:${port}`); 54 | }); 55 | } 56 | 57 | run(); 58 | -------------------------------------------------------------------------------- /client/src/app/admin/admin.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { RouterModule } from '@angular/router'; 4 | import { adminRoutes } from './admin.routes'; 5 | 6 | 7 | 8 | @NgModule({ 9 | declarations: [], 10 | imports: [CommonModule,RouterModule.forChild(adminRoutes)] 11 | }) 12 | export class AdminModule { } 13 | -------------------------------------------------------------------------------- /client/src/app/admin/admin.routes.ts: -------------------------------------------------------------------------------- 1 | import { Routes } from "@angular/router"; 2 | import { AdminLayoutComponent } from "../layouts/admin-layout/admin-layout.component"; 3 | import { UserListComponent } from "../layouts/user-list/user-list.component"; 4 | import { ProjectListComponent } from "../layouts/project-list/project-list.component"; 5 | import { CompanyListComponent } from "../layouts/company-list/company-list.component"; 6 | import { LoginComponent } from "../components/login/login.component"; 7 | 8 | 9 | 10 | export const adminRoutes: Routes = [ 11 | { 12 | path: '', 13 | component: AdminLayoutComponent, 14 | children: [ 15 | { 16 | path: 'list-user', 17 | component: UserListComponent 18 | }, 19 | { 20 | path: 'list-company', 21 | component: CompanyListComponent 22 | } 23 | ] 24 | }, 25 | { 26 | path: 'login', 27 | component: LoginComponent 28 | } 29 | 30 | ]; -------------------------------------------------------------------------------- /client/src/app/apiresponse.spec.ts: -------------------------------------------------------------------------------- 1 | import { Apiresponse } from './apiresponse'; 2 | 3 | describe('Apiresponse', () => { 4 | it('should create an instance', () => { 5 | expect(new Apiresponse()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/apiresponse.ts: -------------------------------------------------------------------------------- 1 | export class Apiresponse { 2 | success!: boolean; 3 | message!: string; 4 | data!: T; 5 | } 6 | -------------------------------------------------------------------------------- /client/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /client/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async () => { 6 | await TestBed.configureTestingModule({ 7 | imports: [AppComponent], 8 | }).compileComponents(); 9 | }); 10 | 11 | it('should create the app', () => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.componentInstance; 14 | expect(app).toBeTruthy(); 15 | }); 16 | 17 | it(`should have the 'angular' title`, () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app.title).toEqual('angular'); 21 | }); 22 | 23 | it('should render title', () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | fixture.detectChanges(); 26 | const compiled = fixture.nativeElement as HTMLElement; 27 | expect(compiled.querySelector('h1')?.textContent).toContain('Hello, angular'); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /client/src/app/app.config.server.ts: -------------------------------------------------------------------------------- 1 | import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; 2 | import { provideServerRendering } from '@angular/platform-server'; 3 | import { appConfig } from './app.config'; 4 | 5 | const serverConfig: ApplicationConfig = { 6 | providers: [ 7 | provideServerRendering() 8 | ] 9 | }; 10 | 11 | export const config = mergeApplicationConfig(appConfig, serverConfig); 12 | -------------------------------------------------------------------------------- /client/src/app/app.config.ts: -------------------------------------------------------------------------------- 1 | import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { routes } from './app.routes'; 5 | import { provideClientHydration } from '@angular/platform-browser'; 6 | import { provideHttpClient,withFetch } from '@angular/common/http'; 7 | import { DatePipe } from '@angular/common'; 8 | import { HTTP_INTERCEPTORS } from '@angular/common/http'; 9 | import { AuthInterceptorService } from './service/auth-interceptor.service'; 10 | 11 | 12 | export const appConfig: ApplicationConfig = { 13 | providers: [ 14 | DatePipe, 15 | provideZoneChangeDetection({ eventCoalescing: true }), 16 | provideRouter(routes), 17 | provideClientHydration(), 18 | provideHttpClient(withFetch()), 19 | { 20 | provide: HTTP_INTERCEPTORS, 21 | useClass: AuthInterceptorService, 22 | multi: true 23 | } 24 | ] 25 | }; -------------------------------------------------------------------------------- /client/src/app/components/company-list/company-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CompanyListComponent } from './company-list.component'; 4 | 5 | describe('CompanyListComponent', () => { 6 | let component: CompanyListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [CompanyListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(CompanyListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/contact/contact.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Contact Us

4 |

You can contact me.

5 |
6 |
7 |
8 |
9 |
10 | 11 |
12 |
13 |
Phone
14 |
    15 |
  • {{contact?.phone}}
  • 16 |
17 |
18 |
19 |
20 | 21 |
22 |
23 |
24 | 25 |
26 |
27 |
Email
28 |
    29 |
  • {{contact?.email}}
  • 30 |
31 |
32 |
33 |
34 | 35 |
36 |
37 |
38 | 39 |
40 |
41 |
Address
42 |
    43 |
  • {{contact?.address}}
  • 44 |
45 |
46 |
47 |
48 | 49 |
50 |
-------------------------------------------------------------------------------- /client/src/app/components/contact/contact.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ContactComponent } from './contact.component'; 4 | 5 | describe('ContactComponent', () => { 6 | let component: ContactComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ContactComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ContactComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/contact/contact.component.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { Component, Input, OnInit } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { ContactServiceService } from '../../service/contact-service.service'; 5 | import { Contact } from '../../model/contact'; 6 | 7 | @Component({ 8 | selector: 'app-contact', 9 | standalone: true, 10 | imports: [FormsModule,CommonModule], 11 | templateUrl: './contact.component.html', 12 | styleUrl: './contact.component.css' 13 | }) 14 | export class ContactComponent implements OnInit { 15 | @Input() contact?: Contact; 16 | constructor(private contactService:ContactServiceService){}; 17 | ngOnInit(): void { 18 | 19 | } 20 | getContact(id:number){ 21 | this.contactService.getContactByUser(id).subscribe(data=>{ 22 | this.contact=data; 23 | }) 24 | } 25 | createContact(contact:Contact){ 26 | this.contactService.createContactByUser(contact).subscribe(data=>{ 27 | this.contact=data; 28 | }) 29 | } 30 | updateContact(contact:Contact){ 31 | this.contactService.updateContactByUser(contact).subscribe(data=>{ 32 | this.contact=data; 33 | }) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /client/src/app/components/create-profile/create-profile.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CreateProfileComponent } from './create-profile.component'; 4 | 5 | describe('CreateProfileComponent', () => { 6 | let component: CreateProfileComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [CreateProfileComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(CreateProfileComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/home/home.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HomeComponent } from './home.component'; 4 | 5 | describe('HomeComponent', () => { 6 | let component: HomeComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [HomeComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(HomeComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/job-details/job-details.component.css: -------------------------------------------------------------------------------- 1 | .container { 2 | margin-top: 100px; 3 | background: #fff; 4 | padding: 20px; 5 | border-radius: 8px; 6 | box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); 7 | width: 80%; 8 | max-width: 1000px; 9 | } 10 | 11 | .company-card { 12 | display: flex; 13 | border-bottom: 2px solid #e0e0e0; 14 | padding-bottom: 20px; 15 | margin-bottom: 20px; 16 | } 17 | 18 | .company-logo { 19 | flex: 1; 20 | margin-right: 20px; 21 | } 22 | 23 | .company-logo img { 24 | width: 100%; 25 | border-radius: 8px; 26 | } 27 | 28 | .company-info { 29 | flex: 2; 30 | } 31 | 32 | .company-name { 33 | color: #333; 34 | margin: 0; 35 | font-size: 24px; 36 | } 37 | 38 | .company-type, .company-description, .company-location, .company-contact { 39 | margin: 5px 0; 40 | color: #555; 41 | } 42 | 43 | .jobs-section { 44 | margin-top: 20px; 45 | } 46 | 47 | .jobs-section h3 { 48 | color: #27c830; 49 | margin-bottom: 20px; 50 | } 51 | 52 | .job-card { 53 | background: #f9f9f9; 54 | border: 1px solid #ddd; 55 | border-radius: 8px; 56 | padding: 15px; 57 | margin-bottom: 15px; 58 | display: flex; 59 | justify-content: space-between; 60 | align-items: center; 61 | } 62 | 63 | .job-title { 64 | margin: 0; 65 | color: #333; 66 | font-size: 18px; 67 | } 68 | 69 | .job-type, .job-size { 70 | margin: 5px 0; 71 | color: #777; 72 | } 73 | 74 | .job-button { 75 | background: #0d6efd; 76 | color: #fff; 77 | border: none; 78 | padding: 10px 15px; 79 | border-radius: 5px; 80 | cursor: pointer; 81 | transition: background-color 0.3s; 82 | margin-left: 10px; 83 | } 84 | 85 | .job-button:hover { 86 | background: #0b5ed7; 87 | } -------------------------------------------------------------------------------- /client/src/app/components/job-details/job-details.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 6 |
7 |

{{company?.name}}

8 |

Type: {{company?.type}}

9 |

Description: {{company?.description}}...

10 |

Location: {{company?.street}}

11 |

Email: {{company?.email}} | Phone: {{company?.phone}}

12 |
13 |
14 | 15 |
16 |

Job

17 |
18 |

{{job.title}}

19 |

{{job.typeJob}}

20 |

Team Size: {{job.size}}

21 |

{{job.description}}

22 | 23 |
24 |
25 |
-------------------------------------------------------------------------------- /client/src/app/components/job-details/job-details.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { JobDetailsComponent } from './job-details.component'; 4 | 5 | describe('JobDetailsComponent', () => { 6 | let component: JobDetailsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [JobDetailsComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(JobDetailsComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/job-details/job-details.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { Company } from '../../model/company'; 3 | import { CommonModule } from '@angular/common'; 4 | import { Job } from '../../model/job'; 5 | import { JobServiceService } from '../../service/job-service.service'; 6 | import { ActivatedRoute } from '@angular/router'; 7 | import { CompanyServiceService } from '../../service/company-service.service'; 8 | 9 | @Component({ 10 | selector: 'app-job-details', 11 | standalone: true, 12 | imports: [CommonModule], 13 | templateUrl: './job-details.component.html', 14 | styleUrl: './job-details.component.css' 15 | }) 16 | export class JobDetailsComponent implements OnInit { 17 | company: Company | undefined; 18 | job: Job | undefined; 19 | 20 | constructor(private jobSerivce: JobServiceService, private companyService: CompanyServiceService, private route: ActivatedRoute) { } 21 | ngOnInit(): void { 22 | this.route.paramMap.subscribe(params => { 23 | const id = Number(params.get('id')); 24 | if (id) { 25 | this.loadJobDetails(id); 26 | } 27 | }); 28 | } 29 | loadJobDetails(id: number): void { 30 | this.jobSerivce.getJobById(id).subscribe(job => { 31 | this.job = job; 32 | this.getCompanyByJob(job.idCompany); 33 | }); 34 | } 35 | 36 | getCompanyByJob(id?:number){ 37 | this.companyService.getCompanyById(id).subscribe(company => { 38 | this.company = company; 39 | }); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /client/src/app/components/job-list/job-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { JobListComponent } from './job-list.component'; 4 | 5 | describe('JobListComponent', () => { 6 | let component: JobListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [JobListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(JobListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [LoginComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(LoginComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/navbar/navbar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NavbarComponent } from './navbar.component'; 4 | 5 | describe('NavbarComponent', () => { 6 | let component: NavbarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [NavbarComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(NavbarComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/notification/notification.component.css: -------------------------------------------------------------------------------- 1 | .notification-dropdown { 2 | background-color: white; 3 | padding: 10px; 4 | position: absolute; 5 | top: 65px; 6 | right: 0; 7 | width: 360px; 8 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); 9 | z-index: 1000; 10 | max-height: 300px; 11 | overflow-y: auto; 12 | } 13 | 14 | .notification-dropdown h5 { 15 | margin: 0 0 10px; 16 | } 17 | 18 | .list-group-item { 19 | display: flex; 20 | align-items: center; 21 | border: none; 22 | } 23 | .list-group-item:hover { 24 | background-color: #f1f1f1; 25 | } 26 | .notification-icon { 27 | width: 24px; 28 | height: 24px; 29 | margin-right: 10px; 30 | } 31 | 32 | .unread { 33 | font-weight: bold; 34 | color: #333; 35 | } 36 | 37 | .no-unread { 38 | margin-top: 10px; 39 | font-style: italic; 40 | color: #777; 41 | } 42 | 43 | .btn-link { 44 | margin-left: 10px; 45 | text-decoration: underline; 46 | cursor: pointer; 47 | } 48 | 49 | .btn-primary { 50 | margin-left: 10px; 51 | } 52 | -------------------------------------------------------------------------------- /client/src/app/components/notification/notification.component.html: -------------------------------------------------------------------------------- 1 |
2 |
Notifications
3 |
    4 |
  • 5 | 6 | Notification Icon 7 | 8 | 9 | {{ notification.message }} 10 |
  • 11 |
12 | 13 | 14 |
15 | All notifications are read. 16 |
17 |
18 | 19 | 20 | 21 |
22 |
Notifications
23 |
    24 |
  • 25 | Notification Icon 26 | No notifications available. 27 |
  • 28 |
29 |
30 |
31 | -------------------------------------------------------------------------------- /client/src/app/components/notification/notification.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NotificationComponent } from './notification.component'; 4 | 5 | describe('NotificationComponent', () => { 6 | let component: NotificationComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [NotificationComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(NotificationComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/post-project/post-project.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { PostProjectComponent } from './post-project.component'; 4 | 5 | describe('PostProjectComponent', () => { 6 | let component: PostProjectComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [PostProjectComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(PostProjectComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/profile-list/profile-list.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 7 |
8 | Full time 9 |
{{ profile.objective }}
10 |

{{ profile.education }}

11 |
12 | 13 |
14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 |

Oops!

26 |

We couldn't find what you're looking for.

27 |

It seems that the page you're searching for doesn't exist or has been moved. Try searching with different keywords or explore other sections.

28 | Go to Homepage 29 |
30 |
31 |
32 | -------------------------------------------------------------------------------- /client/src/app/components/profile-list/profile-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProfileListComponent } from './profile-list.component'; 4 | 5 | describe('ProfileListComponent', () => { 6 | let component: ProfileListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ProfileListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ProfileListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/profile-user/profile-user.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProfileUserComponent } from './profile-user.component'; 4 | 5 | describe('ProfileUserComponent', () => { 6 | let component: ProfileUserComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ProfileUserComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ProfileUserComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/profile/profile.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/src/app/components/profile/profile.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProfileComponent } from './profile.component'; 4 | 5 | describe('ProfileComponent', () => { 6 | let component: ProfileComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ProfileComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ProfileComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/project-list/project-list.component.css: -------------------------------------------------------------------------------- 1 | .shadow-md { 2 | box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.05); 3 | } 4 | 5 | .serv-cove .btn { 6 | margin: 0 5px; /* Tạo khoảng cách ngang giữa các nút */ 7 | } 8 | 9 | @media screen and (min-width: 992px){ 10 | .service{ 11 | margin-top: 50px; 12 | } 13 | } 14 | @media screen and (max-width: 991px){ 15 | .service{ 16 | margin-top: 90px; 17 | } 18 | } -------------------------------------------------------------------------------- /client/src/app/components/project-list/project-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProjectListComponent } from './project-list.component'; 4 | 5 | describe('ProjectListComponent', () => { 6 | let component: ProjectListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ProjectListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ProjectListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/register/register.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { RegisterComponent } from './register.component'; 4 | 5 | describe('RegisterComponent', () => { 6 | let component: RegisterComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [RegisterComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(RegisterComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/user/user.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hoangjunss/microservice/188c17d75152c45181078b5db7ff2a0697fbd5db/client/src/app/components/user/user.component.css -------------------------------------------------------------------------------- /client/src/app/components/user/user.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | 6 |
-------------------------------------------------------------------------------- /client/src/app/components/user/user.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { UserComponent } from './user.component'; 4 | 5 | describe('UserComponent', () => { 6 | let component: UserComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [UserComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(UserComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/components/user/user.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { LoginComponent } from '../login/login.component'; 3 | import { RegisterComponent } from '../register/register.component'; 4 | import { RouterOutlet } from '@angular/router'; 5 | import { CommonModule } from '@angular/common'; 6 | 7 | @Component({ 8 | selector: 'app-user', 9 | standalone: true, 10 | imports: [LoginComponent,RegisterComponent,RouterOutlet,CommonModule], 11 | templateUrl: './user.component.html', 12 | styleUrl: './user.component.css' 13 | }) 14 | export class UserComponent { 15 | isRegisterMode = true; 16 | 17 | onRegisterSuccess() { 18 | this.isRegisterMode = false; 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /client/src/app/layouts/admin-layout/admin-layout.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hoangjunss/microservice/188c17d75152c45181078b5db7ff2a0697fbd5db/client/src/app/layouts/admin-layout/admin-layout.component.css -------------------------------------------------------------------------------- /client/src/app/layouts/admin-layout/admin-layout.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /client/src/app/layouts/admin-layout/admin-layout.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AdminLayoutComponent } from './admin-layout.component'; 4 | 5 | describe('AdminLayoutComponent', () => { 6 | let component: AdminLayoutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [AdminLayoutComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(AdminLayoutComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/layouts/admin-layout/admin-layout.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { NavbarComponent } from '../navbar/navbar.component'; 3 | import { RouterModule, RouterOutlet } from '@angular/router'; 4 | import { CommonModule } from '@angular/common'; 5 | import { ProjectListComponent } from '../project-list/project-list.component'; 6 | import { UserListComponent } from '../user-list/user-list.component'; 7 | 8 | @Component({ 9 | selector: 'app-admin-layout', 10 | standalone: true, 11 | imports: [NavbarComponent,RouterOutlet,CommonModule,RouterModule,ProjectListComponent,UserListComponent], 12 | templateUrl: './admin-layout.component.html', 13 | styleUrl: './admin-layout.component.css' 14 | }) 15 | export class AdminLayoutComponent { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /client/src/app/layouts/company-list/company-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CompanyListComponent } from './company-list.component'; 4 | 5 | describe('CompanyListComponent', () => { 6 | let component: CompanyListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [CompanyListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(CompanyListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/layouts/navbar/navbar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NavbarComponent } from './navbar.component'; 4 | 5 | describe('NavbarComponent', () => { 6 | let component: NavbarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [NavbarComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(NavbarComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/layouts/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { Component, OnInit } from '@angular/core'; 3 | import { NavigationEnd, Router, RouterLink, RouterModule } from '@angular/router'; 4 | import { ProjectListComponent } from '../project-list/project-list.component'; 5 | import { filter } from 'rxjs'; 6 | import { UserListComponent } from '../user-list/user-list.component'; 7 | import { CompanyListComponent } from '../company-list/company-list.component'; 8 | import { LoginComponent } from '../../components/login/login.component'; 9 | 10 | 11 | @Component({ 12 | selector: 'app-navbar-admin', 13 | standalone: true, 14 | imports: [RouterModule,LoginComponent,CommonModule,ProjectListComponent,RouterLink,UserListComponent,CompanyListComponent], 15 | templateUrl: './navbar.component.html', 16 | styleUrl: './navbar.component.css' 17 | }) 18 | export class NavbarComponent implements OnInit { 19 | currentUrl: string = ''; 20 | 21 | constructor(private router: Router) { 22 | this.router.events.pipe( 23 | filter(event => event instanceof NavigationEnd) 24 | ).subscribe(() => { 25 | this.currentUrl = this.router.url; 26 | }); 27 | } 28 | ngOnInit(): void { 29 | this.currentUrl = this.router.url; 30 | } 31 | 32 | isActive(path: string): boolean { 33 | return this.currentUrl === path; 34 | } 35 | 36 | logout(): void { 37 | localStorage.removeItem('authToken'); 38 | this.router.navigate(['/login']); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/src/app/layouts/project-list/project-list.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
Stt IdTitleDescriptionDate
20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
{{ i + 1 }}{{ project.id }}{{ project.title }}{{ project.description }}{{getFormattedDate(project.createAt)}}
40 |
41 |
-------------------------------------------------------------------------------- /client/src/app/layouts/project-list/project-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ProjectListComponent } from './project-list.component'; 4 | 5 | describe('ProjectListComponent', () => { 6 | let component: ProjectListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ProjectListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ProjectListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/layouts/project-list/project-list.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Project } from '../../model/project'; 3 | import { ProjectServiceService } from '../../service/project-service.service'; 4 | import { CommonModule, DatePipe } from '@angular/common'; 5 | 6 | @Component({ 7 | selector: 'app-project-list', 8 | standalone: true, 9 | imports: [CommonModule], 10 | templateUrl: './project-list.component.html', 11 | styleUrl: './project-list.component.css' 12 | }) 13 | export class ProjectListComponent implements OnInit{ 14 | 15 | projects:Project[]=[]; 16 | 17 | project1: Project[] = [ 18 | { id: 0, title: 'facebook', description: 'làm trang mạng xã hội về facebook', createAt: '8-8-2024' }, 19 | { id: 1, title: 'zalo', description: 'làm trang mạng xã hội về zalo', createAt: '8-8-2024' }, 20 | { id: 2, title: 'instagram', description: 'làm trang mạng xã hội về instagram', createAt: '8-8-2024' }, 21 | { id: 3, title: 'X', description: 'làm trang mạng xã hội về X', createAt: '8-8-2024' } 22 | ]; 23 | 24 | constructor(private projectService:ProjectServiceService, private datePipe: DatePipe){} 25 | 26 | ngOnInit(): void { 27 | console.log("Project start"); 28 | this.getProjectByIdProfile(1925006690); 29 | } 30 | 31 | 32 | getFormattedDate(createAt?:string) { 33 | return this.datePipe.transform(createAt, 'MMM d, y'); 34 | } 35 | 36 | getProjectByUser(id:number){ 37 | this.projectService.getProjectByUser(id).subscribe(data=>{ 38 | this.projects=data; 39 | }) 40 | } 41 | 42 | getProjectByIdProfile(id:number){ 43 | this.projectService.getProjectByIdProfile(id).subscribe(data=>{ 44 | this.projects=data; 45 | }) 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /client/src/app/layouts/user-list/user-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { UserListComponent } from './user-list.component'; 4 | 5 | describe('UserListComponent', () => { 6 | let component: UserListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [UserListComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(UserListComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager-router/manager.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { RouterModule } from '@angular/router'; 4 | import { managerRoutes } from './manager.routes'; 5 | 6 | 7 | 8 | @NgModule({ 9 | declarations: [], 10 | imports: [ 11 | CommonModule,RouterModule.forChild(managerRoutes) 12 | ] 13 | }) 14 | export class ManagerModule { } 15 | -------------------------------------------------------------------------------- /client/src/app/manager-router/manager.routes.ts: -------------------------------------------------------------------------------- 1 | import { Routes } from "@angular/router"; 2 | import { LoginComponent } from "../components/login/login.component"; 3 | import { ManagerLayoutComponent } from "../manager/manager-layout/manager-layout.component"; 4 | import { JobLayoutComponent } from "../manager/job-layout/job-layout.component"; 5 | import { ApplyLayoutComponent } from "../manager/apply-layout/apply-layout.component"; 6 | import { HrLayoutComponent } from "../manager/hr-layout/hr-layout.component"; 7 | import { CompanyComponent } from "../manager/company/company.component"; 8 | import { ProfileUserComponent } from "../components/profile-user/profile-user.component"; 9 | import { EmloyeeLayoutComponent } from "../manager/emloyee-layout/emloyee-layout.component"; 10 | 11 | 12 | export const managerRoutes: Routes = [ 13 | { 14 | path: '', 15 | component: ManagerLayoutComponent, 16 | children:[ 17 | { 18 | path: 'job', 19 | component: JobLayoutComponent 20 | }, 21 | { 22 | path: 'emloyee', 23 | component: EmloyeeLayoutComponent 24 | }, 25 | { 26 | path: 'hr', 27 | component: HrLayoutComponent 28 | }, 29 | { 30 | path: 'about', 31 | component: CompanyComponent 32 | }, 33 | { 34 | path: 'profile/profile-user/:id', 35 | component: ProfileUserComponent 36 | } 37 | ] 38 | } 39 | 40 | 41 | ]; -------------------------------------------------------------------------------- /client/src/app/manager/apply-layout/apply-layout.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ApplyLayoutComponent } from './apply-layout.component'; 4 | 5 | describe('ApplyLayoutComponent', () => { 6 | let component: ApplyLayoutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ApplyLayoutComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ApplyLayoutComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager/apply-layout/apply-layout.component.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { Component } from '@angular/core'; 3 | 4 | @Component({ 5 | selector: 'app-apply-layout', 6 | standalone: true, 7 | imports: [CommonModule], 8 | templateUrl: './apply-layout.component.html', 9 | styleUrl: './apply-layout.component.css' 10 | }) 11 | export class ApplyLayoutComponent { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /client/src/app/manager/company/company.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CompanyComponent } from './company.component'; 4 | 5 | describe('CompanyComponent', () => { 6 | let component: CompanyComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [CompanyComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(CompanyComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager/emloyee-layout/emloyee-layout.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { EmloyeeLayoutComponent } from './emloyee-layout.component'; 4 | 5 | describe('EmloyeeLayoutComponent', () => { 6 | let component: EmloyeeLayoutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [EmloyeeLayoutComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(EmloyeeLayoutComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager/hr-layout/hr-layout.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HrLayoutComponent } from './hr-layout.component'; 4 | 5 | describe('HrLayoutComponent', () => { 6 | let component: HrLayoutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [HrLayoutComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(HrLayoutComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager/job-layout/job-layout.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { JobLayoutComponent } from './job-layout.component'; 4 | 5 | describe('JobLayoutComponent', () => { 6 | let component: JobLayoutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [JobLayoutComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(JobLayoutComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager/manager-layout/manager-layout.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hoangjunss/microservice/188c17d75152c45181078b5db7ff2a0697fbd5db/client/src/app/manager/manager-layout/manager-layout.component.css -------------------------------------------------------------------------------- /client/src/app/manager/manager-layout/manager-layout.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/src/app/manager/manager-layout/manager-layout.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ManagerLayoutComponent } from './manager-layout.component'; 4 | 5 | describe('ManagerLayoutComponent', () => { 6 | let component: ManagerLayoutComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [ManagerLayoutComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(ManagerLayoutComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/manager/manager-layout/manager-layout.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { NavabarComponent } from '../navabar/navabar.component'; 3 | import { RouterLink } from '@angular/router'; 4 | import { CompanyComponent } from "../company/company.component"; 5 | 6 | @Component({ 7 | selector: 'app-manager-layout', 8 | standalone: true, 9 | imports: [NavabarComponent, RouterLink, CompanyComponent], 10 | templateUrl: './manager-layout.component.html', 11 | styleUrl: './manager-layout.component.css' 12 | }) 13 | export class ManagerLayoutComponent { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /client/src/app/manager/navabar/navabar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NavabarComponent } from './navabar.component'; 4 | 5 | describe('NavabarComponent', () => { 6 | let component: NavabarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | imports: [NavabarComponent] 12 | }) 13 | .compileComponents(); 14 | 15 | fixture = TestBed.createComponent(NavabarComponent); 16 | component = fixture.componentInstance; 17 | fixture.detectChanges(); 18 | }); 19 | 20 | it('should create', () => { 21 | expect(component).toBeTruthy(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /client/src/app/model/company.spec.ts: -------------------------------------------------------------------------------- 1 | import { Company } from './company'; 2 | 3 | describe('Company', () => { 4 | it('should create an instance', () => { 5 | expect(new Company()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/company.ts: -------------------------------------------------------------------------------- 1 | export class Company { 2 | id?:number; 3 | name?: string; 4 | type?: string; 5 | description?:string; 6 | street?:string; 7 | email?:string; 8 | phone?: string; 9 | city?:string; 10 | country?:string; 11 | idManager?:number; 12 | idHR?:number[]; 13 | idJobs?:number[]; 14 | image?:File; 15 | } 16 | -------------------------------------------------------------------------------- /client/src/app/model/contact.spec.ts: -------------------------------------------------------------------------------- 1 | import { Contact } from './contact'; 2 | 3 | describe('Contact', () => { 4 | it('should create an instance', () => { 5 | expect(new Contact()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/contact.ts: -------------------------------------------------------------------------------- 1 | export class Contact { 2 | id?:number; 3 | address?:string; 4 | phone?:string; 5 | email?:string; 6 | profileID?:number; 7 | } 8 | -------------------------------------------------------------------------------- /client/src/app/model/job.spec.ts: -------------------------------------------------------------------------------- 1 | import { Job } from './job'; 2 | 3 | describe('Job', () => { 4 | it('should create an instance', () => { 5 | expect(new Job()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/job.ts: -------------------------------------------------------------------------------- 1 | export class Job { 2 | id?: number; 3 | title?: string; 4 | description?: string; 5 | typeJob?: string; 6 | size?:number; 7 | idProfiePending?:number[]; 8 | idProfile?: number[]; 9 | idCompany?: number; 10 | } -------------------------------------------------------------------------------- /client/src/app/model/notification.spec.ts: -------------------------------------------------------------------------------- 1 | import { Notification } from './notification'; 2 | 3 | describe('Notification', () => { 4 | it('should create an instance', () => { 5 | expect(new Notification()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/notification.ts: -------------------------------------------------------------------------------- 1 | export class Notification { 2 | id?:number; 3 | message?:string; 4 | createAt?:Date; 5 | url?:string; 6 | idUser?:number; 7 | read?:boolean; 8 | } 9 | -------------------------------------------------------------------------------- /client/src/app/model/profile.spec.ts: -------------------------------------------------------------------------------- 1 | import { Profile } from './profile'; 2 | 3 | describe('Profile', () => { 4 | it('should create an instance', () => { 5 | expect(new Profile()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/profile.ts: -------------------------------------------------------------------------------- 1 | import { Contact } from "./contact"; 2 | 3 | export class Profile { 4 | id?:number; 5 | objective?:string; 6 | education?:string; 7 | workExperience?:string; 8 | skills?:string; 9 | typeProfile?:string; 10 | idUser?:number; 11 | url?:string; 12 | title?:string; 13 | contact?:Contact; 14 | img?:File; 15 | } -------------------------------------------------------------------------------- /client/src/app/model/project.spec.ts: -------------------------------------------------------------------------------- 1 | import { Project } from './project'; 2 | 3 | describe('Project', () => { 4 | it('should create an instance', () => { 5 | expect(new Project()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/project.ts: -------------------------------------------------------------------------------- 1 | export class Project { 2 | id?:number; 3 | title?:string; 4 | description?:string; 5 | createAt?:string; 6 | url?:string; 7 | imageId?:number; 8 | imageFile?:File; 9 | display?:boolean; 10 | idProfile?:number; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /client/src/app/model/user.spec.ts: -------------------------------------------------------------------------------- 1 | import { User } from './user'; 2 | 3 | describe('User', () => { 4 | it('should create an instance', () => { 5 | expect(new User()).toBeTruthy(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /client/src/app/model/user.ts: -------------------------------------------------------------------------------- 1 | export class User { 2 | id?:number 3 | name?:string 4 | email?:string 5 | password?:string 6 | confirmPassword?: string 7 | active?:boolean 8 | role?:string 9 | idEmployee?:string; 10 | } 11 | -------------------------------------------------------------------------------- /client/src/app/service/auth-interceptor.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { AuthInterceptorService } from './auth-interceptor.service'; 4 | 5 | describe('AuthInterceptorService', () => { 6 | let service: AuthInterceptorService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(AuthInterceptorService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/auth-interceptor.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, NgZone } from '@angular/core'; 2 | import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpErrorResponse } from '@angular/common/http'; 3 | import { catchError, Observable, throwError } from 'rxjs'; 4 | import { Router } from '@angular/router'; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class AuthInterceptorService implements HttpInterceptor { 10 | constructor(private router: Router, private ngZone: NgZone) {} 11 | 12 | intercept(req: HttpRequest, next: HttpHandler): Observable> { 13 | return next.handle(req).pipe( 14 | catchError((error: HttpErrorResponse) => { 15 | if (error.status === 401) { 16 | this.ngZone.run(() => { 17 | this.router.navigate(['/login']); 18 | }); 19 | localStorage.removeItem('authToken'); 20 | localStorage.removeItem('userCurrent'); 21 | } 22 | return throwError(() => new Error('Unauthorized')); 23 | }) 24 | ); 25 | } 26 | } -------------------------------------------------------------------------------- /client/src/app/service/company-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { CompanyServiceService } from './company-service.service'; 4 | 5 | describe('CompanyServiceService', () => { 6 | let service: CompanyServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(CompanyServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/contact-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ContactServiceService } from './contact-service.service'; 4 | 5 | describe('ContactServiceService', () => { 6 | let service: ContactServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(ContactServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/image-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ImageServiceService } from './image-service.service'; 4 | 5 | describe('ImageServiceService', () => { 6 | let service: ImageServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(ImageServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/job-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { JobServiceService } from './job-service.service'; 4 | 5 | describe('JobServiceService', () => { 6 | let service: JobServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(JobServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/notification-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { NotificationServiceService } from './notification-service.service'; 4 | 5 | describe('NotificationServiceService', () => { 6 | let service: NotificationServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(NotificationServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/profile-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ProfileServiceService } from './profile-service.service'; 4 | 5 | describe('ProfileServiceService', () => { 6 | let service: ProfileServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(ProfileServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/project-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { ProjectServiceService } from './project-service.service'; 4 | 5 | describe('ProjectServiceService', () => { 6 | let service: ProjectServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(ProjectServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/app/service/user-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { UserServiceService } from './user-service.service'; 4 | 5 | describe('UserServiceService', () => { 6 | let service: UserServiceService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(UserServiceService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /client/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Angular 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /client/src/main.server.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { AppComponent } from './app/app.component'; 3 | import { config } from './app/app.config.server'; 4 | 5 | const bootstrap = () => bootstrapApplication(AppComponent, config); 6 | 7 | export default bootstrap; 8 | -------------------------------------------------------------------------------- /client/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { appConfig } from './app/app.config'; 3 | import { AppComponent } from './app/app.component'; 4 | 5 | bootstrapApplication(AppComponent, appConfig) 6 | .catch((err) => console.error(err)); 7 | -------------------------------------------------------------------------------- /client/src/styles.css: -------------------------------------------------------------------------------- 1 | @media (max-width: 768px) { 2 | body 3 | { 4 | width: 100%; 5 | } 6 | } 7 | 8 | @media (min-width: 768px) { 9 | body 10 | { 11 | min-width: 1024px; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /client/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "./out-tsc/app", 7 | "types": [ 8 | "node" 9 | ] 10 | }, 11 | "files": [ 12 | "src/main.ts", 13 | "src/main.server.ts", 14 | "server.ts" 15 | ], 16 | "include": [ 17 | "src/**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /client/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "compileOnSave": false, 5 | "compilerOptions": { 6 | "outDir": "./dist/out-tsc", 7 | "strict": true, 8 | "noImplicitOverride": true, 9 | "noPropertyAccessFromIndexSignature": true, 10 | "noImplicitReturns": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "skipLibCheck": true, 13 | "esModuleInterop": true, 14 | "sourceMap": true, 15 | "declaration": false, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "bundler", 18 | "importHelpers": true, 19 | "target": "ES2022", 20 | "module": "ES2022", 21 | "lib": [ 22 | "ES2022", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /client/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "./out-tsc/spec", 7 | "types": [ 8 | "jasmine" 9 | ] 10 | }, 11 | "include": [ 12 | "src/**/*.spec.ts", 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /discovery-server/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /discovery-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /discovery-server/src/main/java/com/example/discovery_server/DiscoveryServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.discovery_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class DiscoveryServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(DiscoveryServerApplication.class, args); 13 | } 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /discovery-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | spring: 3 | application: 4 | name: discovery-service 5 | 6 | server: 7 | port: 8671 8 | eureka: 9 | client: 10 | registerWithEureka: false 11 | fetchRegistry: false 12 | -------------------------------------------------------------------------------- /discovery-server/src/test/java/com/example/discovery_server/DiscoveryServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.discovery_server; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DiscoveryServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /email-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /email-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/EmailServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class EmailServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(EmailServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/MailService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service; 2 | 3 | import com.baconbao.email_service.dto.MessageDTO; 4 | import com.baconbao.email_service.model.Mail; 5 | import org.springframework.stereotype.Service; 6 | 7 | 8 | @Service 9 | public interface MailService { 10 | void sendMail(Mail mail); 11 | Mail getMail(String mailTo,String content,String subject); 12 | void send(MessageDTO messageDTO); 13 | } 14 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/config/KafkaConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.config; 2 | import org.apache.kafka.clients.consumer.ConsumerConfig; 3 | import org.apache.kafka.common.serialization.StringDeserializer; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.kafka.annotation.EnableKafka; 7 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; 8 | import org.springframework.kafka.core.ConsumerFactory; 9 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Configuration 15 | @EnableKafka 16 | public class KafkaConfig { 17 | 18 | @Bean 19 | public ConsumerFactory consumerFactory() { 20 | Map props = new HashMap<>(); 21 | props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); 22 | props.put(ConsumerConfig.GROUP_ID_CONFIG, "email-service-group"); 23 | props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 24 | props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 25 | return new DefaultKafkaConsumerFactory<>(props); 26 | } 27 | 28 | @Bean 29 | public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() { 30 | ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>(); 31 | factory.setConsumerFactory(consumerFactory()); 32 | return factory; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/controller/MailController.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.controller; 2 | 3 | import com.baconbao.email_service.MailService; 4 | import com.baconbao.email_service.dto.ApiResponse; 5 | import com.baconbao.email_service.dto.MailDTO; 6 | import com.baconbao.email_service.dto.MessageDTO; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController 12 | @RequestMapping("email") 13 | public class MailController { 14 | @Autowired 15 | private MailService mailService; 16 | @PostMapping("/create") 17 | public ResponseEntity> send(@RequestBody MessageDTO messageDTO) { 18 | mailService.send(messageDTO); 19 | ApiResponse response = new ApiResponse<>(true, "Check user id successfully","true" 20 | ); 21 | return ResponseEntity.ok(response); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Getter 12 | public class ApiResponse { 13 | private boolean success; 14 | private String message; 15 | private T data; 16 | } 17 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/dto/MailDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class MailDTO { 9 | private String mailTo; 10 | private String mailSubject; 11 | private String mailContent; 12 | } 13 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/dto/MessageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class MessageDTO { 9 | private String message; 10 | private Integer id; 11 | } 12 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String role; 18 | } 19 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/model/Mail.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.model; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import lombok.Builder; 7 | import lombok.Data; 8 | 9 | @Data 10 | 11 | @Builder 12 | public class Mail 13 | { 14 | private String mailFrom; 15 | private String mailTo; 16 | private String mailCc; 17 | private String mailBcc; 18 | 19 | 20 | private String mailSubject; 21 | private String mailContent; 22 | private String contentType; 23 | private List attachments; 24 | 25 | public Date getMailSendDate() { 26 | return new Date(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /email-service/src/main/java/com/baconbao/email_service/openfeign/UserClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service.openfeign; 2 | 3 | import com.baconbao.email_service.dto.ApiResponse; 4 | import com.baconbao.email_service.dto.UserDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @FeignClient("user-service") 10 | public interface UserClient { 11 | @GetMapping("/auth/findbyid") 12 | ApiResponse findById(@RequestParam Integer id); 13 | } 14 | -------------------------------------------------------------------------------- /email-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mail.host=smtp.gmail.com 2 | spring.mail.port=587 3 | spring.mail.username=cvreviewbaconbao@gmail.com 4 | spring.mail.password=wvun ghlo dvtb vlmj 5 | spring.mail.properties.mail.smtp.auth=true 6 | spring.mail.properties.mail.smtp.starttls.enable=true 7 | spring.mail.properties.mail.smtp.starttls.required=true 8 | mail.smtp.debug=true 9 | 10 | spring.mail.properties.mail.smtp.connectiontimeout=5000 11 | spring.mail.properties.mail.smtp.timeout=5000 12 | spring.mail.properties.mail.smtp.writetimeout=5000 13 | -------------------------------------------------------------------------------- /email-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: email-service 4 | server: 5 | port: 8087 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /email-service/src/test/java/com/baconbao/email_service/EmailServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.email_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class EmailServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /image-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /image-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/ImageServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class ImageServiceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ImageServiceApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.config; 2 | 3 | 4 | import org.modelmapper.ModelMapper; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class AppConfig { 10 | 11 | @Bean 12 | public ModelMapper modelMapper() { 13 | ModelMapper modelMapper = new ModelMapper(); 14 | return modelMapper; 15 | } 16 | } -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/controller/ImageController.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.controller; 2 | 3 | import com.baconbao.image_service.dto.ApiResponse; 4 | import com.baconbao.image_service.dto.ImageDTO; 5 | import com.baconbao.image_service.services.service.ImageService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.MediaType; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | import org.springframework.web.multipart.MultipartFile; 13 | 14 | @RequestMapping("/image") 15 | @RestController 16 | @Slf4j 17 | public class ImageController { 18 | @Autowired 19 | private ImageService imageService; 20 | 21 | @PostMapping(value = "/save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) 22 | public ResponseEntity> save(@RequestPart(value="image",required = false)MultipartFile image) { 23 | if (image == null || image.isEmpty()) { 24 | return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); 25 | } 26 | // Xử lý lưu ảnh và trả về ImageDTO 27 | ImageDTO imageDTO = imageService.saveImage(image); 28 | log.info("image: {}",imageDTO); 29 | 30 | return ResponseEntity.ok(new ApiResponse(true, "Get all is successfully", imageDTO)); 31 | } 32 | 33 | @GetMapping("getAll") 34 | public ResponseEntity> getAll() { 35 | return ResponseEntity.ok(new ApiResponse<>(true, "Get all is successfully", "ok")); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ApiResponse { 11 | private boolean success; 12 | private String message; 13 | private T data; 14 | } 15 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/dto/ImageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @Builder 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class ImageDTO { 13 | private Integer id; 14 | private String url; 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException{ 8 | public BadRequestException(String message){ 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/exception/CloudinaryException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.exception; 2 | 3 | public class CloudinaryException extends RuntimeException{ 4 | private final Error error; 5 | 6 | public CloudinaryException(Error error) { 7 | super(error.getMessage()); 8 | this.error = error; 9 | } 10 | 11 | public Error getError() { 12 | return error; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.exception; 2 | 3 | import org.springframework.http.HttpStatusCode; 4 | 5 | public class CustomException extends RuntimeException{ 6 | private final Error error; 7 | 8 | public CustomException(Error error){ 9 | super(error.getMessage()); 10 | this.error = error; 11 | } 12 | 13 | public Error getError() { 14 | return error; 15 | } 16 | public int getCode(){ 17 | return error.getCode(); 18 | } 19 | public String getMessage() { 20 | return error.getMessage(); 21 | } 22 | public HttpStatusCode getHttpStatusCode(){ 23 | return error.getStatusCode(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/exception/CustomizedResponseEntityExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.ControllerAdvice; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.RestController; 8 | import org.springframework.web.context.request.WebRequest; 9 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 10 | 11 | import com.baconbao.image_service.dto.ApiResponse; 12 | 13 | @ControllerAdvice 14 | @RestController 15 | public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { 16 | @ExceptionHandler(BadRequestException.class) 17 | public final ResponseEntity> handleBadRequestException(BadRequestException ex, WebRequest request) { 18 | ApiResponse response = new ApiResponse<>( 19 | false, 20 | ex.getMessage(), 21 | "" 22 | ); 23 | return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); 24 | } 25 | 26 | @ExceptionHandler(CustomException.class) 27 | public final ResponseEntity> handleCustomException(CustomException cx, WebRequest request) { 28 | ApiResponse response = new ApiResponse<>( 29 | false, 30 | cx.getMessage(), 31 | "" 32 | ); 33 | return new ResponseEntity<>(response, cx.getError().getStatusCode()); 34 | } 35 | 36 | @ExceptionHandler(Exception.class) 37 | public final ResponseEntity> handleAllException(Exception e, WebRequest request) { 38 | ApiResponse response = new ApiResponse<>( 39 | false, 40 | e.getMessage(), 41 | "" 42 | ); 43 | return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/exception/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.exception; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | @Setter 10 | public class ExceptionResponse { 11 | private LocalDateTime time; 12 | private String message; 13 | private String details; 14 | private boolean success; 15 | 16 | public ExceptionResponse(LocalDateTime time, String message,String details, boolean success) { 17 | this.time = time; 18 | this.message = message; 19 | this.details = details; 20 | this.success = success; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/model/Image.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.model; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Entity 12 | @Builder 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Table(name = "image") 17 | public class Image { 18 | @Id 19 | private Integer id; 20 | private String url; 21 | } -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/repository/ImageRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.repository; 2 | 3 | import com.baconbao.image_service.model.Image; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.Optional; 7 | 8 | public interface ImageRepository extends JpaRepository { 9 | Optional findById(Integer integer); 10 | } 11 | -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/services/service/ImageService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.services.service; 2 | 3 | import com.baconbao.image_service.dto.ImageDTO; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | @Service 8 | public interface ImageService { 9 | 10 | ImageDTO saveImage(MultipartFile imageFile); 11 | 12 | } -------------------------------------------------------------------------------- /image-service/src/main/java/com/baconbao/image_service/services/serviceimpl/ImageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service.services.serviceimpl; 2 | 3 | import com.baconbao.image_service.dto.ImageDTO; 4 | import com.baconbao.image_service.model.Image; 5 | import com.baconbao.image_service.repository.ImageRepository; 6 | import com.baconbao.image_service.services.CloudinaryService; 7 | import com.baconbao.image_service.services.service.ImageService; 8 | import lombok.extern.slf4j.Slf4j; 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.util.Map; 15 | import java.util.UUID; 16 | 17 | @Service 18 | @Slf4j 19 | public class ImageServiceImpl implements ImageService { 20 | @Autowired 21 | private ImageRepository imageRepository; 22 | @Autowired 23 | private CloudinaryService cloudinaryService; 24 | @Autowired 25 | private ModelMapper modelMapper; 26 | 27 | private Image save(MultipartFile imageFile) { 28 | log.info("Uploading image"); 29 | Map resultMap = cloudinaryService.upload(imageFile); 30 | String imageUrl = (String) resultMap.get("url"); 31 | Image image = Image.builder() 32 | .url(imageUrl) 33 | .id(getGenerationId()) 34 | .build(); 35 | return imageRepository.save(image); 36 | } 37 | 38 | @Override 39 | public ImageDTO saveImage(MultipartFile imageFile) { 40 | Image image=save(imageFile); 41 | return ImageDTO.builder().id(image.getId()).url(image.getUrl()).build(); 42 | 43 | } 44 | 45 | public Integer getGenerationId() { 46 | UUID uuid = UUID.randomUUID(); 47 | return (int) (uuid.getMostSignificantBits() & 0xFFFFFFFFL); 48 | } 49 | 50 | public ImageDTO coventToDTO(Image image) { 51 | return modelMapper.map(image, ImageDTO.class); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /image-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=image-service 2 | spring.datasource.url=jdbc:mysql://localhost:3306/image?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true 3 | spring.datasource.username=root 4 | spring.datasource.password= 5 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect 6 | spring.jpa.properties.hibernate.connection.characterEncoding=UTF-8 7 | #Hien thi cau lenh sql 8 | spring.jpa.show-sql=true 9 | #Fomat cau lenh 10 | spring.jpa.properties.hibernate.format_sql=true 11 | # Hibernate ddl auto (create, create-drop, validate, update) 12 | spring.jpa.hibernate.ddl-auto = update 13 | 14 | spring.servlet.multipart.enabled=true 15 | spring.servlet.multipart.max-file-size=10MB 16 | spring.servlet.multipart.max-request-size=10MB 17 | -------------------------------------------------------------------------------- /image-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: image-service 4 | server: 5 | port: 8083 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /image-service/src/test/java/com/baconbao/image_service/ImageServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.image_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ImageServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /manager-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /manager-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/ManagerServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class ManagerServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ManagerServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.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 AppConfig { 9 | @Bean 10 | public ModelMapper modelMapper(){ 11 | return new ModelMapper(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/config/MongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.mongodb.core.MongoTemplate; 6 | import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory; 7 | 8 | @Configuration 9 | public class MongoConfig { 10 | @Bean 11 | public MongoTemplate mongoTemplate() { 12 | return new MongoTemplate(new SimpleMongoClientDatabaseFactory("mongodb://localhost:27017/microservice-portfolio")); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Getter 12 | public class ApiResponse { 13 | private boolean success; 14 | private String message; 15 | private T data; 16 | } 17 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/AuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | 8 | @Data 9 | @Builder 10 | @JsonIgnoreProperties(ignoreUnknown = true) 11 | @JsonInclude(JsonInclude.Include.NON_NULL) 12 | public class AuthenticationRequest { 13 | private String name; 14 | private String email; 15 | private String role; 16 | private String token; 17 | private String password; 18 | private String idEmployee; 19 | } -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/AuthenticationResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | 9 | public class AuthenticationResponse { 10 | private int statusCode; 11 | private String error; 12 | private String message; 13 | private String token; 14 | private String refreshToken; 15 | private String expirationTime; 16 | private UserDTO user; 17 | private boolean isVaild; 18 | private String role; 19 | } -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/BooleanDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class BooleanDTO { 9 | private boolean isCheck; 10 | } 11 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/CompanyDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import java.util.List; 10 | 11 | @Builder 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Data 15 | public class CompanyDTO { 16 | private Integer id; 17 | private String name; 18 | private String type; 19 | private String description; 20 | private String street; 21 | private String email; 22 | private String phone; 23 | private String city; 24 | private String country; 25 | private Integer idManager; 26 | 27 | private List idHR; 28 | private List idJobs; 29 | } 30 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/ImageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @Builder 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class ImageDTO { 13 | private Integer id; 14 | private String url; 15 | } -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/JobDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | 9 | import java.util.List; 10 | 11 | @Builder 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Data 15 | public class JobDTO { 16 | @Id 17 | private Integer id; 18 | private String title; 19 | private String description; 20 | private String typeJob; 21 | private Integer size; 22 | private List idProfiePending; 23 | private List idProfile; 24 | private Integer idCompany; 25 | } 26 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/ProfileDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import com.baconbao.manager_service.models.Contact; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @Builder 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class ProfileDTO { 14 | private Integer id; 15 | private String objective; 16 | private String education; 17 | private String workExperience; 18 | private String skills; 19 | private Contact contact; 20 | private String typeProfile; 21 | private Integer idUser; 22 | private String url; 23 | 24 | private String title; 25 | } 26 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String role; 18 | } 19 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException{ 8 | public BadRequestException(String message){ 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.exception; 2 | 3 | import org.springframework.http.HttpStatusCode; 4 | 5 | public class CustomException extends RuntimeException{ 6 | private final Error error; 7 | 8 | public CustomException(Error error){ 9 | super(error.getMessage()); 10 | this.error = error; 11 | } 12 | 13 | public Error getError() { 14 | return error; 15 | } 16 | public int getCode(){ 17 | return error.getCode(); 18 | } 19 | public String getMessage() { 20 | return error.getMessage(); 21 | } 22 | public HttpStatusCode getHttpStatusCode(){ 23 | return error.getStatusCode(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/exception/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.exception; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | @Setter 10 | public class ExceptionResponse { 11 | private LocalDateTime time; 12 | private String message; 13 | private String details; 14 | private boolean success; 15 | 16 | public ExceptionResponse(LocalDateTime time, String message,String details, boolean success) { 17 | this.time = time; 18 | this.message = message; 19 | this.details = details; 20 | this.success = success; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/models/Company.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | import java.util.List; 11 | 12 | @Document(collection = "company") 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Builder 16 | @Data 17 | public class Company { 18 | @Id 19 | private Integer id; 20 | private String name; 21 | private String type; 22 | private String description; 23 | private String street; 24 | private String email; 25 | private String phone; 26 | private String city; 27 | private String country; 28 | private String url; 29 | private Integer idManager; 30 | private List idHr; 31 | private List idJobs; 32 | } -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/models/Contact.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | 9 | @Builder 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class Contact { 14 | @Id 15 | private Integer id; 16 | private String address; 17 | private String phone; 18 | private String email; 19 | } 20 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/models/Job.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | import java.util.List; 11 | 12 | @Document(collection = "job") 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Builder 16 | @Data 17 | public class Job { 18 | @Id 19 | private Integer id; 20 | private String title; 21 | private String description; 22 | private TypeJob typeJob; 23 | private Integer size; 24 | private List idProfiePending; 25 | private List idProfile; 26 | private Integer idCompany; 27 | } 28 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/models/TypeJob.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.models; 2 | 3 | public enum TypeJob { 4 | java, 5 | python, 6 | php 7 | } 8 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/openfeign/EmailClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.openfeign; 2 | 3 | import com.baconbao.manager_service.dto.ApiResponse; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | 8 | @FeignClient("email-service") 9 | public interface EmailClient { 10 | @PostMapping("/email/create") 11 | ApiResponse send(@RequestBody MessageDTO messageDTO); 12 | } 13 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/openfeign/ImageClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.openfeign; 2 | 3 | import com.baconbao.manager_service.dto.ApiResponse; 4 | import com.baconbao.manager_service.dto.ImageDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestPart; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | @FeignClient("image-service") 11 | public interface ImageClient { 12 | @PostMapping("/image/save") 13 | ApiResponse save(@RequestPart(value="image",required = false)MultipartFile image) ; 14 | } 15 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/openfeign/MessageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.openfeign; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class MessageDTO { 9 | private String message; 10 | private Integer id; 11 | } 12 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/openfeign/NotificationClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.openfeign; 2 | 3 | import com.baconbao.manager_service.dto.ApiResponse; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | 9 | @FeignClient("notification-service") 10 | public interface NotificationClient { 11 | @PostMapping("/notification/create") 12 | ApiResponse create(@RequestBody MessageDTO messageDTO); 13 | } 14 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/openfeign/ProfileClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.openfeign; 2 | 3 | import com.baconbao.manager_service.dto.ApiResponse; 4 | import com.baconbao.manager_service.dto.BooleanDTO; 5 | import com.baconbao.manager_service.dto.ProfileDTO; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | @FeignClient(name = "profile-service") 12 | 13 | public interface ProfileClient { 14 | @GetMapping("/profile/user/checkIdProfile") 15 | ApiResponse checkIdProfile(@RequestParam Integer id); 16 | @GetMapping("/profile/user/findById") 17 | ApiResponse getProfileById(@RequestParam Integer id) ; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/openfeign/UserClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.openfeign; 2 | 3 | import com.baconbao.manager_service.dto.ApiResponse; 4 | import com.baconbao.manager_service.dto.AuthenticationRequest; 5 | import com.baconbao.manager_service.dto.AuthenticationResponse; 6 | import com.baconbao.manager_service.dto.UserDTO; 7 | import org.springframework.cloud.openfeign.FeignClient; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | 14 | @FeignClient(name ="user-service" ) 15 | public interface UserClient { 16 | @PostMapping("/auth/signup") 17 | ApiResponse signUp(@RequestBody AuthenticationRequest signUpRequest); 18 | 19 | @GetMapping("/auth/getCurrentUser") 20 | ApiResponse getCurrentUser(); 21 | 22 | @GetMapping("/findbyid") 23 | ApiResponse findById(@RequestParam Integer id); 24 | } 25 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/repository/CompanyRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.repository; 2 | 3 | import com.baconbao.manager_service.models.Company; 4 | import org.springframework.data.mongodb.repository.MongoRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CompanyRepository extends MongoRepository { 9 | } -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/repository/JobRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.repository; 2 | 3 | import com.baconbao.manager_service.models.Job; 4 | import org.springframework.data.mongodb.repository.MongoRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface JobRepository extends MongoRepository { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/services/service/CompanyService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.services.service; 2 | 3 | import com.baconbao.manager_service.dto.AuthenticationRequest; 4 | import com.baconbao.manager_service.dto.CompanyDTO; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.web.multipart.MultipartFile; 7 | 8 | import java.util.List; 9 | 10 | @Service 11 | public interface CompanyService { 12 | CompanyDTO findById(Integer id); 13 | CompanyDTO findByIdHr(Integer id); 14 | CompanyDTO getCompanyByIdManager(Integer id); 15 | CompanyDTO create(CompanyDTO company, MultipartFile multipartFile); 16 | CompanyDTO update(CompanyDTO company); 17 | void deleteById(Integer id); 18 | List getCompanyDTOs(); 19 | List getCompanyByType(String type); 20 | CompanyDTO setHRToCompany(AuthenticationRequest authenticationRequest,Integer idCompany); 21 | CompanyDTO deleteHRToCompany(Integer idHR, Integer idCompany); 22 | CompanyDTO setManagerToCompany(AuthenticationRequest authenticationRequest,Integer id); 23 | } 24 | -------------------------------------------------------------------------------- /manager-service/src/main/java/com/baconbao/manager_service/services/service/JobService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service.services.service; 2 | 3 | import com.baconbao.manager_service.dto.JobDTO; 4 | 5 | import java.util.List; 6 | 7 | public interface JobService { 8 | JobDTO findById(Integer id); 9 | JobDTO create(JobDTO job); 10 | JobDTO update(JobDTO job); 11 | JobDTO delete(Integer id); 12 | List getAllJobs(); 13 | List getJobByCompany(Integer id); 14 | List getNewJob(Integer id); 15 | List getJobByPrfilePending(Integer id); 16 | List getJobByProfileAccepted(Integer id); 17 | JobDTO applyJob(Integer idJob,Integer idProfile); 18 | JobDTO acceptProfile(Integer idJob,Integer idProfile); 19 | JobDTO rejectProfile(Integer idJob,Integer idProfile); 20 | } 21 | -------------------------------------------------------------------------------- /manager-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.data.mongodb.uri=mongodb://localhost:27017/microservice-portfolio 3 | -------------------------------------------------------------------------------- /manager-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: manager-service 4 | server: 5 | port: 8091 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /manager-service/src/test/java/com/baconbao/manager_service/ManagerServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.manager_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ManagerServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /notification-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /notification-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/NotificationServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class NotificationServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(NotificationServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.modelmapper.ModelMapper; 6 | 7 | @Configuration 8 | public class AppConfig { 9 | @Bean 10 | public ModelMapper modelMapper() { 11 | ModelMapper modelMapper = new ModelMapper(); 12 | return modelMapper; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/config/KafkaConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.config; 2 | 3 | import org.apache.kafka.clients.consumer.ConsumerConfig; 4 | import org.apache.kafka.common.serialization.StringDeserializer; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; 9 | import org.springframework.kafka.core.ConsumerFactory; 10 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; 11 | 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @Configuration 16 | @EnableKafka 17 | public class KafkaConfig { 18 | 19 | @Bean 20 | public ConsumerFactory consumerFactory() { 21 | Map props = new HashMap<>(); 22 | props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); 23 | props.put(ConsumerConfig.GROUP_ID_CONFIG, "email-service-group"); 24 | props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 25 | props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 26 | return new DefaultKafkaConsumerFactory<>(props); 27 | } 28 | 29 | @Bean 30 | public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() { 31 | ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>(); 32 | factory.setConsumerFactory(consumerFactory()); 33 | return factory; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ApiResponse { 11 | private boolean success; 12 | private String message; 13 | private T data; 14 | } -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/dto/MessageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class MessageDTO { 9 | private String message; 10 | private Integer id; 11 | } 12 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/dto/NotificationDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @Builder 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class NotificationDTO { 15 | private Integer id; 16 | private String message; 17 | private LocalDateTime createAt; 18 | private String url; 19 | private boolean isRead; 20 | private Integer idUser; 21 | } 22 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String idEmployee; 18 | private String role; 19 | private boolean isActive; 20 | } 21 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException{ 8 | public BadRequestException(String message){ 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/exception/CloudinaryException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.exception; 2 | 3 | public class CloudinaryException extends RuntimeException{ 4 | private final java.lang.Error error; 5 | 6 | public CloudinaryException(java.lang.Error error) { 7 | super(error.getMessage()); 8 | this.error = error; 9 | } 10 | 11 | public java.lang.Error getError() { 12 | return error; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.exception; 2 | 3 | import org.springframework.http.HttpStatusCode; 4 | 5 | public class CustomException extends RuntimeException{ 6 | private final Error error; 7 | 8 | public CustomException(Error error){ 9 | super(error.getMessage()); 10 | this.error = error; 11 | } 12 | 13 | public Error getError() { 14 | return error; 15 | } 16 | public int getCode(){ 17 | return error.getCode(); 18 | } 19 | public String getMessage() { 20 | return error.getMessage(); 21 | } 22 | public HttpStatusCode getHttpStatusCode(){ 23 | return error.getStatusCode(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/exception/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.exception; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | @Setter 10 | public class ExceptionResponse { 11 | private LocalDateTime time; 12 | private String message; 13 | private String details; 14 | private boolean success; 15 | 16 | public ExceptionResponse(LocalDateTime time, String message,String details, boolean success) { 17 | this.time = time; 18 | this.message = message; 19 | this.details = details; 20 | this.success = success; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/model/Notification.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | @Entity 12 | @Table(name = "notifications") 13 | @Builder 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class Notification { 18 | @Id 19 | private Integer id; 20 | private String message; 21 | private LocalDateTime createAt; 22 | private Integer idUser; 23 | private String url; 24 | private boolean isRead; 25 | } -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/openFeign/UserClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.openFeign; 2 | 3 | import com.baconbao.notification_service.dto.ApiResponse; 4 | import com.baconbao.notification_service.dto.UserDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @FeignClient(name = "user-service") 10 | public interface UserClient { 11 | @GetMapping("/auth/checkId") 12 | ApiResponse checkId(@RequestParam Integer id); 13 | @GetMapping("/auth/getCurrentUser") 14 | ApiResponse getCurrentUser() ; 15 | } 16 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/repository/NotificationRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.repository; 2 | 3 | import com.baconbao.notification_service.model.Notification; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import java.util.List; 7 | 8 | 9 | public interface NotificationRepository extends JpaRepository { 10 | @Query("SELECT n FROM Notification n WHERE n.idUser = :userId") 11 | List getNotificationsByIdUser(Integer userId); 12 | } 13 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/baconbao/notification_service/services/service/NotificationService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service.services.service; 2 | 3 | import com.baconbao.notification_service.dto.MessageDTO; 4 | import com.baconbao.notification_service.dto.NotificationDTO; 5 | import org.springframework.stereotype.Service; 6 | import java.util.List; 7 | 8 | @Service 9 | public interface NotificationService { 10 | NotificationDTO create(NotificationDTO notificationDTO); 11 | NotificationDTO update(NotificationDTO notificationDTO); 12 | NotificationDTO findById(Integer id); 13 | NotificationDTO seenNotification(Integer id); 14 | List getNotificationsByIdUser(Integer userId); 15 | void send(MessageDTO messageDTO); 16 | } 17 | -------------------------------------------------------------------------------- /notification-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=notification-service 2 | spring.datasource.url=jdbc:mysql://localhost:3306/notification1?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true 3 | spring.datasource.username=root 4 | spring.datasource.password= 5 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect 6 | spring.jpa.properties.hibernate.connection.characterEncoding=UTF-8 7 | #Hien thi cau lenh sql 8 | spring.jpa.show-sql=true 9 | #Fomat cau lenh 10 | spring.jpa.properties.hibernate.format_sql=true 11 | # Hibernate ddl auto (create, create-drop, validate, update) 12 | spring.jpa.hibernate.ddl-auto = update -------------------------------------------------------------------------------- /notification-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: notification-service 4 | server: 5 | port: 8084 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /notification-service/src/test/java/com/baconbao/notification_service/NotificationServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.notification_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class NotificationServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /profile-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /profile-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/ProfileServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableFeignClients 10 | @EnableDiscoveryClient 11 | public class ProfileServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ProfileServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/config/FeignClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.config; 2 | 3 | import feign.codec.Encoder; 4 | import feign.form.spring.SpringFormEncoder; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.client.RestTemplate; 8 | 9 | @Configuration 10 | public class FeignClientConfig { 11 | 12 | @Bean 13 | public Encoder feignFormEncoder() { 14 | return new SpringFormEncoder(); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/config/MongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.mongodb.core.MongoTemplate; 6 | import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory; 7 | 8 | 9 | @Configuration 10 | public class MongoConfig { 11 | @Bean 12 | public MongoTemplate mongoTemplate() { 13 | return new MongoTemplate(new SimpleMongoClientDatabaseFactory("mongodb://localhost:27017/microservice-portfolio")); 14 | } 15 | } -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ApiResponse { 11 | private boolean success; 12 | private String message; 13 | private T data; 14 | } 15 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/dto/BooleanDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class BooleanDTO { 9 | private boolean isCheck; 10 | } 11 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/dto/ImageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.dto; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @Builder 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class ImageDTO { 12 | private Integer id; 13 | private String url; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/dto/ProfileDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import com.baconbao.profile_service.model.Contact; 10 | 11 | @Data 12 | @Builder 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class ProfileDTO { 16 | private Integer id; 17 | private String objective; 18 | private String education; 19 | private String workExperience; 20 | private String skills; 21 | private Contact contact; 22 | private String typeProfile; 23 | private Integer idUser; 24 | private String url; 25 | 26 | private String title; 27 | } 28 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String idEmployee; 18 | private String role; 19 | private boolean isActive; 20 | } 21 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException{ 8 | public BadRequestException(String message){ 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.exception; 2 | 3 | import org.springframework.http.HttpStatusCode; 4 | 5 | public class CustomException extends RuntimeException{ 6 | private final Error error; 7 | 8 | public CustomException(Error error){ 9 | super(error.getMessage()); 10 | this.error = error; 11 | } 12 | 13 | public Error getError() { 14 | return error; 15 | } 16 | public int getCode(){ 17 | return error.getCode(); 18 | } 19 | public String getMessage() { 20 | return error.getMessage(); 21 | } 22 | public HttpStatusCode getHttpStatusCode(){ 23 | return error.getStatusCode(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/exception/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.exception; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | @Setter 10 | public class ExceptionResponse { 11 | private LocalDateTime time; 12 | private String message; 13 | private String details; 14 | private boolean success; 15 | 16 | public ExceptionResponse(LocalDateTime time, String message,String details, boolean success) { 17 | this.time = time; 18 | this.message = message; 19 | this.details = details; 20 | this.success = success; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/model/About.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | 9 | public class About { 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/model/Contact.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.model; 2 | 3 | import org.springframework.data.annotation.Id; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Builder 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class Contact { 15 | @Id 16 | private Integer id; 17 | private String address; 18 | private String phone; 19 | private String email; 20 | } 21 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/model/Profile.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.model; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | import lombok.Data; 6 | import lombok.AllArgsConstructor; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Builder; 9 | 10 | @Document(collection = "profile") 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | public class Profile { 16 | @Id 17 | private Integer id; 18 | private String objective; 19 | private String education; 20 | private String workExperience; 21 | private String skills; 22 | private Contact contact; // Refers to Contact ID, if used 23 | private TypeProfile typeProfile; // Enum stored as String 24 | private Integer idImage; // Refers to Image ID, if used 25 | private String title; 26 | private Integer idUser; 27 | private String url; 28 | } 29 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/model/TypeProfile.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.model; 2 | 3 | public enum TypeProfile { 4 | JAVA, 5 | PYTHON, 6 | C; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/openFeign/ImageClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.openFeign; 2 | 3 | import com.baconbao.profile_service.config.FeignClientConfig; 4 | import com.baconbao.profile_service.dto.ApiResponse; 5 | import com.baconbao.profile_service.dto.ImageDTO; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.web.bind.annotation.*; 9 | import org.springframework.web.multipart.MultipartFile; 10 | 11 | @FeignClient(name = "image-service", configuration = FeignClientConfig.class) 12 | 13 | public interface ImageClient { 14 | @PostMapping(value = "/image/save", consumes = "multipart/form-data") 15 | ApiResponse save(@RequestPart(value="image",required = false)MultipartFile image) ; 16 | 17 | @GetMapping("/image/getAll") 18 | ApiResponse getAll(); 19 | } 20 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/openFeign/UserClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.openFeign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | import com.baconbao.profile_service.dto.ApiResponse; 9 | import com.baconbao.profile_service.dto.UserDTO; 10 | 11 | 12 | @FeignClient("user-service") 13 | public interface UserClient { 14 | @GetMapping("/checkId") 15 | Boolean checkId(@RequestParam Integer id); 16 | @GetMapping("/auth/getCurrentUser") 17 | ApiResponsegetCurrentUser() ; 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/repository/ProfileRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.repository; 2 | 3 | import com.baconbao.profile_service.model.Profile; 4 | 5 | import java.util.List; 6 | 7 | import org.springframework.data.mongodb.repository.MongoRepository; 8 | 9 | 10 | public interface ProfileRepository extends MongoRepository { 11 | List findByIdIn(List ids); 12 | } 13 | -------------------------------------------------------------------------------- /profile-service/src/main/java/com/baconbao/profile_service/services/service/ProfileService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service.services.service; 2 | 3 | import com.baconbao.profile_service.dto.BooleanDTO; 4 | import com.baconbao.profile_service.dto.ProfileDTO; 5 | import com.baconbao.profile_service.model.Profile; 6 | import com.baconbao.profile_service.model.TypeProfile; 7 | import org.springframework.web.multipart.MultipartFile; 8 | import java.util.List; 9 | 10 | public interface ProfileService { 11 | ProfileDTO updateProfile(ProfileDTO profileDTO,MultipartFile imageFile); 12 | ProfileDTO saveProfile(ProfileDTO profileDTO,MultipartFile imageFile); 13 | ProfileDTO findById(Integer id); 14 | ProfileDTO findByIdUser(Integer id); 15 | List findProfilesByType(TypeProfile typeProfile); 16 | ProfileDTO convertToDTO(Profile profile); 17 | Profile convertToModel(ProfileDTO profileDTO); 18 | List getAllProfile(); 19 | List findByTitle(String title); 20 | List findListProfileByIdPendingJob(List idJobs); 21 | BooleanDTO checkIdProfile(Integer id); 22 | 23 | } -------------------------------------------------------------------------------- /profile-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.data.mongodb.uri=mongodb://localhost:27017/microservice-portfolio 2 | spring.servlet.multipart.enabled=true 3 | spring.servlet.multipart.max-file-size=10MB 4 | spring.servlet.multipart.max-request-size=10MB -------------------------------------------------------------------------------- /profile-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: profile-service 4 | server: 5 | port: 8085 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /profile-service/src/test/java/com/baconbao/profile_service/ProfileServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.profile_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ProfileServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /project-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /project-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/ProjectServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | @EnableFeignClients 11 | public class ProjectServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ProjectServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.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 AppConfig { 9 | //cần sửa 10 | @Bean 11 | public ModelMapper modelMapper() { 12 | ModelMapper modelMapper = new ModelMapper(); 13 | return modelMapper; 14 | } 15 | } -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ApiResponse { 11 | private boolean success; 12 | private String message; 13 | private T data; 14 | } 15 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/dto/ImageDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @Builder 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class ImageDTO { 13 | private Integer id; 14 | private String url; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/dto/ProfileDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | @Data 10 | @Builder 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class ProfileDTO { 14 | private Integer id; 15 | private String objective; 16 | private String education; 17 | private String workExperience; 18 | private String skills; 19 | private String typeProfile; 20 | private Integer userId; 21 | private String url; 22 | private MultipartFile imageFile; 23 | } 24 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/dto/ProjectDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | @Data 12 | @Builder 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class ProjectDTO { 16 | private Integer id; 17 | private String title; 18 | private String description; 19 | private LocalDateTime createAt; 20 | private String url; 21 | private String imageId; 22 | private boolean isDisplay; 23 | private MultipartFile imageFile; 24 | private Integer idProfile; 25 | } 26 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String idEmployee; 18 | private String role; 19 | private boolean isActive; 20 | } 21 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException{ 8 | public BadRequestException(String message){ 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.exception; 2 | 3 | import org.springframework.http.HttpStatusCode; 4 | 5 | public class CustomException extends RuntimeException{ 6 | private final Error error; 7 | 8 | public CustomException(Error error){ 9 | super(error.getMessage()); 10 | this.error = error; 11 | } 12 | 13 | public Error getError() { 14 | return error; 15 | } 16 | public int getCode(){ 17 | return error.getCode(); 18 | } 19 | public String getMessage() { 20 | return error.getMessage(); 21 | } 22 | public HttpStatusCode getHttpStatusCode(){ 23 | return error.getStatusCode(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/exception/CustomizedResponseEntityExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.ExceptionHandler; 6 | import org.springframework.web.bind.annotation.RestControllerAdvice; 7 | import org.springframework.web.context.request.WebRequest; 8 | 9 | import com.baconbao.project_service.dto.ApiResponse; 10 | 11 | 12 | @RestControllerAdvice 13 | public class CustomizedResponseEntityExceptionHandler { 14 | 15 | @ExceptionHandler(BadRequestException.class) 16 | public final ResponseEntity> handleBadRequestException(BadRequestException ex, WebRequest request) { 17 | ApiResponse response = new ApiResponse<>( 18 | false, 19 | ex.getMessage(), 20 | "" 21 | ); 22 | return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); 23 | } 24 | 25 | @ExceptionHandler(CustomException.class) 26 | public final ResponseEntity> handleCustomException(CustomException cx, WebRequest request) { 27 | ApiResponse response = new ApiResponse<>( 28 | false, 29 | cx.getMessage(), 30 | "" 31 | ); 32 | return new ResponseEntity<>(response, cx.getError().getStatusCode()); 33 | } 34 | 35 | @ExceptionHandler(Exception.class) 36 | public final ResponseEntity> handleAllException(Exception e, WebRequest request) { 37 | ApiResponse response = new ApiResponse<>( 38 | false, 39 | e.getMessage(), 40 | "" 41 | ); 42 | return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/exception/ExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.exception; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | @Getter 9 | @Setter 10 | public class ExceptionResponse { 11 | private LocalDateTime time; 12 | private String message; 13 | private String details; 14 | private boolean success; 15 | 16 | public ExceptionResponse(LocalDateTime time, String message,String details, boolean success) { 17 | this.time = time; 18 | this.message = message; 19 | this.details = details; 20 | this.success = success; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/model/Project.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | @Entity 12 | @Table(name = "project") 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Builder 17 | public class Project { 18 | @Id 19 | private Integer id; 20 | private String title; 21 | private String description; 22 | private LocalDateTime createAt; 23 | private String idImage; 24 | private boolean isDisplay; 25 | @PrePersist 26 | protected void onCreate() { 27 | createAt = LocalDateTime.now(); 28 | 29 | } 30 | private String url; 31 | private Integer idProfile; 32 | 33 | } 34 | 35 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/openFeign/ImageClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.openFeign; 2 | 3 | import com.baconbao.project_service.dto.ApiResponse; 4 | import com.baconbao.project_service.dto.ImageDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestPart; 10 | import org.springframework.web.multipart.MultipartFile; 11 | 12 | @FeignClient(name = "image-service") 13 | public interface ImageClient { 14 | @PostMapping(value = "/image/save", consumes = "multipart/form-data") 15 | ApiResponse save(@RequestPart(value="image",required = false)MultipartFile image) ; 16 | @GetMapping("/image/getAll") 17 | ApiResponse getAll() ; 18 | } 19 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/openFeign/ProfileClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.openFeign; 2 | 3 | import com.baconbao.project_service.dto.ProfileDTO; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | 7 | import java.util.List; 8 | 9 | @FeignClient(name = "profile-service") 10 | public interface ProfileClient { 11 | @GetMapping("/user/profile/getAll") 12 | List< ProfileDTO> getAll() ; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/openFeign/UserClient.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.openFeign; 2 | 3 | import com.baconbao.project_service.dto.ApiResponse; 4 | import com.baconbao.project_service.dto.UserDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | 9 | @FeignClient("user-service") 10 | public interface UserClient { 11 | @GetMapping("/auth/getCurrentUser") 12 | ApiResponse getCurrentUser() ;} 13 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/openFeign/test.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.openFeign; 2 | 3 | import com.baconbao.project_service.dto.ApiResponse; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | @FeignClient("notification-service") 10 | public interface test { 11 | @GetMapping(value = "/notification/getAll") 12 | ApiResponse ok(); 13 | } 14 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/repository/ProjectRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.repository; 2 | 3 | import com.baconbao.project_service.model.Project; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import java.util.List; 6 | 7 | 8 | public interface ProjectRepository extends JpaRepository { 9 | List findByIdProfile(Integer idProfile); 10 | } 11 | -------------------------------------------------------------------------------- /project-service/src/main/java/com/baconbao/project_service/services/service/ProjectService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service.services.service; 2 | 3 | import com.baconbao.project_service.dto.ImageDTO; 4 | import com.baconbao.project_service.dto.ProfileDTO; 5 | import com.baconbao.project_service.dto.ProjectDTO; 6 | import org.springframework.web.multipart.MultipartFile; 7 | 8 | import java.util.List; 9 | 10 | public interface ProjectService { 11 | ProjectDTO saveProject(ProjectDTO projectDTO); 12 | ProjectDTO updateProject(ProjectDTO projectDTO); 13 | ProjectDTO findById(Integer id); 14 | 15 | ListgetAlliProfile(); 16 | ListgetProjectByIdProfile(Integer id); 17 | ImageDTO getall(MultipartFile multipartFile); 18 | } 19 | -------------------------------------------------------------------------------- /project-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=project-service 2 | spring.datasource.url=jdbc:mysql://localhost:3306/project1?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true 3 | spring.datasource.username=root 4 | spring.datasource.password= 5 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect 6 | spring.jpa.properties.hibernate.connection.characterEncoding=UTF-8 7 | #Hien thi cau lenh sql 8 | spring.jpa.show-sql=true 9 | #Fomat cau lenh 10 | spring.jpa.properties.hibernate.format_sql=true 11 | # Hibernate ddl auto (create, create-drop, validate, update) 12 | spring.jpa.hibernate.ddl-auto = update -------------------------------------------------------------------------------- /project-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comment-service 4 | server: 5 | port: 8086 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /project-service/src/test/java/com/baconbao/project_service/ProjectServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.project_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ProjectServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /user-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /user-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip 20 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/UserServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class UserServiceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(UserServiceApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.config; 2 | 3 | import com.baconbao.user_service.dto.UserDTO; 4 | import com.baconbao.user_service.model.Role; 5 | import com.baconbao.user_service.model.User; 6 | import org.modelmapper.ModelMapper; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | public class AppConfig { 10 | @Bean 11 | public ModelMapper modelMapper() { 12 | ModelMapper modelMapper = new ModelMapper(); 13 | 14 | // Custom mapping for User to UserDTO 15 | modelMapper.typeMap(User.class, UserDTO.class).addMappings(mapper -> { 16 | mapper.map(src -> src.getRole().name(), UserDTO::setRole); 17 | }); 18 | 19 | // Custom mapping for UserDTO to User 20 | modelMapper.typeMap(UserDTO.class, User.class).addMappings(mapper -> { 21 | mapper.map(src -> Role.valueOf(src.getRole()), User::setRole); 22 | }); 23 | 24 | return modelMapper; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/config/ModelMapperConfig.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.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 ModelMapperConfig { 9 | 10 | @Bean 11 | public ModelMapper modelMapper() { 12 | return new ModelMapper(); 13 | } 14 | } -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ApiResponse { 11 | private boolean success; 12 | private String message; 13 | private T data; 14 | } 15 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/dto/AuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | 8 | @Data 9 | @Builder 10 | @JsonIgnoreProperties(ignoreUnknown = true) 11 | @JsonInclude(JsonInclude.Include.NON_NULL) 12 | public class AuthenticationRequest { 13 | private String name; 14 | private String email; 15 | private String role; 16 | private String token; 17 | private String password; 18 | private String idEmployee; 19 | } -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/dto/AuthenticationResponse.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.dto; 2 | 3 | import com.baconbao.user_service.model.User; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import com.fasterxml.jackson.annotation.JsonInclude; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | 9 | @Data 10 | @Builder 11 | 12 | public class AuthenticationResponse { 13 | private int statusCode; 14 | private String error; 15 | private String message; 16 | private String token; 17 | private String refreshToken; 18 | private String expirationTime; 19 | private User user; 20 | private boolean isVaild; 21 | private String role; 22 | } -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/dto/UserDTO.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | @Builder 11 | @Data 12 | public class UserDTO { 13 | private Integer id; 14 | private String name; 15 | private String email; 16 | private String password; 17 | private String idEmployee; 18 | private String role; 19 | private boolean isActive; 20 | } 21 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException{ 8 | public BadRequestException(String message){ 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/exception/CustomException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.exception; 2 | 3 | import org.springframework.http.HttpStatusCode; 4 | 5 | public class CustomException extends RuntimeException{ 6 | private final Error error; 7 | 8 | public CustomException(Error error){ 9 | super(error.getMessage()); 10 | this.error = error; 11 | } 12 | 13 | public Error getError() { 14 | return error; 15 | } 16 | public int getCode(){ 17 | return error.getCode(); 18 | } 19 | public String getMessage() { 20 | return error.getMessage(); 21 | } 22 | public HttpStatusCode getHttpStatusCode(){ 23 | return error.getStatusCode(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/exception/CustomJwtException.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.exception; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatusCode; 5 | 6 | @Getter 7 | public class CustomJwtException extends RuntimeException { 8 | 9 | private final int code; 10 | private final String message; 11 | private final HttpStatusCode statusCode; 12 | 13 | public CustomJwtException(Error error, Throwable cause) { 14 | super(error.getMessage(), cause); 15 | this.code = error.getCode(); 16 | this.message = error.getMessage(); 17 | this.statusCode = error.getStatusCode(); 18 | } 19 | } -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.model; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | @RequiredArgsConstructor 6 | public enum Role { 7 | admin, 8 | user, 9 | hr, 10 | manager 11 | } 12 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/model/User.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.springframework.security.core.GrantedAuthority; 9 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 10 | import org.springframework.security.core.userdetails.UserDetails; 11 | 12 | import java.util.Collection; 13 | import java.util.List; 14 | 15 | @Data 16 | @Builder 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Entity 20 | @Table(name = "user") 21 | public class User implements UserDetails { 22 | @Id 23 | private Integer id; 24 | private String name; 25 | private String email; 26 | private String idEmployee; 27 | private String password; 28 | private boolean isActive; 29 | @Enumerated(EnumType.STRING) 30 | private Role role; 31 | @Override 32 | public Collection getAuthorities() { 33 | return List.of(new SimpleGrantedAuthority(role.name())); 34 | } 35 | 36 | 37 | @Override 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | @Override 43 | public String getUsername() { 44 | return email; 45 | } 46 | 47 | @Override 48 | public boolean isAccountNonExpired() { 49 | return UserDetails.super.isAccountNonExpired(); 50 | } 51 | 52 | @Override 53 | public boolean isAccountNonLocked() { 54 | return UserDetails.super.isAccountNonLocked(); 55 | } 56 | 57 | @Override 58 | public boolean isCredentialsNonExpired() { 59 | return UserDetails.super.isCredentialsNonExpired(); 60 | } 61 | 62 | @Override 63 | public boolean isEnabled() { 64 | return UserDetails.super.isEnabled(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.repository; 2 | 3 | 4 | import com.baconbao.user_service.model.User; 5 | 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | import java.util.Optional; 11 | 12 | @Repository 13 | public interface UserRepository extends JpaRepository { 14 | Optional findByEmail(String email); 15 | Optional findById(Integer id); 16 | List findAll(); 17 | void deleteById(Integer id); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/security/OurUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.security; 2 | 3 | 4 | import com.baconbao.user_service.repository.UserRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | public class OurUserDetailsService implements UserDetailsService { 13 | @Autowired 14 | private UserRepository userRepository; 15 | @Override 16 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 17 | return userRepository.findByEmail(username) 18 | .orElseThrow(()-> new UsernameNotFoundException("User not found with email: " + username)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /user-service/src/main/java/com/baconbao/user_service/services/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service.services.service; 2 | 3 | import com.baconbao.user_service.dto.UserDTO; 4 | 5 | import java.util.List; 6 | 7 | import org.springframework.stereotype.Service; 8 | 9 | 10 | @Service 11 | public interface UserService { 12 | UserDTO findById( Integer id); 13 | boolean checkUser(Integer id); 14 | UserDTO getCurrentUser(); 15 | UserDTO update(String token, UserDTO userDTO); 16 | List getALl(String token); 17 | List findAllUserByIds(List idUsers); 18 | UserDTO updateIsActive(String token,Integer id); 19 | UserDTO deleteUser(String token,Integer id); 20 | List findUsersByIds(String token, List idHR); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /user-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=user-service 2 | spring.datasource.url=jdbc:mysql://localhost:3306/portfolio?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true 3 | spring.datasource.username=root 4 | spring.datasource.password= 5 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect 6 | spring.jpa.properties.hibernate.connection.characterEncoding=UTF-8 7 | #Hien thi cau lenh sql 8 | spring.jpa.show-sql=true 9 | #Fomat cau lenh 10 | spring.jpa.properties.hibernate.format_sql=true 11 | # Hibernate ddl auto (create, create-drop, validate, update) 12 | spring.jpa.hibernate.ddl-auto = update -------------------------------------------------------------------------------- /user-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: user-service 4 | server: 5 | port: 8088 6 | eureka: 7 | client: 8 | serviceUrl: 9 | defaultZone: http://localhost:8671/eureka -------------------------------------------------------------------------------- /user-service/src/test/java/com/baconbao/user_service/UserServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.baconbao.user_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class UserServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------