Merge branch 'master' of https://git.loafle.net/overflow/overflow_server
This commit is contained in:
commit
9c25c2f059
22
pom.xml
22
pom.xml
|
@ -173,6 +173,28 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>cz.habarta.typescript-generator</groupId>
|
||||||
|
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||||
|
<version>1.25.322</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jsonLibrary>jackson2</jsonLibrary>
|
||||||
|
<classPatterns>
|
||||||
|
<classPattern>com.loafle.overflow.module.**.model.*</classPattern>
|
||||||
|
</classPatterns>
|
||||||
|
<outputKind>module</outputKind>
|
||||||
|
<outputFileType>implementationFile</outputFileType>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -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.dao.ApiKeyDAO;
|
||||||
import com.loafle.overflow.module.apikey.model.ApiKey;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -16,9 +17,13 @@ public class ApiKeyService {
|
||||||
private ApiKeyDAO apiKeyDAO;
|
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) {
|
public boolean check(String apiKey) {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,19 +25,65 @@ 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 sendEmailByMember(long memberId, String memberEmail) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SimpleMailMessage message1 = new SimpleMailMessage();
|
this.sendSimpleEmail(memberEmail, "Test Spring Mail", "Confirm Email");
|
||||||
message1.setTo(to);
|
}catch (MailException e) {
|
||||||
message1.setSubject(sub);
|
|
||||||
message1.setText(message);
|
|
||||||
message1.setFrom("geek@loafle.com");
|
|
||||||
|
|
||||||
mailSender.send(message1);
|
|
||||||
} catch (MailException e) {
|
|
||||||
e.printStackTrace();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,9 @@ public class NoAuthProbeService {
|
||||||
private NoAuthProbeDAO noAuthProbeDAO;
|
private NoAuthProbeDAO noAuthProbeDAO;
|
||||||
|
|
||||||
|
|
||||||
public void regist(NoAuthProbe noAuthProbe) {
|
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
|
||||||
this.noAuthProbeDAO.save(noAuthProbe);
|
|
||||||
|
return this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NoAuthProbe> readAllByDomain(Domain domain) {
|
public List<NoAuthProbe> readAllByDomain(Domain domain) {
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -17,8 +17,8 @@ public class ProbeService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProbeDAO probeDAO;
|
private ProbeDAO probeDAO;
|
||||||
|
|
||||||
public void regist(Probe probe) {
|
public Probe regist(Probe probe) {
|
||||||
this.probeDAO.save(probe);
|
return this.probeDAO.save(probe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Probe> readAllByDomain(Domain domain) {
|
public List<Probe> readAllByDomain(Domain domain) {
|
||||||
|
|
|
@ -17,8 +17,8 @@ public class ProbeTaskService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProbeTaskDAO probeTaskDAO;
|
private ProbeTaskDAO probeTaskDAO;
|
||||||
|
|
||||||
public void regist(ProbeTask probeTask) {
|
public ProbeTask regist(ProbeTask probeTask) {
|
||||||
this.probeTaskDAO.save(probeTask);
|
return this.probeTaskDAO.save(probeTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProbeTask> readAllByProbe(Probe probe) {
|
public List<ProbeTask> readAllByProbe(Probe probe) {
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ import com.loafle.overflow.module.apikey.model.ApiKey;
|
||||||
import com.loafle.overflow.module.domain.model.Domain;
|
import com.loafle.overflow.module.domain.model.Domain;
|
||||||
import com.loafle.overflow.spring.AppConfig;
|
import com.loafle.overflow.spring.AppConfig;
|
||||||
import com.loafle.overflow.spring.JdbcConfiguration;
|
import com.loafle.overflow.spring.JdbcConfiguration;
|
||||||
|
import com.loafle.overflow.spring.MailConfiguration;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -18,8 +19,7 @@ import static org.junit.Assert.*;
|
||||||
* Created by snoop on 17. 6. 28.
|
* Created by snoop on 17. 6. 28.
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class})
|
||||||
|
|
||||||
public class ApiKeyServiceTest {
|
public class ApiKeyServiceTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -57,4 +57,17 @@ public class ApiKeyServiceTest {
|
||||||
Assert.assertNotEquals(result, false);
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user