mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
1. remove unused typeMappingMysqlOfRpc type.
2. update README.md
This commit is contained in:
parent
7dfe63055e
commit
2e7cd9b414
49
README.md
49
README.md
@ -5,26 +5,6 @@ bee
|
||||
|
||||
Bee is a command line tool facilitating development with beego framework.
|
||||
|
||||
|
||||
## 新增采用 Hprose 发布RPC服务
|
||||
|
||||
```bash
|
||||
go get github.com/Lao-liu/bee
|
||||
|
||||
bee hprose DbApi -conn=root:@tcp\(127.0.0.1:3306\)/test
|
||||
OR
|
||||
bee hprose DbApi -conn=root:@tcp\(127.0.0.1:3306\)/test -tables=tablename
|
||||
|
||||
cd DbApi
|
||||
|
||||
bee run
|
||||
```
|
||||
|
||||
#### 浏览器打开 http://127.0.0.1:8080
|
||||
|
||||
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
- Go version >= 1.1.
|
||||
@ -164,6 +144,35 @@ In the appname folder has the follow struct:
|
||||
└── user.go
|
||||
```
|
||||
|
||||
## bee hprose
|
||||
|
||||
```bash
|
||||
usage: bee hprose [appname]
|
||||
|
||||
create an rpc application use hprose base on beego framework
|
||||
|
||||
bee hprose [appname] [-tables=""] [-driver=mysql] [-conn=root:@tcp(127.0.0.1:3306)/test]
|
||||
-tables: a list of table names separated by ',', default is empty, indicating all tables
|
||||
-driver: [mysql | postgres | sqlite], the default is mysql
|
||||
-conn: the connection string used by the driver, the default is ''
|
||||
e.g. for mysql: root:@tcp(127.0.0.1:3306)/test
|
||||
e.g. for postgres: postgres://postgres:postgres@127.0.0.1:5432/postgres
|
||||
|
||||
if conn is empty will create a example rpc application. otherwise generate rpc application use hprose based on an existing database.
|
||||
|
||||
In the current path, will create a folder named [appname]
|
||||
|
||||
In the appname folder has the follow struct:
|
||||
|
||||
├── conf
|
||||
│ └── app.conf
|
||||
├── main.go
|
||||
└── models
|
||||
└── object.go
|
||||
└── user.go
|
||||
|
||||
```
|
||||
|
||||
## bee bale
|
||||
|
||||
```bash
|
||||
|
@ -500,11 +500,7 @@ func (mysqlDB *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[strin
|
||||
// getGoDataType maps an SQL data type to Golang data type
|
||||
func (*MysqlDB) GetGoDataType(sqlType string) (goType string) {
|
||||
var typeMapping = map[string]string{}
|
||||
if isCreateHproseApp {
|
||||
typeMapping = typeMappingMysqlOfRpc
|
||||
} else {
|
||||
typeMapping = typeMappingMysql
|
||||
}
|
||||
if v, ok := typeMapping[sqlType]; ok {
|
||||
return v
|
||||
} else {
|
||||
|
@ -10,7 +10,7 @@
|
||||
* *
|
||||
* Build rpc application use Hprose base on beego *
|
||||
* *
|
||||
* LastModified: Oct 13, 2014 *
|
||||
* LastModified: Oct 23, 2014 *
|
||||
* Author: Liu jian <laoliu@lanmv.com> *
|
||||
* *
|
||||
\**********************************************************/
|
||||
@ -27,76 +27,6 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// typeMapping maps SQL data type to corresponding Go data type
|
||||
var typeMappingMysqlOfRpc = map[string]string{
|
||||
"int": "int", // int signed
|
||||
"integer": "int",
|
||||
"tinyint": "int8",
|
||||
"smallint": "int16",
|
||||
"mediumint": "int32",
|
||||
"bigint": "int64",
|
||||
"int unsigned": "uint", // int unsigned
|
||||
"integer unsigned": "uint",
|
||||
"tinyint unsigned": "uint8",
|
||||
"smallint unsigned": "uint16",
|
||||
"mediumint unsigned": "uint32",
|
||||
"bigint unsigned": "uint64",
|
||||
"bit": "uint64",
|
||||
"bool": "bool", // boolean
|
||||
"enum": "string", // enum
|
||||
"set": "string", // set
|
||||
"varchar": "string", // string & text
|
||||
"char": "string",
|
||||
"tinytext": "string",
|
||||
"mediumtext": "string",
|
||||
"text": "string",
|
||||
"longtext": "string",
|
||||
"blob": "[]byte", // blob as byte
|
||||
"tinyblob": "[]byte",
|
||||
"mediumblob": "[]byte",
|
||||
"longblob": "[]byte",
|
||||
"date": "time.Time", // time
|
||||
"datetime": "time.Time",
|
||||
"timestamp": "time.Time",
|
||||
"time": "time.Time",
|
||||
"float": "float32", // float & decimal
|
||||
"double": "float64",
|
||||
"decimal": "float64",
|
||||
"binary": "string", // binary
|
||||
"varbinary": "string",
|
||||
}
|
||||
|
||||
// typeMappingPostgres maps SQL data type to corresponding Go data type
|
||||
var typeMappingPostgresOfRpc = map[string]string{
|
||||
"serial": "int", // serial
|
||||
"big serial": "int64",
|
||||
"smallint": "int16", // int
|
||||
"integer": "int",
|
||||
"bigint": "int64",
|
||||
"boolean": "bool", // bool
|
||||
"char": "string", // string
|
||||
"character": "string",
|
||||
"character varying": "string",
|
||||
"varchar": "string",
|
||||
"text": "string",
|
||||
"date": "time.Time", // time
|
||||
"time": "time.Time",
|
||||
"timestamp": "time.Time",
|
||||
"timestamp without time zone": "time.Time",
|
||||
"interval": "string", // time interval, string for now
|
||||
"real": "float32", // float & decimal
|
||||
"double precision": "float64",
|
||||
"decimal": "float64",
|
||||
"numeric": "float64",
|
||||
"money": "float64", // money
|
||||
"bytea": "[]byte", // binary
|
||||
"tsvector": "string", // fulltext
|
||||
"ARRAY": "string", // array
|
||||
"USER-DEFINED": "string", // user defined
|
||||
"uuid": "string", // uuid
|
||||
"json": "string", // json
|
||||
}
|
||||
|
||||
func generateHproseAppcode(driver, connStr, level, tables, currpath string) {
|
||||
var mode byte
|
||||
switch level {
|
||||
|
@ -24,8 +24,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var isCreateHproseApp = false
|
||||
|
||||
var cmdHproseapp = &Command{
|
||||
// CustomFlags: true,
|
||||
UsageLine: "hprose [appname]",
|
||||
@ -257,7 +255,6 @@ func init() {
|
||||
}
|
||||
|
||||
func createhprose(cmd *Command, args []string) int {
|
||||
isCreateHproseApp = true
|
||||
curpath, _ := os.Getwd()
|
||||
if len(args) > 1 {
|
||||
cmd.Flag.Parse(args[1:])
|
||||
|
Loading…
Reference in New Issue
Block a user