-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 修改流水线脚本的保存位置 * 修改代码生成器的编译部署流水线 * 解决代码生成器生成的Vo的版本号错误的BUG
- Loading branch information
1 parent
b0e0cab
commit f76d46a
Showing
16 changed files
with
607 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
pipeline { | ||
agent { | ||
docker { | ||
image 'maven:3.9.5-eclipse-temurin-17-alpine' | ||
args '-v /root/.m2:/root/.m2' | ||
} | ||
} | ||
stages { | ||
stage('编译打包') { | ||
steps { | ||
sh '''mvn clean install -pl qing-codegen-plugin/qing-codegen-apt -am -f pom.xml''' | ||
} | ||
} | ||
stage('代码生成器单元测试') { | ||
steps { | ||
sh '''echo 清理工作空间''' | ||
sh '''mvn clean -pl qing-codegen-plugin/qing-codegen-samples -f pom.xml''' | ||
sh '''echo 开始测试''' | ||
sh '''mvn clean test -pl qing-codegen-plugin/qing-codegen-samples -f pom.xml''' | ||
} | ||
post { | ||
always { | ||
// 收集测试报告 | ||
junit 'qing-codegen-plugin/qing-codegen-samples/target/surefire-reports/*.xml' | ||
} | ||
} | ||
} | ||
stage('代码生成器示例项目单元测试') { | ||
steps { | ||
sh '''mvn clean test -pl qing-codegen-plugin/qing-codegen-samples -f pom.xml''' | ||
} | ||
post { | ||
always { | ||
// 收集测试报告 | ||
junit 'qing-codegen-plugin/qing-codegen-samples/target/surefire-reports/*.xml' | ||
} | ||
} | ||
} | ||
} | ||
} |
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
100 changes: 100 additions & 0 deletions
100
...main/java/cn/chenyunlong/qing/samples/codegen/domain/controller/TestDomainController.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,100 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.controller; | ||
|
||
import cn.chenyunlong.common.constants.CodeEnum; | ||
import cn.chenyunlong.common.model.JsonResult; | ||
import cn.chenyunlong.common.model.PageRequestWrapper; | ||
import cn.chenyunlong.common.model.PageResult; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.creator.TestDomainCreator; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.query.TestDomainQuery; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.request.TestDomainCreateRequest; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.request.TestDomainQueryRequest; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.request.TestDomainUpdateRequest; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.response.TestDomainResponse; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.updater.TestDomainUpdater; | ||
import cn.chenyunlong.qing.samples.codegen.domain.dto.vo.TestDomainVO; | ||
import cn.chenyunlong.qing.samples.codegen.domain.mapper.TestDomainMapper; | ||
import cn.chenyunlong.qing.samples.codegen.domain.service.ITestDomainService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequestMapping("api/v1/test-domain") | ||
@RequiredArgsConstructor | ||
public class TestDomainController { | ||
private final ITestDomainService testDomainService; | ||
|
||
/** | ||
* createRequest | ||
*/ | ||
@PostMapping | ||
public JsonResult<Long> createTestDomain(@RequestBody TestDomainCreateRequest request) { | ||
TestDomainCreator creator = TestDomainMapper.INSTANCE.request2Dto(request); | ||
return JsonResult.success(testDomainService.createTestDomain(creator)); | ||
} | ||
|
||
/** | ||
* update request | ||
*/ | ||
@PostMapping("updateTestDomain") | ||
public JsonResult<String> updateTestDomain(@RequestBody TestDomainUpdateRequest request) { | ||
TestDomainUpdater updater = TestDomainMapper.INSTANCE.request2Updater(request); | ||
testDomainService.updateTestDomain(updater); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* valid | ||
*/ | ||
@PostMapping("valid/{id}") | ||
public JsonResult<String> validTestDomain(@PathVariable Long id) { | ||
testDomainService.validTestDomain(id); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* invalid | ||
*/ | ||
@PostMapping("invalid/{id}") | ||
public JsonResult<String> invalidTestDomain(@PathVariable Long id) { | ||
testDomainService.invalidTestDomain(id); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* findById | ||
*/ | ||
@GetMapping("findById/{id}") | ||
public JsonResult<TestDomainResponse> findById(@PathVariable Long id) { | ||
TestDomainVO vo = testDomainService.findById(id); | ||
TestDomainResponse response = TestDomainMapper.INSTANCE.vo2CustomResponse(vo); | ||
return JsonResult.success(response); | ||
} | ||
|
||
/** | ||
* findByPage request | ||
*/ | ||
@PostMapping("page") | ||
public JsonResult<PageResult<TestDomainResponse>> page( | ||
@RequestBody PageRequestWrapper<TestDomainQueryRequest> request) { | ||
PageRequestWrapper<TestDomainQuery> wrapper = new PageRequestWrapper<>(); | ||
wrapper.setBean(TestDomainMapper.INSTANCE.request2Query(request.getBean())); | ||
wrapper.setSorts(request.getSorts()); | ||
wrapper.setPageSize(request.getPageSize()); | ||
wrapper.setPage(request.getPage()); | ||
Page<TestDomainVO> page = testDomainService.findByPage(wrapper); | ||
return JsonResult.success( | ||
PageResult.of( | ||
page.getContent().stream() | ||
.map(TestDomainMapper.INSTANCE::vo2CustomResponse) | ||
.collect(Collectors.toList()), | ||
page.getTotalElements(), | ||
page.getSize(), | ||
page.getNumber()) | ||
); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...c/main/java/cn/chenyunlong/qing/samples/codegen/domain/dto/creator/TestDomainCreator.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,20 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.dto.creator; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class TestDomainCreator { | ||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
} |
9 changes: 9 additions & 0 deletions
9
...s/src/main/java/cn/chenyunlong/qing/samples/codegen/domain/dto/query/TestDomainQuery.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,9 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.dto.query; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class TestDomainQuery { | ||
} |
21 changes: 21 additions & 0 deletions
21
.../java/cn/chenyunlong/qing/samples/codegen/domain/dto/request/TestDomainCreateRequest.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,21 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.dto.request; | ||
|
||
import cn.chenyunlong.common.model.Request; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class TestDomainCreateRequest implements Request { | ||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/java/cn/chenyunlong/qing/samples/codegen/domain/dto/request/TestDomainQueryRequest.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,10 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.dto.request; | ||
|
||
import cn.chenyunlong.common.model.Request; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class TestDomainQueryRequest implements Request { | ||
} |
31 changes: 31 additions & 0 deletions
31
.../java/cn/chenyunlong/qing/samples/codegen/domain/dto/request/TestDomainUpdateRequest.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 cn.chenyunlong.qing.samples.codegen.domain.dto.request; | ||
|
||
import cn.chenyunlong.common.model.Request; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class TestDomainUpdateRequest implements Request { | ||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
|
||
private Long id; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...main/java/cn/chenyunlong/qing/samples/codegen/domain/dto/response/TestDomainResponse.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,25 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.dto.response; | ||
|
||
import cn.chenyunlong.common.model.AbstractJpaResponse; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@Schema | ||
@EqualsAndHashCode( | ||
callSuper = true | ||
) | ||
public class TestDomainResponse extends AbstractJpaResponse { | ||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
} |
38 changes: 38 additions & 0 deletions
38
...c/main/java/cn/chenyunlong/qing/samples/codegen/domain/dto/updater/TestDomainUpdater.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,38 @@ | ||
package cn.chenyunlong.qing.samples.codegen.domain.dto.updater; | ||
|
||
import cn.chenyunlong.qing.samples.codegen.domain.TestDomain; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
import java.util.Optional; | ||
|
||
@Schema | ||
@Data | ||
public class TestDomainUpdater { | ||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
|
||
private Long id; | ||
|
||
public void updateTestDomain(TestDomain param) { | ||
Optional.ofNullable(getUsername()).ifPresent(param::setUsername); | ||
Optional.ofNullable(getPassword()).ifPresent(param::setPassword); | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
} |
Oops, something went wrong.