xiangjincheng_branch
向金成 2 years ago
parent 045afd2f75
commit 0866c7f967

@ -1,23 +0,0 @@
J
java:S3740"/Provide the parametrized type for this generic.(£ü‰üÿÿÿÿÿ
t java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(<28>Ž×Úýÿÿÿÿ
S
java:S2589<18>"7Remove this expression which always evaluates to "true"( äôóüÿÿÿÿ
S java:S106N"9Replace this use of System.out or System.err by a logger.(»œ¯µÿÿÿÿÿ
S java:S106O"9Replace this use of System.out or System.err by a logger.(˼ü™ûÿÿÿÿ
N java:S106]"9Replace this use of System.out or System.err by a logger.(ÁÞˆ<C39E>
N java:S106k"9Replace this use of System.out or System.err by a logger.(ÁÉã™
T java:S106<18>"9Replace this use of System.out or System.err by a logger.(‹žˆ¢úÿÿÿÿ
N java:S106"9Replace this use of System.out or System.err by a logger.(ÇÆ´7
T java:S106ž"9Replace this use of System.out or System.err by a logger.(㘘¨þÿÿÿÿ
O java:S106ª"9Replace this use of System.out or System.err by a logger.(¼‘œ
N java:S106»"9Replace this use of System.out or System.err by a logger.(Ü<>Å
T java:S106¼"9Replace this use of System.out or System.err by a logger.(£äЯùÿÿÿÿ
O java:S106É"9Replace this use of System.out or System.err by a logger.(žðíÔ
O java:S106Õ"9Replace this use of System.out or System.err by a logger.(³¦É‚
g
java:S1128 "LRemove this unused import 'org.springframework.cache.annotation.CacheEvict'.(½Á¨ˆøÿÿÿÿ
e
java:S1128
"JRemove this unused import 'org.springframework.cache.annotation.CachePut'.(ý≠þÿÿÿÿ

