1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-21 22:40:54 +00:00

Merge pull request #4183 from flycash/rft/module-2

Reorganize package
This commit is contained in:
Ming Deng 2020-08-23 21:43:48 +08:00 committed by GitHub
commit 597c55d547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
260 changed files with 466 additions and 353 deletions

View File

@ -23,6 +23,26 @@ cp ./githook/pre-commit ./.git/hooks/pre-commit
``` ```
This will add git hooks into .git/hooks. Or you can add it manually. This will add git hooks into .git/hooks. Or you can add it manually.
## Prepare middleware
Beego uses many middlewares, including MySQL, Redis, SSDB and so on.
We provide docker compose file to start all middlewares.
You can run:
```shell script
docker-compose -f scripts/test_docker_compose.yml up -d
```
Unit tests read addressed from environment, here is an example:
```shell script
export ORM_DRIVER=mysql
export ORM_SOURCE="beego:test@tcp(192.168.0.105:13306)/orm_test?charset=utf8"
export MEMCACHE_ADDR="192.168.0.105:11211"
export REDIS_ADDR="192.168.0.105:6379"
export SSDB_ADDR="192.168.0.105:8888"
```
## Contribution guidelines ## Contribution guidelines
### Pull requests ### Pull requests

View File

@ -1,4 +1,4 @@
// Copyright 2020 beego // Copyright 2020
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -12,5 +12,5 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// we will move all web related codes here // used to keep compatible with v1.x
package web package adapter

View File

@ -37,7 +37,7 @@ import (
"github.com/bradfitz/gomemcache/memcache" "github.com/bradfitz/gomemcache/memcache"
"github.com/astaxie/beego/pkg/cache" "github.com/astaxie/beego/pkg/client/cache"
) )
// Cache Memcache adapter. // Cache Memcache adapter.

View File

