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

View File

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

View File

@ -1,11 +1,21 @@
package com.loafle.overflow.module.email.service; 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.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.MailException; import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service; 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. * Created by geek on 17. 6. 28.
*/ */
@ -15,10 +25,44 @@ public class EmailAuthService {
@Autowired @Autowired
private JavaMailSender mailSender; private JavaMailSender mailSender;
@Autowired
private EmailAuthDAO emailAuthDAO;
public void sendEmail(String to, String sub, String message) { public EmailAuth sendEmailByMemberId(long memberId, String memberEmail) {
try { try {
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(); SimpleMailMessage message1 = new SimpleMailMessage();
message1.setTo(to); message1.setTo(to);
message1.setSubject(sub); message1.setSubject(sub);
@ -26,8 +70,20 @@ public class EmailAuthService {
message1.setFrom("geek@loafle.com"); message1.setFrom("geek@loafle.com");
mailSender.send(message1); mailSender.send(message1);
} catch (MailException e) { }
e.printStackTrace();
} 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);
} }
} }