Skip to content

Commit

Permalink
perf($maf-mis): DDD modularized microservice
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Feb 3, 2022
1 parent c207cc5 commit 4a827f4
Show file tree
Hide file tree
Showing 38 changed files with 463 additions and 578 deletions.
24 changes: 24 additions & 0 deletions maf-mis/maf-mis-biz/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<!-- Sub-module Basics -->
<artifactId>maf-mis-biz</artifactId>
<name>Muscle and Fitness Server :: MAF MIS - Biz</name>
<description>Exercise Management Information Service.</description>
<parent>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>maf-mis</artifactId>
<version>0.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>maf-mis-domain</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import cn.hutool.core.bean.BeanUtil;
import com.jmsoftware.maf.common.bean.ResponseBodyBean;
import com.jmsoftware.maf.mafmis.exercise.domain.ExercisePo;
import com.jmsoftware.maf.mafmis.exercise.domain.GetPageListPayload;
import com.jmsoftware.maf.mafmis.exercise.persistence.Exercise;
import com.jmsoftware.maf.mafmis.exercise.payload.GetPageListPayload;
import com.jmsoftware.maf.mafmis.exercise.service.ExerciseService;
import lombok.RequiredArgsConstructor;
import lombok.val;
Expand All @@ -29,13 +29,13 @@ public class ExerciseController {
private final ExerciseService exerciseService;

@GetMapping("/get-by-id")
public ResponseBodyBean<ExercisePo> selectOne(Long id) {
public ResponseBodyBean<Exercise> selectOne(Long id) {
return ResponseBodyBean.ofSuccess(this.exerciseService.queryById(id));
}

@GetMapping("/get-page-list")
public ResponseBodyBean<List<ExercisePo>> getPageList(@Valid GetPageListPayload payload) {
val exercisePo = new ExercisePo();
public ResponseBodyBean<List<Exercise>> getPageList(@Valid GetPageListPayload payload) {
val exercisePo = new Exercise();
BeanUtil.copyProperties(payload, exercisePo);
return ResponseBodyBean.ofSuccess(this.exerciseService.getPageList(exercisePo));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.jmsoftware.maf.mafmis.exercise.service;

import com.jmsoftware.maf.mafmis.exercise.domain.ExercisePo;
import com.jmsoftware.maf.mafmis.exercise.persistence.Exercise;

import java.util.List;

Expand All @@ -19,31 +19,31 @@ public interface ExerciseService {
* @param id the id
* @return the exercise po
*/
ExercisePo queryById(Long id);
Exercise queryById(Long id);

/**
* Gets page list.
*
* @param exercisePo the exercise po
* @return the page list
*/
List<ExercisePo> getPageList(ExercisePo exercisePo);
List<Exercise> getPageList(Exercise exercisePo);

/**
* Insert exercise po.
*
* @param exercisePo the exercise po
* @return the exercise po
*/
ExercisePo insert(ExercisePo exercisePo);
Exercise insert(Exercise exercisePo);

/**
* Update exercise po.
*
* @param exercisePo the exercise po
* @return the exercise po
*/
ExercisePo update(ExercisePo exercisePo);
Exercise update(Exercise exercisePo);

/**
* Delete by id boolean.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jmsoftware.maf.common.exception.BizException;
import com.jmsoftware.maf.mafmis.exercise.domain.ExercisePo;
import com.jmsoftware.maf.mafmis.exercise.persistence.Exercise;
import com.jmsoftware.maf.mafmis.exercise.mapper.ExerciseMapper;
import com.jmsoftware.maf.mafmis.exercise.service.ExerciseService;
import lombok.RequiredArgsConstructor;
Expand All @@ -29,29 +29,29 @@ public class ExerciseServiceImpl implements ExerciseService {

@Override
@SneakyThrows
public ExercisePo queryById(Long id) {
public Exercise queryById(Long id) {
if (ObjectUtil.isNull(id)) {
throw new BizException("Cannot execute the query! Cause: the ID is null.");
}
return this.exerciseMapper.selectById(id);
}

@Override
public List<ExercisePo> getPageList(ExercisePo exercisePo) {
var page = new Page<ExercisePo>(exercisePo.getCurrentPage(), exercisePo.getPageSize());
public List<Exercise> getPageList(Exercise exercisePo) {
var page = new Page<Exercise>(exercisePo.getCurrentPage(), exercisePo.getPageSize());
this.exerciseMapper.selectAll(exercisePo, page);
log.info("Total pages: {}", page.getPages());
return page.getRecords();
}

@Override
public ExercisePo insert(ExercisePo exercisePo) {
public Exercise insert(Exercise exercisePo) {
this.exerciseMapper.insert(exercisePo);
return exercisePo;
}

@Override
public ExercisePo update(ExercisePo exercisePo) {
public Exercise update(Exercise exercisePo) {
this.exerciseMapper.update(exercisePo);
return this.queryById(exercisePo.getId());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.jmsoftware.maf.mafmis;
185 changes: 185 additions & 0 deletions maf-mis/maf-mis-bootstrap/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<!-- Sub-module Basics -->
<artifactId>maf-mis-bootstrap</artifactId>
<name>Muscle and Fitness Server :: MAF MIS - Bootstrap</name>
<description>Exercise Management Information Service.</description>
<parent>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>maf-mis</artifactId>
<version>0.0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<!-- Build Settings -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<phase>compile</phase>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<configuration>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<targetJdk>${java.version}</targetJdk>
<printFailingErrors>true</printFailingErrors>
<rulesets>
<ruleset>rulesets/java/ali-comment.xml</ruleset>
<ruleset>rulesets/java/ali-concurrent.xml</ruleset>
<ruleset>rulesets/java/ali-constant.xml</ruleset>
<ruleset>rulesets/java/ali-exception.xml</ruleset>
<ruleset>rulesets/java/ali-flowcontrol.xml</ruleset>
<ruleset>rulesets/java/ali-naming.xml</ruleset>
<ruleset>rulesets/java/ali-oop.xml</ruleset>
<ruleset>rulesets/java/ali-orm.xml</ruleset>
<ruleset>rulesets/java/ali-other.xml</ruleset>
<ruleset>rulesets/java/ali-set.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.alibaba.p3c</groupId>
<artifactId>p3c-pmd</artifactId>
<version>${p3c-pmd.version}</version>
</dependency>
</dependencies>
</plugin>

<!-- https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-spring-boot-extension-maven</artifactId>
<version>${jib-spring-boot-extension-maven.version}</version>
</dependency>
</dependencies>
<executions>
<!-- Bind `jib:dockerBuild` to a Maven lifecycle `verify`. Jib will build your image directly to a Docker daemon.
<execution>
<id>buildDockerImagePhase</id>
<phase>verify</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution> -->
<!-- Bind `jib:build` to a Maven lifecycle `install`. Jib will build and push image to image registry. -->
<execution>
<id>buildAndPushDockerImagePhase</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<from>
<!-- Don't use alpine or slim version, https://hub.docker.com/r/adoptopenjdk/openjdk11/tags?page=1&ordering=last_updated&name=jre-11 -->
<image>adoptopenjdk/openjdk11:${adoptopenjdk11.tag}</image>
</from>
<to>
<image>docker.io/ijohnnymiller/${project.parent.artifactId}.${project.artifactId}</image>
<tags>
<tag>${git.commit.id.abbrev}-${project.version}</tag>
</tags>
</to>
<container>
<!-- The root directory on the container where the app's contents are placed. -->
<appRoot>/${project.artifactId}</appRoot>
<jvmFlags>
<jvmFlag>-Dfile.encoding=${project.build.sourceEncoding}</jvmFlag>
</jvmFlags>
<ports>
<port>${maf-mis.port}</port>
</ports>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
</container>
<pluginExtensions>
<pluginExtension>
<implementation>
com.google.cloud.tools.jib.maven.extension.springboot.JibSpringBootExtension
</implementation>
<properties>
<excludeDevtools>true</excludeDevtools>
</properties>
</pluginExtension>
</pluginExtensions>
</configuration>
</plugin>

<!-- https://github.com/git-commit-id/git-commit-id-maven-plugin -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>get-the-git-info</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>

<dependencies>
<dependency>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>maf-mis-web</artifactId>
</dependency>
<dependency>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>maf-mis-message</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
@SuppressWarnings("scwjava_Createprivateconstructorforutilityclassallfieldsmethodsarestatic")
public class MafMisApplication {
public static void main(String[] args) {
val stopWatch = new StopWatch();
Expand Down
Loading

0 comments on commit 4a827f4

Please sign in to comment.