Commit 04383980 by lepdou

update

parent 4db23ba8
...@@ -14,7 +14,6 @@ import org.springframework.context.annotation.Configuration; ...@@ -14,7 +14,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableEurekaClient @EnableEurekaClient
@Configuration @Configuration
......
...@@ -28,11 +28,6 @@ ...@@ -28,11 +28,6 @@
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>1.3.5.RELEASE</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -9,10 +9,14 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; ...@@ -9,10 +9,14 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAutoConfiguration @EnableAspectJAutoProxy
@Configuration @Configuration
@EnableAutoConfiguration
@EnableTransactionManagement
@PropertySource(value = {"classpath:portal.properties"}) @PropertySource(value = {"classpath:portal.properties"})
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class, @ComponentScan(basePackageClasses = {ApolloCommonConfig.class,
PortalApplication.class}) PortalApplication.class})
......
...@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller; ...@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -17,6 +18,7 @@ import com.ctrip.framework.apollo.common.http.RichResponseEntity; ...@@ -17,6 +18,7 @@ import com.ctrip.framework.apollo.common.http.RichResponseEntity;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.PortalSettings; import com.ctrip.framework.apollo.portal.PortalSettings;
import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo; import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo;
import com.ctrip.framework.apollo.portal.listener.AppCreationEvent;
import com.ctrip.framework.apollo.portal.service.AppService; import com.ctrip.framework.apollo.portal.service.AppService;
import java.util.List; import java.util.List;
...@@ -33,6 +35,9 @@ public class AppController { ...@@ -33,6 +35,9 @@ public class AppController {
@Autowired @Autowired
private PortalSettings portalSettings; private PortalSettings portalSettings;
@Autowired
private ApplicationEventPublisher publisher;
@RequestMapping("") @RequestMapping("")
public List<App> findAllApp() { public List<App> findAllApp() {
return appService.findAll(); return appService.findAll();
...@@ -60,7 +65,10 @@ public class AppController { ...@@ -60,7 +65,10 @@ public class AppController {
checkArgument(app.getName(), app.getAppId(), app.getOwnerEmail(), app.getOwnerName()); checkArgument(app.getName(), app.getAppId(), app.getOwnerEmail(), app.getOwnerName());
appService.createApp(app); appService.enrichUserInfo(app);
App createdApp = appService.createOrUpdateAppInLocal(app);
publisher.publishEvent(new AppCreationEvent(createdApp));
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO; import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.core.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
...@@ -25,7 +26,7 @@ public class NamespaceController { ...@@ -25,7 +26,7 @@ public class NamespaceController {
private NamespaceService namespaceService; private NamespaceService namespaceService;
@RequestMapping("/appnamespaces/public") @RequestMapping("/appnamespaces/public")
public List<AppNamespaceDTO> findPublicAppNamespaces() { public List<AppNamespace> findPublicAppNamespaces() {
return namespaceService.findPublicAppNamespaces(); return namespaceService.findPublicAppNamespaces();
} }
......
...@@ -2,17 +2,11 @@ package com.ctrip.framework.apollo.portal.repository; ...@@ -2,17 +2,11 @@ package com.ctrip.framework.apollo.portal.repository;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface AppRepository extends PagingAndSortingRepository<App, Long> { public interface AppRepository extends PagingAndSortingRepository<App, Long> {
@Query("SELECT a from App a WHERE a.name LIKE %:name%")
List<App> findByName(@Param("name") String name);
App findByAppId(String appId); App findByAppId(String appId);
} }
...@@ -92,21 +92,26 @@ public class AppService { ...@@ -92,21 +92,26 @@ public class AppService {
} }
} }
private void enrichUserInfo(App app) { public void enrichUserInfo(App app) {
String username = userInfoHolder.getUser().getUserId(); String username = userInfoHolder.getUser().getUserId();
app.setDataChangeCreatedBy(username); app.setDataChangeCreatedBy(username);
app.setDataChangeLastModifiedBy(username); app.setDataChangeLastModifiedBy(username);
} }
@Transactional @Transactional
private App createOrUpdateAppInLocal(App app) { public App createOrUpdateAppInLocal(App app) {
String appId = app.getAppId(); String appId = app.getAppId();
App managedApp = appRepository.findByAppId(appId); App managedApp = appRepository.findByAppId(appId);
if (managedApp != null) { if (managedApp != null) {
BeanUtils.copyEntityProperties(app, managedApp); BeanUtils.copyEntityProperties(app, managedApp);
return appRepository.save(managedApp); return appRepository.save(managedApp);
} else { } else {
App createdApp = appRepository.save(app); App createdApp = appRepository.save(app);
if (app.getName().equals("xx")){
throw new RuntimeException("xxxx");
}
namespaceService.createDefaultAppNamespace(appId); namespaceService.createDefaultAppNamespace(appId);
//role //role
roleInitializationService.initAppRoles(createdApp); roleInitializationService.initAppRoles(createdApp);
......
...@@ -58,8 +58,8 @@ public class NamespaceService { ...@@ -58,8 +58,8 @@ public class NamespaceService {
private Gson gson = new Gson(); private Gson gson = new Gson();
public List<AppNamespaceDTO> findPublicAppNamespaces() { public List<AppNamespace> findPublicAppNamespaces() {
return namespaceAPI.findPublicAppNamespaces(portalSettings.getFirstAliveEnv()); return appNamespaceRepository.findByNameNot(ConfigConsts.NAMESPACE_APPLICATION);
} }
public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) { public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) {
......
...@@ -20,7 +20,7 @@ var sync_item_module = angular.module('sync_item', ['app.service', 'apollo.direc ...@@ -20,7 +20,7 @@ var sync_item_module = angular.module('sync_item', ['app.service', 'apollo.direc
var namespace_module = angular.module('namespace', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']); var namespace_module = angular.module('namespace', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
//server config //server config
var server_config_module = angular.module('server_config', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']); var server_config_module = angular.module('server_config', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
// namespace role //role
var role_module = angular.module('role', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']); var role_module = angular.module('role', ['app.service', 'apollo.directive', 'app.util', 'toastr', 'angular-loading-bar']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment