fix: 足迹模块sql优化,增加事务控制
This commit is contained in:
parent
79ccab6869
commit
519ccb7ddd
@ -1,15 +1,9 @@
|
|||||||
package cn.lili.modules.member.mapper;
|
package cn.lili.modules.member.mapper;
|
||||||
|
|
||||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
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.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.Delete;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 浏览历史数据处理层
|
* 浏览历史数据处理层
|
||||||
@ -23,10 +17,21 @@ public interface FootprintMapper extends BaseMapper<FootPrint> {
|
|||||||
*
|
*
|
||||||
* @param memberId 会员ID
|
* @param memberId 会员ID
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Delete("DELETE FROM li_foot_print WHERE id IN ("+
|
@Delete("DELETE li_foot_print " +
|
||||||
"SELECT l2.id FROM (" +
|
"FROM li_foot_print " +
|
||||||
"SELECT l3.id FROM li_foot_print l3 WHERE l3.member_id=${memberId} ORDER BY id DESC LIMIT 100,100) l2)")
|
"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);
|
void deleteLastFootPrint(String memberId);
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user