Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/1.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
fishstormX committed Jul 4, 2019
2 parents 60ad2c5 + 8681ac0 commit c852507
Show file tree
Hide file tree
Showing 10 changed files with 439 additions and 11 deletions.
47 changes: 40 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.fishstorm</groupId>
<artifactId>fishmaple</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.1.3-b-SNAPSHOT</version>
<packaging>jar</packaging>

<name>shirodemo</name>
Expand All @@ -25,7 +25,19 @@
</properties>

<dependencies>
<dependency>

<!-- https://mvnrepository.com/artifact/javax.mail/mail -->

<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
<dependency>
<groupId>locallib</groupId>
<artifactId>mail</artifactId>
<version>1.6.2</version>

</dependency>


<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
Expand Down Expand Up @@ -204,11 +216,7 @@
<version>3.4.1</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
Expand Down Expand Up @@ -266,6 +274,31 @@

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-email-model</id>
<phase>clean</phase>
<configuration>
<file>${project.basedir}/lib/javax.mail.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>locallib</groupId>
<artifactId>mail</artifactId>
<version>1.6.2</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/fishmaple/DAO/BlogTopicMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fishmaple.DAO;

import fishmaple.DTO.Anonymous;
import fishmaple.DTO.BlogTopic;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface BlogTopicMapper {
public List<BlogTopic> getTopicsByUserId(@Param("userId")String userId);
public List<BlogTopic> getAllTopics();
public String getTopicName(@Param("id")Integer topicId);
public List<BlogTopic> getTopicsByUserIdAndTopicId(@Param("userId")String userId,@Param("topicId")Integer topicId);
public Integer addTopic(BlogTopic blogTopic);
public Integer verifyTopic(BlogTopic blogTopic);
}
40 changes: 40 additions & 0 deletions src/main/java/fishmaple/DTO/BlogTopic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package fishmaple.DTO;

public class BlogTopic {
Integer id;
String topic;
String userId;
Integer fTopicId;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getTopic() {
return topic;
}

public void setTopic(String topic) {
this.topic = topic;
}

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

public Integer getfTopicId() {
return fTopicId;
}

public void setfTopicId(Integer fTopicId) {
this.fTopicId = fTopicId;
}
}
5 changes: 5 additions & 0 deletions src/main/java/fishmaple/MainController/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public String blogTopic(@RequestParam Integer topicId,HttpServletRequest request
return "topicBlog";
}

@RequestMapping("/sideWall")
public String sideWall(HttpServletRequest request, Model model, HttpServletResponse response) {
return "sideWall";
}

