fix: 足迹模块sql优化,增加事务控制
This commit is contained in:
parent
79ccab6869
commit
519ccb7ddd
@ -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<FootPrint> {
|
||||
*
|
||||
* @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);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user