38 lines
917 B
Go
38 lines
917 B
Go
package services
|
|
|
|
import (
|
|
"cron_admin/app/http/entities/backend"
|
|
"cron_admin/app/models/userinfomodel"
|
|
"xorm.io/builder"
|
|
)
|
|
|
|
func GetListByWhere(request *backend.UserListRequest, page int, limit int) (count int64, UserListInfo []userinfomodel.UserInfo, err error) {
|
|
conn := builder.NewCond()
|
|
|
|
if request.Mobile != "" {
|
|
conn = conn.And(builder.Like{"Mobile", request.Mobile})
|
|
}
|
|
if request.Status != 0 {
|
|
conn = conn.And(builder.Eq{"Status": request.Status})
|
|
}
|
|
session := userinfomodel.GetInstance().GetDb().Where(conn)
|
|
|
|
if page != 0 && limit != 0 {
|
|
session = session.Limit(page, (page-1)*limit)
|
|
}
|
|
count, err = session.FindAndCount(&UserListInfo)
|
|
|
|
if err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func UserInfo(id int) (has bool, UserCouponModel userinfomodel.UserInfo, err error) {
|
|
has, err = userinfomodel.GetInstance().GetDb().Where("id =?", id).Get(&UserCouponModel)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|