v1.2.6 diet.premium, diet registration email
This commit is contained in:
@@ -7,6 +7,8 @@ import com.aitrainer.api.model.diet.DietCustomer
|
||||
import com.aitrainer.api.model.diet.DietUser
|
||||
import com.aitrainer.api.repository.CustomerRepository
|
||||
import com.aitrainer.api.repository.diet.DietUserRepository
|
||||
import com.aitrainer.api.service.Email
|
||||
import com.aitrainer.api.service.EmailTemplateService
|
||||
import com.aitrainer.api.service.Firebase
|
||||
import com.aitrainer.api.service.ServiceBeans
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@@ -24,6 +26,10 @@ class DietCustomerController(private val dietUserRepository: DietUserRepository,
|
||||
@Autowired
|
||||
var serviceBeans: ServiceBeans? = null
|
||||
|
||||
|
||||
@Autowired
|
||||
private var emailTemplateService: EmailTemplateService? = null
|
||||
|
||||
@PostMapping("/diet_registration")
|
||||
fun insert(@RequestBody dietCustomerJson: String, @Value("\${firebase.key}") apiKey: java.lang.String): ResponseEntity<*> {
|
||||
val newDietCustomer: DietCustomer = DietCustomer().fromJson(dietCustomerJson)
|
||||
@@ -120,17 +126,16 @@ class DietCustomerController(private val dietUserRepository: DietUserRepository,
|
||||
idToken = existingCustomer.firebaseRegToken!!
|
||||
}
|
||||
|
||||
// create email link
|
||||
/*val activationLink = "https://diet4you.andio.hu/welcome/id=$idToken"
|
||||
if ( emailTemplateService == null ) {
|
||||
emailTemplateService = EmailTemplateService()
|
||||
}
|
||||
val html = emailTemplateService!!.getEmailBody(newDietCustomer.firstname, activationLink, "diet_registration_email")
|
||||
|
||||
val html = emailTemplateService!!.getDietRegistrationEmailBody(newDietCustomer.firstname, newDietCustomer.email, "diet_registration_email")
|
||||
val subject = emailTemplateService!!.getSubjectDiet()
|
||||
|
||||
// send email
|
||||
val email = Email()
|
||||
email.send(newDietCustomer.email, html, subject)*/
|
||||
email.send("service@diet4you.eu", html, subject)
|
||||
|
||||
return ResponseEntity.ok().body(existingCustomer)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ data class Diet (
|
||||
@Expose @get: NotNull val dietUserId: Long = 0,
|
||||
@Expose @get: NotNull val dietText: String = "",
|
||||
@Expose @get: NotNull var startDate: String = "",
|
||||
@Expose @get: NotNull val premium: Int = 0,
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "diet")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
|
||||
@@ -21,6 +21,17 @@ class EmailTemplateService {
|
||||
return templateEngine!!.process(template, context)
|
||||
}
|
||||
|
||||
fun getDietRegistrationEmailBody(firstname: String, email: String, template: String): String {
|
||||
val context = Context()
|
||||
context.setVariable("customerName", firstname)
|
||||
context.setVariable("customerEmail", email)
|
||||
if ( templateEngine == null) {
|
||||
templateEngine = TemplateEngine()
|
||||
}
|
||||
|
||||
return templateEngine!!.process(template, context)
|
||||
}
|
||||
|
||||
fun getSubject(): String {
|
||||
val context = Context()
|
||||
if ( templateEngine == null) {
|
||||
|
||||
@@ -16,7 +16,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.2.5
|
||||
application.version=1.2.6
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structue has been changed, increment this version number
|
||||
application.version=1.2.5
|
||||
application.version=1.2.6
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structue has been changed, increment this version number
|
||||
application.version=1.2.5
|
||||
application.version=1.2.6
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.2.5
|
||||
application.version=1.2.6
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
||||
@@ -4,22 +4,19 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<p th:text="'Szia ' + ${firstname} + '!'">Szia [firstname]!</p>
|
||||
<p>
|
||||
Üdvözlünk a Diet 4 You (Diéta Neked) tagjai között! Örülünk, hogy velünk vagy. Az étrended a Diet4You zárt felületén tudod elérni. A belépéshez használd ezt a linket:<br/><br/>
|
||||
<a th:href="${activationLink}" th:text="${activationLink}">${activationLink}</a>
|
||||
New Diet4You user:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Kérlek, kattints a linkre a fiókod aktiválásához. Ha bármilyen problémád van, ne habozz velünk kapcsolatba lépni.
|
||||
</p>
|
||||
<p>
|
||||
Köszönjük, hogy velünk dolgozol.
|
||||
Email:<span th:text="${customerEmail}">Email</span><br/>
|
||||
Name:<span th:text="${customerName}">Name</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Üdvözlettel,<br>
|
||||
Diéta Neked Csapata<br/>
|
||||
Diet 4 You Team<br/>
|
||||
mailto: diet4you@andio.hu<br/>
|
||||
Diet4You Team<br/>
|
||||
mailto: service@diet4you.eu<br/>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +1 @@
|
||||
[Diet4You] Üdv a céltudatosok között!
|
||||
[Diet4You] New Diet User!
|
||||
Reference in New Issue
Block a user