From 519ccb7ddd9e1e22ed259c3f0ad8a597b3147ddb Mon Sep 17 00:00:00 2001 From: Chopper711 Date: Fri, 10 Mar 2023 10:38:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B6=B3=E8=BF=B9=E6=A8=A1=E5=9D=97sql?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/mapper/FootprintMapper.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java b/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java index cdde3b9f..a2626156 100644 --- a/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java +++ b/framework/src/main/java/cn/lili/modules/member/mapper/FootprintMapper.java @@ -1,15 +1,9 @@ package cn.lili.modules.member.mapper; import cn.lili.modules.member.entity.dos.FootPrint; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Constants; import org.apache.ibatis.annotations.Delete; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; +import org.springframework.transaction.annotation.Transactional; /** * 浏览历史数据处理层 @@ -23,10 +17,21 @@ public interface FootprintMapper extends BaseMapper { * * @param memberId 会员ID */ - - @Delete("DELETE FROM li_foot_print WHERE id IN ("+ - "SELECT l2.id FROM (" + - "SELECT l3.id FROM li_foot_print l3 WHERE l3.member_id=${memberId} ORDER BY id DESC LIMIT 100,100) l2)") + @Transactional(rollbackFor = Exception.class) + @Delete("DELETE li_foot_print " + + "FROM li_foot_print " + + "LEFT JOIN ( " + + " SELECT id " + + " FROM ( " + + " SELECT id " + + " FROM li_foot_print " + + " WHERE member_id = ${memberId} " + + " ORDER BY create_time DESC " + + " LIMIT 1 " + + " ) AS keep " + + ") AS latest_footprints " + + "ON li_foot_print.id = latest_footprints.id " + + "WHERE li_foot_print.member_id = ${memberId} AND latest_footprints.id IS NULL; ") void deleteLastFootPrint(String memberId); } \ No newline at end of file