Browse Source

课件管理

eganwu 1 year ago
parent
commit
dbaa253a60

+ 26 - 0
src/custom/restcontroller/R.java

@@ -5614,6 +5614,32 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID20240315110202 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240315131302 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240315131402 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240315131502 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240315131602 {
+        public static class v1 {
+        }
+    }
+
 }
 
 

+ 83 - 82
src/custom/restcontroller/saletool/courseware/courseware.java

@@ -9,6 +9,7 @@ import common.data.Row;
 import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
+import restcontroller.R;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -21,65 +22,65 @@ public class courseware extends Controller {
 
     }
 
-    @API(title = "课程详细")
-    public String selectDetail() throws YosException {
-
-        Long sat_coursewareid = content.getLong("sat_coursewareid");
-        //新增记录
-        addReadLog(sat_coursewareid);
-        SQLFactory sqlFactory = new SQLFactory(this, "课件管理-查询详细");
-        sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory);
-
-        ArrayList<Long> ids = rows.toArrayList("sat_coursewareid", new ArrayList<>());
-        //封面cover
-        RowsMap coverRowsMap = getAttachmentUrl("sat_courseware", ids, "cover");
-        //附件
-        RowsMap attRowsMap = getAttachmentUrl("sat_courseware", ids, "default");
-        for (Row row : rows) {
-            Rows coverRows = coverRowsMap.get(row.getString("sat_coursewareid"));
-            if (coverRows.isEmpty()) {
-                row.put("cover", "");
-            } else {
-                row.put("cover", coverRows.get(0).getString("url"));
-            }
-
-            row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_coursewareid"), new Rows()));
-            row.put("tag", DataTag.queryTag(this, "sat_courseware", sat_coursewareid, false));
-        }
-
-        return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
-    }
-
-    //添加阅读记录
-    public void addReadLog(Long sat_coursewareid) throws YosException {
-        //新增浏览次数
-        dbConnect.runSqlUpdate("UPDATE sat_courseware SET readcount=readcount+1 WHERE sat_coursewareid='" + sat_coursewareid + "'");
-        //查询当前用户的阅读次数是否存在
-        String sql = "SELECT sat_courseware_readid FROM sat_courseware_read WHERE siteid = '" + siteid + "' AND sat_coursewareid = '" + sat_coursewareid + "' AND createuserid = '" + userid + "'";
-        Rows rows = dbConnect.runSqlQuery(sql);
-        if (rows.isEmpty()) {
-            SQLFactory sqlFactory = new SQLFactory(this, "新增阅读记录");
-            sqlFactory.addParameter("siteid", siteid);
-            sqlFactory.addParameter("sat_courseware_readid", createTableID("sat_courseware_read"));
-            sqlFactory.addParameter("createby", username);
-            sqlFactory.addParameter("changeby", username);
-            sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
-            sqlFactory.addParameter("createuserid", userid);
-            sqlFactory.addParameter("sa_agentsid",  userInfo.getAgentID());
-            sqlFactory.addParameter("hrid", hrid);
-            dbConnect.runSqlUpdate(sqlFactory);
-        } else {
-            SQLFactory sqlFactory = new SQLFactory(this, "更新阅读记录");
-            sqlFactory.addParameter("siteid", siteid);
-            sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
-            sqlFactory.addParameter("createuserid", userid);
-            sqlFactory.addParameter("sa_agentsid",  userInfo.getAgentID());
-            sqlFactory.addParameter("hrid", hrid);
-            dbConnect.runSqlUpdate(sqlFactory);
-        }
-
-    }
+//    @API(title = "课件详细")
+//    public String selectDetail() throws YosException {
+//
+//        Long sat_coursewareid = content.getLong("sat_coursewareid");
+//        //新增记录
+//        addReadLog(sat_coursewareid);
+//        SQLFactory sqlFactory = new SQLFactory(this, "课件管理-查询详细");
+//        sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
+//        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+//
+//        ArrayList<Long> ids = rows.toArrayList("sat_coursewareid", new ArrayList<>());
+//        //封面cover
+//        RowsMap coverRowsMap = getAttachmentUrl("sat_courseware", ids, "cover");
+//        //附件
+//        RowsMap attRowsMap = getAttachmentUrl("sat_courseware", ids, "default");
+//        for (Row row : rows) {
+//            Rows coverRows = coverRowsMap.get(row.getString("sat_coursewareid"));
+//            if (coverRows.isEmpty()) {
+//                row.put("cover", "");
+//            } else {
+//                row.put("cover", coverRows.get(0).getString("url"));
+//            }
+//
+//            row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_coursewareid"), new Rows()));
+//            row.put("tag", DataTag.queryTag(this, "sat_courseware", sat_coursewareid, false));
+//        }
+//
+//        return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
+//    }
+
+//    //添加阅读记录
+//    public void addReadLog(Long sat_coursewareid) throws YosException {
+//        //新增浏览次数
+//        dbConnect.runSqlUpdate("UPDATE sat_courseware SET readcount=readcount+1 WHERE sat_coursewareid='" + sat_coursewareid + "'");
+//        //查询当前用户的阅读次数是否存在
+//        String sql = "SELECT sat_courseware_readid FROM sat_courseware_read WHERE siteid = '" + siteid + "' AND sat_coursewareid = '" + sat_coursewareid + "' AND createuserid = '" + userid + "'";
+//        Rows rows = dbConnect.runSqlQuery(sql);
+//        if (rows.isEmpty()) {
+//            SQLFactory sqlFactory = new SQLFactory(this, "新增阅读记录");
+//            sqlFactory.addParameter("siteid", siteid);
+//            sqlFactory.addParameter("sat_courseware_readid", createTableID("sat_courseware_read"));
+//            sqlFactory.addParameter("createby", username);
+//            sqlFactory.addParameter("changeby", username);
+//            sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
+//            sqlFactory.addParameter("createuserid", userid);
+//            sqlFactory.addParameter("sa_agentsid",  userInfo.getAgentID());
+//            sqlFactory.addParameter("hrid", hrid);
+//            dbConnect.runSqlUpdate(sqlFactory);
+//        } else {
+//            SQLFactory sqlFactory = new SQLFactory(this, "更新阅读记录");
+//            sqlFactory.addParameter("siteid", siteid);
+//            sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
+//            sqlFactory.addParameter("createuserid", userid);
+//            sqlFactory.addParameter("sa_agentsid",  userInfo.getAgentID());
+//            sqlFactory.addParameter("hrid", hrid);
+//            dbConnect.runSqlUpdate(sqlFactory);
+//        }
+//
+//    }
 
     @API(title = "更新下载记录")
     public String updateDownloadLog() throws YosException {
@@ -162,29 +163,29 @@ public class courseware extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "课程分类查询")
-    public String selectMenu() throws YosException {
-
-        SQLFactory sqlFactory = new SQLFactory(this, "课程分类-查询");
-        sqlFactory.addParameter("parentid", 0);
-        sqlFactory.addParameter("siteid", siteid);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory);
-
-        Rows resRows = new Rows();
-        for (Row row : rows) {
-            SQLFactory tempFac = new SQLFactory(this, "课程分类-查询");
-            tempFac.addParameter("parentid", row.getString("sat_courseware_classid"));
-            tempFac.addParameter("siteid", siteid);
-            Rows childrenRows = dbConnect.runSqlQuery(tempFac);
-//            if (childrenRows.isNotEmpty()) {
-            row.put("children", childrenRows);
-            resRows.add(row);
-//            }
-        }
-
-
-        return getSucReturnObject().setData(resRows).toString();
-    }
+//    @API(title = "课程分类查询")
+//    public String selectMenu() throws YosException {
+//
+//        SQLFactory sqlFactory = new SQLFactory(this, "课程分类-查询");
+//        sqlFactory.addParameter("parentid", 0);
+//        sqlFactory.addParameter("siteid", siteid);
+//        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+//
+//        Rows resRows = new Rows();
+//        for (Row row : rows) {
+//            SQLFactory tempFac = new SQLFactory(this, "课程分类-查询");
+//            tempFac.addParameter("parentid", row.getString("sat_courseware_classid"));
+//            tempFac.addParameter("siteid", siteid);
+//            Rows childrenRows = dbConnect.runSqlQuery(tempFac);
+////            if (childrenRows.isNotEmpty()) {
+//            row.put("children", childrenRows);
+//            resRows.add(row);
+////            }
+//        }
+//
+//
+//        return getSucReturnObject().setData(resRows).toString();
+//    }
 
 
 }

