Skip to content

Commit b55d362

Browse files
committed
update with ant grid control
1 parent 758b0b7 commit b55d362

File tree

16 files changed

+498
-328
lines changed

16 files changed

+498
-328
lines changed

README.md

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
The practical repository uses coolstore domain which is mainly borrowed from `https://github.com/zkavtaskin/Domain-Driven-Design-Example` to demonstrate how to apply Domain Driven Design seamlessly with Clean Architecture.
44

5-
# Business usecases
5+
6+
7+
# Business Usecases
68

79
![](assets/usecase_diagram.png)
810

@@ -38,8 +40,112 @@ $ npm run dev
3840
>
3941
> Tye Dashboard: [http://localhost:8000](http://localhost:8000)
4042
43+
# Clean Domain Driven-design
44+
45+
Domain-driven Design demonstrates it can help the business tidy and organized in many years. But it is hard to approach and use, we need to make it easier to use in the real project when we get started.
46+
47+
Clean Architecture helps the project structure easier to refactor and evolve in medium and big projects. Especially in the Microservice world, we always want to do and try with a lot of time in the project lifetime.
48+
49+
Clean Domain-driven Design is a collection of basic building blocks and project structure to help we get starting the project with less code boilerplate and effortless. We focus on the Microservice approach of how can we organize code, the project with the monorepo approach, and you can use it for modular monolith project as well.
50+
## Core project
51+
### Domain
52+
53+
TODO
54+
55+
### Repository
56+
57+
TODO
58+
59+
## Infrastructure project
60+
61+
TODO
62+
63+
## Application project
64+
65+
TODO
66+
67+
## Api project
68+
69+
TODO
70+
# Public CRUD interface
71+
72+
In medium and large software projects, we normally implement the CRUD actions over and over again. And it might take around 40-50% codebase just to do CRUD in the projects. The question is can we make standardized CRUD APIs, then we can use them in potential projects in the future? That is in my mind for a long time when I started and finished many projects, and I decide to take time to research and define the public interfaces for it as below
73+
74+
## Common
75+
76+
```csharp
77+
public record ResultModel<T>(T Data, bool IsError = false, string? ErrorMessage = default);
78+
```
79+
80+
## [R]etrieve
81+
82+
```csharp
83+
// input model for list query (normally using for the table UI control with paging, filtering and sorting)
84+
public interface IListQueryInput : ICrudInput
85+
{
86+
public List<string> Includes { get; init; }
87+
public List<FilterModel> Filters { get; init; }
88+
public List<string> Sorts { get; init; }
89+
public int Page { get; init; }
90+
public int PageSize { get; init; }
91+
}
92+
```
93+
94+
```csharp
95+
// output model with items, total items, page and page size with serving for binding with the table UI control
96+
public record ListResponseModel<T>(List<T> Items, long TotalItems, int Page, int PageSize);
97+
```
98+
99+
```csharp
100+
public interface IItemQueryInput<TId> : ICrudInput where TId : struct
101+
{
102+
public List<string> Includes { get; init; }
103+
public TId Id { get; init; }
104+
}
105+
```
106+
107+
## [C]reate
108+
109+
```csharp
110+
public interface ICreateInput<T> : ICrudInput
111+
{
112+
public T Model { get; init; }
113+
}
114+
```
115+
116+
## [U]pdate
117+
118+
```csharp
119+
public interface IUpdateInput<T> : ICrudInput
120+
{
121+
public T Model { get; init; }
122+
}
123+
```
124+
125+
## [D]elete
126+
127+
```csharp
128+
public interface IDeleteInput<TId> : ICrudInput where TId : struct
129+
{
130+
public TId Id { get; init; }
131+
}
132+
```
133+
134+
# CRQS interface
135+
136+
```csharp
137+
public interface ICommand<T> : IRequest<ResultModel<T>> {}
138+
```
139+
140+
```csharp
141+
public interface IQuery<T> : IRequest<ResultModel<T>> {}
142+
```
143+
144+
# Sample pages
145+
41146
![](assets/products_screen.png)
42147

43148
# Refs
149+
- [Ant Design Components](https://ant.design/components/overview)
44150
- [C4 PlaintUML Model](https://github.com/plantuml-stdlib/C4-PlantUML/blob/master/samples/C4CoreDiagrams.md)
45151
- [Real world PlantUML](https://real-world-plantuml.com)

assets/products_screen.png

-1.33 KB
Loading

src/Product/ProductService.Application/Queries/GetProductById.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace ProductService.Application.Queries
1414
{
15-
public static class GetProductById
15+
public class GetProductById
1616
{
1717
public record Query : IItemQueryInput<Guid>, IQuery<ProductDto>
1818
{

src/Web/assets/scss/base/_base.scss

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Web/assets/scss/main.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// // Imports SCSS theme
22
// // Vendors variables override and path
3-
@import "vendors/vendor";
4-
@import "base/base";
5-
63
#components-layout-demo-fixed .logo {
74
float: left;
85
width: 120px;
96
height: 31px;
7+
line-height: 32px;
8+
text-align: center;
109
margin: 16px 24px 16px 0;
1110
background: rgba(255, 255, 255, 0.2);
11+
font-weight: 900;
12+
color: #fff;
1213
}
1314
.site-layout .site-layout-background {
1415
background: #fff;

src/Web/assets/scss/vendors/_vendor.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
import { BarsOutlined, DownOutlined } from "@ant-design/icons";
4+
import { Dropdown, Button, Menu } from "antd";
5+
6+
const DropOption = ({
7+
onMenuClick,
8+
menuOptions = [],
9+
buttonStyle,
10+
dropdownProps,
11+
}) => {
12+
const menu = menuOptions.map((item) => (
13+
<Menu.Item key={item.key}>{item.name}</Menu.Item>
14+
));
15+
return (
16+
<Dropdown
17+
overlay={<Menu onClick={onMenuClick}>{menu}</Menu>}
18+
{...dropdownProps}
19+
>
20+
<Button style={{ border: "none", ...buttonStyle }}>
21+
<BarsOutlined style={{ marginRight: 2 }} />
22+
<DownOutlined />
23+
</Button>
24+
</Dropdown>
25+
);
26+
};
27+
28+
DropOption.propTypes = {
29+
onMenuClick: PropTypes.func,
30+
menuOptions: PropTypes.array.isRequired,
31+
buttonStyle: PropTypes.object,
32+
dropdownProps: PropTypes.object,
33+
};
34+
35+
export default DropOption;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "DropOption",
3+
"version": "0.0.0",
4+
"private": true,
5+
"main": "./DropOption.js"
6+
}

src/Web/layout/nav/NavBar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function NavBar() {
1818
<>
1919
<Header
2020
id="components-layout-demo-fixed"
21-
style={{ position: "fixed", zIndex: 1, width: "100%" }}
21+
style={{ position: "fixed", zIndex: 9999, width: "100%" }}
2222
>
2323
<div className="logo">eCommerce</div>
2424
<Menu

src/Web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"next-images": "^1.7.0",
2626
"node-sass": "^5.0.0",
2727
"nprogress": "^0.2.0",
28+
"prop-types": "^15.7.2",
2829
"react": "17.0.1",
2930
"react-bootstrap-table-next": "^4.0.3",
3031
"react-bootstrap-table2-editor": "^1.4.0",

0 commit comments

Comments
 (0)