|
@@ -1,12 +1,29 @@
|
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
-import com.abi.qms.platform.dao.entity.*;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.abi.qms.platform.dao.entity.BaseActive;
|
|
|
+import com.abi.qms.platform.dao.entity.BaseActiveModifyApply;
|
|
|
import com.abi.qms.platform.dao.enums.ActiveAuditStatusEnum;
|
|
|
import com.abi.qms.platform.dao.enums.ValidEnum;
|
|
|
-import com.abi.qms.platform.dao.mapper.*;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseActiveMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseActiveModifyApplyMapper;
|
|
|
import com.abi.qms.platform.dao.vo.result.ListActiveVO;
|
|
|
-import com.abi.qms.platform.dto.req.*;
|
|
|
-import com.abi.qms.platform.dto.res.*;
|
|
|
+import com.abi.qms.platform.dto.req.AddActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.DeleteActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.DisableActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.EnableActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.GetActiveModifyApplyReq;
|
|
|
+import com.abi.qms.platform.dto.req.GetActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.ListActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.PassActiveModifyApplyReq;
|
|
|
+import com.abi.qms.platform.dto.req.PassActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.RefuseActiveModifyApplyReq;
|
|
|
+import com.abi.qms.platform.dto.req.RefuseActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.ResubmitActiveReq;
|
|
|
+import com.abi.qms.platform.dto.req.UpdateActiveReq;
|
|
|
+import com.abi.qms.platform.dto.res.GetActiveModifyApplyRes;
|
|
|
+import com.abi.qms.platform.dto.res.GetActiveRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListActiveRes;
|
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.UserUtil;
|
|
@@ -21,7 +38,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -47,17 +65,20 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void addActive(AddActiveReq req){
|
|
|
+ public void addActive(AddActiveReq req) {
|
|
|
//校验入参
|
|
|
//活动ID不可重复创建。
|
|
|
QueryWrapper<BaseActive> activeVali = new QueryWrapper<>();
|
|
|
activeVali.eq("active_code", req.getActiveCode());
|
|
|
activeVali.eq("is_delete", 0);
|
|
|
BaseActive baseActive = baseActiveMapper.selectOne(activeVali);
|
|
|
- if (Objects.nonNull(baseActive)){
|
|
|
+ if (Objects.nonNull(baseActive)) {
|
|
|
throw new BusinessException("码活动ID" + req.getActiveCode() + "已存在。");
|
|
|
}
|
|
|
|
|
|
+ //校验活动名称是否存在
|
|
|
+ checkActiveName(req.getActiveName());
|
|
|
+
|
|
|
//1-新增
|
|
|
Long userId = userUtil.getUser().getId();
|
|
|
BaseActive active = new BaseActive();
|
|
@@ -83,13 +104,16 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void updateActive(UpdateActiveReq req){
|
|
|
+ public void updateActive(UpdateActiveReq req) {
|
|
|
|
|
|
//1-查询活动
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(active,"活动不存在");
|
|
|
+ AssertUtil.isNull(active, "活动不存在");
|
|
|
+
|
|
|
+ //校验活动名称是否存在
|
|
|
+ checkActiveName(req.getActiveName());
|
|
|
|
|
|
- if(ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())){
|
|
|
+ if (ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("该数据已审核通过,请调用码活动申请单的接口。");
|
|
|
}
|
|
|
|
|
@@ -117,8 +141,8 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
public void deleteActive(DeleteActiveReq req) {
|
|
|
//1-查询活动
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(active,"活动不存在");
|
|
|
- if(ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())){
|
|
|
+ AssertUtil.isNull(active, "活动不存在");
|
|
|
+ if (ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("活动已审核通过,不可删除");
|
|
|
}
|
|
|
|
|
@@ -133,9 +157,12 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
public void resubmitActive(ResubmitActiveReq req) {
|
|
|
//0-查询活动
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(active,"活动不存在");
|
|
|
+ AssertUtil.isNull(active, "活动不存在");
|
|
|
+
|
|
|
+ //校验活动名称是否存在
|
|
|
+ checkActiveName(req.getActiveName());
|
|
|
|
|
|
- if(!ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())){
|
|
|
+ if (!ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("该数据没有审核通过,请调用编辑码活动的接口。");
|
|
|
}
|
|
|
|
|
@@ -174,7 +201,7 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
* 分页查询活动
|
|
|
*/
|
|
|
@Override
|
|
|
- public ListActiveRes listActive(ListActiveReq req){
|
|
|
+ public ListActiveRes listActive(ListActiveReq req) {
|
|
|
|
|
|
//分页查询
|
|
|
IPage<ListActiveVO> iPage = baseActiveMapper.listActivePage(PageUtil.createPage(req), req);
|
|
@@ -195,7 +222,7 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
* 查询活动明细
|
|
|
*/
|
|
|
@Override
|
|
|
- public GetActiveRes getActive(GetActiveReq req){
|
|
|
+ public GetActiveRes getActive(GetActiveReq req) {
|
|
|
|
|
|
//1-查询活动对象
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
@@ -223,9 +250,9 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
|
|
|
//转化出参(这里逻辑有点特殊,如果存在申请单,则返回申请单、否则返回活动本身)
|
|
|
GetActiveModifyApplyRes res = null;
|
|
|
- if(activeModifyApply!=null){
|
|
|
+ if (activeModifyApply != null) {
|
|
|
res = PojoConverterUtils.copy(activeModifyApply, GetActiveModifyApplyRes.class);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
res = PojoConverterUtils.copy(active, GetActiveModifyApplyRes.class);
|
|
|
}
|
|
|
|
|
@@ -237,7 +264,7 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void enableActive(EnableActiveReq req){
|
|
|
+ public void enableActive(EnableActiveReq req) {
|
|
|
List<Long> ids = req.getIds();
|
|
|
|
|
|
//循环启用
|
|
@@ -261,7 +288,7 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void disableActive(DisableActiveReq req){
|
|
|
+ public void disableActive(DisableActiveReq req) {
|
|
|
List<Long> ids = req.getIds();
|
|
|
|
|
|
//循环禁用
|
|
@@ -286,7 +313,7 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
AssertUtil.isNull(active, "活动不存在");
|
|
|
|
|
|
- if(!ActiveAuditStatusEnum.WAIT_REVIEW.is(active.getAuditStatus())){
|
|
|
+ if (!ActiveAuditStatusEnum.WAIT_REVIEW.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("该活动不能审核");
|
|
|
}
|
|
|
Long userId = userUtil.getUser().getId();
|
|
@@ -303,7 +330,7 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
public void refuseActive(RefuseActiveReq req) {
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
AssertUtil.isNull(active, "活动不存在");
|
|
|
- if(!ActiveAuditStatusEnum.WAIT_REVIEW.is(active.getAuditStatus())){
|
|
|
+ if (!ActiveAuditStatusEnum.WAIT_REVIEW.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("该活动不能审核");
|
|
|
}
|
|
|
Long userId = userUtil.getUser().getId();
|
|
@@ -320,8 +347,8 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
|
|
|
//1-查询活动
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(active,"活动不存在");
|
|
|
- if(!ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())){
|
|
|
+ AssertUtil.isNull(active, "活动不存在");
|
|
|
+ if (!ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("该数据没有审核通过,请调用审核码活动的接口。");
|
|
|
}
|
|
|
//查询码活动申请单
|
|
@@ -329,8 +356,8 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
activeModifyApplyQW.eq("active_id", req.getId());
|
|
|
activeModifyApplyQW.eq("is_delete", 0);
|
|
|
BaseActiveModifyApply activeModifyApply = baseActiveModifyApplyMapper.selectOne(activeModifyApplyQW);
|
|
|
- AssertUtil.isNull(activeModifyApply,"码活动申请单不存在");
|
|
|
- if(!ActiveAuditStatusEnum.WAIT_REVIEW.is(activeModifyApply.getAuditStatus())){
|
|
|
+ AssertUtil.isNull(activeModifyApply, "码活动申请单不存在");
|
|
|
+ if (!ActiveAuditStatusEnum.WAIT_REVIEW.is(activeModifyApply.getAuditStatus())) {
|
|
|
throw new BusinessException("该码活动申请单不能审核");
|
|
|
}
|
|
|
|
|
@@ -361,8 +388,8 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
public void refuseActiveModifyApply(RefuseActiveModifyApplyReq req) {
|
|
|
//1-查询活动
|
|
|
BaseActive active = baseActiveMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(active,"活动不存在");
|
|
|
- if(!ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())){
|
|
|
+ AssertUtil.isNull(active, "活动不存在");
|
|
|
+ if (!ActiveAuditStatusEnum.REVIEW_PASS.is(active.getAuditStatus())) {
|
|
|
throw new BusinessException("该数据没有审核通过,请调用审核码活动的接口。");
|
|
|
}
|
|
|
//查询码活动申请单
|
|
@@ -370,8 +397,8 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
activeModifyApplyQW.eq("active_id", req.getId());
|
|
|
activeModifyApplyQW.eq("is_delete", 0);
|
|
|
BaseActiveModifyApply activeModifyApply = baseActiveModifyApplyMapper.selectOne(activeModifyApplyQW);
|
|
|
- AssertUtil.isNull(activeModifyApply,"码活动申请单不存在");
|
|
|
- if(!ActiveAuditStatusEnum.WAIT_REVIEW.is(activeModifyApply.getAuditStatus())){
|
|
|
+ AssertUtil.isNull(activeModifyApply, "码活动申请单不存在");
|
|
|
+ if (!ActiveAuditStatusEnum.WAIT_REVIEW.is(activeModifyApply.getAuditStatus())) {
|
|
|
throw new BusinessException("该码活动申请单不能审核");
|
|
|
}
|
|
|
|
|
@@ -384,6 +411,18 @@ public class ActiveServiceImpl implements ActiveService {
|
|
|
baseActiveModifyApplyMapper.updateById(activeModifyApply);
|
|
|
}
|
|
|
|
|
|
+ private void checkActiveName(String activeName) {
|
|
|
+ //校验活动名称是否存在
|
|
|
+ if (activeName != null) {
|
|
|
+ QueryWrapper<BaseActive> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("active_name", activeName);
|
|
|
+ qw.eq("is_delete", 0);
|
|
|
+ List<BaseActive> activeList = baseActiveMapper.selectList(qw);
|
|
|
+ if (CollectionUtil.isNotEmpty(activeList)) {
|
|
|
+ throw new BusinessException("码活动名称已存在!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
// 6.03已废弃
|