Merge remote-tracking branch 'origin/master'

# Conflicts:
#	pom.xml
This commit is contained in:
snoop 2017-07-04 11:09:49 +09:00
commit a46fc20cb2
3 changed files with 75 additions and 27 deletions

12
pom.xml
View File

@ -176,7 +176,7 @@
<plugin>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>1.27.339</version>
<version>1.25.322</version>
<executions>
<execution>
<id>generate</id>
@ -188,21 +188,13 @@
</executions>
<configuration>
<jsonLibrary>jackson2</jsonLibrary>
<!--<classes>-->
<!--<class>com.loafle.overflow.module.probe.service.ProbeService</class>-->
<!--</classes>-->
<classPatterns>
<!--<classPattern>com.loafle.overflow.module.**.service.*</classPattern>-->
<classPattern>com.loafle.overflow.module.**.model.*</classPattern>
</classPatterns>
<outputKind>module</outputKind>
<!--<outputFileType>declarationFile</outputFileType>-->
<!--<outputFile>target/typescript-generator/module.d.ts</outputFile>-->
<outputFileType>implementationFile</outputFileType>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -3,7 +3,7 @@ package com.loafle.overflow.module.email.model;
import com.loafle.overflow.module.member.model.Member;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
@ -13,8 +13,8 @@ import java.sql.Timestamp;
public class EmailAuth {
private long id;
private String emailAuthKey;
private Timestamp createDate;
private Timestamp authConfirmDate;
private Date createDate;
private Date authConfirmDate;
private Member member;
@Id
@ -39,21 +39,21 @@ public class EmailAuth {
@Basic
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Timestamp getCreateDate() {
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Timestamp createDate) {
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@Basic
@Column(name = "AUTH_CONFIRM_DATE", nullable = true, insertable = true, updatable = false)
public Timestamp getAuthConfirmDate() {
public Date getAuthConfirmDate() {
return authConfirmDate;
}
public void setAuthConfirmDate(Timestamp authConfirmDate) {
public void setAuthConfirmDate(Date authConfirmDate) {
this.authConfirmDate = authConfirmDate;
}

View File

@ -1,11 +1,21 @@
package com.loafle.overflow.module.email.service;
import com.loafle.overflow.module.email.dao.EmailAuthDAO;
import com.loafle.overflow.module.email.model.EmailAuth;
import com.loafle.overflow.module.member.model.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.util.List;
/**
* Created by geek on 17. 6. 28.
*/
@ -15,19 +25,65 @@ public class EmailAuthService {
@Autowired
private JavaMailSender mailSender;
@Autowired
private EmailAuthDAO emailAuthDAO;
public void sendEmail(String to, String sub, String message) {
public EmailAuth sendEmailByMemberId(long memberId, String memberEmail) {
try {
SimpleMailMessage message1 = new SimpleMailMessage();
message1.setTo(to);
message1.setSubject(sub);
message1.setText(message);
message1.setFrom("geek@loafle.com");
mailSender.send(message1);
} catch (MailException e) {
this.sendSimpleEmail(memberEmail, "Test Spring Mail", "Confirm Email");
}catch (MailException e) {
e.printStackTrace();
}
EmailAuth auth = new EmailAuth();
auth.setMember(new Member(memberId));
// Todo AuthKey Generation
auth.setEmailAuthKey("djdjdjdjeiejdikdjki");
this.emailAuthDAO.save(auth);
return auth;
}
public EmailAuth read(long id) {
return this.emailAuthDAO.findOne(id);
}
public EmailAuth readByAuthKey(String authKey) {
return this.emailAuthDAO.findByEmailAuthKey(authKey);
}
public List<EmailAuth> readByMember(long memberId) {
return this.emailAuthDAO.findByMember(new Member(memberId));
}
public EmailAuth modify(EmailAuth emailAuth) {
return this.emailAuthDAO.save(emailAuth);
}
public void sendSimpleEmail(String to, String sub, String message) throws MailException {
SimpleMailMessage message1 = new SimpleMailMessage();
message1.setTo(to);
message1.setSubject(sub);
message1.setText(message);
message1.setFrom("geek@loafle.com");
mailSender.send(message1);
}
public void sendMailWithAttachment(String to, String sub, String text, String path) throws MessagingException {
MimeMessage message = mailSender.createMimeMessage();
// pass 'true' to the constructor to create a multipart message
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setTo(to);
helper.setSubject(sub);
helper.setText(text);
helper.setFrom("geek@loafle.com");
FileSystemResource file = new FileSystemResource(new File(path));
helper.addAttachment("Invoice", file);
mailSender.send(message);
}
}