Skip to content

Commit

Permalink
修改流水线
Browse files Browse the repository at this point in the history
  • Loading branch information
YunlongChen committed Jan 2, 2024
1 parent d6d0aaf commit 2288430
Show file tree
Hide file tree
Showing 17 changed files with 568 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .workflow/agents/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM jenkins/inbound-agent:alpine as jnlp

FROM maven:3.8.3-openjdk-17-slim

RUN apt-get update && \
apt-get install -y \
git \
libfontconfig1 \
libfreetype6

COPY --from=jnlp /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-agent
COPY --from=jnlp /usr/share/jenkins/agent.jar /usr/share/jenkins/agent.jar

USER root

ENTRYPOINT ["/usr/local/bin/jenkins-agent"]
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,22 @@
</plugins>
</pluginManagement>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>oss</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 代码风格-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
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())
);
}
}
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;
}
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 {
}
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;
}
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 {
}
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;
}
}
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;
}
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cn.chenyunlong.qing.samples.codegen.domain.dto.vo;

import cn.chenyunlong.common.model.AbstractBaseJpaVo;
import cn.chenyunlong.qing.samples.codegen.domain.TestDomain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Schema
@Data
@EqualsAndHashCode(
callSuper = true
)
@NoArgsConstructor(
access = AccessLevel.PROTECTED
)
public class TestDomainVO extends AbstractBaseJpaVo {
@Schema(
title = "username",
description = "username"
)
private String username;

@Schema(
title = "password",
description = "password"
)
private String password;

public TestDomainVO(TestDomain source) {
super();
this.setId(source.getId());
this.setCreatedAt(source.getCreatedAt());
this.setUpdatedAt(source.getCreatedAt());
this.setVersion(source.getVersion());
this.setUsername(source.getUsername());
this.setPassword(source.getPassword());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cn.chenyunlong.qing.samples.codegen.domain.mapper;

import cn.chenyunlong.qing.samples.codegen.domain.TestDomain;
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.hutool.core.bean.BeanUtil;

public interface TestDomainMapper {
TestDomainMapper INSTANCE = new TestDomainMapper() {
};

default TestDomain dtoToEntity(TestDomainCreator dto) {
return BeanUtil.copyProperties(dto, TestDomain.class);
}

default TestDomainUpdater request2Updater(TestDomainUpdateRequest request) {
return BeanUtil.copyProperties(request, TestDomainUpdater.class);
}

default TestDomainCreator request2Dto(TestDomainCreateRequest request) {
return BeanUtil.copyProperties(request, TestDomainCreator.class);
}

default TestDomainQuery request2Query(TestDomainQueryRequest request) {
return BeanUtil.copyProperties(request, TestDomainQuery.class);
}

default TestDomainResponse vo2Response(TestDomainVO vo) {
return BeanUtil.copyProperties(vo, TestDomainResponse.class);
}

default TestDomainResponse vo2CustomResponse(TestDomainVO vo) {
return vo2Response(vo);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cn.chenyunlong.qing.samples.codegen.domain.repository;

import cn.chenyunlong.jpa.support.BaseRepository;
import cn.chenyunlong.qing.samples.codegen.domain.TestDomain;

public interface TestDomainRepository extends BaseRepository<TestDomain, Long> {
}
Loading

0 comments on commit 2288430

Please sign in to comment.