Example #1
0
 @Override
 @Transactional(rollbackFor = Exception.class, timeout = 30)
 public int modifyProject(ModifyProjectReq req) {
   Long projectId = req.getProject().getId();
   // 1.修改项目主表project,还没有日志记录
   req.getProject().setCreatename(req.getPublishName());
   long i = projectDao.updateByPrimaryKeySelective(req.getProject());
   if (i > 0) {
     // 2.修改策略表 projectstrategy 先删除原来的策略 在插入新的策略
     int upDel = projectStrategyDao.updateDeleteByProjectId(projectId); // 策略表打删除标记
     if (upDel > 0) {
       req.getProjectStrategyList().forEach(action -> action.setProjectid(projectId));
       int proStrategyResult =
           projectStrategyDao.insertList(req.getProjectStrategyList()); // 插入新的策略
       // 3.修改项目图片表 projectimage
       if (proStrategyResult > 0) {
         int updeImg = 0;
         // 先删除的原来的图片,在插入新的图片
         List<ModifyProjectImg> modifyProjectImgs = req.getModifyProjectImgList();
         if (modifyProjectImgs != null && modifyProjectImgs.size() > 0) {
           List<ModifyProjectImg> updateImgs =
               modifyProjectImgs
                   .stream()
                   .filter(t -> t.getModifyType() == 2)
                   .collect(Collectors.toList());
           if (updateImgs != null && updateImgs.size() > 0) {
             updeImg = projectImageDao.updateDeleteById(updateImgs);
           }
         } else {
           updeImg = 1;
         }
         int insImg = 0;
         // 插入新的图片
         List<ProjectImage> projectImages = req.getProjectImageList();
         if (projectImages != null && projectImages.size() > 0) {
           req.getProjectImageList()
               .forEach(action -> action.setProjectid(req.getProject().getId()));
           insImg = projectImageDao.insertList(req.getProjectImageList());
         } else {
           insImg = 1;
         }
         if (updeImg > 0 && insImg > 0) {
           return 1;
         }
       }
     }
   }
   return 0;
 }
Example #2
0
 /*
  * 发布项目 wangchao
  */
 @Override
 @Transactional(rollbackFor = Exception.class, timeout = 30)
 public int publishProject(PublishProjectReq req) {
   // 1.项目主表project
   req.getProject().setCreatename(req.getPublishName());
   // String projectimage =req.getProject().getProjectimage();
   // projectimage=PropertyUtils.getProperty("ImgShowUrl")+projectimage;
   long i = projectDao.insert(req.getProject());
   if (i > 0) {
     // 2.插入策略表 projectstrategy
     req.getProjectStrategyList().forEach(action -> action.setProjectid(req.getProject().getId()));
     int proStrategyResult = projectStrategyDao.insertList(req.getProjectStrategyList());
     // 3.项目图片表 projectimage
     if (proStrategyResult > 0) {
       req.getProjectImageList().forEach(action -> action.setProjectid(req.getProject().getId()));
       int k = projectImageDao.insertList(req.getProjectImageList());
       if (k > 0) {
         return 1;
       }
     }
   }
   return 0;
 }