Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b5ba622f02
19
pom.xml
19
pom.xml
@ -106,13 +106,30 @@
|
|||||||
<artifactId>javase</artifactId>
|
<artifactId>javase</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.ws.commons.axiom</groupId>
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
<artifactId>base64-utils</artifactId>
|
<artifactId>base64-utils</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--检测URl依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
<version>4.4.14</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- jackson 2.x 相关依赖 -->
|
<!-- jackson 2.x 相关依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.lovenav.controller;
|
package com.lovenav.controller;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.lovenav.entity.Banners;
|
import com.lovenav.entity.Banners;
|
||||||
import com.lovenav.service.BannersService;
|
import com.lovenav.service.BannersService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
package com.lovenav.controller;
|
package com.lovenav.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.lovenav.entity.Comment;
|
import com.lovenav.entity.Comment;
|
||||||
import com.lovenav.service.CommentService;
|
import com.lovenav.service.CommentService;
|
||||||
import com.lovenav.service.serviceImpl.CommentServiceImpl;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/comment")
|
@RequestMapping("/comment")
|
||||||
|
@ -10,6 +10,7 @@ import com.lovenav.utils.TokenUtils;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -23,6 +24,9 @@ import java.io.IOException;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class UserController {
|
public class UserController {
|
||||||
@ -31,15 +35,30 @@ public class UserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
TokenUtils tokenUtils;
|
TokenUtils tokenUtils;
|
||||||
//发送邮箱验证码
|
//发送邮箱验证码
|
||||||
|
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
||||||
|
//这个是我用户Service实现类可以自行替换
|
||||||
|
|
||||||
|
//这个是邮件类,必须要导入哦
|
||||||
|
|
||||||
@GetMapping("/sendActiveCode")
|
@GetMapping("/sendActiveCode")
|
||||||
public String sendActiveCode(HttpSession session, User user){
|
public String sendActiveCode(HttpSession session, User user){
|
||||||
|
|
||||||
String activecode=userService.sendEmailActivecode(user);
|
String activecode=userService.sendEmailActivecode(user);
|
||||||
session.setAttribute(user.getUserEmail(),activecode);
|
session.setAttribute(user.getUserEmail(),activecode);
|
||||||
|
scheduledExecutorService.schedule(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
session.removeAttribute(user.getUserEmail());
|
||||||
|
System.out.println(session.getAttribute(user.getUserEmail()));
|
||||||
|
}
|
||||||
|
},60, TimeUnit.SECONDS);
|
||||||
return "发送验证码成功!";
|
return "发送验证码成功!";
|
||||||
}
|
}
|
||||||
@RequestMapping("/register")
|
@RequestMapping("/register")
|
||||||
public String userRegister(HttpSession session,User user){
|
public String userRegister(HttpSession session,User user){
|
||||||
|
if (session.getAttribute(user.getUserEmail())==null){
|
||||||
|
return "验证码过期";
|
||||||
|
}
|
||||||
// 比较验证码
|
// 比较验证码
|
||||||
if (!user.getActiveCode().equals((String) session.getAttribute(user.getUserEmail()))) {
|
if (!user.getActiveCode().equals((String) session.getAttribute(user.getUserEmail()))) {
|
||||||
return "验证码不正确";
|
return "验证码不正确";
|
||||||
|
@ -21,5 +21,5 @@ public interface BannersDao {
|
|||||||
|
|
||||||
int updateByPrimaryKey(Banners record);
|
int updateByPrimaryKey(Banners record);
|
||||||
|
|
||||||
List<Banners> selectByAllBanners();
|
List<Banners> selectAllBanners();
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ public interface CommentDao {
|
|||||||
|
|
||||||
int updateByPrimaryKey(Comment record);
|
int updateByPrimaryKey(Comment record);
|
||||||
|
|
||||||
List<Comment> selectByAllComment();
|
List<Comment> selectAllComment();
|
||||||
|
|
||||||
List<Comment> selectByAllReply(int id);
|
List<Comment> selectByAllReply(int id);
|
||||||
}
|
}
|
@ -5,8 +5,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
|
||||||
@Mapper
|
@Mapper
|
||||||
|
@Repository
|
||||||
public interface UserDao {
|
public interface UserDao {
|
||||||
int deleteByPrimaryKey(Integer id);
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ package com.lovenav.entity;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.lovenav.service.serviceImpl;
|
package com.lovenav.service.serviceImpl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.lovenav.dao.BannersDao;
|
import com.lovenav.dao.BannersDao;
|
||||||
import com.lovenav.entity.Banners;
|
import com.lovenav.entity.Banners;
|
||||||
import com.lovenav.service.BannersService;
|
import com.lovenav.service.BannersService;
|
||||||
@ -59,9 +59,8 @@ public class BannersServiceImpl implements BannersService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 展示banner
|
// 展示banner
|
||||||
@Override
|
|
||||||
public String View_banner(){
|
public String View_banner(){
|
||||||
List<Banners> list = bannersDao.selectByAllBanners();
|
List<Banners> list = bannersDao.selectAllBanners();
|
||||||
return JSON.toJSONString(list);
|
return JSON.toJSONString(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,8 @@ import com.lovenav.dao.CommentDao;
|
|||||||
import com.lovenav.dao.UserDao;
|
import com.lovenav.dao.UserDao;
|
||||||
import com.lovenav.entity.Comment;
|
import com.lovenav.entity.Comment;
|
||||||
import com.lovenav.service.CommentService;
|
import com.lovenav.service.CommentService;
|
||||||
import org.apache.ibatis.jdbc.Null;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -69,7 +66,7 @@ public class CommentServiceImpl implements CommentService {
|
|||||||
|
|
||||||
// 显示评论
|
// 显示评论
|
||||||
public String View_comment(){
|
public String View_comment(){
|
||||||
List<Comment> list = commentDao.selectByAllComment();
|
List<Comment> list = commentDao.selectAllComment();
|
||||||
return JSON.toJSONString(list);
|
return JSON.toJSONString(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
74
src/main/java/com/lovenav/utils/UrlCheckUtil.java
Normal file
74
src/main/java/com/lovenav/utils/UrlCheckUtil.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package com.lovenav.utils;
|
||||||
|
import org.apache.http.client.config.RequestConfig;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import sun.net.www.protocol.http.HttpURLConnection;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.*;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
public class UrlCheckUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断链接是否有效
|
||||||
|
* 输入链接
|
||||||
|
* 返回true或者false
|
||||||
|
*/
|
||||||
|
public static boolean isUrlValid(String strLink) {
|
||||||
|
URL url;
|
||||||
|
try {
|
||||||
|
url = new URL(strLink);
|
||||||
|
HttpURLConnection connt = (HttpURLConnection)url.openConnection();
|
||||||
|
connt.setRequestMethod("HEAD");
|
||||||
|
String strMessage = connt.getResponseMessage();
|
||||||
|
if (strMessage.compareTo("Not Found") == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
connt.disconnect();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String checkUrlConnection(String url) {
|
||||||
|
// 创建http POST请求
|
||||||
|
HttpGet httpGet = new HttpGet(url);
|
||||||
|
httpGet.setHeader("Content-Type", "application/json");
|
||||||
|
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(600)// 设置连接主机服务超时时间
|
||||||
|
.setConnectionRequestTimeout(1000)// 设置连接请求超时时间
|
||||||
|
.setSocketTimeout(1000)// 设置读取数据连接超时时间
|
||||||
|
.build();
|
||||||
|
// 为httpPost实例设置配置
|
||||||
|
httpGet.setConfig(requestConfig);
|
||||||
|
// 设置请求头
|
||||||
|
CloseableHttpClient httpclient = null;
|
||||||
|
CloseableHttpResponse response = null;
|
||||||
|
int statusCode = 404;
|
||||||
|
try {
|
||||||
|
httpclient = HttpClients.createDefault();// 创建Httpclient对象
|
||||||
|
response = httpclient.execute(httpGet);// 执行请求
|
||||||
|
statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
}catch (SocketException e) {
|
||||||
|
return "404";
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("报错");
|
||||||
|
return "404";
|
||||||
|
}
|
||||||
|
return String.valueOf(statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean CheckHttp(String address) throws URISyntaxException, MalformedURLException {
|
||||||
|
URL url = new URL(address);
|
||||||
|
URI uri = url.toURI();
|
||||||
|
System.out.println(uri.getScheme());
|
||||||
|
if(uri.getScheme().equals("https")){
|
||||||
|
return true;
|
||||||
|
}else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -97,10 +97,11 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectByAllBanners" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectAllBanners" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
*
|
*
|
||||||
from ln_banners
|
from ln_banners
|
||||||
|
where banner_status = 0;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -146,7 +146,7 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectByAllComment" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectAllComment" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
*
|
*
|
||||||
from ln_comment
|
from ln_comment
|
||||||
|
Loading…
Reference in New Issue
Block a user