|
@ -7,6 +7,7 @@ import com.lh.mapper.CrowdfundingMapper; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
@Service |
|
|
@Service |
|
@ -16,6 +17,10 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { |
|
|
@Override |
|
|
@Override |
|
|
public CrowdfundingInfo loadPage() { |
|
|
public CrowdfundingInfo loadPage() { |
|
|
CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage(); |
|
|
CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage(); |
|
|
|
|
|
//如果当前进度大于等于目标人数,将status变更为0 |
|
|
|
|
|
if (crowdfundingInfoList.getNowNumber() >= crowdfundingInfoList.getTargetNumber()) { |
|
|
|
|
|
crowdfundingMapper.updateStatus(0); |
|
|
|
|
|
} |
|
|
List<Participant> participants = crowdfundingMapper.queryCrowdUser(null); |
|
|
List<Participant> participants = crowdfundingMapper.queryCrowdUser(null); |
|
|
crowdfundingInfoList.setParticipantList(participants); |
|
|
crowdfundingInfoList.setParticipantList(participants); |
|
|
return crowdfundingInfoList; |
|
|
return crowdfundingInfoList; |
|
@ -26,6 +31,9 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { |
|
|
if (title.length() == 0) { |
|
|
if (title.length() == 0) { |
|
|
throw new MyException("标题不能为空"); |
|
|
throw new MyException("标题不能为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
if (title.length() > 25) { |
|
|
|
|
|
throw new MyException("标题不能超过25个字"); |
|
|
|
|
|
} |
|
|
crowdfundingMapper.updateTitle(title); |
|
|
crowdfundingMapper.updateTitle(title); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -48,6 +56,10 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void addCrowdUser(Participant participant) throws MyException { |
|
|
public void addCrowdUser(Participant participant) throws MyException { |
|
|
|
|
|
//当前人数等于目标人数不可继续添加 |
|
|
|
|
|
if (crowdfundingMapper.loadPage().getNowNumber() >= crowdfundingMapper.loadPage().getTargetNumber()) { |
|
|
|
|
|
throw new MyException("当前人数已达到目标人数,不可继续添加"); |
|
|
|
|
|
} |
|
|
//精网号重复 |
|
|
//精网号重复 |
|
|
if (!crowdfundingMapper.queryCrowdUser(participant).isEmpty()) { |
|
|
if (!crowdfundingMapper.queryCrowdUser(participant).isEmpty()) { |
|
|
throw new MyException("精网号重复"); |
|
|
throw new MyException("精网号重复"); |
|
@ -66,7 +78,7 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void deleteCrowdUser(String jwcode) throws MyException { |
|
|
public void deleteCrowdUser(String jwcode) throws MyException { |
|
|
if (crowdfundingMapper.queryCrowdUser(new Participant(null,jwcode,null,null)) == null) { |
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(crowdfundingMapper.queryCrowdUser(new Participant(null,jwcode,null,null)))) { |
|
|
throw new MyException("删除失败,用户不存在"); |
|
|
throw new MyException("删除失败,用户不存在"); |
|
|
} |
|
|
} |
|
|
List<Participant> participants = crowdfundingMapper.queryCrowdUser(new Participant(null, jwcode, null, null)); |
|
|
List<Participant> participants = crowdfundingMapper.queryCrowdUser(new Participant(null, jwcode, null, null)); |
|
|