@ -15,17 +15,26 @@
package memcache package memcache
import ( import (
"fmt"
"os"
_ "github.com/bradfitz/gomemcache/memcache" _ "github.com/bradfitz/gomemcache/memcache"
"strconv" "strconv"
"testing" "testing"
"time" "time"
"github.com/astaxie/beego/pkg/cache" "github.com/astaxie/beego/pkg/client/cache"
) )
func TestMemcacheCache(t *testing.T) { func TestMemcacheCache(t *testing.T) {
bm, err := cache.NewCache("memcache", `{"conn": "127.0.0.1:11211"}`)
addr := os.Getenv("MEMCACHE_ADDR")
if addr == "" {
addr = "127.0.0.1:11211"
}
bm, err := cache.NewCache("memcache", fmt.Sprintf(`{"conn": "%s"}`, addr))
if err != nil { if err != nil {
t.Error("init err") t.Error("init err")
} }

View File

@ -39,7 +39,7 @@ import (
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/astaxie/beego/pkg/cache" "github.com/astaxie/beego/pkg/client/cache"
) )
var ( var (

View File

@ -16,17 +16,24 @@ package redis
import ( import (
"fmt" "fmt"
"os"
"testing" "testing"
"time" "time"
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/astaxie/beego/pkg/cache" "github.com/astaxie/beego/pkg/client/cache"
) )
func TestRedisCache(t *testing.T) { func TestRedisCache(t *testing.T) {
bm, err := cache.NewCache("redis", `{"conn": "127.0.0.1:6379"}`)
redisAddr := os.Getenv("REDIS_ADDR")
if redisAddr == "" {
redisAddr = "127.0.0.1:6379"
}
bm, err := cache.NewCache("redis", fmt.Sprintf(`{"conn": "%s"}`, redisAddr))
if err != nil { if err != nil {
t.Error("init err") t.Error("init err")
} }
@ -110,8 +117,14 @@ func TestRedisCache(t *testing.T) {
func TestCache_Scan(t *testing.T) { func TestCache_Scan(t *testing.T) {
timeoutDuration := 10 * time.Second timeoutDuration := 10 * time.Second
addr := os.Getenv("REDIS_ADDR")
if addr == "" {
addr = "127.0.0.1:6379"
}
// init // init
bm, err := cache.NewCache("redis", `{"conn": "127.0.0.1:6379"}`) bm, err := cache.NewCache("redis", fmt.Sprintf(`{"conn": "%s"}`, addr))
if err != nil { if err != nil {
t.Error("init err") t.Error("init err")
} }
@ -121,6 +134,7 @@ func TestCache_Scan(t *testing.T) {
t.Error("set Error", err) t.Error("set Error", err)
} }
} }
time.Sleep(time.Second)
// scan all for the first time // scan all for the first time
keys, err := bm.(*Cache).Scan(DefaultKey + ":*") keys, err := bm.(*Cache).Scan(DefaultKey + ":*")
if err != nil { if err != nil {

View File

@ -9,7 +9,7 @@ import (
"github.com/ssdb/gossdb/ssdb" "github.com/ssdb/gossdb/ssdb"
"github.com/astaxie/beego/pkg/cache" "github.com/astaxie/beego/pkg/client/cache"
) )
// Cache SSDB adapter // Cache SSDB adapter

View File

@ -1,15 +1,23 @@
package ssdb package ssdb
import ( import (
"fmt"
"os"
"strconv" "strconv"
"testing" "testing"
"time" "time"
"github.com/astaxie/beego/pkg/cache" "github.com/astaxie/beego/pkg/client/cache"
) )
func TestSsdbcacheCache(t *testing.T) { func TestSsdbcacheCache(t *testing.T) {
ssdb, err := cache.NewCache("ssdb", `{"conn": "127.0.0.1:8888"}`)
ssdbAddr := os.Getenv("SSDB_ADDR")
if ssdbAddr == "" {
ssdbAddr = "127.0.0.1:8888"
}
ssdb, err := cache.NewCache("ssdb", fmt.Sprintf(`{"conn": "%s"}`, ssdbAddr))
if err != nil { if err != nil {
t.Error("init err") t.Error("init err")
} }

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/pkg/httplib" "github.com/astaxie/beego/pkg/client/httplib"
logKit "github.com/go-kit/kit/log" logKit "github.com/go-kit/kit/log"
opentracingKit "github.com/go-kit/kit/tracing/opentracing" opentracingKit "github.com/go-kit/kit/tracing/opentracing"
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"

View File

@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/astaxie/beego/pkg/httplib" "github.com/astaxie/beego/pkg/client/httplib"
) )
func TestFilterChainBuilder_FilterChain(t *testing.T) { func TestFilterChainBuilder_FilterChain(t *testing.T) {

View File

@ -22,8 +22,8 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
beego "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/client/httplib"
"github.com/astaxie/beego/pkg/httplib" "github.com/astaxie/beego/pkg/server/web"
) )
type FilterChainBuilder struct { type FilterChainBuilder struct {
@ -36,9 +36,9 @@ func (builder *FilterChainBuilder) FilterChain(next httplib.Filter) httplib.Filt
Name: "beego", Name: "beego",
Subsystem: "remote_http_request", Subsystem: "remote_http_request",
ConstLabels: map[string]string{ ConstLabels: map[string]string{
"server": beego.BConfig.ServerName, "server": web.BConfig.ServerName,
"env": beego.BConfig.RunMode, "env": web.BConfig.RunMode,
"appname": beego.BConfig.AppName, "appname": web.BConfig.AppName,
}, },
Help: "The statics info for remote http requests", Help: "The statics info for remote http requests",
}, []string{"proto", "scheme", "method", "host", "path", "status", "duration", "isError"}) }, []string{"proto", "scheme", "method", "host", "path", "status", "duration", "isError"})

View File

@ -22,7 +22,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/astaxie/beego/pkg/httplib" "github.com/astaxie/beego/pkg/client/httplib"
) )
func TestFilterChainBuilder_FilterChain(t *testing.T) { func TestFilterChainBuilder_FilterChain(t *testing.T) {

View File

@ -15,8 +15,9 @@
package testing package testing
import ( import (
"github.com/astaxie/beego/pkg/config" "github.com/astaxie/beego/pkg/client/httplib"
"github.com/astaxie/beego/pkg/httplib"
"github.com/astaxie/beego/pkg/infrastructure/config"
) )
var port = "" var port = ""

View File

@ -22,7 +22,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
) )
const ( const (

View File

@ -21,11 +21,10 @@ import (
"sync" "sync"
"time" "time"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
"github.com/astaxie/beego/pkg/infrastructure/utils"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/astaxie/beego/pkg/common"
) )
// DriverType database driver constant int. // DriverType database driver constant int.
@ -341,7 +340,7 @@ func detectTZ(al *alias) {
} }
} }
func addAliasWthDB(aliasName, driverName string, db *sql.DB, params ...common.KV) (*alias, error) { func addAliasWthDB(aliasName, driverName string, db *sql.DB, params ...utils.KV) (*alias, error) {
existErr := fmt.Errorf("DataBase alias name `%s` already registered, cannot reuse", aliasName) existErr := fmt.Errorf("DataBase alias name `%s` already registered, cannot reuse", aliasName)
if _, ok := dataBaseCache.get(aliasName); ok { if _, ok := dataBaseCache.get(aliasName); ok {
return nil, existErr return nil, existErr
@ -359,8 +358,8 @@ func addAliasWthDB(aliasName, driverName string, db *sql.DB, params ...common.KV
return al, nil return al, nil
} }
func newAliasWithDb(aliasName, driverName string, db *sql.DB, params ...common.KV) (*alias, error) { func newAliasWithDb(aliasName, driverName string, db *sql.DB, params ...utils.KV) (*alias, error) {
kvs := common.NewKVs(params...) kvs := utils.NewKVs(params...)
var stmtCache *lru.Cache var stmtCache *lru.Cache
var stmtCacheSize int var stmtCacheSize int
@ -418,13 +417,13 @@ func newAliasWithDb(aliasName, driverName string, db *sql.DB, params ...common.K
} }
// AddAliasWthDB add a aliasName for the drivename // AddAliasWthDB add a aliasName for the drivename
func AddAliasWthDB(aliasName, driverName string, db *sql.DB, params ...common.KV) error { func AddAliasWthDB(aliasName, driverName string, db *sql.DB, params ...utils.KV) error {
_, err := addAliasWthDB(aliasName, driverName, db, params...) _, err := addAliasWthDB(aliasName, driverName, db, params...)
return err return err
} }
// RegisterDataBase Setting the database connect params. Use the database driver self dataSource args. // RegisterDataBase Setting the database connect params. Use the database driver self dataSource args.
func RegisterDataBase(aliasName, driverName, dataSource string, params ...common.KV) error { func RegisterDataBase(aliasName, driverName, dataSource string, params ...utils.KV) error {
var ( var (
err error err error
db *sql.DB db *sql.DB

View File

@ -18,7 +18,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -18,7 +18,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
) )
// oracle operators. // oracle operators.

View File

@ -21,7 +21,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
) )
// sqlite operators. // sqlite operators.

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"github.com/astaxie/beego/pkg/common" "github.com/astaxie/beego/pkg/infrastructure/utils"
) )
// DoNothingOrm won't do anything, usually you use this to custom your mock Ormer implementation // DoNothingOrm won't do anything, usually you use this to custom your mock Ormer implementation
@ -54,11 +54,11 @@ func (d *DoNothingOrm) ReadOrCreateWithCtx(ctx context.Context, md interface{},
return false, 0, nil return false, 0, nil
} }
func (d *DoNothingOrm) LoadRelated(md interface{}, name string, args ...common.KV) (int64, error) { func (d *DoNothingOrm) LoadRelated(md interface{}, name string, args ...utils.KV) (int64, error) {
return 0, nil return 0, nil
} }
func (d *DoNothingOrm) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...common.KV) (int64, error) { func (d *DoNothingOrm) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) {
return 0, nil return 0, nil
} }

