diff --git a/code/rest/install_controller.go b/code/rest/install_controller.go index 02b417f..cb942a8 100644 --- a/code/rest/install_controller.go +++ b/code/rest/install_controller.go @@ -226,8 +226,8 @@ func (this *InstallController) CreateTable(writer http.ResponseWriter, request * for _, iBase := range this.tableNames { - //complete the missing fields or create table. - db1 := db.AutoMigrate(iBase) + //complete the missing fields or create table. use utf8 charset + db1 := db.Set("gorm:table_options", "CHARSET=utf8").AutoMigrate(iBase) this.PanicError(db1.Error) exist, allFields, missingFields := this.getTableMeta(db, iBase) diff --git a/code/rest/user_controller.go b/code/rest/user_controller.go index 312aa7d..af4aa3d 100644 --- a/code/rest/user_controller.go +++ b/code/rest/user_controller.go @@ -274,8 +274,6 @@ func (this *UserController) Page(writer http.ResponseWriter, request *http.Reque orderSort := request.FormValue("orderSort") username := request.FormValue("username") - email := request.FormValue("email") - phone := request.FormValue("phone") status := request.FormValue("status") orderLastTime := request.FormValue("orderLastTime") @@ -311,7 +309,7 @@ func (this *UserController) Page(writer http.ResponseWriter, request *http.Reque }, } - pager := this.userDao.Page(page, pageSize, username, email, phone, status, sortArray) + pager := this.userDao.Page(page, pageSize, username, status, sortArray) return this.Success(pager) } diff --git a/code/rest/user_dao.go b/code/rest/user_dao.go index 784b863..f1ec4eb 100644 --- a/code/rest/user_dao.go +++ b/code/rest/user_dao.go @@ -72,7 +72,7 @@ func (this *UserDao) FindByUsername(username string) *User { return user } -func (this *UserDao) Page(page int, pageSize int, username string, email string, phone string, status string, sortArray []builder.OrderPair) *Pager { +func (this *UserDao) Page(page int, pageSize int, username string, status string, sortArray []builder.OrderPair) *Pager { var wp = &builder.WherePair{} @@ -80,14 +80,6 @@ func (this *UserDao) Page(page int, pageSize int, username string, email string, wp = wp.And(&builder.WherePair{Query: "username LIKE ?", Args: []interface{}{"%" + username + "%"}}) } - if email != "" { - wp = wp.And(&builder.WherePair{Query: "email LIKE ?", Args: []interface{}{"%" + email + "%"}}) - } - - if phone != "" { - wp = wp.And(&builder.WherePair{Query: "phone = ?", Args: []interface{}{phone}}) - } - if status != "" { wp = wp.And(&builder.WherePair{Query: "status = ?", Args: []interface{}{status}}) }