diff --git a/pom.xml b/pom.xml
index 2905927..17aa7d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,7 +95,23 @@
test
+
+
+ com.google.zxing
+ core
+ 3.3.0
+
+
+ com.google.zxing
+ javase
+ 3.3.0
+
+
+ org.apache.ws.commons.axiom
+ base64-utils
+ 1.4.0
+
diff --git a/src/main/java/com/lovenav/controller/CommentController.java b/src/main/java/com/lovenav/controller/CommentController.java
index b37c606..5675743 100644
--- a/src/main/java/com/lovenav/controller/CommentController.java
+++ b/src/main/java/com/lovenav/controller/CommentController.java
@@ -46,4 +46,10 @@ public class CommentController {
public String View_comment(){
return commentService.View_comment();
}
+
+// 显示回复
+@RequestMapping(method = RequestMethod.GET, value = "/view_reply")
+ public String View_reply(int id){
+ return commentService.View_Reply(id);
+ }
}
diff --git a/src/main/java/com/lovenav/controller/QRCodeController.java b/src/main/java/com/lovenav/controller/QRCodeController.java
new file mode 100644
index 0000000..5c4e0a7
--- /dev/null
+++ b/src/main/java/com/lovenav/controller/QRCodeController.java
@@ -0,0 +1,27 @@
+package com.lovenav.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.lovenav.utils.QRCodeUtil;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+
+public class QRCodeController {
+ private QRCodeUtil qrCodeUtil;
+@RequestMapping(method = RequestMethod.GET, value = "/qrc")
+ public String QRCode(String url){
+ String text = url;
+ String logoPath ="src/main/resources/static/logo/NAV.png";
+ String destPath = "src/main/resources/static/qr";
+ try {
+ String url2 = qrCodeUtil.encode(text, logoPath, destPath, true);
+ String base64 = qrCodeUtil.getBase64(url2);
+ return JSON.toJSONString(base64);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/lovenav/dao/CollectIconListDao.java b/src/main/java/com/lovenav/dao/CollectIconListDao.java
new file mode 100644
index 0000000..c9bc5ff
--- /dev/null
+++ b/src/main/java/com/lovenav/dao/CollectIconListDao.java
@@ -0,0 +1,19 @@
+package com.lovenav.dao;
+
+import com.lovenav.entity.CollectIconList;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CollectIconListDao {
+ int deleteByPrimaryKey(Long id);
+
+ int insert(CollectIconList record);
+
+ int insertSelective(CollectIconList record);
+
+ CollectIconList selectByPrimaryKey(Long id);
+
+ int updateByPrimaryKeySelective(CollectIconList record);
+
+ int updateByPrimaryKey(CollectIconList record);
+}
\ No newline at end of file
diff --git a/src/main/java/com/lovenav/dao/CommentDao.java b/src/main/java/com/lovenav/dao/CommentDao.java
index f0fba2e..0c3cfe6 100644
--- a/src/main/java/com/lovenav/dao/CommentDao.java
+++ b/src/main/java/com/lovenav/dao/CommentDao.java
@@ -23,4 +23,6 @@ public interface CommentDao {
int updateByPrimaryKey(Comment record);
List selectByAllComment();
+
+ List selectByAllReply(int id);
}
\ No newline at end of file
diff --git a/src/main/java/com/lovenav/entity/CollectIconList.java b/src/main/java/com/lovenav/entity/CollectIconList.java
new file mode 100644
index 0000000..3d999a7
--- /dev/null
+++ b/src/main/java/com/lovenav/entity/CollectIconList.java
@@ -0,0 +1,34 @@
+package com.lovenav.entity;
+
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * 图标表
+ * ln_collect_icon_list
+ */
+@Data
+public class CollectIconList implements Serializable {
+ private Long id;
+
+ /**
+ * 网址id
+ */
+ private String urlid;
+
+ /**
+ * 图片地址
+ */
+ private String iconUrl;
+
+ /**
+ * 二维码地址
+ */
+ private String qrUrl;
+ /**
+ * 状态
+ */
+ private int status;
+
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/src/main/java/com/lovenav/service/CommentService.java b/src/main/java/com/lovenav/service/CommentService.java
index e29e2c3..5d5d04b 100644
--- a/src/main/java/com/lovenav/service/CommentService.java
+++ b/src/main/java/com/lovenav/service/CommentService.java
@@ -15,4 +15,6 @@ public interface CommentService {
String Delete(int id);
// 显示评论
String View_comment();
+// 显示回复
+ String View_Reply(int id);
}
diff --git a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java
index bd16ca4..9b07f99 100644
--- a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java
+++ b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java
@@ -72,4 +72,10 @@ public class CommentServiceImpl implements CommentService {
List list = commentDao.selectByAllComment();
return JSON.toJSONString(list);
}
+
+// 显示回复
+ public String View_Reply(int id){
+ List list = commentDao.selectByAllReply(id);
+ return JSON.toJSONString(list);
+ }
}
diff --git a/src/main/java/com/lovenav/utils/QRCodeUtil.java b/src/main/java/com/lovenav/utils/QRCodeUtil.java
new file mode 100644
index 0000000..05e9330
--- /dev/null
+++ b/src/main/java/com/lovenav/utils/QRCodeUtil.java
@@ -0,0 +1,374 @@
+package com.lovenav.utils;
+
+import com.google.zxing.*;
+import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.HybridBinarizer;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import org.apache.tomcat.util.codec.binary.Base64;
+
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Random;
+
+
+public class QRCodeUtil {
+ private static final String CHARSET = "utf-8";
+ private static final String FORMAT_NAME = "JPG";
+ // 二维码尺寸
+ private static final int QRCODE_SIZE = 300;
+ // LOGO宽度
+ private static final int WIDTH = 60;
+ // LOGO高度
+ private static final int HEIGHT = 60;
+
+ private static BufferedImage createImage(String content, String imgPath,
+ boolean needCompress) throws Exception {
+ Hashtable hints = new Hashtable();
+ hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+ hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
+ hints.put(EncodeHintType.MARGIN, 1);
+ BitMatrix bitMatrix = new MultiFormatWriter().encode(content,
+ BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);
+ int width = bitMatrix.getWidth();
+ int height = bitMatrix.getHeight();
+ BufferedImage image = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_RGB);
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000
+ : 0xFFFFFFFF);
+ }
+ }
+ if (imgPath == null || "".equals(imgPath)) {
+ return image;
+ }
+ // 插入图片
+ QRCodeUtil.insertImage(image, imgPath, needCompress);
+ return image;
+ }
+
+ /**
+ * 插入LOGO
+ *
+ * @param source
+ * 二维码图片
+ * @param imgPath
+ * LOGO图片地址
+ * @param needCompress
+ * 是否压缩
+ * @throws Exception
+ */
+ private static void insertImage(BufferedImage source, String imgPath,
+ boolean needCompress) throws Exception {
+ File file = new File(imgPath);
+ if (!file.exists()) {
+ System.err.println(""+imgPath+" 该文件不存在!");
+ return;
+ }
+ Image src = ImageIO.read(new File(imgPath));
+ int width = src.getWidth(null);
+ int height = src.getHeight(null);
+ if (needCompress) { // 压缩LOGO
+ if (width > WIDTH) {
+ width = WIDTH;
+ }
+ if (height > HEIGHT) {
+ height = HEIGHT;
+ }
+ Image image = src.getScaledInstance(width, height,
+ Image.SCALE_SMOOTH);
+ BufferedImage tag = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics g = tag.getGraphics();
+ g.drawImage(image, 0, 0, null); // 绘制缩小后的图
+ g.dispose();
+ src = image;
+ }
+ // 插入LOGO
+ Graphics2D graph = source.createGraphics();
+ int x = (QRCODE_SIZE - width) / 2;
+ int y = (QRCODE_SIZE - height) / 2;
+ graph.drawImage(src, x, y, width, height, null);
+ Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
+ graph.setStroke(new BasicStroke(3f));
+ graph.draw(shape);
+ graph.dispose();
+ }
+
+ /**
+ * 生成二维码(内嵌LOGO)
+ *
+ * @param content
+ * 内容
+ * @param imgPath
+ * LOGO地址
+ * @param destPath
+ * 存放目录
+ * @param needCompress
+ * 是否压缩LOGO
+ * @throws Exception
+ */
+ public static String encode(String content, String imgPath, String destPath,
+ boolean needCompress) throws Exception {
+ BufferedImage image = QRCodeUtil.createImage(content, imgPath,
+ needCompress);
+ mkdirs(destPath);
+ String file = new Random().nextInt(99999999)+".jpg";
+ ImageIO.write(image, FORMAT_NAME, new File(destPath+"/"+file));
+ return destPath+"/"+file;
+ }
+
+ /**
+ * 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
+ * @param destPath 存放目录
+ */
+ public static void mkdirs(String destPath) {
+ File file =new File(destPath);
+ //当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
+ if (!file.exists() && !file.isDirectory()) {
+ file.mkdirs();
+ }
+ }
+
+ /**
+ * 生成二维码(内嵌LOGO)
+ *
+ * @param content
+ * 内容
+ * @param imgPath
+ * LOGO地址
+ * @param destPath
+ * 存储地址
+ * @throws Exception
+ */
+ public static void encode(String content, String imgPath, String destPath)
+ throws Exception {
+ QRCodeUtil.encode(content, imgPath, destPath, false);
+ }
+
+ /**
+ * 生成二维码
+ *
+ * @param content
+ * 内容
+ * @param destPath
+ * 存储地址
+ * @param needCompress
+ * 是否压缩LOGO
+ * @throws Exception
+ */
+ public static void encode(String content, String destPath,
+ boolean needCompress) throws Exception {
+ QRCodeUtil.encode(content, null, destPath, needCompress);
+ }
+
+ /**
+ * 生成二维码
+ *
+ * @param content
+ * 内容
+ * @param destPath
+ * 存储地址
+ * @throws Exception
+ */
+ public static void encode(String content, String destPath) throws Exception {
+ QRCodeUtil.encode(content, null, destPath, false);
+ }
+
+ /**
+ * 生成二维码(内嵌LOGO)
+ *
+ * @param content
+ * 内容
+ * @param imgPath
+ * LOGO地址
+ * @param output
+ * 输出流
+ * @param needCompress
+ * 是否压缩LOGO
+ * @throws Exception
+ */
+ public static void encode(String content, String imgPath,
+ OutputStream output, boolean needCompress) throws Exception {
+ BufferedImage image = QRCodeUtil.createImage(content, imgPath,
+ needCompress);
+ ImageIO.write(image, FORMAT_NAME, output);
+ }
+
+ /**
+ * 生成二维码
+ *
+ * @param content
+ * 内容
+ * @param output
+ * 输出流
+ * @throws Exception
+ */
+ public static void encode(String content, OutputStream output)
+ throws Exception {
+ QRCodeUtil.encode(content, null, output, false);
+ }
+
+ /**
+ * 解析二维码
+ *
+ * @param file
+ * 二维码图片
+ * @return
+ * @throws Exception
+ */
+ public static String decode(File file) throws Exception {
+ BufferedImage image;
+ image = ImageIO.read(file);
+ if (image == null) {
+ return null;
+ }
+ BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(
+ image);
+ BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
+ Result result;
+ Hashtable hints = new Hashtable();
+ hints.put(DecodeHintType.CHARACTER_SET, CHARSET);
+ result = new MultiFormatReader().decode(bitmap, hints);
+ String resultStr = result.getText();
+ return resultStr;
+ }
+
+ /**
+ * 解析二维码
+ *
+ * @param path
+ * 二维码图片地址
+ * @return
+ * @throws Exception
+ */
+ public static String decode(String path) throws Exception {
+ return QRCodeUtil.decode(new File(path));
+ }
+
+ /**
+ *
+ * @param content
+ * @param imgPath
+ * @param destPath
+ * @param localUrl 当前环境的域名或者ip地址
+ * @param needCompress
+ * @return
+ * @throws Exception
+ */
+ public static String encode(String content, String imgPath, String destPath,String localUrl,
+ boolean needCompress) throws Exception {
+ BufferedImage image = QRCodeUtil.createImage(content, imgPath,
+ needCompress);
+ mkdirs(destPath);
+ String file = new Random().nextInt(99999999)+".jpg";
+ ImageIO.write(image, FORMAT_NAME, new File(destPath+"/"+file));
+ return localUrl+file;
+ }
+
+ public static String encodeDZ(String content, String imgPath, String destPath,String localUrl,int length,int width,
+ boolean needCompress) throws Exception {
+ BufferedImage image = QRCodeUtil.createImageDZ(content, imgPath,length,width,
+ needCompress);
+ mkdirs(destPath);
+ String file = new Random().nextInt(99999999)+".jpg";
+ ImageIO.write(image, FORMAT_NAME, new File(destPath+"/"+file));
+ return localUrl+file;
+ }
+
+ private static BufferedImage createImageDZ(String content, String imgPath,int newlength,int newWidth,
+ boolean needCompress) throws Exception {
+ Hashtable hints = new Hashtable();
+ hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+ hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
+ hints.put(EncodeHintType.MARGIN, 1);
+ BitMatrix bitMatrix = new MultiFormatWriter().encode(content,
+ BarcodeFormat.QR_CODE, newlength, newWidth, hints);
+ int width = bitMatrix.getWidth();
+ int height = bitMatrix.getHeight();
+ BufferedImage image = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_RGB);
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000
+ : 0xFFFFFFFF);
+ }
+ }
+ if (imgPath == null || "".equals(imgPath)) {
+ return image;
+ }
+ // 插入图片
+ QRCodeUtil.insertImage(image, imgPath, needCompress);
+ return image;
+ }
+
+ public static void main(String[] args) throws Exception {
+ String text = "https://www.baidu.com"; //这里设置自定义网站url
+ String logoPath ="src/main/resources/static/logo/NAV.png";
+ String destPath = "src/main/resources/static/qr";
+ String url=QRCodeUtil.encode(text, logoPath, destPath, true);
+ System.out.println(url);
+
+ /* String file="D:\\11.jpg";
+ String info=QRCodeUtil.decode(file);
+ System.out.println(info);*/
+ }
+
+ /**
+ * 将图片url转换成base64流
+ * @param url
+ * @return
+ */
+ public String getBase64(String url){
+ MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
+ Map hints = new HashMap();
+ hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); //设置字符集编码类型
+ hints.put(EncodeHintType.MARGIN, 1); //设置白边
+ BitMatrix bitMatrix = null;
+ try {
+ bitMatrix = multiFormatWriter.encode(url, BarcodeFormat.QR_CODE, 300, 300,hints);
+ BufferedImage image = toBufferedImage(bitMatrix);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ //输出二维码图片流
+ try {
+ ImageIO.write(image, "jpg",outputStream);
+ String base = new Base64().encodeAsString(outputStream.toByteArray());
+// new Base64().encode(outputStream.toByteArray());
+ return base;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } catch (WriterException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ return null;
+ }
+
+
+ public static BufferedImage toBufferedImage(BitMatrix matrix) {
+ int width = matrix.getWidth();
+ int height = matrix.getHeight();
+ BufferedImage image = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_RGB);
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ image.setRGB(x, y, matrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);//0xFF000000黑;0xFFFFFFFF白
+ }
+ }
+ return image;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/resources/mybatis/CollectIconListDao.xml b/src/main/resources/mybatis/CollectIconListDao.xml
new file mode 100644
index 0000000..310dd14
--- /dev/null
+++ b/src/main/resources/mybatis/CollectIconListDao.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+ id, url_id, icon_url,qrUrl,status
+
+
+
+ delete from ln_collect_icon_list
+ where id = #{id,jdbcType=BIGINT}
+
+
+ insert into ln_collect_icon_list (url_md5, icon_url)
+ values (#{urlMd5,jdbcType=VARCHAR}, #{iconUrl,jdbcType=VARCHAR})
+
+
+ insert into ln_collect_icon_list
+
+
+ url_md5,
+
+
+ icon_url,
+
+
+
+
+ #{urlMd5,jdbcType=VARCHAR},
+
+
+ #{iconUrl,jdbcType=VARCHAR},
+
+
+
+
+ update ln_collect_icon_list
+
+
+ url_md5 = #{urlMd5,jdbcType=VARCHAR},
+
+
+ icon_url = #{iconUrl,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=BIGINT}
+
+
+ update ln_collect_icon_list
+ set url_md5 = #{urlMd5,jdbcType=VARCHAR},
+ icon_url = #{iconUrl,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=BIGINT}
+
+
\ No newline at end of file
diff --git a/src/main/resources/mybatis/CommentDao.xml b/src/main/resources/mybatis/CommentDao.xml
index 9c7cd13..e1a4fbf 100644
--- a/src/main/resources/mybatis/CommentDao.xml
+++ b/src/main/resources/mybatis/CommentDao.xml
@@ -153,5 +153,10 @@
where root_comment_id = 0 and comment_status = 0
-
+
\ No newline at end of file
diff --git a/src/main/resources/static/logo/NAV.png b/src/main/resources/static/logo/NAV.png
new file mode 100644
index 0000000..d938511
Binary files /dev/null and b/src/main/resources/static/logo/NAV.png differ