release: 抽奖信息可以在报名中修改

release-2024-04-25
huangyw 2 months ago
parent cb673b9ca4
commit d26b611d55

@ -32,6 +32,7 @@ import exception.BizException;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.persistence.criteria.CriteriaBuilder;
@ -194,6 +195,7 @@ public class LotteryService {
*/
@Transactional(rollbackFor = Exception.class)
public void edit(Lottery lottery, String token) {
String id = lottery.getId();
if (lottery.getDrawTime().isBefore(lottery.getApplyEndTime())) {
throw new BizException(ErrorConstants.DRAW_TIME_CANNOT_BE_BEFORE_APPLY_END_TIME);
@ -208,12 +210,12 @@ public class LotteryService {
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
if (lottery.getStatus() != null && !Objects.equals(lottery.getStatus(), PointEnums.LOTTERY_STATUS_EDITING.getCode())) {
List<Integer> canEditStatusList = Arrays.asList(PointEnums.LOTTERY_STATUS_EDITING.getCode(), PointEnums.LOTTERY_STATUS_SIGN.getCode());
Lottery oldLottery = lotteryDao.getOne(id);
if (oldLottery.getStatus() != null && !canEditStatusList.contains(oldLottery.getStatus())) {
throw new BizException(ErrorConstants.CAN_NOT_EDIT);
}
String id = lottery.getId();
StringBuilder regionCode = new StringBuilder();
StringBuilder regionName = new StringBuilder();
@ -258,12 +260,6 @@ public class LotteryService {
}
}
Lottery oldLottery = lotteryDao.getOne(id);
if (!Objects.equals(PointEnums.LOTTERY_STATUS_EDITING.getCode(), oldLottery.getStatus())) {
// 不是编辑中,不允许修改
throw new BizException(ErrorConstants.CAN_NOT_EDIT);
}
lottery.setCreateTime(oldLottery.getCreateTime());
lottery.setCreateUser(oldLottery.getCreateUser());
lottery.setCreateUserName(oldLottery.getCreateUserName());
@ -273,7 +269,20 @@ public class LotteryService {
lottery.setCode(oldLottery.getCode());
lottery.setType(oldLottery.getType());
if (Objects.equals(oldLottery.getStatus(), PointEnums.LOTTERY_STATUS_SIGN.getCode())) {
// 报名中只允许修改 title,description,num,drawTime
Lottery result = new Lottery();
BeanUtils.copyProperties(oldLottery, result);
result.setTitle(lottery.getTitle());
result.setDescription(lottery.getDescription());
result.setDrawTime(lottery.getDrawTime());
lotteryDao.save(result);
} else {
lottery.setStatus(PointEnums.LOTTERY_STATUS_EDITING.getCode());
lotteryDao.save(lottery);
}
}

Loading…
Cancel
Save