Browse Source

copy时 id主动设置为null

dev
jianjun 4 years ago
parent
commit
ec172e643b
  1. 2
      tduck-api/src/main/java/com/tduck/cloud/api/config/FilterConfig.java
  2. 2
      tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java

2
tduck-api/src/main/java/com/tduck/cloud/api/config/FilterConfig.java

@ -32,7 +32,7 @@ public class FilterConfig {
* *
* @return * @return
*/ */
//@Bean @Bean
public FilterRegistrationBean corsFilterRegistration() { public FilterRegistrationBean corsFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean(); FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST); registration.setDispatcherTypes(DispatcherType.REQUEST);

2
tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java

@ -100,6 +100,7 @@ public class UserProjectController {
List<ProjectTemplateItemEntity> projectTemplateItemEntities = projectTemplateItemService.listByTemplateKey(templateKey); List<ProjectTemplateItemEntity> projectTemplateItemEntities = projectTemplateItemService.listByTemplateKey(templateKey);
UserProjectEntity userProjectEntity = new UserProjectEntity(); UserProjectEntity userProjectEntity = new UserProjectEntity();
BeanUtil.copyProperties(projectTemplateEntity, userProjectEntity, UserProjectEntity.Fields.status); BeanUtil.copyProperties(projectTemplateEntity, userProjectEntity, UserProjectEntity.Fields.status);
userProjectEntity.setId(null);
userProjectEntity.setSourceType(ProjectSourceTypeEnum.TEMPLATE); userProjectEntity.setSourceType(ProjectSourceTypeEnum.TEMPLATE);
userProjectEntity.setSourceId(projectTemplateEntity.getId()); userProjectEntity.setSourceId(projectTemplateEntity.getId());
userProjectEntity.setKey(IdUtil.fastSimpleUUID()); userProjectEntity.setKey(IdUtil.fastSimpleUUID());
@ -127,6 +128,7 @@ public class UserProjectController {
List<UserProjectItemEntity> itemEntityList = projectItemService.listByProjectKey(request.getKey()); List<UserProjectItemEntity> itemEntityList = projectItemService.listByProjectKey(request.getKey());
ProjectTemplateEntity projectTemplateEntity = new ProjectTemplateEntity(); ProjectTemplateEntity projectTemplateEntity = new ProjectTemplateEntity();
BeanUtil.copyProperties(projectEntity, projectTemplateEntity, UserProjectEntity.Fields.status); BeanUtil.copyProperties(projectEntity, projectTemplateEntity, UserProjectEntity.Fields.status);
projectTemplateEntity.setId(null);
projectTemplateEntity.setKey(IdUtil.fastSimpleUUID()); projectTemplateEntity.setKey(IdUtil.fastSimpleUUID());
projectTemplateEntity.setCategoryId(CommonConstants.ConstantNumber.FOUR.longValue()); projectTemplateEntity.setCategoryId(CommonConstants.ConstantNumber.FOUR.longValue());
projectTemplateService.save(projectTemplateEntity); projectTemplateService.save(projectTemplateEntity);

Loading…
Cancel
Save