MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / Generate

Function Generate

pkg/sql2code/sql2code.go:212–231  ·  view source on GitHub ↗

Generate model, json, dao, handler, proto codes

(args *Args)

Source from the content-addressed store, hash-verified

210
211// Generate model, json, dao, handler, proto codes
212func Generate(args *Args) (map[string]string, error) {
213 if err := args.checkValid(); err != nil {
214 return nil, err
215 }
216
217 sql, fieldTypes, err := getSQL(args)
218 if err != nil {
219 return nil, err
220 }
221 if fieldTypes != nil {
222 args.fieldTypes = fieldTypes
223 }
224 if sql == "" {
225 return nil, fmt.Errorf("get sql from %s error, maybe the table %s doesn't exist", args.DBDriver, args.DBTable)
226 }
227
228 opt := setOptions(args)
229
230 return parser.ParseSQL(sql, opt...)
231}

Callers 14

SQLCommandFunction · 0.92
HandlerPbCommandFunction · 0.92
ModelCommandFunction · 0.92
HTTPCommandFunction · 0.92
HandlerCommandFunction · 0.92
DaoCommandFunction · 0.92
ServiceCommandFunction · 0.92
RPCCommandFunction · 0.92
GRPCAndHTTPCommandFunction · 0.92
ProtobufCommandFunction · 0.92
GenerateOneFunction · 0.85

Calls 5

ParseSQLFunction · 0.92
getSQLFunction · 0.85
setOptionsFunction · 0.85
ErrorfMethod · 0.80
checkValidMethod · 0.45

Tested by 2

TestGenerateFunction · 0.68
TestGenerateErrorFunction · 0.68