Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contact controls #441

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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.getSender()+"\n" +
"Email Address: "+contactModel.getSenderEmail()+"\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.getSenderEmail(),"Urban air quality platform - contact","" +
"Dear "+contactModel.getSender()+","+"\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 sender;
private String senderEmail;
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> {
}
Loading