mirror of
https://github.com/zhufuyi/sponge.git
synced 2025-10-04 16:32:42 +08:00
modify the generate proto file command
This commit is contained in:
@@ -380,7 +380,7 @@ func makeCode(stmt *ast.CreateTableStmt, opt options) (*codeText, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
protoFileCode, err := getProtoFileCode(data)
|
||||
protoFileCode, err := getProtoFileCode(data, opt.IsWebProto)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -565,13 +565,20 @@ func getModelJSONCode(data tmplData) (string, error) {
|
||||
return modelJSONCode, nil
|
||||
}
|
||||
|
||||
func getProtoFileCode(data tmplData) (string, error) {
|
||||
func getProtoFileCode(data tmplData, isWebProto bool) (string, error) {
|
||||
data.Fields = goTypeToProto(data.Fields)
|
||||
|
||||
builder := strings.Builder{}
|
||||
err := protoFileTmpl.Execute(&builder, data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
if isWebProto {
|
||||
err := protoFileForWebTmpl.Execute(&builder, data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
err := protoFileTmpl.Execute(&builder, data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
code := builder.String()
|
||||
|
||||
@@ -584,6 +591,9 @@ func getProtoFileCode(data tmplData) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("handlerCreateStructTmpl error: %v", err)
|
||||
}
|
||||
if !isWebProto {
|
||||
protoMessageUpdateCode = strings.ReplaceAll(protoMessageUpdateCode, ` [(tagger.tags) = "uri:\"id\"" ]`, "")
|
||||
}
|
||||
|
||||
protoMessageDetailCode, err := tmplExecuteWithFilter(data, protoMessageDetailTmpl, columnID, columnCreatedAt, columnUpdatedAt)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user