diff --git a/pom.xml b/pom.xml
index 6451413..866e1b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,6 +173,28 @@
+
+ cz.habarta.typescript-generator
+ typescript-generator-maven-plugin
+ 1.25.322
+
+
+ generate
+
+ generate
+
+ process-classes
+
+
+
+ jackson2
+
+ com.loafle.overflow.module.**.model.*
+
+ module
+ implementationFile
+
+
diff --git a/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java b/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java
index ba3148a..b9e8919 100644
--- a/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java
+++ b/src/main/java/com/loafle/overflow/module/apikey/service/ApiKeyService.java
@@ -2,6 +2,7 @@ package com.loafle.overflow.module.apikey.service;
import com.loafle.overflow.module.apikey.dao.ApiKeyDAO;
import com.loafle.overflow.module.apikey.model.ApiKey;
+import com.loafle.overflow.module.domain.model.Domain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -16,9 +17,13 @@ public class ApiKeyService {
private ApiKeyDAO apiKeyDAO;
- public void regist(ApiKey apiKey) {
+ public ApiKey regist(ApiKey apiKey) {
- this.apiKeyDAO.save(apiKey);
+ return this.apiKeyDAO.save(apiKey);
+ }
+
+ public ApiKey readByDomain(Domain domain) {
+ return this.apiKeyDAO.findByDomain(domain);
}
public boolean check(String apiKey) {
diff --git a/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java b/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java
index c46f672..83705fc 100644
--- a/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java
+++ b/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java
@@ -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;
}
diff --git a/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java b/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java
index 69ba19f..ec9a4f9 100644
--- a/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java
+++ b/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java
@@ -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 sendEmailByMember(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 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);
}
}
diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java
index 512e210..7067b6a 100644
--- a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java
+++ b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java
@@ -18,8 +18,9 @@ public class NoAuthProbeService {
private NoAuthProbeDAO noAuthProbeDAO;
- public void regist(NoAuthProbe noAuthProbe) {
- this.noAuthProbeDAO.save(noAuthProbe);
+ public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
+
+ return this.noAuthProbeDAO.save(noAuthProbe);
}
public List readAllByDomain(Domain domain) {
diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/type/AuthType.java b/src/main/java/com/loafle/overflow/module/noauthprobe/type/AuthType.java
deleted file mode 100644
index 1d58a0f..0000000
--- a/src/main/java/com/loafle/overflow/module/noauthprobe/type/AuthType.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.loafle.overflow.module.noauthprobe.type;
-
-/**
- * Created by root on 17. 5. 31.
- */
-public enum AuthType {
- A("ACCEPT"),
- D("DENY"),
- P("PROCESS");
-
- private String stringValue;
- AuthType(String string) {stringValue = string;}
-
- @Override
- public String toString() {
- return stringValue;
- }
-
-}
diff --git a/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java b/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java
index f3903ce..3b78f8a 100644
--- a/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java
+++ b/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java
@@ -17,8 +17,8 @@ public class ProbeService {
@Autowired
private ProbeDAO probeDAO;
- public void regist(Probe probe) {
- this.probeDAO.save(probe);
+ public Probe regist(Probe probe) {
+ return this.probeDAO.save(probe);
}
public List readAllByDomain(Domain domain) {
diff --git a/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java b/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java
index d3d3929..8198f79 100644
--- a/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java
+++ b/src/main/java/com/loafle/overflow/module/probe/service/ProbeTaskService.java
@@ -17,8 +17,8 @@ public class ProbeTaskService {
@Autowired
private ProbeTaskDAO probeTaskDAO;
- public void regist(ProbeTask probeTask) {
- this.probeTaskDAO.save(probeTask);
+ public ProbeTask regist(ProbeTask probeTask) {
+ return this.probeTaskDAO.save(probeTask);
}
public List readAllByProbe(Probe probe) {
diff --git a/src/main/java/com/loafle/overflow/module/probe/type/ProbeStatusType.java b/src/main/java/com/loafle/overflow/module/probe/type/ProbeStatusType.java
deleted file mode 100644
index 1e4c602..0000000
--- a/src/main/java/com/loafle/overflow/module/probe/type/ProbeStatusType.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.loafle.overflow.module.probe.type;
-
-/**
- * Created by root on 17. 6. 23.
- */
-public enum ProbeStatusType {
- I("INITIAL"),
- N("NORMAL");
-
-
- private String stringValue;
- ProbeStatusType(String string) {stringValue = string;}
-
- @Override
- public String toString() {
- return stringValue;
- }
-}
diff --git a/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java b/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java
index fc01b92..be07583 100644
--- a/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java
+++ b/src/test/java/com/loafle/overflow/module/apikey/service/ApiKeyServiceTest.java
@@ -4,6 +4,7 @@ import com.loafle.overflow.module.apikey.model.ApiKey;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.spring.AppConfig;
import com.loafle.overflow.spring.JdbcConfiguration;
+import com.loafle.overflow.spring.MailConfiguration;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -18,8 +19,7 @@ import static org.junit.Assert.*;
* Created by snoop on 17. 6. 28.
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
-
+@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class})
public class ApiKeyServiceTest {
@Autowired
@@ -57,4 +57,17 @@ public class ApiKeyServiceTest {
Assert.assertNotEquals(result, false);
}
+ @Ignore
+ @Test
+ public void findByDomain() {
+
+ Domain domain = new Domain();
+ domain.setId(1);
+
+ ApiKey apiKey = this.apiKeyService.readByDomain(domain);
+
+ Assert.assertNotEquals(apiKey, null);
+
+ }
+
}
\ No newline at end of file