Sfoglia il codice sorgente

课件分类添加职位授权

吴志根 3 anni fa
parent
commit
b0f2cd48cb

+ 22 - 9
src/dsb/com/cnd3b/restcontroller/customer/wechatapplet/SQL/分类.sql

@@ -1,10 +1,23 @@
-SELECT t1.ttypedetailid,
-       t1.fvalue,
-       t1.ftype,
-       t1.fparentid
+select *
+from (
+         SELECT t1.ttypedetailid,
+                t1.fvalue,
+                t1.ftype,
+                t1.fparentid
+         FROM ttypedetail t1
+         where t1.fparentid in (SELECT ttypedetailid FROM ttypedetail where fparentid = 1)
+           and t1.fisused = 1
+           and $where$
+         UNION
+         SELECT t1.ttypedetailid,
+                t1.fvalue,
+                t1.ftype,
+                t1.fparentid
+         FROM ttypedetail t1
+         WHERE t1.ttypedetailid in (SELECT ttypedetailid
+                                    FROM ttypedetail_auth
+                                    WHERE position in (SELECT wechat_position FROM tuser WHERE tuserid = $tuserid$))
+           and $where$
+     ) a
 
-FROM ttypedetail t1
-where t1.fparentid in (SELECT ttypedetailid FROM ttypedetail where fparentid = 1)
-  and t1.fisused = 1
-  and $where$
-order by t1.ttypedetailid desc
+order by ttypedetailid desc

+ 13 - 11
src/dsb/com/cnd3b/restcontroller/customer/wechatapplet/wechatapplet.java

@@ -27,6 +27,7 @@ import java.net.URLEncoder;
 import java.sql.Date;
 import java.util.*;
 
+import static com.cnd3b.common.parameter.parameter.tuserid;
 import static com.cnd3b.service.GetWechatData.sortByStartDigits;
 import static com.cnd3b.utility.aliyun.oss.AliyunOSSUtil.*;
 
