58 lines
1.9 KiB
Markdown
58 lines
1.9 KiB
Markdown
|
# 管理系统客户端---帮助文档
|
|||
|
|
|||
|
新管理系统客户端
|
|||
|
|
|||
|
## 模块汇总
|
|||
|
|
|||
|
## 本地化测试
|
|||
|
修改go.mod文件中replace <br>
|
|||
|
github.com/fonchain_enterprise/fonchain-account => ../fonchain-account <br>
|
|||
|
cd cmd <br>
|
|||
|
go run . <br>
|
|||
|
|
|||
|
## 数据校验
|
|||
|
### 使用govalidators生成pd校验文件,可以在client或者server做数据校验(filter)
|
|||
|
> 校验文件可在proto时生成,建议在client的filter做前置校验,校验文件可通用
|
|||
|
|
|||
|
#### 1、安装go-proto-validators
|
|||
|
* [使用go-proto-validators生成校验文件](https://github.com/mwitkow/go-proto-validators)
|
|||
|
#### 2、生成校验文件
|
|||
|
```
|
|||
|
protoc --proto_path=. --proto_path=C:/Users/user054/go/src --go_out=./api/account --govalidators_out=./api/account --go-triple_out=./api/account ./api/account/account.proto
|
|||
|
```
|
|||
|
#### 3、校验(filter中)
|
|||
|
```go
|
|||
|
func (f *FonValidateFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
|
|||
|
if len(invocation.Arguments()) > 0 {
|
|||
|
if v, ok := invocation.Arguments()[0].(validator); ok {
|
|||
|
if err := v.Validate(); err != nil {
|
|||
|
return &protocol.RPCResult{Err: perrors.Errorf("%v,info:%v,method:%s ", err.Error(),
|
|||
|
invoker, invocation.MethodName())}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return invoker.Invoke(ctx, invocation)
|
|||
|
}
|
|||
|
```
|
|||
|
|
|||
|
|
|||
|
* 使用dubbo-go3的filter校验数据[使用文档](https://github.com/apache/dubbo-go-samples/blob/master/filter/custom/go-server),[filter文件位置](http://192.168.31.6:8090/bugmaker/mgmt/fonchain-account/-/blob/main/pkg/common/filter/filter.go)
|
|||
|
#### server做校验
|
|||
|
|
|||
|
|
|||
|
|
|||
|
## 部署
|
|||
|
### 测试
|
|||
|
```bash
|
|||
|
docker build . -f ./fonchain-main/DockerfileTest -t main-server
|
|||
|
```
|
|||
|
|
|||
|
### 正式
|
|||
|
```bash
|
|||
|
docker build . -f ./fonchain-main/DockerfileProd -t main-server
|
|||
|
```
|
|||
|
|
|||
|
|
|||
|
protoc --proto_path=. --proto_path=C:/Users/Admin/go/pkg/mod --go_out=./api/recruit --govalidators_out=./api/recruit --go-triple_out=./api/recruit ./api/recruit/recruit.proto
|