コード例 #1
0
 public int updateConfig(Config config) {
   try {
     config.setModifyUserId(SecurityUtils.getCurrentUserId());
     return configDao.update(config);
   } finally {
     cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + config.getId());
     cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + config.getKey());
   }
 }
コード例 #2
0
 @Override
 public void moveUp(int projectId, Integer configId) {
   Config config = getConfig(configId);
   if (config == null) {
     throw new EntityNotFoundException("Config[id=" + configId + "] not found.");
   }
   projectDao.lockProject(projectId);
   Config prevConfig = configDao.getPrevConfig(configId);
   if (prevConfig != null) {
     try {
       int seq = config.getSeq();
       config.setSeq(prevConfig.getSeq());
       prevConfig.setSeq(seq);
       configDao.update(config);
       configDao.update(prevConfig);
     } finally {
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + config.getId());
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + config.getKey());
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + prevConfig.getId());
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + prevConfig.getKey());
     }
   }
 }
コード例 #3
0
 @Override
 public void moveDown(int projectId, int configId) {
   Config config = getConfig(configId);
   if (config == null) {
     throw new EntityNotFoundException("Config[id=" + configId + "] not found.");
   }
   projectDao.lockProject(projectId); // 锁定指定projectId,避免同一项目下的config出现相同的seq值
   Config nextConfig = configDao.getNextConfig(configId);
   if (nextConfig != null) {
     try {
       int seq = config.getSeq();
       config.setSeq(nextConfig.getSeq());
       nextConfig.setSeq(seq);
       configDao.update(config);
       configDao.update(nextConfig);
     } finally {
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + config.getId());
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + config.getKey());
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + nextConfig.getId());
       cacheClient.remove(ServiceConstants.CACHE_CONFIG_PREFIX + nextConfig.getKey());
     }
   }
 }