Exemplo n.º 1
0
 @Override
 public int create(Config config) {
   Config configFound = configDao.findConfigByKey(config.getKey());
   if (configFound != null) {
     Project project = projectDao.getProject(configFound.getProjectId());
     throw new RuntimeBusinessException(
         "该配置项已存在(project: "
             + (project != null ? project.getName() : "***")
             + ", desc: "
             + configFound.getDesc()
             + ")!");
   }
   Integer currentUserId = SecurityUtils.getCurrentUserId();
   int projectId = config.getProjectId();
   if (config.getCreateUserId() == null) {
     config.setCreateUserId(currentUserId);
   }
   if (config.getModifyUserId() == null) {
     config.setModifyUserId(currentUserId);
   }
   projectDao.lockProject(projectId);
   if (!config.isPrivatee()) {
     config.setPrivatee(isSharedProject(projectId));
   }
   config.setSeq(configDao.getMaxSeq(projectId) + 1);
   return configDao.create(config);
 }