Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
=====
    [update] readme file
  • Loading branch information
Mahmoud AlSati committed Mar 25, 2024
1 parent fb20fd1 commit 841275b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
46 changes: 30 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ But, as the first release, I have included a test project (Web App) in H2 only.
Providing tests for all type of databases is coming soon.

# How to build
```bash
mvn clean package
```


# How to test
```bash
mvn test
```


while testing the project, I recommend you test using the test runner of IntelliJ Idea Community Edition.
Each test case will output explanatory messages.



# Expressing Where Condition
The Where condition is in JSON notation. It allows you to express a business filter in JSON format.
Expand Down Expand Up @@ -172,7 +183,7 @@ public class Author extends BaseEntity<Long> {

## 2) Design CRUD endpoints DTOs

### CreateOne Endpoint (CreateOneInputDto, CreateOneOutputDto)
#### CreateOne Endpoint (CreateOneInputDto, CreateOneOutputDto)

```java
@Data
Expand All @@ -198,26 +209,27 @@ public class CreateOneAuthorOutputDto extends CreateOneAuthorInputDto {
}
```

### UpdateOne Endpoint (UpdateOneInputDto)
#### UpdateOne Endpoint (UpdateOneInputDto)
```java

public class UpdateOneAuthorInputDto extends CreateOneAuthorOutputDto {
}
```

### GetOne Endpoint (GetOneInputDto)
#### GetOne Endpoint (GetOneInputDto)
```java
public class GetOneAuthorOutputDto extends CreateOneAuthorOutputDto {
}
```

### DeleteOne Endpoint (DeleteOneOutputDto)
#### DeleteOne Endpoint (DeleteOneOutputDto)
```java
public class DeleteOneAuthorOutputDto extends UpdateOneAuthorInputDto {
}
```

## 3) Write down your entity mapper interface that inherits from IMapper
## 3) Write down your entity mapper interface:
It should inherit from IMapper

```java
@Mapper(componentModel = "spring")
Expand Down Expand Up @@ -279,21 +291,22 @@ public interface AuthorMapper extends IMapper<Author,
```


## 4) Design your repository: Make sure you inherit from JpaRepository as well as JpaSpecificationExecutor :
## 4) Design your repository
Make sure you inherit from `JpaRepository` as well as `JpaSpecificationExecutor` :
```java
public interface AuthorRepository extends JpaRepository<Author, Long>, JpaSpecificationExecutor<Author> {
boolean existsByFullName(String name);
}
```

## 5) Write down your service class:
1. It shoud extend CrudServiceORM
1. It should extend CrudServiceORM
2. In its constructor, it should inject the entity
repository and the mapper you've created in previous steps.
3. Implement validateCreateOneInput if needed
4. Implement onPreCreateOne if needed
5. Implement validateUpdateOneInput if needed
6. Implement onPreUpdateOne if needed
3. Implement `validateCreateOneInput` if needed
4. Implement `onPreCreateOne` if needed
5. Implement `validateUpdateOneInput` if needed
6. Implement `onPreUpdateOne` if needed

```java
@Service
Expand Down Expand Up @@ -331,14 +344,14 @@ public class AuthorsService extends CrudServiceORM<
}

@Override
protected void onPreUpdateOne(UpdateOneAuthorInputDto updateOneAuthorInputDto, Author author) {
protected void onPrUpdateOne(UpdateOneAuthorInputDto updateOneAuthorInputDto, Author author) {
// Write down any Business Specific Logic Here before the entity is saved to DB
}
}
```

## 6) Write your CRUD Controller:
1. It should inherit from CRUDController
1. It should inherit from CRUDController<br/>
2. It should pass the service class you've created in previous step

```java
Expand All @@ -358,9 +371,10 @@ public class AuthorsController extends CrudController<Author,
```

Before start using the library, I recommend you check the test project inside the test folder.
You will find:
1. simple_web_app folder : This is a sample web application it contains a practical example of how to use the library.
You will find: <br/>
1. simple_web_app folder : This is a sample web application it contains a practical example of how to use the library.<br/>
2. AuthorControllerTest: All Endpoint test cases. It also has cases of when you can pass JSON condition.
<br/>
<br/>

![Class Diagram](assets/classDiagram.png)

4 changes: 4 additions & 0 deletions assets/commits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
[add] All the above endpoints integration tests

1.0.2
=====
[update] readme file

1.0.3
=====
[update] readme file
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public AuthorControllerTest(@Autowired MockMvc mockMvc,
this.jsonRestHitter = new JsonRestHitter(restHitter, objectMapper);
}

// CreateOne
@Test
@Sql(scripts = "/sql/seed.sql")
@Order(1)
Expand Down Expand Up @@ -469,4 +468,4 @@ private static void printMvcResult(String title, MvcResult mvcResult) throws Exc
System.out.printf("response body: %s\n", mvcResult.getResponse().getContentAsString());
System.out.println("=================================================\n");
}
}
}

0 comments on commit 841275b

Please sign in to comment.