diff --git a/pom.xml b/pom.xml index 3ddd0f6..a6f6284 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ mysql mysql-connector-java - 5.1.49 + 8.0.22 runtime diff --git a/src/main/java/com/lh/service/CrowdfundingServiceImpl.java b/src/main/java/com/lh/service/CrowdfundingServiceImpl.java index 433b657..1916d36 100644 --- a/src/main/java/com/lh/service/CrowdfundingServiceImpl.java +++ b/src/main/java/com/lh/service/CrowdfundingServiceImpl.java @@ -18,11 +18,13 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { public CrowdfundingInfo loadPage() { CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage(); //如果当前进度大于等于目标人数,将status变更为0 - if (crowdfundingInfoList.getNowNumber() >= crowdfundingInfoList.getTargetNumber()) { + if (crowdfundingInfoList != null && crowdfundingInfoList.getNowNumber() >= crowdfundingInfoList.getTargetNumber()) { crowdfundingMapper.updateStatus(0); } List participants = crowdfundingMapper.queryCrowdUser(null); - crowdfundingInfoList.setParticipantList(participants); + if (crowdfundingInfoList != null) { + crowdfundingInfoList.setParticipantList(participants); + } return crowdfundingInfoList; } diff --git a/src/test/java/com/lh/CrowdfundingSystemApplicationTests.java b/src/test/java/com/lh/CrowdfundingSystemApplicationTests.java index f7f89ac..b62e693 100644 --- a/src/test/java/com/lh/CrowdfundingSystemApplicationTests.java +++ b/src/test/java/com/lh/CrowdfundingSystemApplicationTests.java @@ -1,29 +1,11 @@ package com.lh; -import com.lh.bean.CrowdfundingInfo; -import com.lh.mapper.CrowdfundingMapper; -import com.lh.service.CrowdfundingService; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class CrowdfundingSystemApplicationTests { - @Autowired - private CrowdfundingMapper crowdfundingMapper; - - @Autowired - private CrowdfundingService crowdfundingService; - @Test void contextLoads() { - CrowdfundingInfo crowdfundingInfo = crowdfundingMapper.loadPage(); } - - @Test - void contextLoads1() { - System.out.println(crowdfundingService.loadPage()); - } - - }