Skip to content

Commit

Permalink
Merge pull request #56 from zhaoyiqing97/main
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
zhaoyiqing97 authored Aug 22, 2022
2 parents 7cfeb6f + ad0ed29 commit aca250f
Show file tree
Hide file tree
Showing 138 changed files with 706,523 additions and 1,119 deletions.
14 changes: 0 additions & 14 deletions .github/dependabot.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/codiga.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "codiga"
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
jobs:
check-quality:
runs-on: ubuntu-latest
name: Codiga Check
steps:
- name: Check code meets quality standards
id: codiga
uses: codiga/github-action@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
codiga_api_token: ${{ secrets.CODIGA_API_TOKEN }}
min_quality_grade: 'WARNING'
min_quality_score: '50'
max_defects_rate: '0.2'
max_complex_functions_rate: '0.0001'
max_long_functions_rate: '0.0001'
project_name: 'github-action-example'
max_timeout_sec: '600'
73 changes: 73 additions & 0 deletions .github/workflows/elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: elasticsearch image

on:
workflow_dispatch:
inputs:
version:
description: The version of the Docker image to use.
type: string
required: true
default: 1.0.0

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: big_three/elasticsearch
USER_NAME: zhaoyiqing97
CONTEXT: ops/build/elasticsearch

jobs:

docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install cosign
uses: sigstore/[email protected]

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=moby/buildkit:buildx-stable-1

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USER_NAME }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
type=semver,pattern={{version}},value=1.0.0
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
context: ${{env.CONTEXT}}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Sign the published Docker image
env:
COSIGN_EXPERIMENTAL: 1
run: cosign sign ${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_NAME }}:${{ steps.build-and-push.outputs.tags }}
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

strategy:
matrix:
java-version: [8]
java-version: [ 8 ]

steps:
- name: Checkout repository
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Build with Maven
run: |
mvn -v
mvn clean install --file backend/pom.xml
mvn clean install --file backend/pom.xml -DskipTests
mkdir ${{env.CONTEXT}}/target/extracted
java -Djarmode=layertools -jar ${{env.CONTEXT}}/target/*.jar extract --destination ${{env.CONTEXT}}/target/extracted
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*.lock

# Package Files #
*.jar
target/*.jar
*.war
*.ear
target/
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@

## docker 部署

### 部署
### prod-部署

```shell
cd ops/docker/prod
docker compose up -d
```

### dev-部署

```shell
cd ops/docker/dev
build-backend.sh
build-frontend.sh
docker compose up -d
```

### 更新

```shell
Expand Down
6 changes: 5 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM openjdk:8-jre-alpine

RUN apk --update --no-cache add curl jq
HEALTHCHECK --start-period=20s CMD curl -s http://localhost:8080/backend/actuator/health | jq ".status" | grep UP || exit 1

# settings timezone
ENV TZ Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Expand All @@ -7,7 +11,7 @@ RUN mkdir /logs && chown spring:spring /logs
RUN mkdir /app && chown spring:spring /app
USER spring:spring

WORKDIR app
WORKDIR /app
COPY ./target/extracted/dependencies/ ./
COPY ./target/extracted/spring-boot-loader/ ./
COPY ./target/extracted/snapshot-dependencies/ ./
Expand Down
52 changes: 39 additions & 13 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<version>1.0-SNAPSHOT</version>

<properties>
<mybatis-verison>2.2.0</mybatis-verison>
<mysql-connector-verison>8.0.28</mysql-connector-verison>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
Expand All @@ -17,6 +19,7 @@
<relativePath/>
</parent>
<dependencies>
<!--boot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand All @@ -38,39 +41,62 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--data-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-verison}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>8.0.28</version>
<version>${mysql-connector-verison}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!--utils-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<!-- security -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>${mybatis-verison}</version>
<scope>test</scope>
</dependency>


</dependencies>
<build>
Expand Down
10 changes: 6 additions & 4 deletions backend/src/main/java/generator/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

/**
* @author zyq
*/
@SpringBootApplication
@MapperScan("generator.mapper")
@EnableElasticsearchRepositories
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
System.out.println("三巨头,永无BUG!");
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
System.out.println("三巨头,永无BUG!");
}
}
61 changes: 61 additions & 0 deletions backend/src/main/java/generator/config/BeanConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package generator.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import generator.constant.CommonConstant;

/**
* BeanConfig.
*
* @author 刘斌
* @version 0.0.1
* @serial 2022-08-16 : base version.
*/
@Configuration
public class BeanConfig {
/**
* jackSon 的 ObjectMapper
*
* @return ObjectMapper
*/
@Bean
public ObjectMapper objectMapper() {
// 序列化设置
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setTimeZone(TimeZone.getDefault());
// 序列换成json时,将所有的long变成string
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
// 日期序列化设置
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(Date.class, new DateSerializer(false, new SimpleDateFormat(CommonConstant.DATE_TIME_FORMATTER_STRING)));
objectMapper.registerModule(simpleModule).registerModule(javaTimeModule);

return objectMapper;
}

/**
* 国际化
*
* @return 对象
*/
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:org/springframework/security/messages_zh_CN");
return messageSource;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package generator.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;

/**
* ElasticsearchConfiguration.
*
* @author 刘斌
* @version 0.0.1
* @serial 2022-08-18 : base version.
*/
public class ElasticsearchConfiguration extends AbstractElasticsearchConfiguration {
@Override
@Bean
public RestHighLevelClient elasticsearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("localhost:9200")
.build();

return RestClients.create(clientConfiguration).rest();
}
}
6 changes: 4 additions & 2 deletions backend/src/main/java/generator/config/ProjectSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@ConfigurationProperties("big-three")
@Data
public class ProjectSetting {
/** 允许跨域的域名 */
private String[] corsMappings;
/**
* 允许跨域的域名
*/
private String[] corsMappings;
}
Loading

0 comments on commit aca250f

Please sign in to comment.