2 files changed
+25
-1
No files matched your search
@@ -59,7 +59,7 @@ func (e *DBColumns) GetList() ([]DBColumns, error) {
|
||||
table = orm.Eloquent.Select("*").Table("information_schema.columns")
|
||||
table = table.Where("table_schema= ? ", config2.GenConfig.DBName)
|
||||
|
||||
table = table.Where("TABLE_NAME = ?", e.TableName)
|
||||
table = table.Where("TABLE_NAME = ?", e.TableName).Order("ORDINAL_POSITION asc")
|
||||
} else {
|
||||
tools.Assert(true, "目前只支持mysql数据库", 500)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package table
|
||||
|
||||
import (
|
||||
"hash/crc32"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Crc32Hash 用于32张分表
|
||||
func Crc32Hash(src string) string {
|
||||
sum := crc32.ChecksumIEEE([]byte(src)) % 32
|
||||
return strconv.Itoa(int(sum))
|
||||
}
|
||||
|
||||
// Crc16Hash 用于16张分表
|
||||
func Crc16Hash(src string) string {
|
||||
sum := crc32.ChecksumIEEE([]byte(src)) % 16
|
||||
return strconv.Itoa(int(sum))
|
||||
}
|
||||
|
||||
// Crc8Hash 用于8张分表
|
||||
func Crc8Hash(src string) string {
|
||||
sum := crc32.ChecksumIEEE([]byte(src)) % 8
|
||||
return strconv.Itoa(int(sum))
|
||||
}
|
||||
Reference in new issue
Block a user