|
|
@@ -0,0 +1,130 @@
|
|
|
+package com.cnd3b.restcontroller.enterprise.tadministrators;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.cnd3b.common.Controller;
|
|
|
+import com.cnd3b.common.data.Rows;
|
|
|
+import com.cnd3b.common.data.SQLFactory;
|
|
|
+import com.cnd3b.utility.DigitUppercase;
|
|
|
+import oracle.net.aso.MD5;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+import p2.pao.PaoRemote;
|
|
|
+import p2.pao.PaoSetRemote;
|
|
|
+import p2.util.P2Exception;
|
|
|
+
|
|
|
+public class tadministrators extends Controller {
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ */
|
|
|
+ public tadministrators(JSONObject content) {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增管理员
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String inseretTadministrators() throws P2Exception {
|
|
|
+
|
|
|
+ String tuserid = content.getString("tuserid");
|
|
|
+ //管理员密码
|
|
|
+ String fpassword = content.getString("fpassword");
|
|
|
+ //经销商管理权限
|
|
|
+ int fisagent = content.getIntValue("fisagent");
|
|
|
+ //业务员管理权限
|
|
|
+ int fissaler = content.getIntValue("fissaler");
|
|
|
+ //是否总管理
|
|
|
+ int fissysadministrator = content.getIntValue("fissysadministrator");
|
|
|
+ //培训学习管理权限
|
|
|
+ int fispxxx = content.getIntValue("fispxxx");
|
|
|
+ //资料管理权限
|
|
|
+ int fiszl = content.getIntValue("fiszl");
|
|
|
+
|
|
|
+ //新增体系
|
|
|
+ PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tadministrators");
|
|
|
+ PaoRemote paoRemote = paoSetRemote.addAtEnd();
|
|
|
+ paoRemote.setValue("tuserid", tuserid, 11L);
|
|
|
+ paoRemote.setValue("fpassword", DigestUtils.md5Hex(fpassword.getBytes()), 11L);
|
|
|
+ paoRemote.setValue("fisagent", fisagent, 11L);
|
|
|
+ paoRemote.setValue("fissaler", fissaler, 11L);
|
|
|
+ paoRemote.setValue("fissysadministrator", fissysadministrator, 11L);
|
|
|
+ paoRemote.setValue("fispxxx", fispxxx, 11L);
|
|
|
+ paoRemote.setValue("fiszl", fiszl, 11L);
|
|
|
+ paoSetRemote.save();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新管理员
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String updateTadministrators() throws P2Exception {
|
|
|
+ String tadministratorsid = content.getString("tadministratorsid");
|
|
|
+
|
|
|
+ String tuserid = content.getString("tuserid");
|
|
|
+ //管理员密码
|
|
|
+ String fpassword = content.getString("fpassword");
|
|
|
+ //经销商管理权限
|
|
|
+ int fisagent = content.getIntValue("fisagent");
|
|
|
+ //业务员管理权限
|
|
|
+ int fissaler = content.getIntValue("fissaler");
|
|
|
+ //是否总管理
|
|
|
+ int fissysadministrator = content.getIntValue("fissysadministrator");
|
|
|
+ //培训学习管理权限
|
|
|
+ int fispxxx = content.getIntValue("fispxxx");
|
|
|
+ //资料管理权限
|
|
|
+ int fiszl = content.getIntValue("fiszl");
|
|
|
+
|
|
|
+ //新增体系
|
|
|
+ PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tadministrators", "tadministratorsid = '" + tadministratorsid + "'");
|
|
|
+ if (!paoSetRemote.isEmpty()) {
|
|
|
+ PaoRemote paoRemote = paoSetRemote.getPao(0);
|
|
|
+ paoRemote.setValue("tuserid", tuserid, 11L);
|
|
|
+ paoRemote.setValue("fpassword", DigestUtils.md5Hex(fpassword.getBytes()), 11L);
|
|
|
+ paoRemote.setValue("fisagent", fisagent, 11L);
|
|
|
+ paoRemote.setValue("fissaler", fissaler, 11L);
|
|
|
+ paoRemote.setValue("fissysadministrator", fissysadministrator, 11L);
|
|
|
+ paoRemote.setValue("fispxxx", fispxxx, 11L);
|
|
|
+ paoRemote.setValue("fiszl", fiszl, 11L);
|
|
|
+ paoSetRemote.save();
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("未找到更新记录").toString();
|
|
|
+ }
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除管理员
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String deleteTadministrators() throws P2Exception {
|
|
|
+ String tadministratorsid = content.getString("tadministratorsid");
|
|
|
+ PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tadministrators", "tadministratorsid = '" + tadministratorsid + "'");
|
|
|
+ if (!paoSetRemote.isEmpty()) {
|
|
|
+ PaoRemote paoRemote = paoSetRemote.getPao(0);
|
|
|
+ paoRemote.delete();
|
|
|
+ paoSetRemote.save();
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("未找到要删除的记录").toString();
|
|
|
+ }
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询管理员列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String selectTadministratorsList() {
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "查询管理员列表", pageSize, pageNumber, "t1.createdate DESC");
|
|
|
+ Rows rows = sqlFactory.runSqlQuery();
|
|
|
+ return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|