如上,逻辑删除后 除了自己重写mapper 查询语句,还有别的(MP提供的)办法获取吗?
9条回答 默认 最新
西红柿炒鸡蛋Ooo 2021-04-03 23:00关注<choose> <when test="ew != null and ew.sqlFirst != null"> ${ew.sqlFirst} </when> <otherwise></otherwise> </choose> SELECT <choose> <when test="ew != null and ew.sqlSelect != null"> ${ew.sqlSelect} </when> <otherwise>param1,param2,param3</otherwise> </choose> FROM tableName <where> <choose> <when test="ew != null"> <if test="ew.entity != null"> <if test="ew.entity.id != null">id=#{ew.entity.id}</if> </if> AND deleted='0' <if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfNormal"> AND ${ew.sqlSegment} </if> <if test="ew.sqlSegment != null and ew.sqlSegment != '' and ew.emptyOfNormal"> ${ew.sqlSegment} </if> </when> <otherwise> deleted='0' </otherwise> </choose> </where> <choose> <when test="ew != null and ew.sqlComment != null"> ${ew.sqlComment} </when> <otherwise></otherwise> </choose>这是mybatisplus selectList方法用的动态SQL模板。主要看deleted='0'。整体看下来没有给任何机会解决不自动添加deleted='0'的机会。我试着去建议使用
<if test="ew.ignoreTableLogic != true"> AND deleted='0' </if>给wapper添加ignoreTableLogic ,可以由使用者来控制是否携带逻辑判断请求。当然默认是携带的。
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 2无用 2