usermsg.java 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.cnd3b.restcontroller.customer.usercenter.usermsg;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.cnd3b.common.Controller;
  4. import com.cnd3b.common.D3bException;
  5. import com.cnd3b.common.data.Row;
  6. import com.cnd3b.common.data.Rows;
  7. import com.cnd3b.common.data.SQLFactory;
  8. import com.cnd3b.common.parameter.parameter;
  9. import p2.pao.PaoRemote;
  10. import p2.pao.PaoSetRemote;
  11. import p2.util.P2Exception;
  12. import java.util.Date;
  13. public class usermsg extends Controller {
  14. public usermsg(JSONObject content) {
  15. super(content);
  16. }
  17. /**
  18. * 个人信息详情查询
  19. *
  20. * @return
  21. */
  22. public String query_usermsg() {
  23. SQLFactory sqlFactory = new SQLFactory(this, "用户信息查询");
  24. sqlFactory.addParameter("siteid", siteid);
  25. sqlFactory.addParameter("userid", userid);
  26. sqlFactory.addParameter("tagentsid", tagentsid);
  27. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  28. for (Row row : rows) {
  29. SQLFactory sqlFactory2 = new SQLFactory(this, "用户版本授权情况查询");
  30. sqlFactory2.addParameter("siteid", siteid);
  31. sqlFactory2.addParameter("tagentsid", tagentsid);
  32. Rows rows2 = dbConnect.runSqlQuery(sqlFactory2.getSQL());
  33. if (rows2.isEmpty()) {
  34. row.put("fappmodel", "");
  35. row.put("fauthenddate", "");
  36. } else {
  37. row.put("fappmodel", rows2.get(0).getString("fappmodel"));
  38. row.put("fauthenddate", rows2.get(0).getString("fauthenddate"));
  39. }
  40. row.put("attinfos", getAttachmentUrl("tenterprise_users", String.valueOf(userid), "headportrait"));
  41. }
  42. return getSucReturnObject().setData(rows).toString();
  43. }
  44. /**
  45. * 个人信息修改
  46. *
  47. * @return
  48. */
  49. public String update_usermsg() throws D3bException, P2Exception {
  50. String fname = content.getString("fname", "tenterprise_users.fname", "账号名");//姓名
  51. String fsex = content.getString("fsex");//性别
  52. String frole = content.getString("frole", "tenterprise_users.frole", "身份/职位");//身份职位
  53. Date fbirthdate = content.getDate("fbirthdate");//出生日期
  54. String femail = content.getString("femail", "tenterprise_users.femail", "邮箱");//邮箱
  55. String fwechatno = content.getString("fwechatno", "tenterprise_users.fwechatno", "微信");//微信号
  56. String faddress = content.getString("faddress", "tenterprise_users.faddress", "地址");//地址
  57. PaoSetRemote tenterprise_usersSet = getP2ServerSystemPaoSet("tenterprise_users", "siteid='" + siteid + "' and tagentsid='" + tagentsid + "' and tenterprise_userid='" + userid + "'");
  58. if (!tenterprise_usersSet.isEmpty()) {
  59. PaoRemote pao = tenterprise_usersSet.getPao(0);
  60. pao.setValue("fname", fname, 11L);
  61. pao.setValue("fsex", fsex, 11L);
  62. pao.setValue("fbirthdate", fbirthdate, 11L);
  63. pao.setValue("femail", femail, 11L);
  64. pao.setValue("fwechatno", fwechatno, 11L);
  65. pao.setValue("changeby", username, 11L);
  66. pao.setValue("changedate", getDateTime(), 11L);
  67. pao.setValue("faddress", (faddress == null || faddress.equalsIgnoreCase("null")) ? "" : faddress, 11L);
  68. pao.setValue("frole", frole, 11L);
  69. tenterprise_usersSet.save();
  70. //修改账号姓名等缓存信息
  71. Row row = parameter.userIdList.get(userid);
  72. row.put("fname", fname);
  73. parameter.userIdList.put(userid, row);
  74. dbConnect.runSqlUpdate("update tagents set faddress='" + faddress + "' where siteid='" + siteid + "' and tagentsid=" + tagentsid + " and ftype='个人'");
  75. } else {
  76. throw new D3bException("找不到账号信息");
  77. }
  78. return query_usermsg();
  79. }
  80. }