新增查询全部用户api

This commit is contained in:
jiayuqi7813
2022-06-27 20:14:17 +08:00
parent 4b7ef7b4a7
commit d0b5c96f23

View File

@@ -209,14 +209,14 @@ func GetAllUserInfo(c *gin.Context) {
var alla []PublicAllInfoResponse
Link()
DB := db.DBsnctf
rows, err := DB.Debug().Select([]string{"id", "username", "affiliation", "country", "website", "hidden"}).Table("user").Rows()
rows, err := DB.Debug().Select([]string{"id", "username", "affiliation", "country", "website"}).Table("user").Where("hidden = ?", 0).Rows()
if err != nil {
c.JSON(400, gin.H{"code": 400, "msg": "Get info error!"})
return
}
for rows.Next() {
rows.Scan(&info.Id, &info.Username, &info.Affiliation, &info.Country, &info.Website, &info.Hidden)
rows.Scan(&info.Id, &info.Username, &info.Affiliation, &info.Country, &info.Website)
alla = append(alla, info)
}
c.JSON(200, gin.H{"code": 200, "data": alla})