You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
package diamond_register
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/user"
|
|
"recook/tools"
|
|
)
|
|
|
|
type BaseQuery struct {
|
|
Page int64 `json:"page" validate:"numeric"`
|
|
IsPage int `json:"is_page"`
|
|
Phone string `json:"phone"`
|
|
Status string `json:"status"`
|
|
}
|
|
type BaseResponse struct {
|
|
List interface{} `json:"data"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
func QueryDiamondList(c *gin.Context) {
|
|
var limit int64 = 10
|
|
|
|
// 每页显示数据条数
|
|
var page BaseQuery
|
|
err := tools.Params(&page, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
count := 0
|
|
where := "1=1"
|
|
if page.Status != "" {
|
|
where += " and status=" + page.Status
|
|
}
|
|
if page.Phone != "" {
|
|
where += " and phone = " + page.Phone
|
|
}
|
|
var list []user.DiamondRegister
|
|
dbc.DB.Where(where).Limit(limit).Offset((page.Page) * limit).Find(&list)
|
|
dbc.DB.Table("recook_diamond_register").Where(where).Count(&count)
|
|
for key, _info := range list {
|
|
userInfo := user.Information{}
|
|
dbc.DB.Where("id = ?", _info.IntroUserId).First(&userInfo)
|
|
list[key].IntroUserInfo = userInfo
|
|
}
|
|
back.Suc(c, "", &BaseResponse{
|
|
List: list,
|
|
Total: count,
|
|
})
|
|
//http.Suc(c, "操作成功", list)
|
|
}
|