Commit a4c0dc51 authored by 刘基明's avatar 刘基明

查重

parent 6d18b645
......@@ -19,9 +19,9 @@ public class CodeAutoGenerator {
String currentPath = System.getProperty("user.dir");
String codeBaseHome = "/community-service/src/main/java";
String author = "xudong";
String mysqlUserName = "tamp_admin";
String mysqlPassword = "@imeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community";
String mysqlUserName = "dev";
String mysqlPassword = "qimeng123";
String jdbcUrl = "jdbc:mysql://rm-uf6lqwk9969zao53uro.mysql.rds.aliyuncs.com:3306/tamp_community";
// String[] tables = new String[]{"theme"};
String[] tables = new String[]{"theme_check_duplicate"};
String basePackage = "com.tanpu.community";
......
......@@ -19,7 +19,7 @@ import java.time.LocalDateTime;
* </p>
*
* @author xudong
* @since 2021-09-08
* @since 2021-09-14
*/
@Builder
@Data
......@@ -44,7 +44,7 @@ public class ThemeCheckDuplicateEntity implements Serializable {
private String partitionText;
@ApiModelProperty(value = "分块hash")
private String partitionHash;
private Integer partitionHash;
@ApiModelProperty(value = "分块号")
private Integer partitionNum;
......@@ -94,11 +94,11 @@ public class ThemeCheckDuplicateEntity implements Serializable {
this.partitionText = partitionText;
}
public String getPartitionHash() {
public Integer getPartitionHash() {
return partitionHash;
}
public void setPartitionHash(String partitionHash) {
public void setPartitionHash(Integer partitionHash) {
this.partitionHash = partitionHash;
}
......
......@@ -2,7 +2,6 @@ package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.common.constant.BizStatus;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity;
import com.tanpu.community.dao.mapper.community.ThemeCheckDuplicateMapper;
import com.tanpu.community.util.TimeUtils;
......@@ -10,8 +9,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -43,7 +40,7 @@ public class ThemeTextCheckService {
themeCheckDuplicateMapper.deleteByThemeId(themeId);
}
private void insert(String themeId, String partition, String partitionHash, Integer num, Integer total, String userId,Integer themeType) {
private void insert(String themeId, String partition, Integer partitionHash, Integer num, Integer total, String userId,Integer themeType) {
ThemeCheckDuplicateEntity build = ThemeCheckDuplicateEntity.builder()
.themeId(themeId)
......@@ -64,7 +61,7 @@ public class ThemeTextCheckService {
}
content = content.replaceAll(regex, "。");
String[] split = content.split("。");
List<String> list = new ArrayList<>();
List<Integer> list = new ArrayList<>();
for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]);
list.add(getHash(trim));
......@@ -83,18 +80,19 @@ public class ThemeTextCheckService {
}
public static String getHash(String str) {
try {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(str.getBytes());
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
return new BigInteger(1, md.digest()).toString(16);
} catch (Exception e) {
throw new BizException("MD5加密出现错误");
}
public static Integer getHash(String str) {
return str.hashCode();
// try {
// // 生成一个MD5加密计算摘要
// MessageDigest md = MessageDigest.getInstance("MD5");
// // 计算md5函数
// md.update(str.getBytes());
// // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
// // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
// return new BigInteger(1, md.digest()).toString(16);
// } catch (Exception e) {
// throw new BizException("MD5加密出现错误");
// }
}
// 初始化
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment