大面积重构
Response部分 usersController部分 中间件部分
This commit is contained in:
37
pkg/dao/sentences.go
Normal file
37
pkg/dao/sentences.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Conditions *map[string]interface{}
|
||||
|
||||
//TODO:未完成的sql语句构建器
|
||||
type QuerySql struct {
|
||||
Table string
|
||||
Tail string
|
||||
Conditions Conditions
|
||||
Rebind int
|
||||
body string
|
||||
}
|
||||
|
||||
func (b *QuerySql) Build() {
|
||||
|
||||
if b.Conditions == nil {
|
||||
|
||||
}
|
||||
var where []string
|
||||
var values []interface{}
|
||||
|
||||
for k, v := range *b.Conditions {
|
||||
values = append(values, v)
|
||||
where = append(where, fmt.Sprintf(`"%s"=%s`, k, "?"))
|
||||
}
|
||||
|
||||
b.body = "SELECT * FROM " + b.Table + " WHERE " + strings.Join(where, "AND")
|
||||
}
|
||||
|
||||
func (b *QuerySql) String() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user