Browse Source

删除部分配置

master
lenghui 5 months ago
parent
commit
d654190e3f
  1. 2
      pom.xml
  2. 2
      src/main/java/com/lh/mapper/CrowdfundingMapper.java
  3. 11
      src/main/java/com/lh/service/CrowdfundingServiceImpl.java
  4. 3
      src/main/resources/com/lh/mapper/CrowdfundingMapper.xml

2
pom.xml

@ -43,7 +43,7 @@
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
<version>8.0.26</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
</dependencies> </dependencies>

2
src/main/java/com/lh/mapper/CrowdfundingMapper.java

@ -19,6 +19,8 @@ public interface CrowdfundingMapper {
//当前众筹数量+1 //当前众筹数量+1
void updateNowNumber(); void updateNowNumber();
//当前众筹数量-1
void updateMinusNowNumber();
//修改状态 //修改状态
void updateStatus(Integer status); void updateStatus(Integer status);

11
src/main/java/com/lh/service/CrowdfundingServiceImpl.java

@ -15,12 +15,15 @@ public class CrowdfundingServiceImpl implements CrowdfundingService {
@Autowired @Autowired
private CrowdfundingMapper crowdfundingMapper; private CrowdfundingMapper crowdfundingMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public CrowdfundingInfo loadPage() { public CrowdfundingInfo loadPage() {
CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage();
//如果当前进度大于等于目标人数将status变更为0
if (crowdfundingInfoList != null && crowdfundingInfoList.getNowNumber() >= crowdfundingInfoList.getTargetNumber()) {
CrowdfundingInfo crowdfundingInfoList1 = crowdfundingMapper.loadPage();
if (crowdfundingInfoList1 != null && crowdfundingInfoList1.getNowNumber() >= crowdfundingInfoList1.getTargetNumber()) {
crowdfundingMapper.updateStatus(1);
}else {
crowdfundingMapper.updateStatus(0); crowdfundingMapper.updateStatus(0);
} }
CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage();
List<Participant> participants = crowdfundingMapper.queryCrowdUser(null); List<Participant> participants = crowdfundingMapper.queryCrowdUser(null);
if (crowdfundingInfoList != null) { if (crowdfundingInfoList != null) {
crowdfundingInfoList.setParticipantList(participants); crowdfundingInfoList.setParticipantList(participants);
@ -79,6 +82,7 @@ public class CrowdfundingServiceImpl implements CrowdfundingService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void deleteCrowdUser(String jwcode) throws MyException { public void deleteCrowdUser(String jwcode) throws MyException {
if (CollectionUtils.isEmpty(crowdfundingMapper.queryCrowdUser(new Participant(null,jwcode,null,null)))) { if (CollectionUtils.isEmpty(crowdfundingMapper.queryCrowdUser(new Participant(null,jwcode,null,null)))) {
throw new MyException("删除失败,用户不存在"); throw new MyException("删除失败,用户不存在");
@ -86,6 +90,7 @@ public class CrowdfundingServiceImpl implements CrowdfundingService {
List<Participant> participants = crowdfundingMapper.queryCrowdUser(new Participant(null, jwcode, null, null)); List<Participant> participants = crowdfundingMapper.queryCrowdUser(new Participant(null, jwcode, null, null));
Participant participant = participants.get(0); Participant participant = participants.get(0);
crowdfundingMapper.saveDeleteCrowdUser(participant); crowdfundingMapper.saveDeleteCrowdUser(participant);
crowdfundingMapper.updateMinusNowNumber();
crowdfundingMapper.deleteCrowdUser(jwcode); crowdfundingMapper.deleteCrowdUser(jwcode);
} }

3
src/main/resources/com/lh/mapper/CrowdfundingMapper.xml

@ -19,6 +19,9 @@
<update id="updateStatus"> <update id="updateStatus">
update crowdfundinginfo set status=#{status} update crowdfundinginfo set status=#{status}
</update> </update>
<update id="updateMinusNowNumber">
update crowdfundinginfo set now_number=now_number-1
</update>
<delete id="deleteCrowdUser"> <delete id="deleteCrowdUser">
delete from participants where jwcode=#{jwcode} delete from participants where jwcode=#{jwcode}
</delete> </delete>

Loading…
Cancel
Save