|
@@ -2,12 +2,14 @@ package com.github.jfcloud.gene.lis.controller;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.Entity;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
|
|
import com.github.jfcloud.common.annotation.WebApiLog;
|
|
|
import com.github.jfcloud.common.core.util.R;
|
|
|
import com.github.jfcloud.gene.lis.config.LisDb;
|
|
|
import com.github.jfcloud.gene.lis.constants.LisDictType;
|
|
|
import com.github.jfcloud.gene.lis.vo.CheckItem;
|
|
|
-import com.github.jfcloud.gene.lis.vo.DeptItem;
|
|
|
+import com.github.jfcloud.gene.lis.vo.DepItem;
|
|
|
import com.github.jfcloud.gene.lis.vo.DeptUserItem;
|
|
|
import com.github.jfcloud.gene.lis.vo.DictItem;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -53,20 +55,32 @@ public class SampleLisController {
|
|
|
|
|
|
@Operation(summary = "获取机构")
|
|
|
@GetMapping("/dep")
|
|
|
- public R<List<DeptItem>> getLisDept(@RequestParam(required = false) String name) {
|
|
|
- String sql = "select dep.id, dep.name, dict.sub_class_name as dep_name from dbo.HT_INFO_DEP dep " +
|
|
|
+ public R<Page<DepItem>> getLisDept(@RequestParam(required = false) String name, Page<?> page) {
|
|
|
+ String sql = "select dep.id, dep.name, dict.sub_class_name as dep_type from dbo.HT_INFO_DEP dep " +
|
|
|
"left join dbo.HT_BAS_DICT dict on dep.dep_type = dict.sub_class_no and dict.class_no = 1154 " +
|
|
|
- "where dep.status=1 %s order by dep.id desc";
|
|
|
+ "where dep.status=1 ";
|
|
|
if (StrUtil.isNotBlank(name)) {
|
|
|
- sql = String.format(sql, "and name like '%" + name + "%'");
|
|
|
- } else {
|
|
|
- sql = String.format(sql, "");
|
|
|
+ sql += " and name like '%" + name + "%'";
|
|
|
+ }
|
|
|
+
|
|
|
+ //计数
|
|
|
+ Entity countEntity = lisDb.queryOne("select count(*)as num from (" + sql + ") tmp");
|
|
|
+ Long num = countEntity.getLong("num");
|
|
|
+ if (num < 1) {
|
|
|
+ return R.ok(new PageDTO<>());
|
|
|
}
|
|
|
+
|
|
|
+ //分页
|
|
|
+ sql += String.format(" order by dep.id desc offset %d rows fetch next %d rows only", page.offset(), page.getSize());
|
|
|
+
|
|
|
List<Entity> entities = lisDb.query(sql);
|
|
|
- List<DeptItem> dictItems = entities.stream()
|
|
|
- .map(entity -> entity.toBeanWithCamelCase(new DeptItem()))
|
|
|
+ List<DepItem> dictItems = entities.stream()
|
|
|
+ .map(entity -> entity.toBeanWithCamelCase(new DepItem()))
|
|
|
.collect(Collectors.toList());
|
|
|
- return R.ok(dictItems);
|
|
|
+
|
|
|
+ Page<DepItem> pageResult = PageDTO.of(page.getCurrent(), page.getSize(), num);
|
|
|
+ pageResult.setRecords(dictItems);
|
|
|
+ return R.ok(pageResult);
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "获取机构下医生")
|