From 349479e5d638d46a90014e9a26f05e948f55f106 Mon Sep 17 00:00:00 2001
From: lige <bestlige@outlook.com>
Date: 星期三, 13 十二月 2023 19:56:38 +0800
Subject: [PATCH] json

---
 ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjCustomerMapper.java            |    5 ++
 ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjCustomerService.java         |    3 +
 ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjCustomerServiceImpl.java |    6 +++
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/JsonController.java   |   73 ++++++++++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/JsonController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/JsonController.java
new file mode 100644
index 0000000..7024dee
--- /dev/null
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/JsonController.java
@@ -0,0 +1,73 @@
+package com.ltkj.web.controller.system;
+
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.ltkj.common.core.controller.BaseController;
+import com.ltkj.common.core.domain.AjaxResult;
+import com.ltkj.hosp.domain.TjCustomer;
+import com.ltkj.hosp.service.ITjCustomerService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Company: 瑗垮畨璺嘲绉戞妧鏈夐檺鍏徃
+ * @Author: lige
+ * @Date: 2023/12/13 19:33
+ */
+@RestController
+@RequestMapping("/json/parse")
+public class JsonController extends BaseController implements Serializable {
+    @Resource
+    private ITjCustomerService tjCustomerService;
+
+
+    /**
+     * 鍖栭獙妫�鏌ラ〉闈㈠垪琛�
+     */
+    @GetMapping("/huaYangetProList")
+    @ApiOperation("褰卞儚/鍖栭獙妫�鏌ラ〉闈㈠垪琛�")
+    public AjaxResult huaYangetProList(@RequestParam String deptId,
+                                       @RequestParam(defaultValue = "1") Integer page,
+                                       @RequestParam(defaultValue = "10") Integer pageSize,
+                                       @RequestParam String cusName,
+                                       @RequestParam String tjNumber) {
+        return AjaxResult.success(tjCustomerService.getJsonParseCustomerList(deptId, page, pageSize, cusName, tjNumber));
+    }
+
+
+    /**
+     * 灏嗙粨鏋滈泦淇℃伅杞崲涓篔SON鏁扮粍鐨勫舰寮�
+     *
+     * @param rs sql璇彞鏌ヨ鍑烘潵鐨勭粨鏋滈泦
+     * @return 杩斿洖涓�涓狫SON鏁扮粍
+     * @throws Exception
+     */
+    public static JSONArray formatRsToJsonArray(ResultSet rs) throws Exception {
+        ResultSetMetaData md = rs.getMetaData();
+        int num = md.getColumnCount();
+        JSONArray array = new JSONArray();
+        while (rs.next()) {
+            JSONObject mapOfColValues = new JSONObject();
+            for (int i = 1; i <= num; i++) {
+                Object o = rs.getObject(i);
+                mapOfColValues.put(md.getColumnName(i), rs.getObject(i));
+            }
+            array.add(mapOfColValues);
+        }
+        return array;
+    }
+
+}
diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjCustomerMapper.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjCustomerMapper.java
index f61ebfb..39703f1 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjCustomerMapper.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjCustomerMapper.java
@@ -1,5 +1,6 @@
 package com.ltkj.hosp.mapper;
 
+import java.sql.ResultSet;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -70,4 +71,8 @@
 
     @Select("SELECT * FROM tj_customer WHERE cus_idcard = #{cusIdCard}")
     TjCustomer getTjCustomerByCusIdCard(String cusIdCard);
+
+
+    @Select("SELECT * FROM tj_customer WHERE cus_idcard = #{cusIdCard}")
+    ResultSet getJsonParseCustomerList(String deptId, Integer page, Integer pageSize, String cusName, String tjNumber);
 }
diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjCustomerService.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjCustomerService.java
index ca4745e..77fe5e6 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjCustomerService.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjCustomerService.java
@@ -1,5 +1,6 @@
 package com.ltkj.hosp.service;
 
+import java.sql.ResultSet;
 import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -63,4 +64,6 @@
     List<TjCustomer> getTjCustomerList(String name);
 
     TjCustomer getTjCustomerByCusIdCard(String cusIdCard);
+
+    ResultSet getJsonParseCustomerList(String deptId, Integer page, Integer pageSize, String cusName, String tjNumber);
 }
diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjCustomerServiceImpl.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjCustomerServiceImpl.java
index ec6b0b5..1b1be0b 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjCustomerServiceImpl.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjCustomerServiceImpl.java
@@ -1,5 +1,6 @@
 package com.ltkj.hosp.service.impl;
 
+import java.sql.ResultSet;
 import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -100,4 +101,9 @@
     public TjCustomer getTjCustomerByCusIdCard(String cusIdCard) {
         return tjCustomerMapper.getTjCustomerByCusIdCard(cusIdCard);
     }
+
+    @Override
+    public ResultSet getJsonParseCustomerList(String deptId, Integer page, Integer pageSize, String cusName, String tjNumber) {
+        return tjCustomerMapper.getJsonParseCustomerList(deptId,page,pageSize,cusName,tjNumber);
+    }
 }

--
Gitblit v1.8.0