|
@@ -0,0 +1,110 @@
|
|
|
+package restcontroller.webmanage.saletool.phonebook;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+public class PhoneBookGroup2 extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public PhoneBookGroup2(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "通讯录分组新增或编辑", apiversion = R.ID20240516135002.v1.class)
|
|
|
+ public String insertOrUpdate() throws YosException {
|
|
|
+ long sys_phonebookgroupid = content.getLongValue("sys_phonebookgroupid");
|
|
|
+ if (sys_phonebookgroupid <= 0) {
|
|
|
+ sys_phonebookgroupid = createTableID("sys_phonebookgroup");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_phonebookgroup");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sys_phonebookgroupid);
|
|
|
+ insertSQL.setValue("groupname", content.getStringValue("groupname"));
|
|
|
+ insertSQL.setValue("classid", 1);
|
|
|
+ insertSQL.setValue("isenable", content.getBooleanValue("isenable"));
|
|
|
+ insertSQL.setValue("sequence", content.getLongValue("sequence", 1L));
|
|
|
+ insertSQL.insert();
|
|
|
+ } else {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_phonebookgroup");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sys_phonebookgroupid);
|
|
|
+ updateSQL.setValue("groupname", content.getStringValue("groupname"));
|
|
|
+ updateSQL.setValue("isenable", content.getBooleanValue("isenable"));
|
|
|
+ updateSQL.setValue("sequence", content.getLongValue("sequence", 1L));
|
|
|
+ updateSQL.update();
|
|
|
+ }
|
|
|
+
|
|
|
+ Row row = new Row();
|
|
|
+ row.put("sys_phonebookgroupid", sys_phonebookgroupid);
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "通讯录分组删除", apiversion = R.ID20240516135102.v1.class)
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray sys_phonebookgroupids = content.getJSONArray("sys_phonebookgroupids");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_phonebook").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sys_phonebookgroupid", sys_phonebookgroupids);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前分组已有数据,不可删除").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_phonebookgroup");
|
|
|
+ deleteSQL.setSiteid(siteid);
|
|
|
+ deleteSQL.setWhere("sys_phonebookgroupid", sys_phonebookgroupids.toArray());
|
|
|
+ deleteSQL.delete();
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "通讯录分组列表", apiversion = R.ID20240516135202.v1.class)
|
|
|
+ public String list() throws YosException {
|
|
|
+
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("isenable") && !"".equals(whereObject.getString("isenable"))) {
|
|
|
+ where.append(" and (");
|
|
|
+ where.append("isenable=" + whereObject.getBoolean("isenable"));
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageSorting.equals("''")) {
|
|
|
+ pageSorting = "t1.sequence";
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_phonebookgroup").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "通讯录分组启用停用", apiversion = R.ID20240516135302.v1.class)
|
|
|
+ public String isenable() throws YosException {
|
|
|
+ JSONArray sys_phonebookgroupids = content.getJSONArray("sys_phonebookgroupids");
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_phonebookgroup");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("isenable", content.getBooleanValue("isenable"));
|
|
|
+ updateSQL.setWhere("sys_phonebookgroupid ", sys_phonebookgroupids.toArray());
|
|
|
+ updateSQL.update();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|