-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the logic about ScriptContent
- Loading branch information
rchen9
committed
Nov 18, 2024
1 parent
51eaddb
commit d59b51d
Showing
15 changed files
with
320 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
|
@@ -106,5 +106,4 @@ private List<PageQueryComparisonResponseType.ScriptInfo> contractFromDto( | |
} | ||
return result; | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...ain/java/com/arextest/web/core/business/config/replay/ComparisonScriptContentHandler.java
This file contains 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,31 @@ | ||
package com.arextest.web.core.business.config.replay; | ||
|
||
import com.arextest.web.core.repository.mongo.ComparisonScriptContentRepository; | ||
import com.arextest.web.model.contract.contracts.config.replay.ComparisonScriptContentRequestType; | ||
import com.arextest.web.model.dto.config.ComparisonScriptContent; | ||
import com.arextest.web.model.mapper.ConfigComparisonScriptContentMapper; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class ComparisonScriptContentHandler { | ||
|
||
|
||
private final ComparisonScriptContentRepository comparisonScriptContentRepository; | ||
|
||
public List<ComparisonScriptContent> queryScriptMethodNames() { | ||
return comparisonScriptContentRepository.queryScriptMethodNames(); | ||
} | ||
|
||
public boolean saveScriptContent(ComparisonScriptContentRequestType request) { | ||
ComparisonScriptContent dto = | ||
ConfigComparisonScriptContentMapper.INSTANCE.dtoFromContract(request); | ||
return comparisonScriptContentRepository.save(dto); | ||
} | ||
|
||
public List<ComparisonScriptContent> queryAll() { | ||
return comparisonScriptContentRepository.queryAll(); | ||
} | ||
} |
This file contains 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
56 changes: 56 additions & 0 deletions
56
...c/main/java/com/arextest/web/core/repository/mongo/ComparisonScriptContentRepository.java
This file contains 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,56 @@ | ||
package com.arextest.web.core.repository.mongo; | ||
|
||
import com.arextest.web.model.dao.mongodb.ComparisonScriptContentCollection; | ||
import com.arextest.web.model.dao.mongodb.ComparisonScriptContentCollection.Fields; | ||
import com.arextest.web.model.dto.config.ComparisonScriptContent; | ||
import com.arextest.web.model.mapper.ConfigComparisonScriptContentMapper; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.springframework.data.mongodb.core.MongoTemplate; | ||
import org.springframework.data.mongodb.core.query.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class ComparisonScriptContentRepository { | ||
|
||
private final MongoTemplate mongoTemplate; | ||
|
||
|
||
public List<ComparisonScriptContent> queryScriptMethodNames() { | ||
Query query = new Query(); | ||
query.fields().exclude(Fields.content); | ||
List<ComparisonScriptContentCollection> daos = mongoTemplate.find(query, | ||
ComparisonScriptContentCollection.class); | ||
|
||
if (CollectionUtils.isNotEmpty(daos)) { | ||
return daos.stream() | ||
.map(ConfigComparisonScriptContentMapper.INSTANCE::dtoFromDao) | ||
.collect(Collectors.toList()); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
public boolean save(ComparisonScriptContent dto) { | ||
ComparisonScriptContentCollection dao = | ||
ConfigComparisonScriptContentMapper.INSTANCE.daoFromDto(dto); | ||
mongoTemplate.save(dao); | ||
return true; | ||
} | ||
|
||
public List<ComparisonScriptContent> queryAll() { | ||
List<ComparisonScriptContentCollection> daos = mongoTemplate.findAll( | ||
ComparisonScriptContentCollection.class); | ||
|
||
if (CollectionUtils.isNotEmpty(daos)) { | ||
return daos.stream() | ||
.map(ConfigComparisonScriptContentMapper.INSTANCE::dtoFromDao) | ||
.collect(Collectors.toList()); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
This file contains 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
14 changes: 14 additions & 0 deletions
14
...extest/web/model/contract/contracts/config/replay/ComparisonScriptContentRequestType.java
This file contains 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.web.model.contract.contracts.config.replay; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class ComparisonScriptContentRequestType { | ||
|
||
private String id; | ||
|
||
private String aliasName; | ||
|
||
private String content; | ||
|
||
} |
This file contains 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.