From bf89af49b270d6df8e32069e7c370485c80808b2 Mon Sep 17 00:00:00 2001 From: lenghui Date: Fri, 20 Dec 2024 22:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../java/com/lh/service/CrowdfundingServiceImpl.java | 6 ++++-- .../com/lh/CrowdfundingSystemApplicationTests.java | 18 ------------------ 3 files changed, 5 insertions(+), 21 deletions(-) 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()); - } - - }