新增查询全部用户api
This commit is contained in:
19
api/user.go
19
api/user.go
@@ -203,6 +203,25 @@ func GetInfoByUserId(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// GetAllUserInfo 获取所有用户信息
|
||||
func GetAllUserInfo(c *gin.Context) {
|
||||
var info PublicAllInfoResponse
|
||||
var alla []PublicAllInfoResponse
|
||||
Link()
|
||||
DB := db.DBsnctf
|
||||
rows, err := DB.Debug().Select([]string{"id", "username", "affiliation", "country", "website", "hidden"}).Table("user").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)
|
||||
alla = append(alla, info)
|
||||
}
|
||||
c.JSON(200, gin.H{"code": 200, "data": alla})
|
||||
}
|
||||
|
||||
// checkUsername 验证用户名是否符合中文数字字母下划线横杠,长度1到10位,返回true或false
|
||||
func checkUsername(username string) bool {
|
||||
if !(utf8.RuneCountInString(username) > 0) || !(utf8.RuneCountInString(username) < 11) {
|
||||
|
Reference in New Issue
Block a user