Przeglądaj źródła

修改日志输出格式

qdy 2 miesięcy temu
rodzic
commit
bca1583cb0

BIN
.DS_Store Wyświetl plik


+ 2
- 1
functions/exchange_functions.go Wyświetl plik

3
 import (
3
 import (
4
 	"time"
4
 	"time"
5
 
5
 
6
+	"git.x2erp.com/qdy/go-base/ctx"
6
 	"git.x2erp.com/qdy/go-base/types"
7
 	"git.x2erp.com/qdy/go-base/types"
7
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
8
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
8
 )
9
 )
9
 
10
 
10
 // CreateExchange 创建交换机
11
 // CreateExchange 创建交换机
11
-func CreateExchange(rabbitFactory *rabbitmq.RabbitMQFactory, req types.ExchangeRequest) *types.QueryResult {
12
+func CreateExchange(rabbitFactory *rabbitmq.RabbitMQFactory, req types.ExchangeRequest, reqCtx *ctx.RequestContext) *types.QueryResult {
12
 	// 设置默认值
13
 	// 设置默认值
13
 	if req.ChannelName == "" {
14
 	if req.ChannelName == "" {
14
 		req.ChannelName = "default"
15
 		req.ChannelName = "default"

+ 3
- 2
functions/message_functions.go Wyświetl plik

4
 	"encoding/json"
4
 	"encoding/json"
5
 	"time"
5
 	"time"
6
 
6
 
7
+	"git.x2erp.com/qdy/go-base/ctx"
7
 	"git.x2erp.com/qdy/go-base/types"
8
 	"git.x2erp.com/qdy/go-base/types"
8
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
9
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
9
 	"github.com/streadway/amqp"
10
 	"github.com/streadway/amqp"
10
 )
11
 )
11
 
12
 
12
 // SendMessage 发送JSON消息
13
 // SendMessage 发送JSON消息
13
-func SendMessage(rabbitFactory *rabbitmq.RabbitMQFactory, req types.MessageRequest) *types.QueryResult {
14
+func SendMessage(rabbitFactory *rabbitmq.RabbitMQFactory, req types.MessageRequest, reqCtx *ctx.RequestContext) *types.QueryResult {
14
 	// 设置默认值
15
 	// 设置默认值
15
 	if req.ChannelName == "" {
16
 	if req.ChannelName == "" {
16
 		req.ChannelName = "default"
17
 		req.ChannelName = "default"
94
 }
95
 }
95
 
96
 
96
 // SendBytesMessage 发送字节消息
97
 // SendBytesMessage 发送字节消息
97
-func SendBytesMessage(rabbitFactory *rabbitmq.RabbitMQFactory, req types.BytesMessageRequest) *types.QueryResult {
98
+func SendBytesMessage(rabbitFactory *rabbitmq.RabbitMQFactory, req types.BytesMessageRequest, reqCtx *ctx.RequestContext) *types.QueryResult {
98
 	// 设置默认值
99
 	// 设置默认值
99
 	if req.ChannelName == "" {
100
 	if req.ChannelName == "" {
100
 		req.ChannelName = "default"
101
 		req.ChannelName = "default"

+ 3
- 2
functions/queue_functions.go Wyświetl plik

3
 import (
3
 import (
4
 	"time"
4
 	"time"
5
 
5
 
6
+	"git.x2erp.com/qdy/go-base/ctx"
6
 	"git.x2erp.com/qdy/go-base/types"
7
 	"git.x2erp.com/qdy/go-base/types"
7
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
8
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
8
 )
9
 )
9
 
10
 
10
 // CreateQueue 创建队列
11
 // CreateQueue 创建队列
11
-func CreateQueue(rabbitFactory *rabbitmq.RabbitMQFactory, req types.QueueRequest) *types.QueryResult {
12
+func CreateQueue(rabbitFactory *rabbitmq.RabbitMQFactory, req types.QueueRequest, reqCtx *ctx.RequestContext) *types.QueryResult {
12
 	// 设置默认值
13
 	// 设置默认值
13
 	if req.ChannelName == "" {
14
 	if req.ChannelName == "" {
14
 		req.ChannelName = "default"
15
 		req.ChannelName = "default"
55
 }
56
 }
56
 
57
 
57
 // BindQueue 绑定队列到交换机
58
 // BindQueue 绑定队列到交换机
58
-func BindQueue(rabbitFactory *rabbitmq.RabbitMQFactory, req types.QueueBindRequest) *types.QueryResult {
59
+func BindQueue(rabbitFactory *rabbitmq.RabbitMQFactory, req types.QueueBindRequest, reqCtx *ctx.RequestContext) *types.QueryResult {
59
 	// 设置默认值
60
 	// 设置默认值
60
 	if req.ChannelName == "" {
61
 	if req.ChannelName == "" {
61
 		req.ChannelName = "default"
62
 		req.ChannelName = "default"

+ 2
- 1
functions/utility_functions.go Wyświetl plik

5
 	"net/http"
5
 	"net/http"
6
 	"time"
6
 	"time"
7
 
7
 
8
+	"git.x2erp.com/qdy/go-base/ctx"
8
 	"git.x2erp.com/qdy/go-base/types"
9
 	"git.x2erp.com/qdy/go-base/types"
9
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
10
 	"git.x2erp.com/qdy/go-db/factory/rabbitmq"
10
 )
11
 )
36
 }
37
 }
37
 
38
 
38
 // GetQueueInfo 获取队列信息
39
 // GetQueueInfo 获取队列信息
39
-func GetQueueInfo(rabbitFactory *rabbitmq.RabbitMQFactory, req types.QueueInfoRequest) *types.QueryResult {
40
+func GetQueueInfo(rabbitFactory *rabbitmq.RabbitMQFactory, req types.QueueInfoRequest, reqCtx *ctx.RequestContext) *types.QueryResult {
40
 	// 设置默认值
41
 	// 设置默认值
41
 	if req.ChannelName == "" {
42
 	if req.ChannelName == "" {
42
 		req.ChannelName = "default"
43
 		req.ChannelName = "default"

+ 17
- 74
gct.sh Wyświetl plik

1
 #!/bin/bash
1
 #!/bin/bash
2
 
2
 
3
-# 脚本用法:./git-commit-and-tag.sh "你的提交描述" "版本号"
3
+# 使用命令行参数,如果没有提供则使用默认值
4
+COMMIT_MSG="${1:-初始提交}"
5
+TAG_VERSION="${2:-v0.1.0}"
4
 
6
 
5
-# 检查参数数量
6
-if [ $# -ne 2 ]; then
7
-    echo "错误: 脚本需要2个参数。"
8
-    echo "用法: $0 \"提交描述\" \"版本号\""
9
-    echo "示例: $0 \"修复了登录问题\" \"v1.2.3\""
10
-    exit 1
11
-fi
7
+echo "提交信息: $COMMIT_MSG"
8
+echo "标签版本: $TAG_VERSION"
12
 
9
 
13
-# 分配参数
14
-COMMIT_MESSAGE="$1"
15
-VERSION_TAG="$2"
10
+# 提交和推送
11
+git add .
12
+git commit -m "$COMMIT_MSG"
13
+git push -u origin master
16
 
14
 
17
-# 检查当前目录是否为Git仓库
18
-if ! git rev-parse --git-dir > /dev/null 2>&1; then
19
-    echo "错误: 当前目录不是一个Git仓库。"
20
-    exit 1
21
-fi
15
+# 创建标签(关键修改在这里)
16
+# 方法1:使用注释标签(推荐,不会打开编辑器)
17
+git tag -a "$TAG_VERSION" -m "Release $TAG_VERSION"
22
 
18
 
23
-echo "开始处理提交和版本标签..."
24
-echo "提交描述: $COMMIT_MESSAGE"
25
-echo "版本标签: $VERSION_TAG"
19
+# 或者方法2:如果你需要GPG签名,使用这个
20
+# GIT_EDITOR=true git tag -s "$TAG_VERSION" -m "Release $TAG_VERSION"
26
 
21
 
27
-# 检查是否有未提交的更改
28
-if [ -n "$(git status --porcelain)" ]; then
29
-    echo "检测到未提交的更改,正在提交..."
30
-    
31
-    # 添加所有更改到暂存区
32
-    git add .
33
-    
34
-    # 进行提交
35
-    git commit -m "$COMMIT_MESSAGE"
36
-    if [ $? -ne 0 ]; then
37
-        echo "错误: 提交失败。"
38
-        exit 1
39
-    fi
40
-    echo "✅ 更改已提交"
41
-else
42
-    echo "提示: 没有未提交的更改,跳过提交步骤"
43
-    
44
-    # 检查是否有未提交的commit但未推送
45
-    LOCAL_COMMITS=$(git log @{u}..HEAD --oneline 2>/dev/null | wc -l)
46
-    if [ $LOCAL_COMMITS -eq 0 ]; then
47
-        echo "错误: 没有需要推送的提交。"
48
-        exit 1
49
-    else
50
-        echo "检测到 $LOCAL_COMMITS 个本地提交等待推送"
51
-    fi
52
-fi
22
+# 推送标签
23
+git push origin "$TAG_VERSION"
53
 
24
 
54
-# 检查标签是否已存在
55
-if git rev-parse "$VERSION_TAG" >/dev/null 2>&1; then
56
-    echo "错误: 标签 '$VERSION_TAG' 已经存在。"
57
-    exit 1
58
-fi
59
-
60
-# 创建标签
61
-git tag "$VERSION_TAG"
62
-if [ $? -ne 0 ]; then
63
-    echo "错误: 创建标签失败。"
64
-    exit 1
65
-fi
66
-echo "✅ 标签 '$VERSION_TAG' 已创建"
67
-
68
-# 推送到远程仓库并推送标签
69
-echo "正在推送到远程仓库..."
70
-git push
71
-if [ $? -ne 0 ]; then
72
-    echo "错误: 推送提交失败。"
73
-    exit 1
74
-fi
75
-
76
-git push origin "$VERSION_TAG"
77
-if [ $? -ne 0 ]; then
78
-    echo "错误: 推送标签失败。"
79
-    exit 1
80
-fi
81
-
82
-echo "✅ 完成!提交已推送,版本标签 $VERSION_TAG 已创建并推送。"
25
+echo "完成!"

+ 6
- 5
main.go Wyświetl plik

18
 )
18
 )
19
 
19
 
20
 func main() {
20
 func main() {
21
-	cfg := config.GetConfig()
21
+	cfg, err := config.GetConfig()
22
+	if err != nil {
23
+		log.Fatalf("Failed to create RabbitMQ factory: %v", err)
24
+	}
22
 	serviceConfig := cfg.GetService()
25
 	serviceConfig := cfg.GetService()
23
 
26
 
24
 	log.Printf("RabbitMQ Service Starting...")
27
 	log.Printf("RabbitMQ Service Starting...")
26
 	log.Printf("Service Name: %s", serviceConfig.ServiceName)
29
 	log.Printf("Service Name: %s", serviceConfig.ServiceName)
27
 
30
 
28
 	// 启动微服务
31
 	// 启动微服务
29
-	startRabbitMQService()
32
+	startRabbitMQService(cfg)
30
 }
33
 }
31
 
34
 
32
 // 启动RabbitMQ微服务
35
 // 启动RabbitMQ微服务
33
-func startRabbitMQService() {
34
-	cfg := config.GetConfig()
35
-	//serviceConfig := cfg.GetService()
36
+func startRabbitMQService(cfg config.IConfig) {
36
 
37
 
37
 	// 初始化RabbitMQ工厂
38
 	// 初始化RabbitMQ工厂
38
 	rabbitFactory, err := rabbitmq.NewRabbitMQFactory()
39
 	rabbitFactory, err := rabbitmq.NewRabbitMQFactory()

+ 1
- 1
test/my_create_exchange_test.go Wyświetl plik

45
 	}
45
 	}
46
 
46
 
47
 	queueBindRequest := types.QueueBindRequest{
47
 	queueBindRequest := types.QueueBindRequest{
48
-		ChannelName:  requestData.ChannelName,
48
+		//ChannelName:  requestData.ChannelName,
49
 		QueueName:    queueRequest.QueueName,
49
 		QueueName:    queueRequest.QueueName,
50
 		ExchangeName: requestData.ExchangeName,
50
 		ExchangeName: requestData.ExchangeName,
51
 		RoutingKey:   "v-bdx.#",
51
 		RoutingKey:   "v-bdx.#",

Ładowanie…
Anuluj
Zapisz