|
|
@@ -11,10 +11,7 @@ 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.RowsMap;
|
|
|
-import common.data.SQLFactory;
|
|
|
+import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
import utility.email.EmailContent;
|
|
|
|
|
|
@@ -27,48 +24,44 @@ public class courseware extends Controller {
|
|
|
super(content);
|
|
|
}
|
|
|
|
|
|
- @API(title = "新增或更新")
|
|
|
+ @API(title = "新增或更新", apiversion = R.ID20240314102902.v1.class)
|
|
|
@CACHEING_CLEAN(cms = {@cm(clazz = courseware.class, method = {"select"})})
|
|
|
public String insertOrUpdate() throws YosException {
|
|
|
|
|
|
- String title = content.getString("title", "sat_courseware");
|
|
|
- Long sat_courseware_classid = content.getLong("sat_courseware_classid");
|
|
|
- String notes = content.getString("notes", "sat_courseware");
|
|
|
- JSONArray tagArray = content.getJSONArray("tag");
|
|
|
- boolean canfiledownload = content.getBoolean("canfiledownload");
|
|
|
- String begdate = content.getString("begdate");
|
|
|
- String enddate = content.getString("enddate");
|
|
|
Long sat_coursewareid = content.getLong("sat_coursewareid");
|
|
|
|
|
|
- SQLFactory sqlFactory;
|
|
|
+
|
|
|
if (sat_coursewareid <= 0) {
|
|
|
sat_coursewareid = createTableID("sat_courseware");
|
|
|
- sqlFactory = new SQLFactory(this, "课件管理-新增");
|
|
|
- sqlFactory.addParameter("createuserid", userid);
|
|
|
- sqlFactory.addParameter("createby", username);
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware");
|
|
|
+ insertSQL.setUniqueid(sat_coursewareid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("createdepid", departmentid);
|
|
|
+ insertSQL.setValue("authuserid", userid);
|
|
|
+ insertSQL.setValue("authdepid", departmentid);
|
|
|
+ insertSQL.setValue("title", content.getStringValue("title"));
|
|
|
+ insertSQL.setValue("sequence", content.getLongValue("sequence"));
|
|
|
+ insertSQL.setValue("description", content.getStringValue("description"));
|
|
|
+ insertSQL.setValue("teacher", content.getStringValue("teacher"));
|
|
|
+ insertSQL.setValue("sat_courseware_classid", content.getLongValue("sat_courseware_classid"));
|
|
|
+ insertSQL.setValue("publishdate", content.getStringValueForDate("publishdate", "yyyy-MM-dd", "null"));
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ insertSQL.insert();
|
|
|
+
|
|
|
} else {
|
|
|
- sqlFactory = new SQLFactory(this, "课件管理-更新");
|
|
|
- sqlFactory.addParameter("changeby", username);
|
|
|
- sqlFactory.addParameter("changeuserid", userid);
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_courseware");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sat_coursewareid);
|
|
|
+ updateSQL.setValue("title", content.getString("title"));
|
|
|
+ updateSQL.setValue("publishdate", content.getStringValueForDate("publishdate", "yyyy-MM-dd", "null"));
|
|
|
+ updateSQL.setValue("sat_courseware_classid", content.getLongValue("sat_courseware_classid"));
|
|
|
+ updateSQL.setValue("sequence", content.getLongValue("sequence"));
|
|
|
+ updateSQL.setValue("teacher", content.getStringValue("teacher"));
|
|
|
+ updateSQL.setValue("description", content.getStringValue("description"));
|
|
|
+ updateSQL.update();
|
|
|
}
|
|
|
- sqlFactory.addParameter("createdepid", departmentid);
|
|
|
- sqlFactory.addParameter("authuserid", userid);
|
|
|
- sqlFactory.addParameter("authdepid", departmentid);
|
|
|
- sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
|
|
|
- sqlFactory.addParameter("title", title);
|
|
|
- sqlFactory.addParameter("sat_courseware_classid", sat_courseware_classid);
|
|
|
- sqlFactory.addParameter("notes", notes);
|
|
|
- sqlFactory.addParameter("canfiledownload", canfiledownload);
|
|
|
-// sqlFactory.addParameter("tag", tagArray.toJSONString());
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("begdate", begdate);
|
|
|
- sqlFactory.addParameter("enddate", enddate);
|
|
|
|
|
|
- ArrayList<String> list = (ArrayList<String>) JSONObject.parseArray(tagArray.toJSONString(), String.class);
|
|
|
- DataTag.updateTag(this, "sat_courseware", sat_coursewareid, list);
|
|
|
|
|
|
-
|
|
|
- dbConnect.runSqlUpdate(sqlFactory);
|
|
|
content.put("sat_coursewareid", sat_coursewareid);
|
|
|
return selectDetail();
|
|
|
}
|
|
|
@@ -79,6 +72,18 @@ public class courseware extends Controller {
|
|
|
public String delete() throws YosException {
|
|
|
|
|
|
JSONArray array = content.getJSONArray("sat_coursewareids");
|
|
|
+
|
|
|
+ for (Object obj : array) {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sat_courseware WHERE sat_coursewareid=" + obj + " and siteid='" + siteid + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("课程不存在").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态不可删除").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "课程-删除");
|
|
|
sqlFactory.addParameter_in("sat_coursewareid", array.toArray());
|
|
|
String sql = sqlFactory.getSQL();
|
|
|
@@ -88,27 +93,23 @@ public class courseware extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @API(title = "审核")
|
|
|
+ @API(title = "课程发布", apiversion = R.ID20240314112102.v1.class)
|
|
|
@CACHEING_CLEAN(cms = {@cm(clazz = courseware.class, method = {"select"})})
|
|
|
public String audit() throws Exception {
|
|
|
- Long sat_coursewareid = content.getLong("sat_coursewareid");
|
|
|
+ JSONArray sat_coursewareids = content.getJSONArray("sat_coursewareids");
|
|
|
int type = content.getIntValue("type");
|
|
|
- String status = "新建";
|
|
|
- if (type == 0) {
|
|
|
- status = "新建";
|
|
|
- } else {
|
|
|
- status = "发布";
|
|
|
- }
|
|
|
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "课件管理-审核");
|
|
|
- sqlFactory.addParameter("sat_coursewareid", sat_coursewareid);
|
|
|
- sqlFactory.addParameter("checkby", username);
|
|
|
- sqlFactory.addParameter("status", status);
|
|
|
- dbConnect.runSqlUpdate(sqlFactory);
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_courseware");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", type == 0 ? "新建" : "发布");
|
|
|
+ updateSQL.setValue("checkby",type == 0 ? "null" : username);
|
|
|
+ updateSQL.setValue("checkdate",type == 0 ? "null" : getDateTime_Str());
|
|
|
+ updateSQL.setWhere("sat_coursewareid",sat_coursewareids.toArray());
|
|
|
+ updateSQL.update();
|
|
|
//发送邮件和消息,发布时发送消息
|
|
|
- if (type != 0) {
|
|
|
- sendMsg(sat_coursewareid);
|
|
|
- }
|
|
|
+// if (type != 0) {
|
|
|
+// sendMsg(sat_coursewareid);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -146,7 +147,6 @@ public class courseware extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "管理端-商学院-课程列表", apiversion = R.ID20221102143402.v1.class)
|
|
|
- @CACHEING
|
|
|
public String select() throws YosException {
|
|
|
|
|
|
/*
|
|
|
@@ -180,6 +180,16 @@ public class courseware extends Controller {
|
|
|
where.append(")");
|
|
|
}
|
|
|
}
|
|
|
+ if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.checkdate >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("t1.checkdate <='").append(whereObject.getString("enddate")).append(" 23:59:59' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -206,12 +216,20 @@ public class courseware extends Controller {
|
|
|
row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_coursewareid"), new Rows()));
|
|
|
row.put("tag", tagMap.get(row.getString("sat_coursewareid")));
|
|
|
|
|
|
+ String classname1=row.getString("classname1");
|
|
|
+ String classname2=row.getString("classname2");
|
|
|
+ if(classname1.equals("")){
|
|
|
+ row.put("classname",classname2);
|
|
|
+ }else{
|
|
|
+ row.put("classname",classname1+"/"+classname2);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "课程详细")
|
|
|
+ @API(title = "课程详细",apiversion =R.ID20240314134002.v1.class )
|
|
|
public String selectDetail() throws YosException {
|
|
|
Long sat_coursewareid = content.getLong("sat_coursewareid");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "课件管理-查询详细");
|
|
|
@@ -223,7 +241,19 @@ public class courseware extends Controller {
|
|
|
RowsMap coverRowsMap = getAttachmentUrl("sat_courseware", ids, "cover");
|
|
|
//附件
|
|
|
RowsMap attRowsMap = getAttachmentUrl("sat_courseware", ids, "default");
|
|
|
- for (Row row : rows) {
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_courseware_auth",
|
|
|
+ "roleid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sys_role", "t2", "t1.roleid=t2.roleid and t1.siteid=t2.siteid",
|
|
|
+ "rolename");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setWhere("t1.sat_coursewareid", sat_coursewareid);
|
|
|
+ Rows roleRows = querySQL.query();
|
|
|
+
|
|
|
+ Row row = new Row();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ row = rows.get(0);
|
|
|
Rows coverRows = coverRowsMap.get(row.getString("sat_coursewareid"));
|
|
|
if (coverRows.isEmpty()) {
|
|
|
row.put("cover", "");
|
|
|
@@ -233,9 +263,11 @@ public class courseware extends Controller {
|
|
|
|
|
|
row.put("attinfos", attRowsMap.getOrDefault(row.getString("sat_coursewareid"), new Rows()));
|
|
|
row.put("tag", DataTag.queryTag(this, "sat_courseware", sat_coursewareid, false));
|
|
|
+ row.putIfAbsent("publishdate","");
|
|
|
+ row.put("role", roleRows);
|
|
|
}
|
|
|
|
|
|
- return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
|
|
|
}
|