实现目录数据的上移(up)、下移(down)、置顶(top)、置底(bottom)的操作

java 复制代码
@ApiOperation("8-15 交接班-标签设置排序")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", dataType = "string", required = true),
            @ApiImplicitParam(name = "orgnCode", value = "机构代码", dataType = "string", required = true),
            @ApiImplicitParam(name = "sortId", value = "排序id", dataType = "string", required = true),
            @ApiImplicitParam(name = "sectionCode", value = "科室代码", dataType = "string", required = true),
            @ApiImplicitParam(name = "button", value = "上移(up)、下移(down)、置顶(top)、置底(bottom)", dataType = "string", required = true),
    })
    @GetMapping("sortOperate")
    public ResponseEntity<Object> sortOperate(@RequestParam("id") String id,
                                              @RequestParam("orgnCode") String orgnCode,
                                              @RequestParam("sortId") String sortId,
                                              @RequestParam("sectionCode") String sectionCode,
                                              @RequestParam("button") String button) {
        return shiftService.sortOperate(id, orgnCode, sortId, sectionCode, button);
    }
java 复制代码
ResponseEntity<Object> sortOperate(String id, String orgnCode, String sortId, String sectionCode, String button);
java 复制代码
@Override
    public ResponseEntity<Object> sortOperate(String id, String orgnCode, String sortId, String sectionCode, String button) {
        ResponseMessage<Object> responseMessage = new ResponseMessage();
        //上移(up)、下移(down)、置顶(top)、置底(bottom)
        if (button != null && button.equals("up")) {
        	//查出小于排序id的第一个
            HashMap<String, String> sortMap = nursingHandoverMapper.infoBySortUp(orgnCode, sectionCode, sortId);
            if (sortMap != null && !sortMap.isEmpty()) {
                String upId = sortMap.get("id");
                String upSortId = sortMap.get("sortId");
                if (StringUtil.isNotEmpty(upId) && StringUtil.isNotEmpty(upSortId)) {
                    nursingHandoverMapper.updateBySort(upId, sortId);
                    nursingHandoverMapper.updateBySort(id, upSortId);
                }
            }
        } else if (button != null && button.equals("down")) {
            HashMap<String, String> sortMap = nursingHandoverMapper.infoBySortDown(orgnCode, sectionCode, sortId);
            if (sortMap != null && !sortMap.isEmpty()) {
                String downId = sortMap.get("id");
                String downSortId = sortMap.get("sortId");
                if (StringUtil.isNotEmpty(downId) && StringUtil.isNotEmpty(downSortId)) {
                    nursingHandoverMapper.updateBySort(downId, sortId);
                    nursingHandoverMapper.updateBySort(id, downSortId);
                }
            }
        } else if (button != null && button.equals("top")) {
            HashMap<String, String> sortMap = nursingHandoverMapper.infoBySortTop(orgnCode, sectionCode);
            if (sortMap != null && !sortMap.isEmpty()) {
                String topId = sortMap.get("id");
                String topSortId = sortMap.get("sortId");
                if (StringUtil.isNotEmpty(topId) && StringUtil.isNotEmpty(topSortId)) {
                    nursingHandoverMapper.updateBySort(topId, sortId);
                    nursingHandoverMapper.updateBySort(id, topSortId);
                }
            }
        } else if (button != null && button.equals("bottom")) {
            HashMap<String, String> sortMap = nursingHandoverMapper.infoBySortTop(orgnCode, sectionCode);
            if (sortMap != null && !sortMap.isEmpty()) {
                String bottomId = sortMap.get("id");
                String bottomSortId = sortMap.get("sortId");
                if (StringUtil.isNotEmpty(bottomId) && StringUtil.isNotEmpty(bottomSortId)) {
                    nursingHandoverMapper.updateBySort(bottomId, sortId);
                    nursingHandoverMapper.updateBySort(id, bottomSortId);
                }
            }
        }
        responseMessage.setCode("T").setMessage("success");
        return new ResponseEntity<>(responseMessage, HttpStatus.OK);
    }
java 复制代码
HashMap<String, String> infoBySortUp(@Param("orgnCode") String orgnCode, @Param("sectionCode") String sectionCode, @Param("sortId") String sortId);

<select id="infoBySortUp" resultType="java.util.HashMap">
        SELECT top 1 ID id, SORT_ID sortId
        from NEMR_SET_SHIFT
        WHERE ORGN_CODE = #{orgnCode}
          AND SECTION_CODE = #{sectionCode}
          AND SORT_ID &lt; #{sortId}
        ORDER BY SORT_ID DESC
    </select>
java 复制代码
HashMap<String, String> infoBySortDown(@Param("orgnCode") String orgnCode, @Param("sectionCode") String sectionCode, @Param("sortId") String sortId);

<select id="infoBySortDown" resultType="java.util.HashMap">
        SELECT top 1 ID id, SORT_ID sortId
        from NEMR_SET_SHIFT
        WHERE ORGN_CODE = #{orgnCode}
          AND SECTION_CODE = #{sectionCode}
          AND SORT_ID &gt; #{sortId}
        ORDER BY SORT_ID asc
    </select>
java 复制代码
HashMap<String, String> infoBySortTop(@Param("orgnCode") String orgnCode, @Param("sectionCode") String sectionCode);

<select id="infoBySortTop" resultType="java.util.HashMap">
        SELECT top 1 ID id, SORT_ID sortId
        FROM NEMR_SET_SHIFT(nolock)
        WHERE ORGN_CODE = #{orgnCode}
          AND SECTION_CODE = #{sectionCode}
        order by SORT_ID asc
    </select>
java 复制代码
HashMap<String, String> infoBySortTop(@Param("orgnCode") String orgnCode, @Param("sectionCode") String sectionCode);


<select id="infoBySortTop" resultType="java.util.HashMap">
        SELECT top 1 ID id, SORT_ID sortId
        FROM NEMR_SET_SHIFT(nolock)
        WHERE ORGN_CODE = #{orgnCode}
          AND SECTION_CODE = #{sectionCode}
        order by SORT_ID asc
    </select>
相关推荐
ONE_SIX_MIX2 分钟前
lightweight-charts-onesixth v2.8.1 → v3.1.1 更新总览
java·前端·python
SimonKing5 分钟前
一文终结 SpringBoot 国际化!从 0 到 1 完整案例(中/英/日)
java·后端·程序员
ByWalker_6 分钟前
web应用技术—MyBatis入门
java·数据库·mybatis·lombok
在书中成长16 分钟前
HarmonyOS 小游戏《对战五子棋》开发第17篇 - AI的两种评估策略
android·java·javascript
奋斗的小方17 分钟前
Java进阶篇1-3:集合框架(单列集合)
java·windows·python
湮w23 分钟前
JavaWeb(三)JavaScript详细讲解
java·javascript·web
gcw102442 分钟前
Cron专业工具:定时任务与开发办公的一站式在线工具箱
java·前端·数据库·工具·crontab·cron·spring cron
whaledown1 小时前
互联网大厂Java求职面试三轮提问详解(涵盖Spring Boot、微服务、Kafka等核心技术)
java·jvm·数据库·spring boot·微服务·面试·kafka
xixingzhe21 小时前
Spring 依赖注入
java·后端·spring
带刺的坐椅1 小时前
多 Agent 协作实战:任务编排与子代理系统
java·ai·llm·agent·solon·harness