完善排序功能

master
rong.liu 2 years ago
parent 5e48be6055
commit dabe5e677e
  1. 3
      src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml
  2. 14
      src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java

@ -185,7 +185,8 @@
AND is_release = 1) t AND is_release = 1) t
WHERE FIND_IN_SET(t.column_id, #{columnId}) WHERE FIND_IN_SET(t.column_id, #{columnId})
ORDER BY t.release_time DESC ORDER BY
t.sequence ASC
</select> </select>
<!-- &lt;!&ndash;根据 sequence 查询下一条记录主键&ndash;&gt; <!-- &lt;!&ndash;根据 sequence 查询下一条记录主键&ndash;&gt;

@ -159,7 +159,17 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
//获取当前文章所属栏目id //获取当前文章所属栏目id
Integer columnId = content.getColumnId(); Integer columnId = content.getColumnId();
if (currentSerialNumber.equals(sequenceNumber)){ //获取栏目下全部文章的数量与当前输入的序号判断 如果要更改的序号大于当前有的数量,直接替换
QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("column_id", columnId);
queryWrapper.eq("deleted", 1);
List<SysContent> contentList = baseMapper.selectList(queryWrapper);
if (sequenceNumber >= contentList.size()) {
sequenceNumber = contentList.size();
}
if (currentSerialNumber.equals(sequenceNumber)) {
return R.success(); return R.success();
} }
@ -178,7 +188,7 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
if (currentSerialNumber > sequenceNumber) { if (currentSerialNumber > sequenceNumber) {
//改大 gt > //改大 gt >
updateWrapper1.setSql(" sequence = sequence + 1"); updateWrapper1.setSql(" sequence = sequence + 1");
updateWrapper1.last(" and sequence >= "+sequenceNumber+ " and sequence < "+currentSerialNumber); updateWrapper1.last(" and sequence >= " + sequenceNumber + " and sequence < " + currentSerialNumber);
} else if (currentSerialNumber < sequenceNumber) { } else if (currentSerialNumber < sequenceNumber) {
//改小 //改小
updateWrapper1.le("sequence", sequenceNumber); updateWrapper1.le("sequence", sequenceNumber);

Loading…
Cancel
Save