Чуть измени список пользователей

actency-mysql57-replication
Andrey Ivanov 2021-01-11 09:59:00 +03:00 committed by ya@tiburon.su
parent 4499a3c7f2
commit f067e68d3d
2 changed files with 21 additions and 2 deletions

View File

@ -93,7 +93,26 @@ func GetUserList(app application.App, user auth.User, r render.Render) {
var users []auth.UserModel
var tmp auth.UserModel
var tmpTime string
var results, err = app.DB.Query(`SELECT id, name, surname, birthdate, gender, city FROM users`)
query := fmt.Sprintf(`SELECT
users.id as id,
users.name as name,
users.surname as surname,
users.birthdate as birthdate,
users.gender as gender,
users.city as city
FROM
users
WHERE
NOT users.id=%d
AND users.id NOT IN (
SELECT
relations.friendId
FROM
relations
WHERE
relations.userId=%d)`, int(user.(*auth.UserModel).Id), int(user.(*auth.UserModel).Id))
var results, err = app.DB.Query(query)
if err != nil || results == nil {
err500("can't get user list from DB: ", err, r)
}

View File

@ -18,7 +18,7 @@
</style>
</head>
<body>
<h2>List of all users</h2>
<h2>List of all unrelated users</h2>
<table>
<thead>
<tr>