From e11cf4b083793e65760e4001e3331db05c22bff7 Mon Sep 17 00:00:00 2001
From: lvleigang <957075182@qq.com>
Date: Sat, 14 Sep 2024 09:53:23 +0800
Subject: [PATCH] =?UTF-8?q?fw-nc=E5=88=86=E6=94=AF=E7=BB=93=E6=9E=84?=
 =?UTF-8?q?=E4=B8=8A=E4=BC=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 base-webapp/pom.xml                           |  10 +-
 fw-nc/pom.xml                                 |  48 ++++++
 .../com/hzya/frame/nc/entity/NcInterface.java |  27 ++++
 .../frame/nc/entity/NcInterfaceMapper.xml     |  31 ++++
 .../frame/nc/service/INcInterfaceService.java |  26 ++++
 .../com/hzya/frame/nc/service/Test01.java     |  10 ++
 .../service/impl/NcInterfaceServiceImpl.java  | 146 ++++++++++++++++++
 fw-nc/src/main/webapp/WEB-INF/web.xml         |   6 +
 pom.xml                                       |   2 +-
 9 files changed, 300 insertions(+), 6 deletions(-)
 create mode 100644 fw-nc/pom.xml
 create mode 100644 fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterface.java
 create mode 100644 fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterfaceMapper.xml
 create mode 100644 fw-nc/src/main/java/com/hzya/frame/nc/service/INcInterfaceService.java
 create mode 100644 fw-nc/src/main/java/com/hzya/frame/nc/service/Test01.java
 create mode 100644 fw-nc/src/main/java/com/hzya/frame/nc/service/impl/NcInterfaceServiceImpl.java
 create mode 100644 fw-nc/src/main/webapp/WEB-INF/web.xml

diff --git a/base-webapp/pom.xml b/base-webapp/pom.xml
index 79bd4cf9..1aafd04e 100644
--- a/base-webapp/pom.xml
+++ b/base-webapp/pom.xml
@@ -39,11 +39,11 @@
 <!--            <artifactId>fw-grpU8</artifactId>-->
 <!--            <version>${revision}</version>-->
 <!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>com.hzya.frame</groupId>-->
-<!--            <artifactId>fw-nc</artifactId>-->
-<!--            <version>${revision}</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>com.hzya.frame</groupId>
+            <artifactId>fw-nc</artifactId>
+            <version>${revision}</version>
+        </dependency>
 <!--        <dependency>-->
 <!--            <groupId>com.hzya.frame</groupId>-->
 <!--            <artifactId>fw-ncc</artifactId>-->
