-
Notifications
You must be signed in to change notification settings - Fork 42
feat:permission control for application #84
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8cd05e1
feat:permission control for application
7a9ece1
Merge branch 'main' into feat_permission
wildeslam 44eae58
feat:permission control for application
52a1f22
Merge remote-tracking branch 'origin/feat_permission' into feat_permi…
41f1f40
feat:permission control for application
d9e3652
feat:permission control for application
1ee7c23
feat:permission control for application
c143c4f
feat:permission control for application
9686335
feat:permission control for application
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
arex-storage-config/src/main/java/com/arextest/config/model/vo/AddApplicationRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.arextest.config.model.vo; | ||
|
||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author wildeslam. | ||
* @create 2023/9/15 14:21 | ||
*/ | ||
@Data | ||
public class AddApplicationRequest { | ||
@NotNull | ||
private String appName; | ||
@NotEmpty | ||
private Set<String> owners; | ||
} |
14 changes: 14 additions & 0 deletions
14
arex-storage-config/src/main/java/com/arextest/config/model/vo/AddApplicationResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.arextest.config.model.vo; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* @author wildeslam. | ||
* @create 2023/9/15 14:31 | ||
*/ | ||
@Data | ||
public class AddApplicationResponse { | ||
private Boolean success; | ||
private String msg; | ||
private String appId; | ||
} |
4 changes: 2 additions & 2 deletions
4
...ge-config/src/main/java/com/arextest/config/model/vo/AgentRemoteConfigurationRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
arex-storage-config/src/main/java/com/arextest/config/model/vo/UpdateApplicationRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.arextest.config.model.vo; | ||
|
||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author wildeslam. | ||
* @create 2023/9/19 11:21 | ||
*/ | ||
@Data | ||
public class UpdateApplicationRequest { | ||
@NotNull | ||
private String appId; | ||
private String appName; | ||
private Set<String> owners; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...storage-web-api/src/main/java/com/arextest/storage/service/config/ApplicationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.arextest.storage.service.config; | ||
|
||
import com.arextest.config.model.dto.StatusType; | ||
import com.arextest.config.model.dto.application.ApplicationConfiguration; | ||
import com.arextest.config.model.vo.AddApplicationRequest; | ||
import com.arextest.config.model.vo.AddApplicationResponse; | ||
import com.arextest.config.model.vo.UpdateApplicationRequest; | ||
import com.arextest.config.repository.impl.ApplicationConfigurationRepositoryImpl; | ||
import com.arextest.storage.utils.RandomUtils; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author wildeslam. | ||
* @create 2023/9/15 14:37 | ||
*/ | ||
@Component | ||
public class ApplicationService { | ||
|
||
@Autowired | ||
private ApplicationConfigurationRepositoryImpl applicationConfigurationRepository; | ||
|
||
public AddApplicationResponse addApplication(AddApplicationRequest request) { | ||
AddApplicationResponse response = new AddApplicationResponse(); | ||
|
||
ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration(); | ||
applicationConfiguration.setAppName(request.getAppName()); | ||
applicationConfiguration.setAgentVersion(StringUtils.EMPTY); | ||
applicationConfiguration.setAgentExtVersion(StringUtils.EMPTY); | ||
applicationConfiguration.setRecordedCaseCount(0); | ||
applicationConfiguration.setStatus(StatusType.RECORD.getMask() | StatusType.REPLAY.getMask()); | ||
applicationConfiguration.setOwners(request.getOwners()); | ||
|
||
applicationConfiguration.setOrganizationName("unknown organization name"); | ||
applicationConfiguration.setGroupName("unknown group name"); | ||
applicationConfiguration.setGroupId("unknown group id"); | ||
applicationConfiguration.setOrganizationId("unknown organization id"); | ||
applicationConfiguration.setDescription("unknown description"); | ||
applicationConfiguration.setCategory("unknown category"); | ||
|
||
String appId = RandomUtils.generateRandomId(request.getAppName()); | ||
applicationConfiguration.setAppId(appId); | ||
|
||
boolean success = applicationConfigurationRepository.insert(applicationConfiguration); | ||
response.setAppId(appId); | ||
response.setSuccess(success); | ||
return response; | ||
} | ||
|
||
public boolean modifyApplication(UpdateApplicationRequest request) { | ||
List<ApplicationConfiguration> applicationConfigurationList = | ||
applicationConfigurationRepository.listBy(request.getAppId()); | ||
if (CollectionUtils.isEmpty(applicationConfigurationList)) { | ||
return false; | ||
} | ||
ApplicationConfiguration applicationConfiguration = applicationConfigurationList.get(0); | ||
if (request.getAppName() != null) { | ||
applicationConfiguration.setAppName(request.getAppName()); | ||
} | ||
if (request.getOwners() != null) { | ||
applicationConfiguration.setOwners(request.getOwners()); | ||
} | ||
return applicationConfigurationRepository.update(applicationConfiguration); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
arex-storage-web-api/src/main/java/com/arextest/storage/utils/RandomUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.arextest.storage.utils; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.security.MessageDigest; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.SecureRandom; | ||
|
||
/** | ||
* @author wildeslam. | ||
* @create 2023/9/15 14:38 | ||
*/ | ||
@Slf4j | ||
public class RandomUtils { | ||
private static final int ID_LENGTH = 16; | ||
private static final SecureRandom RANDOM = new SecureRandom(); | ||
|
||
public static String generateRandomId(String identifier) { | ||
String sourceString = System.currentTimeMillis() + "-" + RANDOM.nextInt() + "-" + identifier; | ||
try { | ||
MessageDigest md = MessageDigest.getInstance("SHA-512"); | ||
byte[] bytes = md.digest((sourceString).getBytes()); | ||
StringBuilder sb = new StringBuilder(); | ||
for (byte b : bytes) { | ||
String hexString = Integer.toHexString(b & 0xff); | ||
sb.append(hexString); | ||
} | ||
return sb.substring(0, ID_LENGTH); | ||
} catch (NoSuchAlgorithmException e) { | ||
LOGGER.error("generateRandomId error", e); | ||
return null; | ||
} | ||
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.