|
@@ -10,6 +10,7 @@ import common.data.*;
|
|
|
import restcontroller.R;
|
|
import restcontroller.R;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.logging.LoggingPermission;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 课件
|
|
* 课件
|
|
@@ -112,6 +113,7 @@ public class coursewaredetail extends Controller {
|
|
|
public String detail() throws YosException {
|
|
public String detail() throws YosException {
|
|
|
Long sat_coursewaredetailid = content.getLongValue("sat_coursewaredetailid");
|
|
Long sat_coursewaredetailid = content.getLongValue("sat_coursewaredetailid");
|
|
|
|
|
|
|
|
|
|
+
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_coursewaredetail");
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_coursewaredetail");
|
|
|
querySQL.setSiteid(siteid);
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setUniqueid(sat_coursewaredetailid);
|
|
querySQL.setUniqueid(sat_coursewaredetailid);
|
|
@@ -136,13 +138,106 @@ public class coursewaredetail extends Controller {
|
|
|
detailRow.put("attinfos", attRowsMap.getOrDefault(detailRow.getString("sat_coursewareid"), new Rows()));
|
|
detailRow.put("attinfos", attRowsMap.getOrDefault(detailRow.getString("sat_coursewareid"), new Rows()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Long sat_coursewareid = detailRow.getLong("sat_coursewareid");
|
|
|
|
|
+
|
|
|
|
|
+ addReadLog(sat_coursewareid, sat_coursewaredetailid);
|
|
|
|
|
+
|
|
|
return getSucReturnObject().setData(detailRow).toString();
|
|
return getSucReturnObject().setData(detailRow).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//课件列表
|
|
//课件列表
|
|
|
@API(title = "课件列表", apiversion = R.ID20240315131602.v1.class)
|
|
@API(title = "课件列表", apiversion = R.ID20240315131602.v1.class)
|
|
|
- public String list() {
|
|
|
|
|
|
|
+ public String list() 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 (pageSorting.equals("''")) {
|
|
|
|
|
+ pageSorting = "t1.status DESC,t1.sequence";
|
|
|
|
|
+ }
|
|
|
|
|
+ Long sat_coursewareid = content.getLongValue("sat_coursewareid");
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_coursewaredetail");
|
|
|
|
|
+
|
|
|
|
|
+ querySQL.setTableAlias("t1").setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
|
|
+ querySQL.setWhere("sat_coursewareid", sat_coursewareid);
|
|
|
|
|
+ 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");
|
|
|
|
|
+
|
|
|
|
|
+ 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"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //添加阅读记录
|
|
|
|
|
+ public void addReadLog(Long sat_coursewareid, Long sat_coursewaredetailid) throws YosException {
|
|
|
|
|
+ //查询当前用户的阅读次数是否存在
|
|
|
|
|
+ String sql = "SELECT * FROM sat_courseware_read WHERE siteid = '" + siteid + "' AND sat_coursewaredetailid = '" + sat_coursewaredetailid + "' AND userid = '" + userid + "'";
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
|
|
+ if (rows.isEmpty()) {
|
|
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware_read");
|
|
|
|
|
+ insertSQL.setUniqueid(createTableID("sat_courseware_read"));
|
|
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
|
|
+ insertSQL.setValue("sat_coursewareid", sat_coursewareid);
|
|
|
|
|
+ insertSQL.setValue("sat_coursewaredetailid", sat_coursewaredetailid);
|
|
|
|
|
+ insertSQL.setValue("userid", userid);
|
|
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
|
|
+ insertSQL.setValue("hrid", hrid);
|
|
|
|
|
+ insertSQL.setValue("firstreadtime", getDateTime_Str());
|
|
|
|
|
+ insertSQL.setValue("lastreadtime", getDateTime_Str());
|
|
|
|
|
+ insertSQL.setValue("studycount", 1);
|
|
|
|
|
+
|
|
|
|
|
+ insertSQL.insert();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Long sat_courseware_readid = rows.get(0).getLong("sat_courseware_readid");
|
|
|
|
|
+ Long studycount = rows.get(0).getLong("studycount");
|
|
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_courseware_read");
|
|
|
|
|
+ updateSQL.setUniqueid(sat_courseware_readid);
|
|
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
|
|
+ updateSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
|
|
+ updateSQL.setValue("hrid", hrid);
|
|
|
|
|
+ updateSQL.setValue("lastreadtime", getDateTime_Str());
|
|
|
|
|
+ updateSQL.setValue("studycount", studycount + 1);
|
|
|
|
|
+ System.err.println(updateSQL.getSQL());
|
|
|
|
|
+ updateSQL.update();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return getSucReturnObject().toString();
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|