@RequestMapping("/blog")
public String blog(HttpServletRequest request, Model model, HttpServletResponse response) {
String content="";
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/fishmaple/api/TalkTo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package fishmaple.api;

import fishmaple.Objects.FileObject;
import fishmaple.utils.SendEmail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.security.GeneralSecurityException;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@RestController
@RequestMapping("/api")
public class TalkTo {

@PostMapping("sendTalk")
public String sendTalk(@RequestBody Map<String,String> map) throws GeneralSecurityException {
if(map.get("content").equals("")||map.get("email").equals("")||map.get("name").equals("")){
return "请完善必填项";
}
String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(map.get("email"));
boolean isMatched = matcher.matches();
if(!isMatched){
return "邮箱地址格式错误";
} else{
try {
SendEmail.send("新留言(#^.^#)-鱼鱼的博客", "收到新留言<br>" + map.get("content") + "<br>" +
map.get("email") + "<br>" + map.get("name") + "<br>" + map.get("website") + "<br>",
"[email protected]", SendEmail.REDIRECT);

String content = "你好 ,我已经收到你在我网站的留言噜,我会及时处理并给予反馈,敬请关注邮件。<br>  感谢您对本博客的关注<br>  祝:生活愉快<br><br>" +
" <a href=\"https://www.fishmaple.cn\"><img src=\"https://www.fishmaple.cn/pics/logo_m_m.png\" class=\"logo middle_pic\"> <img src=\"https://www.fishmaple.cn/pics/logo-fish-small.png\" class=\"logo middle_fish\"></a>"+
" <br><br><br><span style='float:right'>from </strong>鱼鱼的博客</strong></span>" +
" <br><br><span style='float:right;color:darkgrey'>Copyright © fishmaple. </span>";

SendEmail.send("留言已揽收(#^.^#)-鱼鱼的博客", content, map.get("email"), SendEmail.REDIRECT);
}catch(Exception e){
e.printStackTrace();
}finally{
return "博主已经收到留言 请等待反馈";
}
}
}
}
79 changes: 79 additions & 0 deletions src/main/java/fishmaple/utils/SendEmail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package fishmaple.utils;
import com.sun.mail.util.MailSSLSocketFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.mail.*;
import javax.mail.internet.*;
import java.security.GeneralSecurityException;
import java.util.Properties;

public class SendEmail {
static String HOST = "smtp.qq.com"; // smtp服务器
static String FROM = "[email protected]"; // 发件人地址
public static String REDIRECT = "[email protected]"; // 发件人地址
static String USER = "鱼鱼"; // 用户名
static String PWD = "-"; // 授权码
static Logger log = LoggerFactory.getLogger(SendEmail.class);


public static void send(String subject,String context,String tos,String ccs) {
Properties props = new Properties();

try {

MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.socketFactory",sf);//设置发送邮件的邮件服务器的属性(这里使用网易的smtp服务器)
}catch(Exception e){

// props.put("mail.smtp.ssl.socketFactory.class", "javax.net.ssl.SSLSocketFactory");//设置发送邮件的邮件服务器的属性(这里使用网易的smtp服务器)

} props.put("mail.smtp.ssl.enable", "true");//设置发送邮件的邮件服务器的属性(这里使用网易的smtp服务器)
// props.put("mail.smtp.socketFactory.port", "456");//设置发送邮件的邮件服务器的属性(这里使用网易的smtp服务器)
props.put("mail.smtp.host", HOST);//设置发送邮件的邮件服务器的属性(这里使用网易的smtp服务器)
props.put("mail.smtp.port", "465");//设置发送邮件的邮件服务器的属性(这里使用网易的smtp服务器)
props.put("mail.smtp.auth", "true"); //需要经过授权,也就是有户名和密码的校验,这样才能通过验证(一定要有这一条)
Session session = Session.getDefaultInstance(props);//用props对象构建一个session
session.setDebug(true);
try {
Transport transport = session.getTransport("smtp");//发送邮件
transport.connect(HOST,FROM, PWD);//连接服务器的邮箱
MimeMessage message = new MimeMessage(session);//用session为参数定义消息对象
message.setFrom(new InternetAddress(FROM));// 加载发件人地址
String TOS[]=tos.split(",");
InternetAddress[] sendTo = new InternetAddress[TOS.length]; // 加载收件人地址
for (int i = 0; i < TOS.length; i++) {
sendTo[i] = new InternetAddress(TOS[i]);
}
String CCS[]=ccs.split(",");
InternetAddress[] cc = new InternetAddress[CCS.length]; // 加载收件人地址
InternetAddress[] sendCC = new InternetAddress[CCS.length]; // 加载收件人地址
for (int i = 0; i < CCS.length; i++) {
sendCC[i] = new InternetAddress(CCS[i]);
}
message.addRecipients(Message.RecipientType.TO,sendTo);
message.addRecipients(MimeMessage.RecipientType.CC, sendCC);//抄送
message.setSubject(MimeUtility.encodeText(subject,"utf-8","B"));//加载标题
Multipart multipart = new MimeMultipart();//向multipart对象中添加邮件的各个部分内容,包括文本内容和附件
BodyPart contentPart = new MimeBodyPart();//设置邮件的文本内容
contentPart.setContent(context, "text/html;charset=utf-8");
//contentPart.setText(context);
multipart.addBodyPart(contentPart);
message.setContent(multipart);//将multipart对象放到message中
message.saveChanges(); //保存邮件


transport.sendMessage(message, message.getAllRecipients());//把邮件发送出去
transport.close();//关闭连接
////

} catch (Exception e) {
e.printStackTrace();
System.out.println(e.toString());
}
}



}
4 changes: 2 additions & 2 deletions src/main/resources/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Vue.component('foot-component', {
' <li><a href="/version.html">版本迭代</a></li>' +
' <li><a href="/friendLinks">友情链接</a></li>' +
' <li><a href="/restart.html">重启服务器</a></li>' +
' <li><a href="/log.html">日志查看</span></a></li>' +
' <li><span style="color:darkgray">与我互动</span></li>' +
' <li><a href="/log.html">日志查看</a></li>' +
' <li><a href="/sideWall">与我互动/友链申请</a></li>' +
' <li><a href="/druid">druid监控</a></li>' +
' <li><a href="/sitemap.html">网站地图</a></li>' +
' <li><a href="https://github.com/fishstormX"><img class="icons" src="/img/giticon.png" height="17px">github</a></li>' +
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
主题分类
</div>
<el-divider></el-divider>
<div class="taglist-block" th:each="topic:${blogTopics}">
<div class="taglist-block" style="margin-top: 20px" th:each="topic:${blogTopics}">
<a style="font-weight: 500;" class="nav_link" th:text="${topic.topic}" th:href="${topic.url}"></a>
</div>
</el-card>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/friendLinks.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<a target="_blank"v-bind:href="link.url" class="linkcard-describe">{{link.describe}}</a>
</el-card>
<div style="margin-top:20px">
<p style="color:grey">交换友链请发送邮件到[email protected],友链页UI设计中,目前只接受技术领域相关的网站,望见谅</p>
<p style="color:grey">交换友链请发送邮件到[email protected]或点击页面下方的"与我互动",友链页UI设计中,目前只接受技术领域相关的网站,望见谅</p>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit c852507

Please sign in to comment.