Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kavicastelo committed Apr 29, 2024
2 parents 473b9a7 + dfe530b commit fd2ba02
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 9 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches:
- '*'

jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install dependencies
run: |
cd client
npm install --force
- name: Build frontend
run: |
cd client
npm run build
build-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Build backend
run: |
chmod +x ./mvnw
./mvnw clean package
3 changes: 3 additions & 0 deletions .idea/codestream.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 38 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
package com.api.air_quality.controller;

import com.api.air_quality.dto.ApiResponse;
import com.api.air_quality.model.ContactModel;
import com.api.air_quality.repository.ContactRepository;
import com.api.air_quality.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ContactController {

@Autowired
ContactRepository contactRepository;

@Autowired
EmailService emailService;

@PostMapping("/api/v1/contact")
public ResponseEntity<ApiResponse> sendMail(@RequestBody ContactModel contactModel){
emailService.sendSimpleEmail("[email protected]","Urban air quality platform - contact","" +
"Dear Administration,"+"\n" +
"You got an contact email from: "+contactModel.getName()+"\n" +
"Email Address: "+contactModel.getEmail()+"\n\n" +
""+contactModel.getMessage()+"\n\n" +
"Client is waiting for your response. Reply ASAP\n\n\n" +
"System Automated Email - Urban Air Quality Platform");

emailService.sendSimpleEmail(contactModel.getEmail(),"Urban air quality platform - contact","" +
"Dear "+contactModel.getName()+","+"\n" +
"We got your contact message. Our agent will be contact you ASAP. Thank you for contacting with us! \n\n" +
"Sincerely,\n" +
"Urban Air Quality Platform.\n\n" +
"Note:- Don't reply to this email. This is system automated email.");

ApiResponse response = new ApiResponse("Contact message sent successfully!");
return ResponseEntity.ok(response);
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/api/air_quality/model/ContactModel.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
package com.api.air_quality.model;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Getter
@Setter
@ToString

@Document(collection = "contact")
public class ContactModel {
@Id
private String id;
private String name;
private String email;
private String message;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.api.air_quality.repository;

public interface ContactRepository {
import com.api.air_quality.model.ContactModel;
import org.springframework.data.mongodb.repository.MongoRepository;

public interface ContactRepository extends MongoRepository<ContactModel, String> {
}

0 comments on commit fd2ba02

Please sign in to comment.