dengzedong
2024-09-24 423f243b6c9d5f3dd24268887087c60d5c9d2ac0
项目管理 事务处理
已修改3个文件
51 ■■■■ 文件已修改
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ProjectModelService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ProjectModelServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ProjectServiceImpl.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/ProjectModelService.java
@@ -1,6 +1,7 @@
package com.iailab.module.model.mpk.service;
import com.iailab.framework.common.service.CrudService;
import com.iailab.module.model.mpk.dto.MpkFileDTO;
import com.iailab.module.model.mpk.dto.ProjectModelDTO;
import com.iailab.module.model.mpk.entity.ProjectModelEntity;
@@ -17,4 +18,6 @@
    List<ProjectModelDTO> list(Map<String, Object> params);
    void deleteByMap(Map<String,Object> map);
    void create(List<MpkFileDTO> models, String projectId);
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ProjectModelServiceImpl.java
@@ -4,15 +4,17 @@
import com.iailab.framework.common.service.impl.CrudServiceImpl;
import com.iailab.framework.common.util.object.ConvertUtils;
import com.iailab.module.model.mpk.dao.ProjectModelDao;
import com.iailab.module.model.mpk.dto.MpkFileDTO;
import com.iailab.module.model.mpk.dto.ProjectModelDTO;
import com.iailab.module.model.mpk.entity.ProjectModelEntity;
import com.iailab.module.model.mpk.service.ProjectModelService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * @description:
@@ -34,6 +36,19 @@
    }
    @Override
    public void create(List<MpkFileDTO> models, String projectId) {
        List<ProjectModelEntity> list = new ArrayList<>(models.size());
        for (MpkFileDTO model : models) {
            ProjectModelEntity projectModel = new ProjectModelEntity();
            projectModel.setId(UUID.randomUUID().toString());
            projectModel.setProjectId(projectId);
            projectModel.setModelId(model.getId());
            list.add(projectModel);
        }
        baseDao.insert(list);
    }
    @Override
    public QueryWrapper<ProjectModelEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String projectId = (String)params.get("projectId");
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/ProjectServiceImpl.java
@@ -1,6 +1,6 @@
package com.iailab.module.model.mpk.service.impl;
import cn.hutool.core.io.FileUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.iailab.framework.common.page.PageData;
@@ -13,8 +13,6 @@
import com.iailab.module.model.mpk.dto.ProjectModelDTO;
import com.iailab.module.model.mpk.dto.ProjectPackageHistoryDTO;
import com.iailab.module.model.mpk.entity.ProjectEntity;
import com.iailab.module.model.mpk.entity.ProjectModelEntity;
import com.iailab.module.model.mpk.entity.ProjectPackageHistoryModelEntity;
import com.iailab.module.model.mpk.service.ProjectModelService;
import com.iailab.module.model.mpk.service.ProjectPackageHistoryModelService;
import com.iailab.module.model.mpk.service.ProjectPackageHistoryService;
@@ -24,7 +22,6 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.util.*;
@@ -83,7 +80,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    @DSTransactional(rollbackFor = Exception.class)
    public void save(ProjectDTO dto) {
        ProjectEntity entity = ConvertUtils.sourceToTarget(dto, ProjectEntity.class);
        String projectId = UUID.randomUUID().toString();
@@ -94,20 +91,12 @@
        //关联模型
        List<MpkFileDTO> models = dto.getModels();
        if (CollectionUtils.isNotEmpty(models)) {
            List<ProjectModelEntity> projectModelList = new ArrayList<>(models.size());
            for (MpkFileDTO model : models) {
                ProjectModelEntity projectModel = new ProjectModelEntity();
                projectModel.setId(UUID.randomUUID().toString());
                projectModel.setProjectId(projectId);
                projectModel.setModelId(model.getId());
                projectModelList.add(projectModel);
            }
            projectModelService.insertBatch(projectModelList);
            projectModelService.create(models,projectId);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    @DSTransactional(rollbackFor = Exception.class)
    public void update(ProjectDTO dto) {
        ProjectEntity entity = ConvertUtils.sourceToTarget(dto, ProjectEntity.class);
        entity.setUpdateTime(new Date());
@@ -122,20 +111,12 @@
        //关联模型
        List<MpkFileDTO> models = dto.getModels();
        if (CollectionUtils.isNotEmpty(models)) {
            List<ProjectModelEntity> projectModelList = new ArrayList<>(models.size());
            for (MpkFileDTO model : models) {
                ProjectModelEntity projectModel = new ProjectModelEntity();
                projectModel.setId(UUID.randomUUID().toString());
                projectModel.setProjectId(projectId);
                projectModel.setModelId(model.getId());
                projectModelList.add(projectModel);
            }
            projectModelService.insertBatch(projectModelList);
            projectModelService.create(models,projectId);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    @DSTransactional(rollbackFor = Exception.class)
    public void delete(String id) {
        //删除备份文件
        Map<String,Object> map = new HashMap<>();