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