Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a config adjust the property source overriden behavior #4377

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e23f628
feat: add a config adjust the property source overriden behavior
shenhuaxin May 23, 2022
b6dafd2
feat: add a config adjust the property source overriden behavior
shenhuaxin May 23, 2022
6d4b5d8
feat: add a config adjust the property source overriden behavior
shenhuaxin May 24, 2022
4d1d27d
feat: add a config adjust the property source overriden behavior
shenhuaxin May 24, 2022
6e85efa
feat: add a config adjust the property source overriden behavior
shenhuaxin May 24, 2022
b235a98
feat: add a config adjust the property source overriden behavior for …
shenhuaxin May 25, 2022
27be3f9
fix: change property name
shenhuaxin May 28, 2022
6bcb67d
refactor: remove isOverrideSystemProperties()
shenhuaxin May 28, 2022
0975296
refactor: remove isOverrideSystemProperties()
shenhuaxin May 28, 2022
8a4930f
test: remove isOverrideSystemProperties()
shenhuaxin May 28, 2022
5db5b4d
Update apollo-client/src/main/resources/META-INF/additional-spring-co…
shenhuaxin May 29, 2022
8b3f899
Merge branch 'master' into override-system-properties
shenhuaxin May 29, 2022
cada7d1
fix: rename override system properties, original name is not valid
shenhuaxin May 31, 2022
60c15ce
docs: add apollo.override-system-properties docs
shenhuaxin May 31, 2022
92fc457
fix the delete appnamespace failed issue
nobodyiam May 29, 2022
6360408
Bump gson from 2.8.0 to 2.8.9
dependabot[bot] May 28, 2022
f5d1092
Bump okhttp3 from 3.11.0 to 4.9.3
shoothzj Jun 2, 2022
56be420
Update apollo-open-api-platform.md
lepdou Jun 4, 2022
e357378
Update apollo-open-api-platform.md
lepdou Jun 4, 2022
5d1d261
bump version to 2.1.0-SNAPSHOT (#4403)
nobodyiam Jun 9, 2022
cfa9333
add a config adjust the property source overriden behavior
shenhuaxin Jun 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ Changes by Version
==================
Release Notes.

Apollo 2.0.1
Apollo 2.1.0

------------------
* [Upgrade spring boot to fix search user issue](https://github.com/apolloconfig/apollo/pull/4366)
* [Fix search user duplication issue](https://github.com/apolloconfig/apollo/pull/4371)
* [Fix the npe issue for old version of gray release rules](https://github.com/apolloconfig/apollo/pull/4382)
* [Add a config adjust the property source overriden behavior](https://github.com/apolloconfig/apollo/pull/4377)

------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/12?closed=1)
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/11?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
List<AppNamespace> findFirst500ByIdGreaterThanOrderByIdAsc(long id);

@Modifying
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1")
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1 and IsDeleted = 0")
int batchDeleteByAppId(String appId, String operator);

@Modifying
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2")
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2 and IsDeleted = 0")
int delete(String appId, String namespaceName, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ List<Commit> findByAppIdAndClusterNameAndNamespaceNameAndDataChangeLastModifiedT
String appId, String clusterName, String namespaceName, Date dataChangeLastModifiedTime, Pageable pageable);

@Modifying
@Query("update Commit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3")
@Query("update Commit set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3 and IsDeleted = 0")
int batchDelete(String appId, String clusterName, String namespaceName, String operator);

List<Commit> findByAppIdAndClusterNameAndNamespaceNameAndChangeSetsLikeOrderByIdDesc(String appId, String clusterName, String namespaceName,String changeSets, Pageable page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {
Item findFirst1ByNamespaceIdOrderByLineNumDesc(Long namespaceId);

@Modifying
@Query("update Item set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 where namespaceId = ?1")
@Query("update Item set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 where namespaceId = ?1 and IsDeleted = 0")
int deleteByNamespaceId(long namespaceId, String operator);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface NamespaceRepository extends PagingAndSortingRepository<Namespac
Namespace findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName);

@Modifying
@Query("update Namespace set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 where appId=?1 and clusterName=?2")
@Query("update Namespace set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 where appId=?1 and clusterName=?2 and IsDeleted = 0")
int batchDelete(String appId, String clusterName, String operator);

List<Namespace> findByAppIdAndNamespaceNameOrderByIdAsc(String appId, String namespaceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Page<ReleaseHistory> findByAppIdAndClusterNameAndNamespaceNameOrderByIdDesc(Stri
Page<ReleaseHistory> findByReleaseIdAndOperationInOrderByIdDesc(long releaseId, Set<Integer> operations, Pageable pageable);

@Modifying
@Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3")
@Query("update ReleaseHistory set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3 and IsDeleted = 0")
int batchDelete(String appId, String clusterName, String namespaceName, String operator);

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Release findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderBy
List<Release> findByIdIn(Set<Long> releaseIds);

@Modifying
@Query("update Release set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3")
@Query("update Release set IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3 and IsDeleted = 0")
int batchDelete(String appId, String clusterName, String namespaceName, String operator);

// For release history conversion program, need to delete after conversion it done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.springframework.core.Ordered;
import org.springframework.core.env.CompositePropertySource;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.StandardEnvironment;

/**
* Initialize apollo system properties and inject the Apollo config in Spring Boot bootstrap phase
Expand Down Expand Up @@ -90,7 +91,8 @@ public class ApolloApplicationContextInitializer implements
ApolloClientSystemConsts.APOLLO_META,
ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE,
ApolloClientSystemConsts.APOLLO_PROPERTY_ORDER_ENABLE,
ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE};
ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE,
ApolloClientSystemConsts.APOLLO_OVERRIDE_SYSTEM_PROPERTIES};

private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector
.getInstance(ConfigPropertySourceFactory.class);
Expand Down Expand Up @@ -140,7 +142,12 @@ protected void initialize(ConfigurableEnvironment environment) {

composite.addPropertySource(configPropertySourceFactory.getConfigPropertySource(namespace, config));
}

if (!configUtil.isOverrideSystemProperties()) {
if (environment.getPropertySources().contains(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)) {
environment.getPropertySources().addAfter(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, composite);
return;
}
}
environment.getPropertySources().addFirst(composite);
}

Expand Down Expand Up @@ -215,4 +222,5 @@ public int getOrder() {
public void setOrder(int order) {
this.order = order;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigService;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
import com.ctrip.framework.apollo.spring.events.ApolloConfigChangeEvent;
import com.ctrip.framework.apollo.spring.util.SpringInjector;
import com.ctrip.framework.apollo.util.ConfigUtil;
Expand All @@ -40,11 +41,7 @@
import org.springframework.context.EnvironmentAware;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.env.CompositePropertySource;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.*;

/**
* Apollo Property Sources processor for Spring Annotation Based Application. <br /> <br />
Expand Down Expand Up @@ -110,12 +107,20 @@ private void initializePropertySources() {
if (environment.getPropertySources()
.contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME)) {

// ensure ApolloBootstrapPropertySources is still the first
ensureBootstrapPropertyPrecedence(environment);
if (configUtil.isOverrideSystemProperties()) {
// ensure ApolloBootstrapPropertySources is still the first
ensureBootstrapPropertyPrecedence(environment);
}

environment.getPropertySources()
.addAfter(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME, composite);
} else {
if (!configUtil.isOverrideSystemProperties()) {
if (environment.getPropertySources().contains(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)) {
environment.getPropertySources().addAfter(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, composite);
return;
}
}
environment.getPropertySources().addFirst(composite);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ConfigUtil {
private boolean propertiesOrdered = false;
private boolean propertyNamesCacheEnabled = false;
private boolean propertyFileCacheEnabled = true;
private boolean overrideSystemProperties = true;

public ConfigUtil() {
warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute
Expand All @@ -72,6 +73,7 @@ public ConfigUtil() {
initPropertiesOrdered();
initPropertyNamesCacheEnabled();
initPropertyFileCacheEnabled();
initOverrideSystemProperties();
}

/**
Expand Down Expand Up @@ -416,6 +418,10 @@ public boolean isPropertyFileCacheEnabled() {
return propertyFileCacheEnabled;
}

public boolean isOverrideSystemProperties() {
return overrideSystemProperties;
}

private void initPropertyNamesCacheEnabled() {
propertyNamesCacheEnabled = getPropertyBoolean(ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE,
ApolloClientSystemConsts.APOLLO_PROPERTY_NAMES_CACHE_ENABLE_ENVIRONMENT_VARIABLES,
Expand All @@ -428,6 +434,12 @@ private void initPropertyFileCacheEnabled() {
propertyFileCacheEnabled);
}

private void initOverrideSystemProperties() {
overrideSystemProperties = getPropertyBoolean(ApolloClientSystemConsts.APOLLO_OVERRIDE_SYSTEM_PROPERTIES,
ApolloClientSystemConsts.APOLLO_OVERRIDE_SYSTEM_PROPERTIES,
overrideSystemProperties);
}

private boolean getPropertyBoolean(String propertyName, String envName, boolean defaultVal) {
String enablePropertyNamesCache = System.getProperty(propertyName);
if (Strings.isNullOrEmpty(enablePropertyNamesCache)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
"description": "enable apollo initialization before logging system initialization.",
"defaultValue": false
},
{
"name": "apollo.override-system-properties",
"type": "java.lang.Boolean",
"sourceType": "com.ctrip.framework.apollo.util.ConfigUtil",
"description": "enable apollo server config override system properties.",
"defaultValue": true
},
{
"name": "apollo.cache-dir",
"type": "java.lang.String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
import org.junit.Test;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.StandardEnvironment;

import java.util.Properties;

public class ApolloApplicationContextInitializerTest {

Expand Down Expand Up @@ -143,4 +147,27 @@ public void testPropertyNamesCacheEnabled() {
assertTrue(propertySources.contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME));
assertTrue(propertySources.iterator().next() instanceof CachedCompositePropertySource);
}

@Test
public void testOverrideSystemProperties() {
Properties properties = new Properties();
properties.setProperty("server.port", "8080");
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);

MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(new PropertiesPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, properties));

when(environment.getPropertySources()).thenReturn(propertySources);
when(environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_NAMESPACES,
ConfigConsts.NAMESPACE_APPLICATION)).thenReturn("");
ConfigUtil configUtil = new ConfigUtil();
configUtil = spy(configUtil);
when(configUtil.isOverrideSystemProperties()).thenReturn(false);
MockInjector.setInstance(ConfigUtil.class, configUtil);

apolloApplicationContextInitializer.initialize(environment);

assertTrue(propertySources.contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME));
assertEquals(propertySources.iterator().next().getName(), StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,29 @@
*/
package com.ctrip.framework.apollo.spring.config;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.build.MockInjector;
import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.AbstractSpringIntegrationTest;
import com.ctrip.framework.apollo.spring.events.ApolloConfigChangeEvent;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.google.common.collect.Lists;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.env.CompositePropertySource;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.*;

import java.util.Properties;

public class PropertySourcesProcessorTest extends AbstractSpringIntegrationTest {

Expand Down Expand Up @@ -122,4 +124,31 @@ public void testApplicationEvent() {
ApolloConfigChangeEvent event = eventCaptor.getValue();
assertSame(someConfigChangeEvent, event.getConfigChangeEvent());
}


@Test
public void testOverrideSystemProperties() {
Properties properties = new Properties();
properties.setProperty("server.port", "8080");
properties.setProperty(ApolloClientSystemConsts.APOLLO_OVERRIDE_SYSTEM_PROPERTIES, "false");
ConfigurableEnvironment environment = mock(ConfigurableEnvironment.class);

MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(new PropertiesPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, properties));

when(environment.getPropertySources()).thenReturn(propertySources);
when(environment.getProperty(PropertySourcesConstants.APOLLO_BOOTSTRAP_NAMESPACES,
ConfigConsts.NAMESPACE_APPLICATION)).thenReturn("");

ConfigUtil configUtil = new ConfigUtil();
configUtil = spy(configUtil);
when(configUtil.isOverrideSystemProperties()).thenReturn(false);
MockInjector.setInstance(ConfigUtil.class, configUtil);

processor.setEnvironment(environment);
processor.postProcessBeanFactory(beanFactory);

assertTrue(propertySources.contains(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME));
assertEquals(propertySources.iterator().next().getName(), StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,9 @@ public class ApolloClientSystemConsts {
* enable property names cache environment variables
*/
public static final String APOLLO_CACHE_FILE_ENABLE_ENVIRONMENT_VARIABLES = "APOLLO_CACHE_FILE_ENABLE";

/**
* enable apollo overrideSystemProperties
*/
public static final String APOLLO_OVERRIDE_SYSTEM_PROPERTIES = "apollo.override-system-properties";
}
5 changes: 3 additions & 2 deletions apollo-mockserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@

<properties>
<github.path>${project.artifactId}</github.path>
<okhttp3.version>4.9.3</okhttp3.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>3.11.0</version>
<version>${okhttp3.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.11.0</version>
<version>${okhttp3.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public interface ConsumerRoleRepository extends PagingAndSortingRepository<Consu
ConsumerRole findByConsumerIdAndRoleId(long consumerId, long roleId);

@Modifying
@Query("UPDATE ConsumerRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1")
@Query("UPDATE ConsumerRole SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE RoleId in ?1 and IsDeleted = 0")
Integer batchDeleteByRoleIds(List<Long> roleIds, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
List<AppNamespace> findByAppId(String appId);

@Modifying
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy=?2 WHERE AppId=?1")
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy=?2 WHERE AppId=?1 and IsDeleted = 0")
int batchDeleteByAppId(String appId, String operator);

@Modifying
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2")
@Query("UPDATE AppNamespace SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?3 WHERE AppId=?1 and Name = ?2 and IsDeleted = 0")
int delete(String appId, String namespaceName, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public interface AppRepository extends PagingAndSortingRepository<App, Long> {
Page<App> findByAppIdContainingOrNameContaining(String appId, String name, Pageable pageable);

@Modifying
@Query("UPDATE App SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1")
@Query("UPDATE App SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1 and IsDeleted = 0")
int deleteApp(String appId, String operator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite,
Favorite findByUserIdAndAppId(String userId, String appId);

@Modifying
@Query("UPDATE Favorite SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1")
@Query("UPDATE Favorite SET IsDeleted = 1, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000), DataChange_LastModifiedBy = ?2 WHERE AppId=?1 and IsDeleted = 0")
int batchDeleteByAppId(String appId, String operator);
}
Loading