View File

@ -19,9 +19,10 @@ import (
"reflect" "reflect"
"strings" "strings"
"github.com/astaxie/beego/pkg/bean" "github.com/astaxie/beego/pkg/infrastructure/logs"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/client/orm"
"github.com/astaxie/beego/pkg/infrastructure/bean"
) )
// DefaultValueFilterChainBuilder only works for InsertXXX method, // DefaultValueFilterChainBuilder only works for InsertXXX method,

View File

@ -19,7 +19,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/client/orm"
) )
func TestDefaultValueFilterChainBuilder_FilterChain(t *testing.T) { func TestDefaultValueFilterChainBuilder_FilterChain(t *testing.T) {

View File

@ -20,7 +20,7 @@ import (
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/client/orm"
) )
// FilterChainBuilder provides an extension point // FilterChainBuilder provides an extension point

View File

@ -21,7 +21,7 @@ import (
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/client/orm"
) )
func TestFilterChainBuilder_FilterChain(t *testing.T) { func TestFilterChainBuilder_FilterChain(t *testing.T) {

View File

@ -22,8 +22,8 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
beego "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/client/orm"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/server/web"
) )
// FilterChainBuilder is an extension point, // FilterChainBuilder is an extension point,
@ -42,9 +42,9 @@ func NewFilterChainBuilder() *FilterChainBuilder {
Name: "beego", Name: "beego",
Subsystem: "orm_operation", Subsystem: "orm_operation",
ConstLabels: map[string]string{ ConstLabels: map[string]string{
"server": beego.BConfig.ServerName, "server": web.BConfig.ServerName,
"env": beego.BConfig.RunMode, "env": web.BConfig.RunMode,
"appname": beego.BConfig.AppName, "appname": web.BConfig.AppName,
}, },
Help: "The statics info for orm operation", Help: "The statics info for orm operation",
}, []string{"method", "name", "duration", "insideTx", "txName"}) }, []string{"method", "name", "duration", "insideTx", "txName"})

