mirror of
				https://github.com/beego/bee.git
				synced 2025-11-04 14:33:24 +00:00 
			
		
		
		
	bee 1.1.2
This commit is contained in:
		
							
								
								
									
										2
									
								
								bee.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								bee.go
									
									
									
									
									
								
							@@ -25,7 +25,7 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const version = "1.1.1"
 | 
					const version = "1.1.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Command struct {
 | 
					type Command struct {
 | 
				
			||||||
	// Run runs the command.
 | 
						// Run runs the command.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								g_docs.go
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								g_docs.go
									
									
									
									
									
								
							@@ -377,6 +377,8 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat
 | 
				
			|||||||
						panic(controllerName + " " + funcName + " has no object")
 | 
											panic(controllerName + " " + funcName + " has no object")
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					cmpath, m, mod, realTypes := getModel(st[2])
 | 
										cmpath, m, mod, realTypes := getModel(st[2])
 | 
				
			||||||
 | 
										//ll := strings.Split(st[2], ".")
 | 
				
			||||||
 | 
										//opts.Type = ll[len(ll)-1]
 | 
				
			||||||
					rs.ResponseModel = m
 | 
										rs.ResponseModel = m
 | 
				
			||||||
					if _, ok := modelsList[pkgpath+controllerName]; !ok {
 | 
										if _, ok := modelsList[pkgpath+controllerName]; !ok {
 | 
				
			||||||
						modelsList[pkgpath+controllerName] = make([]swagger.Model, 0)
 | 
											modelsList[pkgpath+controllerName] = make([]swagger.Model, 0)
 | 
				
			||||||
@@ -395,7 +397,8 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				para.Name = p[0]
 | 
									para.Name = p[0]
 | 
				
			||||||
				para.ParamType = p[1]
 | 
									para.ParamType = p[1]
 | 
				
			||||||
				para.DataType = p[2]
 | 
									pp := strings.Split(p[2], ".")
 | 
				
			||||||
 | 
									para.DataType = pp[len(pp)-1]
 | 
				
			||||||
				if len(p) > 4 {
 | 
									if len(p) > 4 {
 | 
				
			||||||
					para.Required, _ = strconv.ParseBool(p[3])
 | 
										para.Required, _ = strconv.ParseBool(p[3])
 | 
				
			||||||
					para.Description = p[4]
 | 
										para.Description = p[4]
 | 
				
			||||||
@@ -562,7 +565,6 @@ func getModel(str string) (pkgpath, objectname string, m swagger.Model, realType
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	fmt.Println(str)
 | 
					 | 
				
			||||||
	if m.Id == "" {
 | 
						if m.Id == "" {
 | 
				
			||||||
		ColorLog("can't find the object: %v", str)
 | 
							ColorLog("can't find the object: %v", str)
 | 
				
			||||||
		os.Exit(1)
 | 
							os.Exit(1)
 | 
				
			||||||
@@ -584,6 +586,10 @@ func typeAnalyser(f *ast.Field) (isSlice bool, realType string) {
 | 
				
			|||||||
			return true, fmt.Sprint(arr.Elt)
 | 
								return true, fmt.Sprint(arr.Elt)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
 | 
							switch t := f.Type.(type) {
 | 
				
			||||||
 | 
							case *ast.StarExpr:
 | 
				
			||||||
 | 
								return false, fmt.Sprint(t.X)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		return false, fmt.Sprint(f.Type)
 | 
							return false, fmt.Sprint(f.Type)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -599,13 +605,13 @@ func isBasicType(Type string) bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// refer to builtin.go
 | 
					// refer to builtin.go
 | 
				
			||||||
var basicTypes = []string{
 | 
					var basicTypes = []string{
 | 
				
			||||||
	"bool", "byte",
 | 
						"bool",
 | 
				
			||||||
	"uint", "uint8", "uint16", "uint32", "uint64",
 | 
						"uint", "uint8", "uint16", "uint32", "uint64",
 | 
				
			||||||
	"int", "int8", "int16", "int32", "int64",
 | 
						"int", "int8", "int16", "int32", "int64",
 | 
				
			||||||
	"float32", "float64",
 | 
						"float32", "float64",
 | 
				
			||||||
	"string",
 | 
						"string",
 | 
				
			||||||
	// "complex64", "complex128",
 | 
						"complex64", "complex128",
 | 
				
			||||||
	// "byte", "rune", "uintptr",
 | 
						"byte", "rune", "uintptr",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// regexp get json tag
 | 
					// regexp get json tag
 | 
				
			||||||
@@ -621,7 +627,8 @@ func grepJsonTag(tag string) string {
 | 
				
			|||||||
// append models
 | 
					// append models
 | 
				
			||||||
func appendModels(cmpath, pkgpath, controllerName string, realTypes []string) {
 | 
					func appendModels(cmpath, pkgpath, controllerName string, realTypes []string) {
 | 
				
			||||||
	for _, realType := range realTypes {
 | 
						for _, realType := range realTypes {
 | 
				
			||||||
		if realType != "" && strings.HasPrefix(realType, "[]") && !isBasicType(strings.TrimLeft(realType, "[]")) {
 | 
							if realType != "" && !isBasicType(strings.TrimLeft(realType, "[]")) &&
 | 
				
			||||||
 | 
								!strings.HasPrefix(realType, "map") && !strings.HasPrefix(realType, "&") {
 | 
				
			||||||
			if cmpath != "" {
 | 
								if cmpath != "" {
 | 
				
			||||||
				cmpath = strings.Join(strings.Split(cmpath, "/"), ".") + "."
 | 
									cmpath = strings.Join(strings.Split(cmpath, "/"), ".") + "."
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user