change docs

This commit is contained in:
zhuyasen
2023-09-07 22:22:10 +08:00
parent 84039ef380
commit 1ce3dbd294
12 changed files with 118 additions and 10 deletions

View File

@@ -177,7 +177,13 @@ patch:
.PHONY: copy-proto .PHONY: copy-proto
# copy proto file from the rpc server directory, multiple directories separated by commas. e.g. make copy-proto SERVER=yourServerDir # copy proto file from the rpc server directory, multiple directories separated by commas. e.g. make copy-proto SERVER=yourServerDir
copy-proto: copy-proto:
@bash scripts/copy-proto.sh $(SERVER) @sponge patch copy-proto --server-dir=$(SERVER)
.PHONY: update-config
# update internal/config code base on yaml file
update-config:
@sponge config --server-dir=.
.PHONY: clean .PHONY: clean

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 93 KiB

View File

@@ -179,9 +179,10 @@ import (
{{- range .PbServices}} {{- range .PbServices}}
// {{.LowerName}} http service level error code // {{.LowerName}} business-level http error codes.
// the {{.LowerName}}NO value range is 1~100, if the same number appears, it will cause a failure to start the service.
var ( var (
{{.LowerName}}NO = {{.RandNumber}} // number range 1~100, if there is the same number, trigger panic. {{.LowerName}}NO = {{.RandNumber}}
{{.LowerName}}Name = "{{.LowerName}}" {{.LowerName}}Name = "{{.LowerName}}"
{{.LowerName}}BaseCode = errcode.HCode({{.LowerName}}NO) {{.LowerName}}BaseCode = errcode.HCode({{.LowerName}}NO)
// --blank line-- // --blank line--

View File

@@ -189,9 +189,10 @@ import (
{{- range .PbServices}} {{- range .PbServices}}
// {{.LowerName}} rpc service level error code // {{.LowerName}} business-level rpc error codes.
// the {{.LowerName}}NO value range is 1~100, if the same number appears, it will cause a failure to start the service.
var ( var (
_{{.LowerName}}NO = {{.RandNumber}} // number range 1~100, if there is the same number, trigger panic. _{{.LowerName}}NO = {{.RandNumber}}
_{{.LowerName}}Name = "{{.LowerName}}" _{{.LowerName}}Name = "{{.LowerName}}"
_{{.LowerName}}BaseCode = errcode.RCode(_{{.LowerName}}NO) _{{.LowerName}}BaseCode = errcode.RCode(_{{.LowerName}}NO)
// --blank line-- // --blank line--

View File

@@ -244,9 +244,10 @@ import (
{{- range .PbServices}} {{- range .PbServices}}
// {{.LowerName}} rpc service level error code // {{.LowerName}} business-level rpc error codes.
// the _{{.LowerName}}NO value range is 1~100, if the same number appears, it will cause a failure to start the service.
var ( var (
_{{.LowerName}}NO = {{.RandNumber}} // number range 1~100, if there is the same number, trigger panic. _{{.LowerName}}NO = {{.RandNumber}}
_{{.LowerName}}Name = "{{.LowerName}}" _{{.LowerName}}Name = "{{.LowerName}}"
_{{.LowerName}}BaseCode = errcode.RCode(_{{.LowerName}}NO) _{{.LowerName}}BaseCode = errcode.RCode(_{{.LowerName}}NO)
// --blank line-- // --blank line--

View File

@@ -155,7 +155,7 @@ func saveFile(inputFile string, outputFile string, code string) error {
if err != nil { if err != nil {
return err return err
} }
fmt.Printf("%s ----> %s\n", inputFile, outputFile) fmt.Printf("update \"%s\" --> \"%s\"\n", inputFile, outputFile)
return nil return nil
} }

View File

@@ -212,8 +212,8 @@ func Init(configFile string, fs ...func()) error {
return conf.Parse(configFile, config, fs...) return conf.Parse(configFile, config, fs...)
} }
func Show() string { func Show(hiddenFields ...string) string {
return conf.Show(config) return conf.Show(config, hiddenFields...)
} }
func Get() *Config { func Get() *Config {

View File

@@ -253,6 +253,38 @@ const docTemplate = `{
} }
} }
}, },
"/codes": {
"get": {
"description": "list error codes info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "list error codes info",
"responses": {}
}
},
"/config": {
"get": {
"description": "show config info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "show config info",
"responses": {}
}
},
"/health": { "/health": {
"get": { "get": {
"description": "check health", "description": "check health",

View File

@@ -249,6 +249,38 @@
} }
} }
}, },
"/codes": {
"get": {
"description": "list error codes info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "list error codes info",
"responses": {}
}
},
"/config": {
"get": {
"description": "show config info",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "show config info",
"responses": {}
}
},
"/health": { "/health": {
"get": { "get": {
"description": "check health", "description": "check health",

View File

@@ -286,6 +286,28 @@ paths:
summary: list of userExamples by batch id summary: list of userExamples by batch id
tags: tags:
- userExample - userExample
/codes:
get:
consumes:
- application/json
description: list error codes info
produces:
- application/json
responses: {}
summary: list error codes info
tags:
- system
/config:
get:
consumes:
- application/json
description: show config info
produces:
- application/json
responses: {}
summary: show config info
tags:
- system
/health: /health:
get: get:
consumes: consumes:

View File

@@ -442,6 +442,11 @@ func getModelStructCode(data tmplData, importPaths []string, isEmbed bool) (stri
for i, field := range data.Fields { for i, field := range data.Fields {
if strings.Contains(field.GoType, "time.Time") { if strings.Contains(field.GoType, "time.Time") {
data.Fields[i].GoType = "*time.Time" data.Fields[i].GoType = "*time.Time"
continue
}
// force conversion of ID field to uint64 type
if field.Name == "ID" {
data.Fields[i].GoType = "uint64"
} }
} }
newImportPaths = importPaths newImportPaths = importPaths

View File

@@ -2,6 +2,13 @@
HOST_ADDR=$1 HOST_ADDR=$1
function checkResult() {
result=$1
if [ ${result} -ne 0 ]; then
exit ${result}
fi
}
# change host addr # change host addr
if [ "X${HOST_ADDR}" = "X" ];then if [ "X${HOST_ADDR}" = "X" ];then
HOST_ADDR=$(cat cmd/serverNameExample_mixExample/main.go | grep "@host" | awk '{print $3}') HOST_ADDR=$(cat cmd/serverNameExample_mixExample/main.go | grep "@host" | awk '{print $3}')
@@ -11,6 +18,7 @@ else
fi fi
swag init -g cmd/serverNameExample_mixExample/main.go swag init -g cmd/serverNameExample_mixExample/main.go
checkResult $?
colorCyan='\e[1;36m' colorCyan='\e[1;36m'
highBright='\e[1m' highBright='\e[1m'