View File

@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/client/orm"
) )
func TestFilterChainBuilder_FilterChain(t *testing.T) { func TestFilterChainBuilder_FilterChain(t *testing.T) {

View File

@ -20,7 +20,7 @@ import (
"reflect" "reflect"
"time" "time"
"github.com/astaxie/beego/pkg/common" "github.com/astaxie/beego/pkg/infrastructure/utils"
) )
const ( const (
@ -137,11 +137,11 @@ func (f *filterOrmDecorator) ReadOrCreateWithCtx(ctx context.Context, md interfa
return res[0].(bool), res[1].(int64), f.convertError(res[2]) return res[0].(bool), res[1].(int64), f.convertError(res[2])
} }
func (f *filterOrmDecorator) LoadRelated(md interface{}, name string, args ...common.KV) (int64, error) { func (f *filterOrmDecorator) LoadRelated(md interface{}, name string, args ...utils.KV) (int64, error) {
return f.LoadRelatedWithCtx(context.Background(), md, name, args...) return f.LoadRelatedWithCtx(context.Background(), md, name, args...)
} }
func (f *filterOrmDecorator) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...common.KV) (int64, error) { func (f *filterOrmDecorator) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) {
mi, _ := modelCache.getByMd(md) mi, _ := modelCache.getByMd(md)
inv := &Invocation{ inv := &Invocation{

View File

@ -21,7 +21,7 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/astaxie/beego/pkg/common" "github.com/astaxie/beego/pkg/infrastructure/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -362,7 +362,7 @@ func (f *filterMockOrm) ReadForUpdateWithCtx(ctx context.Context, md interface{}
return errors.New("read for update error") return errors.New("read for update error")
} }
func (f *filterMockOrm) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...common.KV) (int64, error) { func (f *filterMockOrm) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) {
return 99, errors.New("load related error") return 99, errors.New("load related error")
} }

View File

@ -17,7 +17,7 @@ package hints
import ( import (
"time" "time"
"github.com/astaxie/beego/pkg/common" "github.com/astaxie/beego/pkg/infrastructure/utils"
) )
const ( const (
@ -43,7 +43,7 @@ type Hint struct {
value interface{} value interface{}
} }
var _ common.KV = new(Hint) var _ utils.KV = new(Hint)
// GetKey return key // GetKey return key
func (s *Hint) GetKey() interface{} { func (s *Hint) GetKey() interface{} {
@ -55,7 +55,7 @@ func (s *Hint) GetValue() interface{} {
return s.value return s.value
} }
var _ common.KV = new(Hint) var _ utils.KV = new(Hint)
// MaxIdleConnections return a hint about MaxIdleConnections // MaxIdleConnections return a hint about MaxIdleConnections
func MaxIdleConnections(v int) *Hint { func MaxIdleConnections(v int) *Hint {

View File

@ -17,7 +17,7 @@ package migration
import ( import (
"fmt" "fmt"
"github.com/astaxie/beego/pkg/logs" "github.com/astaxie/beego/pkg/infrastructure/logs"
) )
// Index struct defines the structure of Index Columns // Index struct defines the structure of Index Columns

View File

@ -33,8 +33,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/astaxie/beego/pkg/logs" "github.com/astaxie/beego/pkg/client/orm"
"github.com/astaxie/beego/pkg/orm" "github.com/astaxie/beego/pkg/infrastructure/logs"
) )
// const the data format for the bee generate migration datatype // const the data format for the bee generate migration datatype

View File

@ -22,7 +22,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq" _ "github.com/lib/pq"
@ -303,7 +303,7 @@ type Post struct {
Content string `orm:"type(text)"` Content string `orm:"type(text)"`
Created time.Time `orm:"auto_now_add"` Created time.Time `orm:"auto_now_add"`
Updated time.Time `orm:"auto_now"` Updated time.Time `orm:"auto_now"`
Tags []*Tag `orm:"rel(m2m);rel_through(github.com/astaxie/beego/pkg/orm.PostTags)"` Tags []*Tag `orm:"rel(m2m);rel_through(github.com/astaxie/beego/pkg/client/orm.PostTags)"`
} }
func (u *Post) TableIndex() [][]string { func (u *Post) TableIndex() [][]string {
@ -361,7 +361,7 @@ type Group struct {
type Permission struct { type Permission struct {
ID int `orm:"column(id)"` ID int `orm:"column(id)"`
Name string Name string
Groups []*Group `orm:"rel(m2m);rel_through(github.com/astaxie/beego/pkg/orm.GroupPermissions)"` Groups []*Group `orm:"rel(m2m);rel_through(github.com/astaxie/beego/pkg/client/orm.GroupPermissions)"`
} }
type GroupPermissions struct { type GroupPermissions struct {
@ -470,7 +470,7 @@ var (
usage: usage:
go get -u github.com/astaxie/beego/pkg/orm go get -u github.com/astaxie/beego/pkg/client/orm
go get -u github.com/go-sql-driver/mysql go get -u github.com/go-sql-driver/mysql
go get -u github.com/mattn/go-sqlite3 go get -u github.com/mattn/go-sqlite3
go get -u github.com/lib/pq go get -u github.com/lib/pq
@ -480,20 +480,20 @@ var (
mysql -u root -e 'create database orm_test;' mysql -u root -e 'create database orm_test;'
export ORM_DRIVER=mysql export ORM_DRIVER=mysql
export ORM_SOURCE="root:@/orm_test?charset=utf8" export ORM_SOURCE="root:@/orm_test?charset=utf8"
go test -v github.com/astaxie/beego/pkg/orm go test -v github.com/astaxie/beego/pkg/client/orm
#### Sqlite3 #### Sqlite3
export ORM_DRIVER=sqlite3 export ORM_DRIVER=sqlite3
export ORM_SOURCE='file:memory_test?mode=memory' export ORM_SOURCE='file:memory_test?mode=memory'
go test -v github.com/astaxie/beego/pkg/orm go test -v github.com/astaxie/beego/pkg/client/orm
#### PostgreSQL #### PostgreSQL
psql -c 'create database orm_test;' -U postgres psql -c 'create database orm_test;' -U postgres
export ORM_DRIVER=postgres export ORM_DRIVER=postgres
export ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable" export ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable"
go test -v github.com/astaxie/beego/pkg/orm go test -v github.com/astaxie/beego/pkg/client/orm
#### TiDB #### TiDB
export ORM_DRIVER=tidb export ORM_DRIVER=tidb

View File

@ -21,7 +21,7 @@
// //
// import ( // import (
// "fmt" // "fmt"
// "github.com/astaxie/beego/pkg/orm" // "github.com/astaxie/beego/pkg/client/orm"
// _ "github.com/go-sql-driver/mysql" // import your used driver // _ "github.com/go-sql-driver/mysql" // import your used driver
// ) // )
// //
@ -62,10 +62,10 @@ import (
"reflect" "reflect"
"time" "time"
"github.com/astaxie/beego/pkg/common" "github.com/astaxie/beego/pkg/client/orm/hints"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/infrastructure/utils"
"github.com/astaxie/beego/pkg/logs" "github.com/astaxie/beego/pkg/infrastructure/logs"
) )
// DebugQueries define the debug // DebugQueries define the debug
@ -307,10 +307,10 @@ func (o *ormBase) QueryM2MWithCtx(ctx context.Context, md interface{}, name stri
// for _,tag := range post.Tags{...} // for _,tag := range post.Tags{...}
// //
// make sure the relation is defined in model struct tags. // make sure the relation is defined in model struct tags.
func (o *ormBase) LoadRelated(md interface{}, name string, args ...common.KV) (int64, error) { func (o *ormBase) LoadRelated(md interface{}, name string, args ...utils.KV) (int64, error) {
return o.LoadRelatedWithCtx(context.Background(), md, name, args...) return o.LoadRelatedWithCtx(context.Background(), md, name, args...)
} }
func (o *ormBase) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...common.KV) (int64, error) { func (o *ormBase) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) {
_, fi, ind, qseter := o.queryRelated(md, name) _, fi, ind, qseter := o.queryRelated(md, name)
qs := qseter.(*querySet) qs := qseter.(*querySet)
@ -319,7 +319,7 @@ func (o *ormBase) LoadRelatedWithCtx(ctx context.Context, md interface{}, name s
var limit, offset int64 var limit, offset int64
var order string var order string
kvs := common.NewKVs(args...) kvs := utils.NewKVs(args...)
kvs.IfContains(hints.KeyRelDepth, func(value interface{}) { kvs.IfContains(hints.KeyRelDepth, func(value interface{}) {
if v, ok := value.(bool); ok { if v, ok := value.(bool); ok {
if v { if v {
@ -603,7 +603,7 @@ func NewOrmUsingDB(aliasName string) Ormer {
} }
// NewOrmWithDB create a new ormer object with specify *sql.DB for query // NewOrmWithDB create a new ormer object with specify *sql.DB for query
func NewOrmWithDB(driverName, aliasName string, db *sql.DB, params ...common.KV) (Ormer, error) { func NewOrmWithDB(driverName, aliasName string, db *sql.DB, params ...utils.KV) (Ormer, error) {
al, err := newAliasWithDb(aliasName, driverName, db, params...) al, err := newAliasWithDb(aliasName, driverName, db, params...)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
) )
type colValue struct { type colValue struct {

View File

@ -31,7 +31,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/astaxie/beego/pkg/orm/hints" "github.com/astaxie/beego/pkg/client/orm/hints"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -20,7 +20,7 @@ import (
"reflect" "reflect"
"time" "time"
"github.com/astaxie/beego/pkg/common" "github.com/astaxie/beego/pkg/infrastructure/utils"
) )
// TableNaming is usually used by model // TableNaming is usually used by model
@ -183,8 +183,8 @@ type DQL interface {
// hints.Offset int offset default offset 0 // hints.Offset int offset default offset 0
// hints.OrderBy string order for example : "-Id" // hints.OrderBy string order for example : "-Id"
// make sure the relation is defined in model struct tags. // make sure the relation is defined in model struct tags.
LoadRelated(md interface{}, name string, args ...common.KV) (int64, error) LoadRelated(md interface{}, name string, args ...utils.KV) (int64, error)
LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...common.KV) (int64, error) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error)
// create a models to models queryer // create a models to models queryer
// for example: // for example:

View File

@ -1,17 +1,15 @@
/* // Copyright 2020
Package beego provide a MVC framework //
beego: an open-source, high-performance, modular, full-stack web framework // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
It is used for rapid development of RESTful APIs, web apps and backend services in Go. package pkg
beego is inspired by Tornado, Sinatra and Flask with the added benefit of some Go-specific features such as interfaces and struct embedding.
package main
import "github.com/astaxie/beego/pkg"
func main() {
beego.Run()
}
more information: http://beego.me
*/
package beego

View File

@ -22,7 +22,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/astaxie/beego/pkg/logs" "github.com/astaxie/beego/pkg/infrastructure/logs"
) )
const DefaultValueTagKey = "default" const DefaultValueTagKey = "default"

View File

@ -21,7 +21,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/astaxie/beego/pkg/utils" "github.com/astaxie/beego/pkg/infrastructure/utils"
) )
var env *utils.BeeMap var env *utils.BeeMap

View File

@ -24,7 +24,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/astaxie/beego/pkg/config" "github.com/astaxie/beego/pkg/infrastructure/config"
) )
// JSONConfig is a json config parser and implements Config interface. // JSONConfig is a json config parser and implements Config interface.

View File

@ -19,7 +19,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/astaxie/beego/pkg/config" "github.com/astaxie/beego/pkg/infrastructure/config"
) )
func TestJsonStartsWithArray(t *testing.T) { func TestJsonStartsWithArray(t *testing.T) {

View File

@ -39,7 +39,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/astaxie/beego/pkg/config" "github.com/astaxie/beego/pkg/infrastructure/config"
"github.com/beego/x2j" "github.com/beego/x2j"
) )

View File

@ -19,7 +19,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/astaxie/beego/pkg/config" "github.com/astaxie/beego/pkg/infrastructure/config"
) )
func TestXML(t *testing.T) { func TestXML(t *testing.T) {

View File

@ -40,7 +40,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/astaxie/beego/pkg/config" "github.com/astaxie/beego/pkg/infrastructure/config"
"github.com/beego/goyaml2" "github.com/beego/goyaml2"
) )

Some files were not shown because too many files have changed in this diff Show More