@@ -159,7 +160,7 @@ public class wechatapplet extends Controller {
         SQLFactory sqlFactory = new SQLFactory(this, "创建用户学习记录");
         sqlFactory.addParameter("tuser_studyid", tuser_studyid);
         sqlFactory.addParameter("tarchives_scid", tarchives_scid);
-        sqlFactory.addParameter("tuserid", parameter.tuserid);
+        sqlFactory.addParameter("tuserid", tuserid);
         dbConnect.runSqlUpdate(sqlFactory);
 
 
@@ -184,6 +185,7 @@ public class wechatapplet extends Controller {
 
         SQLFactory sqlFactory = new SQLFactory(this, "分类");
         sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("tuserid", tuserid);
         String sql = sqlFactory.getSQL();
         Rows rows = dbConnect.runSqlQuery(sql);
 
@@ -205,7 +207,7 @@ public class wechatapplet extends Controller {
         new Thread() {
             @Override
             public void run() {
-                String sql = "SELECT*FROM tuserrequestlog WHERE fdate='" + getDate_Str() + "' AND tuserid='" + parameter.tuserid + "'";
+                String sql = "SELECT*FROM tuserrequestlog WHERE fdate='" + getDate_Str() + "' AND tuserid='" + tuserid + "'";
                 Rows rows = dbConnect.runSqlQuery(sql);
                 if (rows.isEmpty()) {
                     SQLFactory sqlFactory = new SQLFactory(this, "新增日志");
@@ -213,7 +215,7 @@ public class wechatapplet extends Controller {
                     sqlFactory.addParameter("siteid", parameter.defaultsiteid);
                     sqlFactory.addParameter("fdate", getDate_Str());
                     sqlFactory.addParameter("flastrequestdate", getDateTime_Str());
-                    sqlFactory.addParameter("tuserid", parameter.tuserid);
+                    sqlFactory.addParameter("tuserid", tuserid);
                     sqlFactory.addParameter("type", type);
                     dbConnect.runSqlUpdate(sqlFactory.getSQL());
                 } else {
@@ -433,13 +435,13 @@ public class wechatapplet extends Controller {
         String tprocess = content.getString("tprocess");
         String tlogintime = content.getString("tlogintime");
 
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tviewlog", "tarchives_scid = '" + tarchives_scid + "' and tattachmentid = '" + tattachmentid + "' and tuserid = '" + parameter.tuserid + "' ");
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tviewlog", "tarchives_scid = '" + tarchives_scid + "' and tattachmentid = '" + tattachmentid + "' and tuserid = '" + tuserid + "' ");
         if (paoSetRemote.isEmpty()) {
             PaoRemote paoRemote = paoSetRemote.addAtEnd();
             paoRemote.setValue("tarchives_scid", tarchives_scid, 11L);
             paoRemote.setValue("tattachmentid", tattachmentid, 11L);
             paoRemote.setValue("tprocess", tprocess, 11L);
-            paoRemote.setValue("tuserid", parameter.tuserid, 11L);
+            paoRemote.setValue("tuserid", tuserid, 11L);
             paoRemote.setValue("changedate", getDateTime_Str(), 11L);
             paoRemote.setValue("tlogintime", tlogintime, 11L);
             paoSetRemote.save();
@@ -465,7 +467,7 @@ public class wechatapplet extends Controller {
     public String selectViewlog() throws P2Exception {
         Long tarchives_scid = content.getLong("tarchives_scid");
         SQLFactory sqlFactory = new SQLFactory(this, "查询视频播放记录");
-        sqlFactory.addParameter("tuserid", parameter.tuserid);
+        sqlFactory.addParameter("tuserid", tuserid);
         sqlFactory.addParameter("tarchives_scid", tarchives_scid);
         String sql = sqlFactory.getSQL();
         Rows rows = dbConnect.runSqlQuery(sql);
@@ -479,7 +481,7 @@ public class wechatapplet extends Controller {
      */
     public Rows getUserRoles() {
         //查询对应用户的角色
-        String sqlRoles = "SELECT wechat_position ,fusertype FROM tuser WHERE tuserid = '" + parameter.tuserid + "'";
+        String sqlRoles = "SELECT wechat_position ,fusertype FROM tuser WHERE tuserid = '" + tuserid + "'";
         return dbConnect.runSqlQuery(sqlRoles);
     }
 
@@ -507,7 +509,7 @@ public class wechatapplet extends Controller {
      * @return
      */
     public ArrayList<String> getUserFauthtypeList() {
-        String sqlFauthtype = "SELECT fauthtype FROM tagentauth WHERE tagentsid=( SELECT tagentsid FROM tagents WHERE wechat_depid=(SELECT wechat_depid FROM tuser WHERE tuserid= '" + parameter.tuserid + "'))";
+        String sqlFauthtype = "SELECT fauthtype FROM tagentauth WHERE tagentsid=( SELECT tagentsid FROM tagents WHERE wechat_depid=(SELECT wechat_depid FROM tuser WHERE tuserid= '" + tuserid + "'))";
         return dbConnect.runSqlQuery(sqlFauthtype).toArrayList("fauthtype");
     }
 
@@ -515,7 +517,7 @@ public class wechatapplet extends Controller {
     public ArrayList<String> getUserFolderList(ArrayList<String> listRole, ArrayList<String> listfauthtype) {
         ArrayList<String> listFolders = new ArrayList<>();
         SQLFactory sqlFactory = new SQLFactory(this, "查询账号目录");
-        sqlFactory.addParameter("tuserid", parameter.tuserid);
+        sqlFactory.addParameter("tuserid", tuserid);
         sqlFactory.addParameter_in("frole", listRole);
         sqlFactory.addParameter_in("fauthtype", listfauthtype);
         String sql = sqlFactory.getSQL();
@@ -606,7 +608,7 @@ public class wechatapplet extends Controller {
         ArrayList<JSONObject> commonPrefixList2 = new ArrayList<>();
         //查询当前用户的上级部门id
         String deptId = "";
-        String sql = "SELECT tdepartmentid FROM tdepartment WHERE wechat_depid = ( SELECT wechat_parendeptid FROM tdepartment WHERE wechat_depid = ( SELECT wechat_depid FROM tuser WHERE tuserid = '" + parameter.tuserid + "'))";
+        String sql = "SELECT tdepartmentid FROM tdepartment WHERE wechat_depid = ( SELECT wechat_parendeptid FROM tdepartment WHERE wechat_depid = ( SELECT wechat_depid FROM tuser WHERE tuserid = '" + tuserid + "'))";
         Rows rowsDept = dbConnect.runSqlQuery(sql);
         if (!rowsDept.isEmpty()) {
             deptId = rowsDept.get(0).getString("tdepartmentid");
@@ -671,7 +673,7 @@ public class wechatapplet extends Controller {
                 isTuserid = true;
             } else {
                 for (String str : list_tuserid) {
-                    if (Objects.equals(parameter.tuserid, str)) {
+                    if (Objects.equals(tuserid, str)) {
                         isTuserid = true;
                     }
                 }

+ 4 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/ttypedetail/SQL/删除职位授权.sql

@@ -0,0 +1,4 @@
+delete
+from ttypedetail_auth
+WHERE ttypedetailid = $ttypedetailid$
+  and position not in $position$

+ 3 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/ttypedetail/SQL/查询资料分类职位.sql

@@ -0,0 +1,3 @@
+SELECT ttypedetailid, position
+from ttypedetail_auth
+WHERE ttypedetailid in $ttypedetailid$

+ 41 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/ttypedetail/ttypedetail.java

@@ -1,5 +1,6 @@
 package com.cnd3b.restcontroller.enterprise.ttypedetail;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
 import com.cnd3b.common.data.Row;
@@ -8,6 +9,7 @@ import com.cnd3b.common.data.RowsMap;
 import com.cnd3b.common.data.SQLFactory;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
+import p2.pao.SqlFormat;
 import p2.util.P2Exception;
 
 import java.util.ArrayList;
@@ -41,9 +43,12 @@ public class ttypedetail extends Controller {
         String fissaler = content.getString("fissaler");
         //经销商可见
         String fisagent = content.getString("fisagent");
+        JSONArray positions = content.getJSONArray("positions");
 
         PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("ttypedetail");
         PaoRemote paoRemote = paoSetRemote.addAtEnd();
+        Long ttypedetailid = paoRemote.getUniqueIDValue();
+        paoRemote.setValue("ttypedetailid", ttypedetailid, 11L);
         paoRemote.setValue("ftype", ftype, 11L);
         paoRemote.setValue("fisused", fisused, 11L);
         paoRemote.setValue("fvalue", fvalue, 11L);
@@ -51,6 +56,16 @@ public class ttypedetail extends Controller {
         paoRemote.setValue("fissaler", fissaler, 11L);
         paoRemote.setValue("fisagent", fisagent, 11L);
         paoSetRemote.save();
+
+        for (Object position : positions) {
+            PaoSetRemote paoSetRemote2 = getP2ServerSystemPaoSet("ttypedetail_auth");
+            PaoRemote paoRemote2 = paoSetRemote2.addAtEnd();
+            paoRemote2.setValue("ttypedetailid", ttypedetailid, 11L);
+            paoRemote2.setValue("position", position.toString(), 11L);
+            paoSetRemote2.save();
+        }
+
+
         System.err.println(wechatID);
         return getSucReturnObject().toString();
     }
@@ -74,6 +89,7 @@ public class ttypedetail extends Controller {
         String fissaler = content.getString("fissaler");
         //经销商可见
         String fisagent = content.getString("fisagent");
+        JSONArray positions = content.getJSONArray("positions");
 
         PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("ttypedetail", "ttypedetailid = '" + ttypedetailid + "'");
         if (!paoSetRemote.isEmpty()) {
@@ -89,6 +105,25 @@ public class ttypedetail extends Controller {
             return getErrReturnObject().setErrMsg("未找到更新的数据").toString();
         }
 
+
+        for (Object position : positions) {
+            PaoSetRemote paoSetRemote2 = getP2ServerSystemPaoSet("ttypedetail_auth", "ttypedetailid = '" + ttypedetailid + "' and position = '" + position + "'");
+            if (paoSetRemote2.isEmpty()) {
+                PaoRemote paoRemote2 = paoSetRemote2.addAtEnd();
+                paoRemote2.setValue("ttypedetailid", ttypedetailid, 11L);
+                paoRemote2.setValue("position", position.toString(), 11L);
+                paoSetRemote2.save();
+            }
+        }
+
+
+        SQLFactory deleteFac = new SQLFactory(this, "删除职位授权");
+        deleteFac.addParameter_in("position", (ArrayList<String>) positions.toJavaList(String.class));
+        deleteFac.addParameter("ttypedetailid", ttypedetailid);
+        String sql = deleteFac.getSQL();
+        dbConnect.runSqlUpdate(sql);
+
+
         return getSucReturnObject().toString();
     }
 
@@ -148,8 +183,14 @@ public class ttypedetail extends Controller {
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         ArrayList<String> ids = rows.toArrayList("ttypedetailid");
         RowsMap rowsMap = getAttachmentUrl("ttypedetail", ids);
+
+        SQLFactory sqlFactory1 = new SQLFactory(this, "查询资料分类职位");
+        sqlFactory1.addParameter_in("ttypedetailid", ids);
+        RowsMap rowsMap2 = dbConnect.runSqlQuery(sqlFactory1).toRowsMap("ttypedetailid");
+
         for (Row row : rows) {
             row.put("attinfos", rowsMap.get(row.getString("ttypedetailid")));
+            row.put("position", rowsMap2.get(row.getString("ttypedetailid")));
 
         }
         return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();