什么是DDD?
DDD是一种软件设计思想和方法论,以领域为核心构建软件设计体系,将业务模型抽象成领域模型进行拆解和封装。
Domain Driven Design(领域驱动设计, DDD),不是一种架构,而是一种架构方法论,是一种拆解业务、划分业务、确定业务边界的方法,是一种领域设计思想。
DDD(领域驱动设计)实际上是一套软件架构设计的方法论,我们可以在此之上更好的理解业务。并且我们可以根据这套方法论进行架构风格填充,包括微服务架构,面向服务架构,REST风格架构以及六边形架构等等。
项目框架
GORM
go get -u gorm.io/gorm
## sqlite驱动
go get -u gorm.io/driver/sqlite
## mysql驱动
go get -u gorm.io/driver/mysql
Wire
go get github.com/google/wire/cmd/wire
gRPC
## 插件
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
## 安装依赖包
go get google.golang.org/grpc
## 使用protoc命令生成gRPC Go代码
protoc --go_out=. --go-grpc_out=. ./path/to/your/proto/files/*.proto
yaml(yaml文件配置解析)
https://pkg.go.dev/gopkg.in/yaml.v3#section-readme
go get gopkg.in/yaml.v3
MQ
RabbitMQ tutorial - "Hello World!" | RabbitMQ
go get github.com/rabbitmq/amqp091-go
建表SQL
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for employees
-- ----------------------------
DROP TABLE IF EXISTS `employees`;
CREATE TABLE `employees` (
`ID` int NOT NULL AUTO_INCREMENT,
`EmployeeID` int NOT NULL,
`FirstName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`LastName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`Gender` enum('Male','Female','Other') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`Age` int NULL DEFAULT NULL,
`Position` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`Department` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`HireDate` date NULL DEFAULT NULL,
`Salary` decimal(10, 2) NULL DEFAULT NULL,
`deleted_at` int NULL DEFAULT NULL,
`Updated_At` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`Created_At` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 511 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;