|
@@ -1,20 +1,24 @@
|
|
|
package com.platform.service.custom.impl;
|
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.exception.DeniedException;
|
|
|
+import com.platform.common.util.BeanConverterUtil;
|
|
|
+import com.platform.common.util.IdGeneratorUtils;
|
|
|
+import com.platform.common.util.SecurityUtils;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
-import com.platform.dao.vo.query.custom.CustomWorkflowRelationVO;
|
|
|
import com.platform.dao.dto.custom.CustomWorkflowRelationDTO;
|
|
|
import com.platform.dao.entity.custom.CustomWorkflowRelation;
|
|
|
import com.platform.dao.mapper.custom.CustomWorkflowRelationMapper;
|
|
|
+import com.platform.dao.vo.query.custom.CustomWorkflowRelationVO;
|
|
|
+import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import com.platform.service.custom.CustomWorkflowRelationService;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -42,6 +46,40 @@ public class CustomWorkflowRelationServiceImpl extends BaseServiceImpl<CustomWor
|
|
|
return new MyPage(mapper.selectList(record));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CustomWorkflowRelation saveByDTO(CustomWorkflowRelationDTO record) {
|
|
|
+ // 校验重复
|
|
|
+ if(countRepeatNum(record.getLinkType()) > 0){
|
|
|
+ throw new DeniedException("关联类型数据库已存在");
|
|
|
+ }
|
|
|
+ CustomWorkflowRelation entity = BeanConverterUtil.copyObjectProperties(record, CustomWorkflowRelation.class);
|
|
|
+ entity.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ entity.setCreatedTime(LocalDateTime.now());
|
|
|
+ entity.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ entity.setCreatedUserName(SecurityUtils.getUserInfo().getRealName());
|
|
|
+ mapper.insertSelective(entity);
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int countRepeatNum(String linkType){
|
|
|
+ CustomWorkflowRelation relation = new CustomWorkflowRelation();
|
|
|
+ relation.setLinkType(linkType);
|
|
|
+ return mapper.selectCount(relation);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void modByDTO(CustomWorkflowRelationDTO record) {
|
|
|
+ CustomWorkflowRelation oldRelation = mapper.selectByPrimaryKey(record.getId());
|
|
|
+ String linkType = oldRelation.getLinkType();
|
|
|
+ if(!linkType.equals(record.getLinkType())){
|
|
|
+ if(countRepeatNum(record.getLinkType()) > 0) {
|
|
|
+ throw new DeniedException("修改的关联类型数据库已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ modModelByDTO(record);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public AbstractPageResultBean<CustomWorkflowRelation> selectPageInfo(CustomWorkflowRelationDTO record, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|