eganwu 1 éve
szülő
commit
a9c89cbcb6

+ 14 - 8
src/custom/restcontroller/R.java

@@ -5195,7 +5195,6 @@ public class R {
     }
 
 
-
     public static class ID20230729142603 {
         public static class v1 {
         }
@@ -5425,7 +5424,6 @@ public class R {
     }
 
 
-
     public static class ID20231208134102 {
         public static class v1 {
         }
@@ -5443,7 +5441,6 @@ public class R {
     }
 
 
-
     public static class ID2023121221131702 {
         public static class v1 {
         }
@@ -5485,7 +5482,6 @@ public class R {
     }
 
 
-
     public static class ID20240312145602 {
         public static class v1 {
         }
@@ -5797,14 +5793,17 @@ public class R {
         public static class v1 {
         }
     }
+
     public static class ID20240329131802 {
         public static class v1 {
         }
     }
+
     public static class ID20240329131902 {
         public static class v1 {
         }
     }
+
     public static class ID20240329132002 {
         public static class v1 {
         }
@@ -5829,24 +5828,31 @@ public class R {
         public static class v1 {
         }
     }
+
     public static class ID20240402101702 {
         public static class v1 {
         }
     }
+
     public static class ID20240402101802 {
         public static class v1 {
         }
     }
+
     public static class ID20240402101902 {
         public static class v1 {
         }
     }
 
+    public static class ID20240403132302 {
+        public static class v1 {
+        }
+    }
 
-
-
-
-
+    public static class ID20240403153602 {
+        public static class v1 {
+        }
+    }
 
 
 }

+ 2 - 1
src/custom/restcontroller/webmanage/saletool/courseware/coursewaretesthead.java

@@ -539,7 +539,8 @@ public class coursewaretesthead extends Controller {
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_courseware_testhead"
                 ,"sat_courseware_testheadid","title","num")
                 .setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left,"sat_courseware_test","t2","t2.sat_courseware_testheadid=t1.sat_courseware_testheadid and t2.siteid=t1.siteid");
+        querySQL.addJoinTable(JOINTYPE.left,"sat_courseware_test","t2","t2.sat_courseware_testheadid=t1.sat_courseware_testheadid and t2.siteid=t1.siteid"
+                ,"answercount");
         querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
         querySQL.setSiteid(siteid);
         querySQL.setWhere("status", "发布");

+ 0 - 31
src/custom/restcontroller/webmanage/saletool/sharematerial/SQL/素材分类-新增.sql

@@ -1,31 +0,0 @@
-INSERT INTO sat_sharematerial_class (sat_sharematerial_classid,
-                                  siteid,
-                                  createuserid,
-                                  createby,
-                                  createdate,
-                                  changeuserid,
-                                  changeby,
-                                  changedate,
-                                  classname,
-                                  parentid,
-                                  issystem,
-                                     isenable,
-                                  level)
-VALUES ($sat_sharematerial_classid$,
-        $siteid$,
-        $createuserid$,
-        $createby$,
-        CURRENT_TIME,
-        $changeuserid$,
-        $changeby$,
-        CURRENT_TIME,
-        $classname$,
-        $parentid$,
-        $issystem$,
-        $isenable$,
-        $level$)
-
-
-
-
-

+ 0 - 10
src/custom/restcontroller/webmanage/saletool/sharematerial/SQL/素材分类-更新.sql

@@ -1,10 +0,0 @@
-UPDATE sat_sharematerial_class
-SET classname=$classname$,
-    changedate = CURRENT_TIME,
-    changeuserid = $changeuserid$,
-    changeby = $changeby$,
-    level = $level$,
-    issystem = $issystem$,
-    parentid = $parentid$,
-    isenable = $isenable$
-WHERE sat_sharematerial_classid = $sat_sharematerial_classid$

+ 2 - 2
src/custom/restcontroller/webmanage/saletool/sharematerial/SQL/素材分类-查询.sql

@@ -1,4 +1,4 @@
-SELECT sat_sharematerial_classid, classname, parentid,createdate, isenable
+SELECT sat_sharematerial_classid, classname, parentid,createdate, isenable,sequence
 FROM sat_sharematerial_class
 WHERE parentid = $parentid$ and siteid = $siteid$ and $where$
-ORDER BY issystem DESC,createdate DESC
+ORDER BY sequence DESC,createdate DESC

+ 90 - 72
src/custom/restcontroller/webmanage/saletool/sharematerial/sharematerialClass.java

@@ -1,5 +1,7 @@
 package restcontroller.webmanage.saletool.sharematerial;
 
+import beans.attachment.Attachment;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
 import common.YosException;
@@ -7,10 +9,9 @@ import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.annotation.cm;
-import common.data.Row;
-import common.data.Rows;
-import common.data.SQLFactory;
+import common.data.*;
 import restcontroller.R;
+import restcontroller.webmanage.saletool.courseware.courseware;
 import restcontroller.webmanage.saletool.courseware.coursewareclass;
 
 import java.util.ArrayList;
@@ -21,17 +22,12 @@ public class sharematerialClass extends Controller {
         super(content);
     }
 
-    @API(title = "新增")
-    @CACHEING_CLEAN(cms = {@cm(clazz = sharematerialClass.class, method = {"select"})})
+    @API(title = "新增", apiversion = R.ID20240403132302.v1.class)
     public String insertOrUpdate() throws YosException {
-        Long sat_sharematerial_classid = content.getLong("sat_sharematerial_classid");
-        String classname = content.getString("classname", "sat_sharematerial_class");
-        Long parentid = content.getLong("parentid");
-        boolean isenable = content.getBoolean("isenable");
+        Long sat_sharematerial_classid = content.getLongValue("sat_sharematerial_classid");
+        Long parentid = content.getLongValue("parentid");
         long level = 1;
-        if (parentid == 0) {
-            level = 1;
-        } else {
+        if (parentid > 0) {
             //查询level
             String sqlLevel = "SELECT IFNULL(level,0) level FROM sat_sharematerial_class WHERE sat_sharematerial_classid = '" + parentid + "'";
             Rows rows = dbConnect.runSqlQuery(sqlLevel);
@@ -39,72 +35,67 @@ public class sharematerialClass extends Controller {
                 level = rows.get(0).getLong("level") + 1;
             }
         }
-        SQLFactory sqlFactory;
         if (sat_sharematerial_classid <= 0) {
-            sqlFactory = new SQLFactory(this, "素材分类-新增");
-            sqlFactory.addParameter("sat_sharematerial_classid", createTableID("sat_sharematerial_class"));
-            sqlFactory.addParameter("siteid", siteid);
-            sqlFactory.addParameter("createuserid", userid);
-            sqlFactory.addParameter("createby", username);
+            sat_sharematerial_classid = createTableID("sat_sharematerial_class");
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_sharematerial_class");
+            insertSQL.setUniqueid(sat_sharematerial_classid);
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("classname", content.getStringValue("classname"));
+            insertSQL.setValue("isenable", content.getBooleanValue("isenable"));
+            insertSQL.setValue("sequence", content.getLongValue("sequence"));
+            insertSQL.setValue("level", level);
+            insertSQL.setValue("parentid", parentid);
+            insertSQL.insert();
+            content.put("sat_sharematerial_classid", sat_sharematerial_classid);
+        }
+        if (sat_sharematerial_classid > 0) {
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_sharematerial_class");
+            updateSQL.setUniqueid(sat_sharematerial_classid);
+            updateSQL.setSiteid(siteid);
+            updateSQL.setValue("classname", content.getStringValue("classname"));
+            updateSQL.setValue("isenable", content.getBooleanValue("isenable"));
+            updateSQL.setValue("sequence", content.getLongValue("sequence"));
+            updateSQL.setValue("level", level);
+            updateSQL.update();
+        }
 
 
-        } else {
-            sqlFactory = new SQLFactory(this, "素材分类-更新");
-            sqlFactory.addParameter("sat_sharematerial_classid", sat_sharematerial_classid);
-            sqlFactory.addParameter("changeuserid", userid);
-            sqlFactory.addParameter("changeby", username);
+        Rows rows = dbConnect.runSqlQuery("SELECT * from sat_sharematerial_class WHERE sat_sharematerial_classid=" + sat_sharematerial_classid + " and siteid='" + siteid + "'");
 
-        }
-        sqlFactory.addParameter("changeuserid", userid);
-        sqlFactory.addParameter("changeby", username);
-        sqlFactory.addParameter("classname", classname);
-        sqlFactory.addParameter("parentid", parentid);
-        sqlFactory.addParameter("issystem", 0);
-        sqlFactory.addParameter("level", level);
-        sqlFactory.addParameter("isenable", isenable);
-
-        String sql = sqlFactory.getSQL();
-        dbConnect.runSqlUpdate(sql);
-        return getSucReturnObject().toString();
+        return getSucReturnObject().setData(rows.get(0)).toString();
     }
 
 
     @API(title = "删除", apiversion = R.ID20221102143502.v1.class)
-    @CACHEING_CLEAN(cms = {@cm(clazz = sharematerialClass.class, method = {"select"}),@cm(clazz = sharematerial.class, method = {"select"})})
     public String delete() throws YosException {
-        Long sat_sharematerial_classid = content.getLong("sat_sharematerial_classid");
-
-        Rows rows = dbConnect.runSqlQuery("select issystem,parentid  from sat_sharematerial_class where sat_sharematerial_classid=" + sat_sharematerial_classid);
-        if (rows.isEmpty()) {
-            return getErrReturnObject().setErrMsg("当前分类不存在,无法删除").toString();
-        } else {
-            if (rows.get(0).getBoolean("issystem")) {
-                return getErrReturnObject().setErrMsg("当前分类为系统分类,无法删除").toString();
-            }
-            if (rows.get(0).getLong("parentid") == 0) {
-                Rows subRows = dbConnect.runSqlQuery("select sat_sharematerial_classid from sat_sharematerial_class  WHERE parentid = " + sat_sharematerial_classid);
-                if (subRows.isNotEmpty()) {
-                    return getErrReturnObject().setErrMsg("当前分类下包含子类,无法删除").toString();
-                }
-            }
-        }
-        Rows rowssite = dbConnect.runSqlQuery("select sat_sharematerial_classid from sat_sharematerial_class where issystem=1 AND parentid !=0 and  siteid='" + siteid + "'");
-        if (rowssite.isEmpty()) {
-            return getErrReturnObject().setErrMsg("当前分类下不存在系统板块,无法删除").toString();
+
+        JSONArray sat_sharematerial_classids = content.getJSONArray("sat_sharematerial_classids");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_sharematerial");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("sat_sharematerial_classid", sat_sharematerial_classids);
+        Rows rows = querySQL.query();
+        if (rows.isNotEmpty()) {
+            return getErrReturnObject().setErrMsg("当前分类已使用,无法删除").toString();
         }
-        ArrayList<String> sqllist = new ArrayList<>();
-        String deletesql = "DELETE FROM sat_sharematerial_class WHERE sat_sharematerial_classid = '" + sat_sharematerial_classid + "'";
-        sqllist.add(deletesql);
-        if (rows.get(0).getLong("parentid") != 0) {
-            String updatesql = "update sat_sharematerial set sat_sharematerial_classid=" + rowssite.get(0).getLong("sat_sharematerial_classid") + " where sat_sharematerial_classid = '" + sat_sharematerial_classid + "'";
-            sqllist.add(updatesql);
+
+        querySQL = SQLFactory.createQuerySQL(this, "sat_sharematerial_class");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("parentid", sat_sharematerial_classids);
+        rows = querySQL.query();
+        if (rows.isNotEmpty()) {
+            return getErrReturnObject().setErrMsg("当前分类存在下级分类,无法删除").toString();
         }
-        dbConnect.runSqlUpdate(sqllist);
+
+
+        DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_sharematerial_class");
+        deleteSQL.setSiteid(siteid);
+        deleteSQL.setWhere("sat_sharematerial_classid", sat_sharematerial_classids);
+        deleteSQL.delete();
         return getSucReturnObject().toString();
     }
 
-    @API(title = "推广素材分类列表",apiversion = R.ID20221102143202.v1.class)
-    @CACHEING
+    @API(title = "推广素材分类列表", apiversion = R.ID20221102143202.v1.class)
     public String select() throws YosException {
         /*
           过滤条件设置
@@ -122,18 +113,45 @@ public class sharematerialClass extends Controller {
         }
 
         Long parentid = content.getLong("parentid");
+
+        Rows rows = getClassRows(parentid, where);
+        for (Row row : rows) {
+            Rows attRows = Attachment.get(this, "sat_sharematerial_class", row.getLong("sat_sharematerial_classid"));
+            row.put("attinfos", attRows);
+
+            Rows secondRows = getClassRows(row.getLong("sat_sharematerial_classid"), where);
+            row.put("children", secondRows);
+            for (Row secondRow : secondRows) {
+                Rows threeRows = getClassRows(secondRow.getLong("sat_sharematerial_classid"), where);
+                secondRow.put("children", threeRows);
+            }
+
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    public Rows getClassRows(Long parentid, StringBuffer where) throws YosException {
         SQLFactory sqlFactory = new SQLFactory(this, "素材分类-查询");
         sqlFactory.addParameter("parentid", parentid);
         sqlFactory.addParameter("siteid", siteid);
         sqlFactory.addParameter_SQL("where", where);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
-        for (Row row : rows) {
-            SQLFactory tempFac = new SQLFactory(this, "素材分类-查询");
-            tempFac.addParameter("parentid", row.getString("sat_sharematerial_classid"));
-            tempFac.addParameter("siteid", siteid);
-            tempFac.addParameter_SQL("where", where);
-            row.put("children", dbConnect.runSqlQuery(tempFac));
-        }
-        return getSucReturnObject().setData(rows).toString();
+        return rows;
     }
+
+    @API(title = "启用", apiversion = R.ID20240403153602.v1.class)
+    public String isenadle() throws YosException {
+        JSONArray sat_sharematerial_classids = content.getJSONArray("sat_sharematerial_classids");
+
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_sharematerial_class");
+        updateSQL.setSiteid(siteid);
+        updateSQL.setValue("isenable", content.getBooleanValue("isenable"));
+        updateSQL.setWhere("sat_sharematerial_classid ", sat_sharematerial_classids.toArray());
+        updateSQL.update();
+
+
+        return getSucReturnObject().toString();
+    }
+
+
 }