diff --git a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/StringUtils.java b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/StringUtils.java index 965c9de..1310b8f 100644 --- a/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/StringUtils.java +++ b/fw-dalaran-common/src/main/java/cn/fw/dalaran/common/utils/StringUtils.java @@ -548,4 +548,4 @@ public final class StringUtils { System.out.println(repeat("?", 10, ",")); length("AAA中国()111222bb"); } -} \ No newline at end of file +} diff --git a/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/AccountDao.java b/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/AccountDao.java index d79b21a..93bffd0 100644 --- a/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/AccountDao.java +++ b/fw-dalaran-dao/src/main/java/cn/fw/dalaran/dao/AccountDao.java @@ -36,4 +36,12 @@ public interface AccountDao extends BaseMapper { * @return 对应账户 */ List getByUserAccountNo(String accountNo); + + /** + * 根据id获取账户(忽略逻辑删除) + * + * @param accountId 账户id + * @return 对应账户 + */ + Account getByIdIgnoreLogicDel(Long accountId); } diff --git a/fw-dalaran-dao/src/main/resources/mapper/AccountMapper.xml b/fw-dalaran-dao/src/main/resources/mapper/AccountMapper.xml index a149ad6..03eca32 100644 --- a/fw-dalaran-dao/src/main/resources/mapper/AccountMapper.xml +++ b/fw-dalaran-dao/src/main/resources/mapper/AccountMapper.xml @@ -60,11 +60,21 @@ + + diff --git a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LivePoolVO.java b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LivePoolVO.java index 0260feb..5bd5556 100644 --- a/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LivePoolVO.java +++ b/fw-dalaran-domain/src/main/java/cn/fw/dalaran/domain/vo/LivePoolVO.java @@ -77,7 +77,7 @@ public class LivePoolVO { */ private Integer liveDuration; /** - * 是否有效直播 + * 是否有效直播(-2:被判空挂, -1:付费, 0:无效, 1:有效, 11:有效且最佳) */ private Integer valid; /** @@ -126,6 +126,23 @@ public class LivePoolVO { private String account; /** + * 获取有效性描述 + */ + public String getValidStatusDesc() { + if (Objects.equals(this.valid, -2)) + return "空挂"; + if (Objects.equals(this.valid, -1)) + return "付费"; + if (Objects.equals(this.valid, 0)) + return "无效"; + if (Objects.equals(this.valid, 1)) + return "有效"; + if (Objects.equals(this.valid, 11)) + return "最佳"; + return "未知"; + } + + /** * 是否为最佳直播 */ public boolean getBestLive() { diff --git a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/config/MyControllerAdvice.java b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/config/MyControllerAdvice.java index 18edcc1..a11a84c 100644 --- a/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/config/MyControllerAdvice.java +++ b/fw-dalaran-server/src/main/java/cn/fw/dalaran/server/config/MyControllerAdvice.java @@ -2,6 +2,7 @@ package cn.fw.dalaran.server.config; import cn.fw.dalaran.common.exception.BusinessException; import cn.fw.data.base.domain.common.Message; +import org.hibernate.validator.internal.engine.path.PathImpl; import org.springframework.validation.BindException; import org.springframework.validation.FieldError; import org.springframework.validation.ObjectError; @@ -9,8 +10,11 @@ import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * @author wmy3969 @@ -22,15 +26,7 @@ import java.util.List; public class MyControllerAdvice { /** - * BusinessException - */ - @ExceptionHandler(value = {BusinessException.class}) - public Message handleException(BusinessException e) { - return Message.failure(50000, e.getMessage()); - } - - /** - * 参数校验未通过异常处理 + * 参数校验未通过异常处理(校验注解在实体类中) */ @ExceptionHandler(value = {MethodArgumentNotValidException.class, BindException.class}) public Message exception(Exception e) { @@ -52,7 +48,38 @@ public class MyControllerAdvice { sb.append(","); } } - return Message.failure(sb.toString()); + return Message.failure(50500, sb.toString()); + } + + /** + * 参数校验未通过异常处理(校验注解在方法参数列表上) + */ + @ExceptionHandler(value = ConstraintViolationException.class) + public Message exception(ConstraintViolationException e) { + Set> set = e.getConstraintViolations(); + StringBuilder sb = new StringBuilder(); + int size = set.size(); + if (size > 0) { + ArrayList> list = new ArrayList<>(set); + for (int i = 0; i < size; i++) { + final ConstraintViolation error = list.get(i); + sb.append("「"); + sb.append(((PathImpl) error.getPropertyPath()).getLeafNode().getName()); + sb.append("」"); + sb.append(error.getMessageTemplate()); + if (i < size - 1) + sb.append(","); + } + } + return Message.failure(50501, sb.toString()); + } + + /** + * BusinessException + */ + @ExceptionHandler(value = {BusinessException.class}) + public Message handleException(BusinessException e) { + return Message.failure(50502, e.getMessage()); } } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java index deecbc3..06068b1 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/biz/OtherBizService.java @@ -6,6 +6,7 @@ import cn.fw.dalaran.common.utils.PublicUtil; import cn.fw.dalaran.common.utils.StringUtils; import cn.fw.dalaran.domain.db.*; import cn.fw.dalaran.domain.enums.FileTypeEnum; +import cn.fw.dalaran.domain.enums.PlatformEnum; import cn.fw.dalaran.domain.param.LiveCheckParams; import cn.fw.dalaran.domain.vo.FileDesc; import cn.fw.dalaran.domain.vo.LiveCheckVo; @@ -14,9 +15,14 @@ import cn.fw.dalaran.rpc.erp.dto.ShopMsg; import cn.fw.dalaran.service.data.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -29,6 +35,7 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; +import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; /** @@ -51,6 +58,9 @@ public class OtherBizService { private final TodoHistoryService todoHistoryService; private final ThemeFileService themeFileService; + private final PlatformTransactionManager platformTransactionManager; + private final TransactionDefinition transactionDefinition; + /** * 获取直播审计页面 * @@ -80,7 +90,12 @@ public class OtherBizService { .list() .stream() .map(item -> { - final Account account = accountService.getById(item.getAccountId()); + Long accountId = item.getAccountId(); + Account account; + if (Objects.isNull(account = accountService.getById(accountId))) + account = accountService.getByIdIgnoreLogicDel(accountId); + if (Objects.isNull(account)) + return null; return LiveCheckResult.builder() .themeId(themeId) .userId(account.getUserId()) @@ -92,6 +107,7 @@ public class OtherBizService { .status(-1) .build(); }) + .filter(Objects::nonNull) .collect(Collectors.toList()); liveCheckResultService.saveBatch(waitCheckLives); } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/AccountService.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/AccountService.java index fa3d381..e3f12da 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/AccountService.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/AccountService.java @@ -33,4 +33,12 @@ public interface AccountService extends IService { * @return 对应账户 */ List getByUserAccountNo(String accountNo); + + /** + * 根据id获取账户(忽略逻辑删除) + * + * @param accountId 账户id + * @return 对应账户 + */ + Account getByIdIgnoreLogicDel(Long accountId); } diff --git a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/AccountServiceImpl.java b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/AccountServiceImpl.java index 722e409..03d0112 100644 --- a/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/AccountServiceImpl.java +++ b/fw-dalaran-service/src/main/java/cn/fw/dalaran/service/data/impl/AccountServiceImpl.java @@ -52,4 +52,15 @@ public class AccountServiceImpl extends ServiceImpl impleme return accountDao.getByUserAccountNo(accountNo); } + /** + * 根据id获取账户(忽略逻辑删除) + * + * @param accountId 账户id + * @return 对应账户 + */ + @Override + public Account getByIdIgnoreLogicDel(Long accountId) { + return accountDao.getByIdIgnoreLogicDel(accountId); + } + }