From 46bcb9552e2e78d1d449a757e238e259141a5a28 Mon Sep 17 00:00:00 2001 From: Ke Chen Date: Fri, 20 Oct 2023 16:06:17 +0800 Subject: [PATCH] feat: floor_punishment distinct content --- apis/floor/apis.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apis/floor/apis.go b/apis/floor/apis.go index 777d0a3..2a2dfa6 100644 --- a/apis/floor/apis.go +++ b/apis/floor/apis.go @@ -739,11 +739,16 @@ func GetPunishmentHistory(c *fiber.Ctx) error { // search DB for user punishment history punishments := make([]string, 0, 10) err = DB.Raw( - `SELECT floor.content - FROM floor JOIN floor_history ON floor.id = floor_history.floor_id - WHERE floor.user_id <> floor_history.user_id - AND floor.user_id = ? - AND floor.deleted`, userID).Scan(&punishments).Error + `SELECT f.content +FROM floor f +WHERE f.id IN ( + SELECT distinct floor.id + FROM floor + JOIN floor_history ON floor.id = floor_history.floor_id + WHERE floor.user_id <> floor_history.user_id + AND floor.user_id = ? + AND floor.deleted = true +)`, userID).Scan(&punishments).Error if err != nil { return err }