diff --git a/fw-nc/pom.xml b/fw-nc/pom.xml
new file mode 100644
index 00000000..a7ecada9
--- /dev/null
+++ b/fw-nc/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>kangarooDataCenterV3</artifactId>
+        <groupId>com.hzya.frame</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>fw-nc</artifactId>
+    <packaging>jar</packaging>
+    <version>${revision}</version>
+
+    <dependencies>
+            <dependency>
+                <groupId>com.hzya.frame</groupId>
+                <artifactId>base-service</artifactId>
+                <version>${revision}</version>
+            </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql-connector-java}</version>
+        </dependency>
+
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <mainClass>none</mainClass>     <!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
+                    <classifier>execute</classifier>    <!-- 为了解决依赖模块找不到此模块中的类或属性 -->
+                    <skip>true</skip>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterface.java b/fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterface.java
new file mode 100644
index 00000000..81018a0c
--- /dev/null
+++ b/fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterface.java
@@ -0,0 +1,27 @@
+package com.hzya.frame.nc.entity;
+
+import com.alibaba.fastjson2.JSON;
+import com.hzya.frame.web.entity.BaseEntity;
+import lombok.ToString;
+
+/**
+ * @Content
+ * @Author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @Date 2023-06-14 10:20
+ * @Version 1.0
+ */
+//@ToString(callSuper=true)
+public class NcInterface extends BaseEntity {
+
+
+    public static void main(String[] args) {
+        NcInterface s = new NcInterface();
+        s.setId("2");
+        s.setLimit(1L);
+        s.setSts("Y");
+        String str = JSON.toJSONString(s);
+        //System.out.println(str);
+        NcInterface s2 = JSON.parseObject(str,NcInterface.class);
+        //System.out.println(JSON.toJSONString(s2));
+    }
+}
diff --git a/fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterfaceMapper.xml b/fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterfaceMapper.xml
new file mode 100644
index 00000000..fe940407
--- /dev/null
+++ b/fw-nc/src/main/java/com/hzya/frame/nc/entity/NcInterfaceMapper.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hzya.frame.nc.entity.NcInterface">
+	<resultMap id="get-entity-result" type="com.hzya.frame.nc.entity.NcInterface">
+        <!--主键 -->
+        <result property="id" column="id" />
+	</resultMap>
+
+	<sql id="Sysproduct_Base_Column_List">
+		ID as id,
+		code as code,
+		name as name,
+		classify as classify,
+		description as description,
+		production_company as production_company,
+		picture_path as picture_path,
+		sys_type as sys_type,
+		sorts as sorts,
+		org_id as org_id,
+		sts as sts,
+		create_user_id as create_user_id,
+		create_time as create_time,
+		modify_time as modify_time,
+		modify_user_id as modify_user_id
+	</sql>
+
+	<!-- 修改 -->
+	<update id="test_update_user" parameterType="com.hzya.frame.nc.entity.NcInterface">
+		 update sys_user SET view_name = '超级管理员221' WHERE login_name = 'admin'
+	</update>
+</mapper>
diff --git a/fw-nc/src/main/java/com/hzya/frame/nc/service/INcInterfaceService.java b/fw-nc/src/main/java/com/hzya/frame/nc/service/INcInterfaceService.java
new file mode 100644
index 00000000..d8691dfe
--- /dev/null
+++ b/fw-nc/src/main/java/com/hzya/frame/nc/service/INcInterfaceService.java
@@ -0,0 +1,26 @@
+package com.hzya.frame.nc.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
+import com.hzya.frame.web.entity.JsonResultEntity;
+
+/**
+ * @Content
+ * @Author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @Date 2023-06-13 14:13
+ * @Version 1.0
+ */
+public interface INcInterfaceService {
+
+    void queryNccBasicArchives(JSONObject req);
+
+    //@DSTransactional()
+    //JsonResultEntity updateUser(JSONObject jsonObject);
+
+    @DS("dataSource1")
+    int updateUser1(JSONObject jsonObject);
+
+    @DS("dataSource2")
+    int updateUser2(JSONObject jsonObject);
+}
diff --git a/fw-nc/src/main/java/com/hzya/frame/nc/service/Test01.java b/fw-nc/src/main/java/com/hzya/frame/nc/service/Test01.java
new file mode 100644
index 00000000..4df37ded
--- /dev/null
+++ b/fw-nc/src/main/java/com/hzya/frame/nc/service/Test01.java
@@ -0,0 +1,10 @@
+package com.hzya.frame.nc.service;
+
+/**
+ * @Content
+ * @Author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @Date 2023-06-15 15:20
+ * @Version 1.0
+ */
+public interface Test01 {
+}
diff --git a/fw-nc/src/main/java/com/hzya/frame/nc/service/impl/NcInterfaceServiceImpl.java b/fw-nc/src/main/java/com/hzya/frame/nc/service/impl/NcInterfaceServiceImpl.java
new file mode 100644
index 00000000..0b9a3577
--- /dev/null
+++ b/fw-nc/src/main/java/com/hzya/frame/nc/service/impl/NcInterfaceServiceImpl.java
@@ -0,0 +1,146 @@
+package com.hzya.frame.nc.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+//import com.hzya.frame.demo.bean.Test;
+//import com.hzya.frame.demo.mapper.TestMapper;
+import com.hzya.frame.nc.entity.NcInterface;
+import com.hzya.frame.nc.service.INcInterfaceService;
+import com.hzya.frame.sys.user.service.IUserService;
+import com.hzya.frame.web.action.ApplicationContextUtil;
+import com.hzya.frame.web.entity.JsonResultEntity;
+import com.hzya.frame.web.exception.BaseSystemException;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @Content
+ * @Author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @Date 2023-06-13 14:29
+ * @Version 1.0
+ */
+@Service(value = "ncInterfaceService")
+public class NcInterfaceServiceImpl implements INcInterfaceService {
+    public final static Logger log = LoggerFactory.getLogger(NcInterfaceServiceImpl.class);
+//    @Resource
+//    private TestMapper testMapper;
+    @Resource
+    private IUserService userService;
+    @Override
+    public void queryNccBasicArchives(JSONObject req) {
+        JSONObject jsonStrObj = req.getJSONObject("jsonStr");
+        //基础档案类型
+        String type = jsonStrObj.getString("type");
+        //查询的参数
+        JSONObject queryParameters = jsonStrObj.getJSONObject("queryParameters");
+        switch (type) {
+            case "1":
+                //供应商视图
+                String view_name = "v_hzya_nc_supplier";
+                //验证参数是否存在视图内
+                checkingParametersKeyEffective(view_name, queryParameters);
+                break;
+            case "2":
+                break;
+            case "3":
+                break;
+            default:
+                throw new BaseSystemException("未匹配到档案类型!请确认档案类型 1、客户2、供应商3、人员、4项目");
+        }
+
+
+    }
+
+    /****
+     * 根据视图名称,验证查询前参数是否有效
+     * @content:
+     * @author 👻👻👻👻👻👻👻👻 gjh
+     * @date 2023-08-08 16:20
+     * @param
+     * @return void
+     **/
+    private void checkingParametersKeyEffective(String view_name, JSONObject queryParameters) {
+        //查询视图所有列
+        List<String> viewFields = new ArrayList<>();
+        StringBuffer buffer = new StringBuffer();
+
+        for (String key : queryParameters.keySet()) {
+            boolean flag = viewFields.contains(key);
+            //不包含key的时候,说明查询参数在视图内不存在,需要抛出去异常
+            if (!flag) {
+                buffer.append("参数code:" + key + "在视图内不存在!请检查后在传递查询。\n");
+            }
+        }
+        if (buffer.length() > 1) {
+            throw new BaseSystemException(buffer.toString());
+        }
+    }
+
+
+//    @Override
+//    public JsonResultEntity updateUser(JSONObject jsonObject) {
+//
+//            NcInterface s2 = JSON.parseObject(jsonObject.getString("jsonStr"),NcInterface.class);
+//            //System.out.println(JSON.toJSONString(s2));
+//        userService.updateEntity(jsonObject);
+////        int as = 1/0;
+//            JsonResultEntity jsonResultEntity = new JsonResultEntity();
+//
+//
+//            jsonResultEntity.setFlag(true);
+////        throw new RuntimeException("系统异常");
+//            return jsonResultEntity;
+//    }
+
+    @Override
+//    @DS("dataSource1")
+    public int updateUser1(JSONObject jsonObject) {
+//        List<WhereCriterion> whereList = new ArrayList<>();
+//        WhereCriterion loginCondition = new WhereCriterion("", "login_name", ConditionType.等于.getValue(), "admin", "", ConnectType.AND);
+//        whereList.add(loginCondition);
+//        List<ModifyCriterion> modifyExamples = new ArrayList<>();
+//        ModifyCriterion modifyCriterion = new ModifyCriterion();
+//        modifyCriterion.setFiledName("view_name");
+//        modifyCriterion.setFiledValue("超级管理员1");
+//        modifyCriterion.setStringValue(true);
+//        modifyExamples.add(modifyCriterion);
+
+        SqlSessionFactory s = ApplicationContextUtil.getBeanByClass(SqlSessionFactory.class);
+        if (s == null) {
+            s = (SqlSessionFactory) ApplicationContextUtil.getBeanByName("mySqlSessionFactory");
+        }
+
+        Integer result = s.openSession().update("com.hzya.frame.nc.entity.NcInterface.test_update_user");
+//        Integer result = baseDaoUtilImpl.update("sys_user",modifyExamples,whereList);
+        log.info("ya251修改人员结果:" + result);
+        return result;
+    }
+
+    @Override
+//    @DS("dataSource2")
+    public int updateUser2(JSONObject jsonObject) {
+//        List<WhereCriterion> whereList = new ArrayList<>();
+//        WhereCriterion loginCondition = new WhereCriterion("", "login_name", ConditionType.等于.getValue(), "admin", "", ConnectType.AND);
+//        whereList.add(loginCondition);
+//        List<ModifyCriterion> modifyExamples = new ArrayList<>();
+//        ModifyCriterion modifyCriterion = new ModifyCriterion();
+//        modifyCriterion.setFiledName("view_name");
+//        modifyCriterion.setFiledValue("超级管理员3");
+//        modifyCriterion.setStringValue(true);
+//        modifyExamples.add(modifyCriterion);
+//        DataSourceUtil.getDefaultSqlSession()
+        SqlSessionFactory s = ApplicationContextUtil.getBeanByClass(SqlSessionFactory.class);
+        Integer result = s.openSession().update("test_update_user");
+//        Integer result = baseDaoUtilImpl.update("sys_user",modifyExamples,whereList);
+        log.info("ya237修改人员结果:" + result);
+        return result;
+    }
+
+}
diff --git a/fw-nc/src/main/webapp/WEB-INF/web.xml b/fw-nc/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000..d80081d1
--- /dev/null
+++ b/fw-nc/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
+         version="4.0">
+</web-app>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index fc53bd54..adcd1ccd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
 <!--        <module>fw-cbs</module>-->
 <!--        <module>fw-dd</module>-->
 <!--        <module>fw-grpU8</module>-->
-<!--        <module>fw-nc</module>-->
+        <module>fw-nc</module>
 <!--        <module>fw-ncc</module>-->
 <!--        <module>fw-ningbobank</module>-->
 <!--        <module>fw-oa</module>-->