+ 101 - 0
src/custom/restcontroller/webmanage/saletool/courseware/coursewaredetail.java

@@ -0,0 +1,101 @@
+package restcontroller.webmanage.saletool.courseware;
+
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import restcontroller.R;
+
+/**
+ * 课件
+ */
+public class coursewaredetail extends Controller {
+    String sat_coursewaredetail = "sat_coursewaredetail";
+
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public coursewaredetail(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    //新增或更新
+    @API(title = "课件新增或更新", apiversion = R.ID20240315110202.v1.class)
+    public String insertOrUpdate() throws YosException {
+        Long sat_coursewareid = content.getLongValue("sat_coursewareid");
+        Long sat_coursewaredetailid = content.getLongValue("sat_coursewaredetailid");
+
+        if (sat_coursewaredetailid <= 0) {
+            sat_coursewaredetailid = createTableID(sat_coursewaredetail);
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, sat_coursewaredetail);
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(sat_coursewaredetailid);
+            insertSQL.setValue("sat_coursewareid", sat_coursewareid);
+            insertSQL.setValue("title", content.getStringValue("title"));
+            insertSQL.setValue("description", content.getStringValue("description"));
+            insertSQL.setValue("sequence", content.getLongValue("sequence"));
+            insertSQL.setValue("teacher", content.getStringValue("teacher"));
+            insertSQL.setValue("status", "新建");
+            insertSQL.setValue("filetype", content.getStringValue("filetype"));//图片、视频、pdf
+            insertSQL.insert();
+
+            content.put("sat_coursewaredetailid", sat_coursewaredetailid);
+        }
+        if (sat_coursewaredetailid > 0) {
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, sat_coursewaredetail);
+            updateSQL.setSiteid(siteid);
+            updateSQL.setUniqueid(sat_coursewaredetailid);
+            updateSQL.setValue("title", content.getStringValue("title"));
+            updateSQL.setValue("description", content.getStringValue("description"));
+            updateSQL.setValue("sequence", content.getLongValue("sequence"));
+            updateSQL.setValue("teacher", content.getStringValue("teacher"));
+            updateSQL.setValue("filetype", content.getStringValue("filetype"));//图片、视频、pdf
+            updateSQL.update();
+        }
+
+
+        return detail();
+    }
+
+    //
+    @API(title = "上架,下架", apiversion = R.ID20240315131302.v1.class)
+    public String UpOrDown() {
+
+        return getSucReturnObject().toString();
+    }
+
+    //课件删除
+    @API(title = "课件删除", apiversion = R.ID20240315131402.v1.class)
+    public String delete() {
+
+        return getSucReturnObject().toString();
+    }
+
+    //课件详细
+    @API(title = "课件详细", apiversion = R.ID20240315131502.v1.class)
+    public String detail() throws YosException {
+        Long sat_coursewaredetailid = content.getLongValue("sat_coursewaredetailid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_coursewaredetail");
+        querySQL.setSiteid(siteid);
+        querySQL.setUniqueid(sat_coursewaredetailid);
+        Rows rows = querySQL.query();
+        Row detailRow = new Row();
+        if (rows.isNotEmpty()) {
+            detailRow = rows.get(0);
+        }
+
+
+        return getSucReturnObject().setData(detailRow).toString();
+    }
+
+    //课件列表
+    @API(title = "课件列表", apiversion = R.ID20240315131602.v1.class)
+    public String list() {
+
+        return getSucReturnObject().toString();
+    }
+}