|
@@ -449,4 +449,72 @@ public class coursewaredetail extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+ //课件列表
|
|
|
+ @API(title = "收藏课件列表", apiversion = R.ID20240506100502.v1.class)
|
|
|
+ public String collectlist() throws YosException {
|
|
|
+ /*
|
|
|
+ 过滤条件设置
|
|
|
+ */
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.title like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("iscollect") && !"".equals(whereObject.getString("iscollect"))) {
|
|
|
+ if (whereObject.getString("iscollect").equals("1")) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append(" t1.sat_coursewaredetailid in (SELECT ownerid from sys_datacollect WHERE ownertable='sat_coursewaredetail' and type=1 and siteid='" + siteid + "' and userid=" + userid + ")");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageSorting.equals("''")) {
|
|
|
+ pageSorting = "t1.status DESC,t1.sequence";
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_coursewaredetail");
|
|
|
+ querySQL.setTableAlias("t1").setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sat_coursewaredetailid", new ArrayList<>());
|
|
|
+
|
|
|
+ QuerySQL readSql = SQLFactory.createQuerySQL(this, "sat_courseware_read",
|
|
|
+ "sat_coursewaredetailid");
|
|
|
+ readSql.addQueryFields("user_count", "count(1)");
|
|
|
+ readSql.setSiteid(siteid);
|
|
|
+ readSql.setWhere("sat_coursewaredetailid", ids);
|
|
|
+ readSql.addGroupBy("sat_coursewaredetailid");
|
|
|
+ RowsMap coursewareRowsMap = readSql.query().toRowsMap("sat_coursewaredetailid");
|
|
|
+ //附件
|
|
|
+ RowsMap attRowsMap = getAttachmentUrl("sat_coursewaredetail", ids);
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ Rows coursewareRows = coursewareRowsMap.get(row.getString("sat_coursewaredetailid"));
|
|
|
+ if (coursewareRows.isEmpty()) {
|
|
|
+ row.put("user_count", 0);
|
|
|
+ } else {
|
|
|
+ row.put("user_count", coursewareRows.get(0).getString("user_count"));
|
|
|
+ }
|
|
|
+ row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_coursewaredetailid"), new Rows()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|