Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
91f65064ff | ||
![]() |
06d888e8de | ||
![]() |
f6c7d66376 | ||
![]() |
7f0c64fd8a | ||
![]() |
093b34f32f | ||
![]() |
33e119864e | ||
![]() |
f6a41a5e7c | ||
![]() |
994ed9e639 | ||
![]() |
e2dfb3e5ad | ||
![]() |
be976b73f6 | ||
![]() |
0537361ddf | ||
![]() |
fe311de89f | ||
![]() |
a5cb0496c0 | ||
![]() |
9b838fd5d9 | ||
![]() |
a1b4fe772c | ||
![]() |
431fd441a7 | ||
![]() |
f6a19bd7e9 | ||
![]() |
07ff135eea | ||
![]() |
eeed182985 | ||
![]() |
d233f3a1a3 | ||
![]() |
6bf054e1e8 | ||
![]() |
a48afa14b7 | ||
![]() |
3b335785a4 | ||
![]() |
d311a8368a | ||
![]() |
7b077e25b4 | ||
![]() |
72127fecd7 | ||
![]() |
2841d52187 | ||
![]() |
ffb9dd6112 | ||
![]() |
b8bd72806f | ||
![]() |
2b080ef98e | ||
![]() |
52c21d0814 | ||
![]() |
1915dc0a2a | ||
![]() |
f8ebbff9d8 |
36
README.en.md
36
README.en.md
@ -1,36 +0,0 @@
|
||||
# rabbitMQ公共结构体
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
50
README.md
50
README.md
@ -1,39 +1,19 @@
|
||||
# rabbitMQ公共结构体
|
||||
|
||||
#### 介绍
|
||||
{**以下是 Gitee 平台说明,您可以替换此简介**
|
||||
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
|
||||
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
||||
## window开发者执行
|
||||
```bash
|
||||
git config --global core.autocrlf true # 提交时转 CRLF 为 LF,检出时转 LF 为 CRLF
|
||||
```
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
## mac开发者执行
|
||||
```bash
|
||||
git config --global core.autocrlf input # 提交时转 CRLF 为 LF,检出时不转换
|
||||
```
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
## 格式化
|
||||
```bash
|
||||
gofumpt -l -w .
|
||||
```
|
||||
```bash
|
||||
go install mvdan.cc/gofumpt@latest
|
||||
```
|
||||
|
31
go.mod
31
go.mod
@ -1,3 +1,34 @@
|
||||
module git.ssgfgtfy.com/public/common_structure
|
||||
|
||||
go 1.18.0
|
||||
|
||||
require (
|
||||
github.com/dromara/carbon/v2 v2.6.4
|
||||
github.com/gogf/gf/v2 v2.7.2
|
||||
go.uber.org/zap v1.27.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/gorilla/websocket v1.5.1 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
go.uber.org/multierr v1.10.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
61
go.sum
Normal file
61
go.sum
Normal file
@ -0,0 +1,61 @@
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/dromara/carbon/v2 v2.6.4 h1:cpIansyiEIEed3OlEIqo1IXj86qu0x6pf/E2keL2wYo=
|
||||
github.com/dromara/carbon/v2 v2.6.4/go.mod h1:Baj3A1uBBctJmpZWJd6/+WWnmIuY2pobR6IOpB6xigc=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/gogf/gf/v2 v2.7.2 h1:uZDfyblasI12lZUtFd1mfxsIr8b14cd/F88DJUTCSDM=
|
||||
github.com/gogf/gf/v2 v2.7.2/go.mod h1:EBXneAg/wes86rfeh68XC0a2JBNQylmT7Sp6/8Axk88=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
|
||||
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
|
||||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
|
||||
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
|
||||
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
|
||||
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
||||
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
51
log.go
51
log.go
@ -1,51 +0,0 @@
|
||||
package common_structure
|
||||
|
||||
import "time"
|
||||
|
||||
type LogType = string
|
||||
|
||||
const (
|
||||
LogTypeOrder LogType = "order" // 订单
|
||||
LogTypeProduct LogType = "product" // 商品
|
||||
LogTypeGPS LogType = "gps" // gps
|
||||
)
|
||||
|
||||
type LogInfo struct {
|
||||
InfoType LogType `json:"info_type"` // 类型
|
||||
Operator Operator `json:"operator"` // 操作人
|
||||
ObjectorID int `json:"objector_id"` // 被操作对象ID,如果是gps,短信等服务则为0
|
||||
Title string `json:"title"` // 标题,做什么事情
|
||||
Param interface{} `json:"param"` // 参数,请求参数,函数、方法就是参数
|
||||
Result interface{} `json:"result"` // 结果,返回值
|
||||
ErrStr string `json:"err_str"` // 错误信息,json转义error没有自动存储,需要手动转义
|
||||
At time.Time `json:"at"` // 记录时间
|
||||
}
|
||||
|
||||
type OperatorType = string
|
||||
|
||||
const (
|
||||
SystemOperatorType OperatorType = "system" // 系统
|
||||
AdminOperatorType OperatorType = "admin" // 管理员
|
||||
MerchantOperatorType OperatorType = "merchant" // 商家
|
||||
UserOperatorType OperatorType = "user" // 用户
|
||||
)
|
||||
|
||||
type Operator struct {
|
||||
ID int // 系统ID设置0
|
||||
OperatorType OperatorType
|
||||
}
|
||||
|
||||
type ObjectorType = string
|
||||
|
||||
const (
|
||||
ObjectorTypeGPS ObjectorType = "gps" // gps
|
||||
ObjectorTypeSMS ObjectorType = "sms" // sms
|
||||
ObjectorTypeProduct ObjectorType = "product"
|
||||
ObjectorTypeOrder ObjectorType = "order"
|
||||
ObjectorTypePay ObjectorType = "pay"
|
||||
)
|
||||
|
||||
type Objector struct {
|
||||
ID int // 系统ID设置0
|
||||
ObjectorType ObjectorType
|
||||
}
|
158
log/log.go
Normal file
158
log/log.go
Normal file
@ -0,0 +1,158 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type LogType = string
|
||||
|
||||
const (
|
||||
LogTypeOrder LogType = "order" // 订单
|
||||
LogTypeProduct LogType = "product" // 商品
|
||||
LogTypeMerchant LogType = "merchant" // 商家
|
||||
LogTypeMerchantRedPack LogType = "merchant_red_pack" // 商家红包
|
||||
LogTypePay LogType = "pay" // 支付
|
||||
LogTypeUser LogType = "user" // 用户
|
||||
LogTypeUserRedPack LogType = "user_red_pack" // 用户红包
|
||||
LogTypeGPS LogType = "gps" // gps
|
||||
LogTypeSMS LogType = "sms" // 短信
|
||||
LogTypeIP LogType = "ip" // ip信息
|
||||
LogTypeAdmin LogType = "admin" // 管理员操作,例如登录、退出、修改密码、修改用户信息、修改角色信息、审核等
|
||||
LogTypeSystem LogType = "system" // 系统、日志、定时任务初始化、定时任务、mq初始化等
|
||||
LogTypeSystemRedPack LogType = "system_red_pack" // 系统红包
|
||||
LogTypeActivity LogType = "activity" // 活动
|
||||
LogTypeJJT LogType = "jjt" // 交易所
|
||||
)
|
||||
|
||||
type OperatorType = string
|
||||
|
||||
const (
|
||||
OperatorTypeAdmin OperatorType = "admin" // 管理员
|
||||
OperatorTypeMerchant OperatorType = "merchant" // 商家
|
||||
OperatorTypeUser OperatorType = "user" // 用户
|
||||
)
|
||||
|
||||
type Operator struct {
|
||||
ID int `json:"id"` // 系统ID设置0
|
||||
OperatorType OperatorType `json:"operator_type"`
|
||||
}
|
||||
|
||||
type LogInfo struct {
|
||||
LogType LogType `json:"log_type"` // 日志类型,按被操作对象划分
|
||||
Operator *Operator `json:"operator,omitempty"` // 操作人,系统操作不用填写操作人,写日志类型就可以
|
||||
ObjectorID int `json:"objector_id,omitempty"` // 被操作对象ID,如果是gps,短信等服务则为0
|
||||
Title string `json:"title"` // 必填,标题,做什么事情
|
||||
Param interface{} `json:"param,omitempty"` // 参数,请求参数,传指针
|
||||
Result interface{} `json:"result,omitempty"` // 结果,返回值,传指针,如果是报错,传err
|
||||
}
|
||||
|
||||
type TempGLog struct {
|
||||
Time string `json:"Time"`
|
||||
TraceId string `json:"TraceId"`
|
||||
Level string `json:"Level"`
|
||||
Content string `json:"Content"`
|
||||
}
|
||||
|
||||
type GLog struct {
|
||||
Time string `json:"Time"`
|
||||
TraceId string `json:"TraceId"`
|
||||
Level string `json:"Level"`
|
||||
Content *LogInfo `json:"Content"`
|
||||
}
|
||||
|
||||
func ZapDebug(logger *zap.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
logger.Debug("", zap.Any("log", log))
|
||||
}
|
||||
|
||||
func ZapInfo(logger *zap.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
logger.Info("", zap.Any("log", log))
|
||||
}
|
||||
|
||||
func ZapWarn(logger *zap.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
logger.Warn("", zap.Any("log", log))
|
||||
}
|
||||
|
||||
func ZapError(logger *zap.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
logger.Error("", zap.Any("log", log))
|
||||
}
|
||||
|
||||
func ZapPanic(logger *zap.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
logger.Panic("", zap.Any("log", log))
|
||||
}
|
||||
|
||||
func ZapFatal(logger *zap.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
logger.Fatal("", zap.Any("log", log))
|
||||
}
|
||||
|
||||
func HandleLog(log *LogInfo) {
|
||||
// 处理 Param
|
||||
log.Param = processValue(log.Param)
|
||||
// 处理 Result
|
||||
log.Result = processValue(log.Result)
|
||||
}
|
||||
|
||||
func GFInfo(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
g.Info(ctx, log)
|
||||
}
|
||||
|
||||
func GFWarning(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
g.Warning(ctx, log)
|
||||
}
|
||||
|
||||
func GFError(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
g.Error(ctx, log)
|
||||
}
|
||||
|
||||
func GFDebug(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
g.Debug(ctx, log)
|
||||
}
|
||||
|
||||
func GFPanic(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
g.Panic(ctx, log)
|
||||
}
|
||||
|
||||
func GFFatal(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||
HandleLog(log)
|
||||
g.Fatal(ctx, log)
|
||||
}
|
||||
|
||||
func (l *LogInfo) GFCommonHandelResult(ctx context.Context, g *glog.Logger, result interface{}, err error) {
|
||||
if err != nil {
|
||||
l.Result = err
|
||||
GFError(ctx, g, l)
|
||||
} else {
|
||||
l.Result = result
|
||||
GFInfo(ctx, g, l)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LogInfo) ZapCommonHandelResult(logger *zap.Logger, result interface{}, err error) {
|
||||
if err != nil {
|
||||
l.Result = err
|
||||
ZapError(logger, l)
|
||||
} else {
|
||||
l.Result = result
|
||||
ZapInfo(logger, l)
|
||||
}
|
||||
}
|
||||
|
||||
func processValue(value interface{}) interface{} {
|
||||
if value == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%+v", value)
|
||||
}
|
5
rabbitmq_coupon.go
Normal file
5
rabbitmq_coupon.go
Normal file
@ -0,0 +1,5 @@
|
||||
package common_structure
|
||||
|
||||
type CouponCode struct {
|
||||
ID uint `json:"id"` // 优惠券ID
|
||||
}
|
@ -12,10 +12,10 @@ const (
|
||||
OrderCloseTypeMerchantClose OrderCloseType = 30 // 商家关闭
|
||||
OrderCloseTypeThirdOrderFailedClose OrderCloseType = 40 // 第三方订单下单失败关闭
|
||||
OrderCloseTypeUser OrderCloseType = 50 // 用户主动关闭
|
||||
OrderCloseTypeMerchantCancel OrderCloseType = 60 //商家取消订单关闭
|
||||
OrderCloseTypeDeliveryTimeout OrderCloseType = 70 //发货超时关闭
|
||||
OrderCloseTypePaymentFailed OrderCloseType = 80 //创建支付失败
|
||||
OrderCloseTypeAbandonPayment OrderCloseType = 90 //放弃支付
|
||||
OrderCloseTypeMerchantCancel OrderCloseType = 60 // 商家取消订单关闭
|
||||
OrderCloseTypeDeliveryTimeout OrderCloseType = 70 // 发货超时关闭
|
||||
OrderCloseTypePaymentFailed OrderCloseType = 80 // 创建支付失败
|
||||
OrderCloseTypeAbandonPayment OrderCloseType = 90 // 放弃支付
|
||||
|
||||
)
|
||||
|
||||
|
@ -17,8 +17,8 @@ type ProductsIncreaseSold struct {
|
||||
type StockState = string
|
||||
|
||||
const (
|
||||
StockStateIncrease StockState = "increase_inventory" //增加库存
|
||||
StockStateDecrease StockState = "reduce_inventory" //减少库存
|
||||
StockStateIncrease StockState = "increase_inventory" // 增加库存
|
||||
StockStateDecrease StockState = "reduce_inventory" // 减少库存
|
||||
)
|
||||
|
||||
type ProductsChangeStockType = int
|
||||
|
5
rabbitmq_red_packet.go
Normal file
5
rabbitmq_red_packet.go
Normal file
@ -0,0 +1,5 @@
|
||||
package common_structure
|
||||
|
||||
type GiveRedPacketTask struct {
|
||||
TaskID uint `json:"task_id"` // 任务ID
|
||||
}
|
5
rabbitmq_user.go
Normal file
5
rabbitmq_user.go
Normal file
@ -0,0 +1,5 @@
|
||||
package common_structure
|
||||
|
||||
type UserLogout struct {
|
||||
UserID uint `json:"user_id"`
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user