From c54adee9b730abed501ed8d13e3df946a7c02dfe Mon Sep 17 00:00:00 2001 From: wangxy <1356089412@qq.com> Date: Thu, 11 Apr 2024 11:31:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=94=9F=E6=88=90applyId=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/ApplyInfoListManager.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/hyp-admin/src/main/java/com/hyp/web/controller/manager/ApplyInfoListManager.java b/hyp-admin/src/main/java/com/hyp/web/controller/manager/ApplyInfoListManager.java index c9eb538..a139a71 100644 --- a/hyp-admin/src/main/java/com/hyp/web/controller/manager/ApplyInfoListManager.java +++ b/hyp-admin/src/main/java/com/hyp/web/controller/manager/ApplyInfoListManager.java @@ -1,7 +1,9 @@ package com.hyp.web.controller.manager; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import com.hyp.common.core.domain.model.LoginUser; +import com.hyp.common.exception.ServiceException; import com.hyp.common.utils.SecurityUtils; import com.hyp.system.domain.RewApplyInfoList; import com.hyp.system.domain.dto.ApplyInfoListDTO; @@ -9,8 +11,10 @@ import com.hyp.system.domain.vo.ApplyInfoListVO; import com.hyp.system.service.RewApplyInfoListService; import com.hyp.system.service.RewScoreInfoService; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Date; import java.util.List; /** @@ -39,12 +43,29 @@ public class ApplyInfoListManager { } + /** + * + * 生成applyId + * @param applyType + * @return com.hyp.system.domain.vo.ApplyInfoListVO + */ + @Transactional(rollbackFor = Exception.class) public ApplyInfoListVO getApplyId(String applyType){ LoginUser loginUser = SecurityUtils.getLoginUser(); + List list = applyInfoListService.lambdaQuery() + .eq(RewApplyInfoList::getApplyType, applyType) + .eq(RewApplyInfoList::getCreateId, loginUser.getUserId()) + .list(); + if(CollUtil.isNotEmpty(list)){ + throw new ServiceException("该用户已申请,不能重复申请!"); + } RewApplyInfoList applyInfoList = new RewApplyInfoList(); applyInfoList.setApplyType(applyType); applyInfoList.setApplyStatus(0); applyInfoList.setCreateId(loginUser.getUserId()); + applyInfoList.setCreateBy(loginUser.getUsername()); + applyInfoList.setUpdateTime(new Date()); + applyInfoList.setCreateTime(new Date()); applyInfoListService.save(applyInfoList); return Convert.convert(ApplyInfoListVO.class, applyInfoList); }