@ -1,6 +0,0 @@
{ java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(±ÖÀ—úÿÿÿÿ­¶Ï¥1
^
java:S1128"ARemove this unused import 'org.apache.ibatis.annotations.Select'.(ž²ß˜8¨Ú Ð¥1
g
java:S1128"ERemove this unused import 'org.springframework.stereotype.Component'.(Þ÷Ѹÿÿÿÿÿ8ÔÑ·Ð¥1

@ -1,8 +1,6 @@
z
Jspringboot/src/main/java/com/xht/springboot/pythonspider/PythonSpider.java,8\2\82d065e13dbb46b69838db763af0105eec47337f
{
Kspringboot/src/main/java/com/xht/springboot/Dao/LoginAndRegisterMapper.java,6\4\6455addaf8475c1ee66ddf019aba9934cde58b33
m
=train_cancer/test_information/train_model_and_load_picture.py,b\c\bc14878c6e46b0ed0df34c90b21fc25660f0e1f1
W
@ -33,13 +31,23 @@ q
Aspringboot/src/main/java/com/xht/springboot/Entity/UserReply.java,0\5\051eaf551b928a8ccf651611c070ebb2b8155264
l
<test_model/src/main/java/org/example/python/output_result.py,c\f\cf2b6f7a1e504e3a80407b7fb223ab50a8c9f4bf
z
Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6
|
Lspringboot/src/main/java/com/xht/springboot/Service/CancerDetectService.java,5\a\5aa79857db1807fe40f0941af9e17d8a19d8bc97
w
Gspringboot/src/main/java/com/xht/springboot/Dao/PersonalHomeMapper.java,8\e\8ea61bcc473345da7a8363076b3ae562bc76fedc
w
Gspringboot/src/main/java/com/xht/springboot/Service/WebHomeService.java,5\f\5feb9f75e1bc678660918562fd0ce2745899be29
p
@springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
@springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
B
springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907
w
Gspringboot/src/main/java/com/xht/springboot/Config/RedissionConfig.java,e\7\e7fb8e0140bfaca4a8371f31a806802c8dad2ee2

Ospringboot/src/main/java/com/xht/springboot/Control/PersonalHomeController.java,b\e\be5bf7d32cedc052850e2cc0c99f2cf7357cac12
w
Gspringboot/src/main/java/com/xht/springboot/Utils/BloomFilterUtils.java,6\6\661af37e1535a382309f94140434b4de4d42f13f
s
Cspringboot/src/main/java/com/xht/springboot/Config/RedisConfig.java,0\3\03febb48c6f14848416295ea77d17704b452f798
z
Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6
m
=springboot/src/main/java/com/xht/springboot/Utils/MyLock.java,d\6\d6d02a5bfa15e38571f6a2c3200cbaaebce3a1ae

@ -1,8 +1,6 @@
z
Jspringboot/src/main/java/com/xht/springboot/pythonspider/PythonSpider.java,8\2\82d065e13dbb46b69838db763af0105eec47337f
{
Kspringboot/src/main/java/com/xht/springboot/Dao/LoginAndRegisterMapper.java,6\4\6455addaf8475c1ee66ddf019aba9934cde58b33
m
=train_cancer/test_information/train_model_and_load_picture.py,b\c\bc14878c6e46b0ed0df34c90b21fc25660f0e1f1
W
@ -33,13 +31,23 @@ q
Aspringboot/src/main/java/com/xht/springboot/Entity/UserReply.java,0\5\051eaf551b928a8ccf651611c070ebb2b8155264
l
<test_model/src/main/java/org/example/python/output_result.py,c\f\cf2b6f7a1e504e3a80407b7fb223ab50a8c9f4bf
z
Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6
|
Lspringboot/src/main/java/com/xht/springboot/Service/CancerDetectService.java,5\a\5aa79857db1807fe40f0941af9e17d8a19d8bc97
w
Gspringboot/src/main/java/com/xht/springboot/Dao/PersonalHomeMapper.java,8\e\8ea61bcc473345da7a8363076b3ae562bc76fedc
w
Gspringboot/src/main/java/com/xht/springboot/Service/WebHomeService.java,5\f\5feb9f75e1bc678660918562fd0ce2745899be29
p
@springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
@springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
B
springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907
w
Gspringboot/src/main/java/com/xht/springboot/Config/RedissionConfig.java,e\7\e7fb8e0140bfaca4a8371f31a806802c8dad2ee2

Ospringboot/src/main/java/com/xht/springboot/Control/PersonalHomeController.java,b\e\be5bf7d32cedc052850e2cc0c99f2cf7357cac12
w
Gspringboot/src/main/java/com/xht/springboot/Utils/BloomFilterUtils.java,6\6\661af37e1535a382309f94140434b4de4d42f13f
s
Cspringboot/src/main/java/com/xht/springboot/Config/RedisConfig.java,0\3\03febb48c6f14848416295ea77d17704b452f798
z
Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6
m
=springboot/src/main/java/com/xht/springboot/Utils/MyLock.java,d\6\d6d02a5bfa15e38571f6a2c3200cbaaebce3a1ae

@ -5,15 +5,22 @@ import com.xht.springboot.Dao.WebHomeMapper;
import com.xht.springboot.Entity.UserComment;
import com.xht.springboot.Entity.UserReply;
import com.xht.springboot.Entity.UserText;
import com.xht.springboot.Utils.BloomFilterUtils;
import com.xht.springboot.Utils.FunctionsForDB;
import com.xht.springboot.Utils.RedisAndDbOpsUtils;
import org.checkerframework.checker.units.qual.A;
import org.redisson.RedissonMultiLock;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service
public class WebHomeService {
@ -21,49 +28,82 @@ public class WebHomeService {
WebHomeMapper webHomeMapper;
@Autowired
RedisTemplate redisTemplate;
@Autowired
BloomFilterUtils bloomFilterUtils;
@Autowired
RedissonClient redissonClient;
@Autowired
RedisAndDbOpsUtils redisAndDbOpsUtils;
String webHomeDataCacheName = "userTxt&Cmt::";
String webHomeDataKey = "all";
String userRepliesCacheName = "userRepliesOfCmt::";
String userRepliesOfCmtCacheName = "userRepliesOfCmt::";
String userTxtCacheName = "userTxt::";
String userCmtCacheName = "userCmt::";
String userReplyCacheName = "userReply::";
String userFindTxtCacheName = "userFindTxt::";
String webHomeDataLockName = "webHomeDataLock";
String userRepliesOfCmtLockName = "userRepliesOfCmtLock";
String userTxtLockName = "userTxtLock";
String userFindTxtLockName = "userFindTxtLock";
String userCmtLockName = "userCmtLock";
String userReplyLockName = "userReplyLock";
//获得所有文章除了评论的回复
public List<UserText> getWebHomeData(){
List<UserText> userTexts = (List<UserText>) redisTemplate.opsForValue().get(webHomeDataCacheName+webHomeDataKey);
if(userTexts!=null)
return userTexts;
else{
synchronized (WebHomeService.class){
userTexts = (List<UserText>) redisTemplate.opsForValue().get(webHomeDataCacheName+webHomeDataKey);
if(userTexts!=null)
return userTexts;
else {
userTexts = webHomeMapper.findAllTextAndComments();
if(userTexts!=null)
redisTemplate.opsForValue().set(webHomeDataCacheName+webHomeDataKey,userTexts);
return userTexts;
}
FunctionsForDB<List<UserText>> functionsForDB = new FunctionsForDB<List<UserText>>() {
@Override
public List<UserText> queryFunctionForDB(String token) {
List<UserText> userTexts = webHomeMapper.findAllTextAndComments();
return userTexts;
}
}
}
};
return redisAndDbOpsUtils.queryNoFilter(webHomeDataCacheName,webHomeDataKey,webHomeDataLockName,functionsForDB,"");
}
public List<UserReply> getUserReplies(int commentid){
List<UserReply> userReplies = (List<UserReply>) redisTemplate.opsForValue().get(userRepliesCacheName+commentid);
FunctionsForDB<List<UserReply>> functionsForDB = new FunctionsForDB<List<UserReply>>() {
@Override
public List<UserReply> queryFunctionForDB(String token) {
List<UserReply> userReplies = webHomeMapper.findRepliesByCommentId(Integer.parseInt(token));
return userReplies;
}
};
if(!bloomFilterUtils.queryKey(userRepliesOfCmtCacheName+commentid))
return null;
List<UserReply> userReplies = (List<UserReply>) redisTemplate.opsForValue().get(userRepliesOfCmtCacheName+commentid);
if(userReplies!=null)
return userReplies;
else{
synchronized (WebHomeService.class){
userReplies = (List<UserReply>) redisTemplate.opsForValue().get(userRepliesCacheName+commentid);
userReplies = (List<UserReply>) redisTemplate.opsForValue().get(userRepliesOfCmtCacheName+commentid);
if(userReplies!=null)
return userReplies;
else {
userReplies = webHomeMapper.findRepliesByCommentId(commentid);
if(userReplies!=null)
redisTemplate.opsForValue().set(userRepliesCacheName+commentid,userReplies);
RLock lock = redissonClient.getLock(userRepliesOfCmtLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
if(userReplies!=null)
redisTemplate.opsForValue().set(userRepliesOfCmtCacheName+commentid,userReplies);
else
redisTemplate.opsForValue().set(userRepliesOfCmtCacheName+commentid,null,30,TimeUnit.SECONDS);
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return userReplies;
}
}
@ -78,7 +118,7 @@ public class WebHomeService {
System.out.println("insert text OK "+rows);
System.out.println("textid "+userText.getTextid());
redisTemplate.opsForValue().set(userTxtCacheName+userText.getTextid(),userText);//写入缓存
bloomFilterUtils.putIntoBloomFilter(userTxtCacheName+userText.getTextid());
return true;
}else{
return false;
@ -92,7 +132,18 @@ public class WebHomeService {
if(rows >= 1){
System.out.println("delete text OK "+rows);
redisTemplate.opsForValue().getAndDelete(userTxtCacheName+userText.getTextid());//删除缓存中数据
RLock lock = redissonClient.getLock(userTxtLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
redisTemplate.delete(userTxtCacheName+userText.getTextid());//删除缓存中数据
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return true;
}else{
return false;
@ -105,7 +156,19 @@ public class WebHomeService {
rows = webHomeMapper.updateUserText(userText);
if(rows >= 1){
System.out.println("update text OK "+rows);
redisTemplate.opsForValue().getAndDelete(userTxtCacheName+userText.getTextid());//删除缓存中数据
RLock lock = redissonClient.getLock(userTxtLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
redisTemplate.delete(userTxtCacheName+userText.getTextid());//删除缓存中数据
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return true;
}else{
@ -115,6 +178,9 @@ public class WebHomeService {
@Transactional
public List<UserText> findUserText(String token){
if(!bloomFilterUtils.queryKey(userFindTxtCacheName+token))
return null;
List<UserText> userTexts = (List<UserText>) redisTemplate.opsForValue().get(userFindTxtCacheName+token);
if(userTexts!=null)
return userTexts;
@ -126,8 +192,24 @@ public class WebHomeService {
else{
userTexts = webHomeMapper.findOfTextContains(token);//查询文本中是否包含
userTexts.addAll(webHomeMapper.findOfTitleContains(token));//查询标题中是否包含
if(userTexts!=null)
redisTemplate.opsForValue().set(userFindTxtCacheName+token,userTexts);
RLock lock = redissonClient.getLock(userFindTxtLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
if(userTexts!=null)
redisTemplate.opsForValue().set(userFindTxtCacheName+token,userTexts);
else
redisTemplate.opsForValue().set(userFindTxtCacheName+token,null,30,TimeUnit.SECONDS);
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return userTexts;
}
}
@ -144,7 +226,7 @@ public class WebHomeService {
System.out.println("insert comment OK "+rows);
System.out.println("commentid "+userComment.getCommentid());
redisTemplate.opsForValue().set(userCmtCacheName+userComment.getCommentid(),userComment);
bloomFilterUtils.putIntoBloomFilter(userCmtCacheName+userComment.getCommentid());
return true;
}else{
return false;
@ -156,7 +238,19 @@ public class WebHomeService {
rows = webHomeMapper.deleteUserComment(userComment);
if(rows >= 1){
System.out.println("delete comment OK "+rows);
redisTemplate.opsForValue().getAndDelete(userCmtCacheName+userComment.getCommentid());
RLock lock = redissonClient.getLock(userCmtLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
redisTemplate.delete(userCmtCacheName+userComment.getCommentid());
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return true;
}else{
return false;
@ -168,7 +262,19 @@ public class WebHomeService {
rows = webHomeMapper.updateUserComment(userComment);
if(rows >= 1){
System.out.println("update comment OK "+rows);
redisTemplate.opsForValue().getAndDelete(userCmtCacheName+userComment.getCommentid());
RLock lock = redissonClient.getLock(userCmtLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
redisTemplate.delete(userCmtCacheName+userComment.getCommentid());
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return true;
}else{
return false;
@ -187,7 +293,8 @@ public class WebHomeService {
System.out.println("insert reply OK "+rows);
System.out.println("replyid "+userReply.getReplyid());
redisTemplate.opsForValue().set(userReplyCacheName+userReply.getReplyid(),userReply);
bloomFilterUtils.putIntoBloomFilter(userReplyCacheName+userReply.getReplyid());
return true;
}else{
return false;
@ -199,7 +306,19 @@ public class WebHomeService {
rows = webHomeMapper.deleteUserReply(userReply);
if(rows >= 1){
System.out.println("delete reply OK "+rows);
redisTemplate.opsForValue().getAndDelete(userReplyCacheName+userReply.getReplyid());
RLock lock = redissonClient.getLock(userReplyLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
redisTemplate.delete(userReplyCacheName+userReply.getReplyid());
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return true;
}else{
return false;
@ -211,7 +330,19 @@ public class WebHomeService {
rows = webHomeMapper.updateUserReply(userReply);
if(rows >= 1){
System.out.println("update reply OK "+rows);
redisTemplate.opsForValue().getAndDelete(userReplyCacheName+userReply.getReplyid());
RLock lock = redissonClient.getLock(userReplyLockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
redisTemplate.delete(userReplyCacheName+userReply.getReplyid());
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return true;
}else{
return false;

@ -0,0 +1,6 @@
package com.xht.springboot.Utils;
@FunctionalInterface
public interface FunctionsForDB <T>{
public T queryFunctionForDB(String token);
}

@ -0,0 +1,68 @@
package com.xht.springboot.Utils;
import com.xht.springboot.Entity.UserText;
import com.xht.springboot.Service.WebHomeService;
import org.redisson.RedissonMultiLock;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Component
public class RedisAndDbOpsUtils {
@Autowired
BloomFilterUtils bloomFilterUtils;
@Autowired
RedisTemplate redisTemplate;
@Autowired
RedissonClient redissonClient;
public <T> T queryNoFilter(String cacheName,String key,String lockName,FunctionsForDB queryFunctionsForDB,String token){
if(!bloomFilterUtils.queryKey(cacheName+key))
return null;
return baseQuery(cacheName,key,lockName,queryFunctionsForDB,token);
}
public <T> T queryHaveFilter(String cacheName,String key,String lockName,FunctionsForDB queryFunctionsForDB,String token){
return baseQuery(cacheName,key,lockName,queryFunctionsForDB,token);
}
public <T> T baseQuery(String cacheName,String key,String lockName,FunctionsForDB queryFunctionsForDB,String token){
T result = (T) redisTemplate.opsForValue().get(cacheName+key);
if(result!=null)
return result;
else{
synchronized (this){
result = (T) redisTemplate.opsForValue().get(cacheName+key);
if(result!=null)
return result;
else {
result = (T) queryFunctionsForDB.queryFunctionForDB(token);
RLock lock = redissonClient.getLock(lockName);
RedissonMultiLock redissonMultiLock = new RedissonMultiLock(lock);
redissonMultiLock.lock();
try {
if(result!=null)
redisTemplate.opsForValue().set(cacheName+key,result);
else
redisTemplate.opsForValue().set(cacheName+key,null,30, TimeUnit.SECONDS);
}catch (Exception e){
e.printStackTrace();
}finally {
redissonMultiLock.unlock();
}
return result;
}
}
}
}
}
Loading…
Cancel
Save