Преглед изворни кода

查询某个文件夹的授权详情
查询资料中心列表

吴志根 пре 4 година
родитељ
комит
349b8c5d91

+ 1 - 1
src/dsb/com/cnd3b/common/parameter/parameter.java

@@ -25,7 +25,7 @@ public class parameter {
     public static HashMap<Long, Row> userIdList = new HashMap<>(16);
 
     public static String defaultsiteid = "JIUSHENG";
-    public static Boolean isMac = false;
+    public static Boolean isMac = true;
     //设置改部门下的为经销商
     public static String depname = "经销商";
     public static String tuserid = "";

+ 4 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tagentauth/SQL/查询体系是否存在.sql

@@ -0,0 +1,4 @@
+SELECT DISTINCT fauthtype
+FROM tagentauth
+WHERE tagentsid = $tagentsid$
+  AND fauthtype in $fauthtype$

+ 34 - 11
src/dsb/com/cnd3b/restcontroller/enterprise/tagentauth/tagentauth.java

@@ -1,7 +1,9 @@
 package com.cnd3b.restcontroller.enterprise.tagentauth;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
 import p2.common.parse.S;
@@ -9,6 +11,8 @@ import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.util.P2Exception;
 
+import java.util.ArrayList;
+
 public class tagentauth extends Controller {
     /**
      * 构造函数
@@ -28,19 +32,38 @@ public class tagentauth extends Controller {
         //经销商id
         String tagentsid = content.getString("tagentsid");
         //体系类型
-        String fauthtype = content.getString("fauthtype");
-        if (tagentsid == null || tagentsid.equals("")) {
-            return getErrReturnObject().setErrMsg("经销商id为空").toString();
+        JSONArray fauthtype = content.getJSONArray("fauthtype");
+
+        ArrayList<String> list = new ArrayList<>();
+        for (Object obj : fauthtype) {
+            list.add(obj.toString());
         }
-        if (fauthtype == null || fauthtype.equals("")) {
-            return getErrReturnObject().setErrMsg("体系类型不能为空").toString();
+
+
+        SQLFactory sqlFactory = new SQLFactory(this, "查询体系是否存在");
+        sqlFactory.addParameter_in("fauthtype", list);
+        sqlFactory.addParameter("tagentsid", tagentsid);
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+
+        if (!rows.isEmpty()) {
+            String msg = "";
+            for (Row row : rows) {
+                msg = msg + row.getString("fauthtype") + ",";
+            }
+            return getErrReturnObject().setErrMsg("新增失败,下列体系已授权:" + msg.substring(0, msg.length() - 1)).toString();
+        }
+
+        //新增体系
+        for (Object obj : fauthtype) {
+            //新增
+            PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth");
+            PaoRemote paoRemote = paoSetRemote.addAtEnd();
+            paoRemote.setValue("tagentsid", tagentsid, 11L);
+            paoRemote.setValue("fauthtype", obj.toString(), 11L);
+            paoSetRemote.save();
+
         }
-        //新增
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth");
-        PaoRemote paoRemote = paoSetRemote.addAtEnd();
-        paoRemote.setValue("tagentsid", tagentsid, 11L);
-        paoRemote.setValue("fauthtype", fauthtype, 11L);
-        paoSetRemote.save();
         return getSucReturnObject().toString();
     }
 

+ 3 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tauthtype/SQL/查询体系是否存在.sql

@@ -0,0 +1,3 @@
+SELECT DISTINCT fauthtype
+FROM tauthtype
+WHERE fauthtype IN $fauthtype$

+ 29 - 7
src/dsb/com/cnd3b/restcontroller/enterprise/tauthtype/tauthtype.java

@@ -1,13 +1,17 @@
 package com.cnd3b.restcontroller.enterprise.tauthtype;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.util.P2Exception;
 
+import java.util.ArrayList;
+
 public class tauthtype extends Controller {
     /**
      * 构造函数
@@ -25,15 +29,33 @@ public class tauthtype extends Controller {
      */
     public String inseretTauthtype() throws P2Exception {
         //体系类型
-        String fauthtype = content.getString("fauthtype");
-        if (fauthtype == null || fauthtype.equals("")) {
-            return getErrReturnObject().setErrMsg("体系类型不能为空").toString();
+        JSONArray fauthtype = content.getJSONArray("fauthtype");
+        ArrayList<String> list = new ArrayList<>();
+        for (Object obj : fauthtype) {
+            list.add(obj.toString());
+        }
+
+        SQLFactory sqlFactory = new SQLFactory(this, "查询体系是否存在");
+        sqlFactory.addParameter_in("fauthtype", list);
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+
+        if (!rows.isEmpty()) {
+            String msg = "";
+            for (Row row : rows) {
+                msg = msg + row.getString("fauthtype") + ",";
+            }
+            return getErrReturnObject().setErrMsg("新增失败,下列体系已存在:" + msg.substring(0, msg.length() - 1)).toString();
         }
+
         //新增体系
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tauthtype");
-        PaoRemote paoRemote = paoSetRemote.addAtEnd();
-        paoRemote.setValue("fauthtype", fauthtype, 11L);
-        paoSetRemote.save();
+        for (Object obj : fauthtype) {
+            PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tauthtype");
+            PaoRemote paoRemote = paoSetRemote.addAtEnd();
+            paoRemote.setValue("fauthtype", obj.toString(), 11L);
+            paoSetRemote.save();
+        }
+
         return getSucReturnObject().toString();
     }
 

+ 2 - 1
src/dsb/com/cnd3b/restcontroller/enterprise/tfolderauth/SQL/查询某个文件路径的授权详情.sql

@@ -2,4 +2,5 @@ SELECT t1.frole, t1.fauthtype, t2.wechat_name, t1.tuserid, t1.tfolderauthid, t1.
 FROM tfolderauth t1
          LEFT JOIN tuser t2
                    ON t1.tuserid = t2.tuserid
-WHERE tfolderid = (SELECT tfolderid FROM tfolder WHERE fpath = $fpath$)
+WHERE tfolderid = (SELECT tfolderid FROM tfolder WHERE fpath = $fpath$)
+  and $where$

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/enterprise/tfolderauth/SQL/查询资料中心授权列表.sql

@@ -11,4 +11,4 @@ FROM tfolderauth t1
                    ON t2.tfolderid = t1.tfolderid
          LEFT JOIN tuser t3
                    ON t3.tuserid = t1.tuserid
-ORDER BY t1.createdate DESC
+where $where$

+ 61 - 16
src/dsb/com/cnd3b/restcontroller/enterprise/tfolderauth/tfolderauth.java

@@ -107,10 +107,36 @@ public class tfolderauth extends Controller {
      * @return
      */
     public String selectTfolderauthList() {
-        SQLFactory sqlFactory = new SQLFactory(this, "查询资料中心授权列表");
+
+        /**
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("type")) {
+            int type = content.getIntValue("type");
+            if (type == 1) {
+                where.append(" and(");
+                where.append("t1.frole is NOT NULL");
+                where.append(")");
+            }
+            if (type == 2) {
+                where.append(" and(");
+                where.append("t1.fauthtype is NOT NULL");
+                where.append(")");
+            }
+            if (type == 3) {
+                where.append(" and(");
+                where.append("t1.tuserid is NOT NULL");
+                where.append(")");
+            }
+
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "查询资料中心授权列表", pageSize, pageNumber, "t1.createdate DESC");
+        sqlFactory.addParameter_SQL("where", where);
 //        String sql = "SELECT tfolderauthid,tfolderid,frole, fauthtype FROM tfolderauth ORDER BY createdate DESC";
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-        return getSucReturnObject().setData(rows).toString();
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+        return getSucReturnObject().setDataByPaging(rows).toString();
     }
 
     /**
@@ -121,20 +147,39 @@ public class tfolderauth extends Controller {
     public String selectFolderauthDetail() {
         String fpath = content.getString("fpath");
 
-        SQLFactory sqlFactory = new SQLFactory(this, "查询某个文件路径的授权详情");
+
+        /**
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("type")) {
+            int type = content.getIntValue("type");
+            if (type == 1) {
+                where.append(" and(");
+                where.append("t1.frole is NOT NULL");
+                where.append(")");
+            }
+            if (type == 2) {
+                where.append(" and(");
+                where.append("t1.fauthtype is NOT NULL");
+                where.append(")");
+            }
+            if (type == 3) {
+                where.append(" and(");
+                where.append("t1.tuserid is NOT NULL");
+                where.append(")");
+            }
+
+        }
+
+        SQLFactory sqlFactory = new SQLFactory(this, "查询某个文件路径的授权详情", pageSize, pageNumber, "t1.createdate DESC");
         sqlFactory.addParameter("fpath", fpath);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-//        JSONArray jsonArray = new JSONArray();
-//        for (Row row :rows) {
-//            JSONObject jsonObject = new JSONObject();
-//            jsonObject.put("frole", row.getString("frole"));
-//        }
-//
-//
-//        jsonObject.put("fauthtype", rows.toJsonArray("fauthtype"));
-//        jsonObject.put("wechat_name", rows.toJsonArray("wechat_name"));
-
-        return getSucReturnObject().setData(rows).toString();
+        sqlFactory.addParameter_SQL("where", where);
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+
+
+        return getSucReturnObject().setDataByPaging(rows).toString();
 
 
     }

+ 4 - 1
src/dsb/com/cnd3b/restcontroller/enterprise/tuser/SQL/部门成员列表.sql

@@ -5,7 +5,10 @@ SELECT t1.tuserid,
        t1.wechat_open_userid,
        t1.wechat_mobile,
        t1.wechat_position,
-       t1.fusertype
+       t1.fusertype,
+       t2.wechat_depname
 FROM tuser t1
+         LEFT JOIN tdepartment t2
+                   ON t1.wechat_depid = t2.wechat_depid
 WHERE t1.fusertype = $fusertype$
   and (t1.wechat_name LIKE $keywords$ OR t1.wechat_position LIKE $keywords$ OR t1.wechat_mobile LIKE $keywords$)