提交 04383980 编写于 作者: L lepdou

update

上级 4db23ba8
......@@ -14,7 +14,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAspectJAutoProxy
@EnableEurekaClient
@Configuration
......
......@@ -28,11 +28,6 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>1.3.5.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -9,10 +9,14 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAutoConfiguration
@EnableAspectJAutoProxy
@Configuration
@EnableAutoConfiguration
@EnableTransactionManagement
@PropertySource(value = {"classpath:portal.properties"})
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class,
PortalApplication.class})
......
......@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -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.portal.PortalSettings;
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 java.util.List;
......@@ -33,6 +35,9 @@ public class AppController {
@Autowired
private PortalSettings portalSettings;
@Autowired
private ApplicationEventPublisher publisher;
@RequestMapping("")
public List<App> findAllApp() {
return appService.findAll();
......@@ -60,7 +65,10 @@ public class AppController {
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();
}
......
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.NamespaceDTO;
import com.ctrip.framework.apollo.core.enums.Env;
......@@ -25,7 +26,7 @@ public class NamespaceController {
private NamespaceService namespaceService;
@RequestMapping("/appnamespaces/public")
public List<AppNamespaceDTO> findPublicAppNamespaces() {
public List<AppNamespace> findPublicAppNamespaces() {
return namespaceService.findPublicAppNamespaces();
}
......
......@@ -2,17 +2,11 @@ package com.ctrip.framework.apollo.portal.repository;
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.query.Param;
import java.util.List;
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);
}
......@@ -92,21 +92,26 @@ public class AppService {
}
}
private void enrichUserInfo(App app) {
public void enrichUserInfo(App app) {
String username = userInfoHolder.getUser().getUserId();
app.setDataChangeCreatedBy(username);
app.setDataChangeLastModifiedBy(username);
}
@Transactional
private App createOrUpdateAppInLocal(App app) {
public App createOrUpdateAppInLocal(App app) {
String appId = app.getAppId();
App managedApp = appRepository.findByAppId(appId);
if (managedApp != null) {
BeanUtils.copyEntityProperties(app, managedApp);
return appRepository.save(managedApp);
} else {
App createdApp = appRepository.save(app);
if (app.getName().equals("xx")){
throw new RuntimeException("xxxx");
}
namespaceService.createDefaultAppNamespace(appId);
//role
roleInitializationService.initAppRoles(createdApp);
......
......@@ -58,8 +58,8 @@ public class NamespaceService {
private Gson gson = new Gson();
public List<AppNamespaceDTO> findPublicAppNamespaces() {
return namespaceAPI.findPublicAppNamespaces(portalSettings.getFirstAliveEnv());
public List<AppNamespace> findPublicAppNamespaces() {
return appNamespaceRepository.findByNameNot(ConfigConsts.NAMESPACE_APPLICATION);
}
public NamespaceDTO createNamespace(Env env, NamespaceDTO namespace) {
......
......@@ -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']);
//server config
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']);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册