Browse Source

按名称收索和查询

pull/322/head
娄文智 3 years ago
parent
commit
b7fea79aa9
2 changed files with 7 additions and 0 deletions
  1. +1
    -0
      web/controllers/user_controller.go
  2. +6
    -0
      web/models/usertab_model.go

+ 1
- 0
web/controllers/user_controller.go View File

@ -185,6 +185,7 @@ func GetSysUserList(ctx iris.Context) {
data.Userid = ctx.URLParam("userid") data.Userid = ctx.URLParam("userid")
data.Status = ctx.URLParam("status") data.Status = ctx.URLParam("status")
data.Phone = ctx.URLParam("phone") data.Phone = ctx.URLParam("phone")
data.Name = ctx.URLParam("name")
result, count, err := data.GetPage(pageSize, pageIndex) result, count, err := data.GetPage(pageSize, pageIndex)
if err != nil { if err != nil {


+ 6
- 0
web/models/usertab_model.go View File

@ -174,6 +174,11 @@ func (t *Usertab) GetPage(pageSize int, pageIndex int) ([]Usertab, int, error) {
query = query.And("phone like ?", search) query = query.And("phone like ?", search)
where += " and phone like " + "'%" + t.Phone + "%'" where += " and phone like " + "'%" + t.Phone + "%'"
} }
if !utils.ValueIsEmpty(t.Name) {
searchName := "%" + t.Name + "%"
query = query.And("name like ?", searchName)
where += " and name like " + "'%" + t.Name + "%'"
}
Offset := (pageIndex - 1) * pageSize Offset := (pageIndex - 1) * pageSize
err := e.SQL("SELECT TOP " + utils.ValueToString(pageSize, "") + " usertab.* FROM usertab " + where + " AND (convert(varchar(10),pid)+convert(varchar(40),userid) NOT IN (SELECT TOP " + utils.ValueToString(Offset, "") + " convert(varchar(10),pid)+convert(varchar(40),userid) FROM usertab " + where + " ORDER BY createtime DESC)) ORDER BY createtime DESC").Find(&doc) err := e.SQL("SELECT TOP " + utils.ValueToString(pageSize, "") + " usertab.* FROM usertab " + where + " AND (convert(varchar(10),pid)+convert(varchar(40),userid) NOT IN (SELECT TOP " + utils.ValueToString(Offset, "") + " convert(varchar(10),pid)+convert(varchar(40),userid) FROM usertab " + where + " ORDER BY createtime DESC)) ORDER BY createtime DESC").Find(&doc)
if err != nil { if err != nil {
@ -251,6 +256,7 @@ func (t *Usertab) Update(id string) (update Usertab, err error) {
upuser.Avatar = t.Avatar upuser.Avatar = t.Avatar
upuser.Status = t.Status upuser.Status = t.Status
upuser.Nickname = t.Nickname upuser.Nickname = t.Nickname
upuser.Name = t.Name
upuser.Lastmodify = t.Lastmodify upuser.Lastmodify = t.Lastmodify
upuser.Lastmodifytime = t.Lastmodifytime upuser.Lastmodifytime = t.Lastmodifytime


Loading…
Cancel
Save