ClientUserInfo.java 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package restcontroller;
  2. import common.Controller;
  3. import common.UserInfo;
  4. import common.YosException;
  5. import common.data.Row;
  6. import common.data.Rows;
  7. import java.util.ArrayList;
  8. public class ClientUserInfo extends UserInfo {
  9. public ClientUserInfo(Controller controller) {
  10. super(controller);
  11. }
  12. public static Row setLoginReturn(long usersiteid, Row userrow) {
  13. return userrow;
  14. }
  15. private Row hrRow = null;
  16. private Row enterpriseRow = null;
  17. private Row enterprise_HrRow = null;
  18. private Row agentsRow = null;
  19. public Row getHrRow() throws YosException {
  20. if (hrRow == null) {
  21. Rows hrRows = controller.dbConnect.runSqlQuery("select * from sys_hr where siteid='" + getSiteId() + "' and userid=" + getUserId());
  22. if (hrRows.isNotEmpty()) {
  23. hrRow = hrRows.getRow(0);
  24. }
  25. }
  26. return hrRow;
  27. }
  28. public Row getEnterpriseRow() throws YosException {
  29. if (enterpriseRow == null) {
  30. Rows enterpriseRows = controller.dbConnect.runSqlQuery("select * from sys_enterprise t1 where t1.siteid='" + getSiteId() + "' and exists(select *from sys_enterprise_hr where siteid='" + getSiteId() + "' and userid=" + getUserId() + " and t1.sys_enterpriseid=sys_enterpriseid)");
  31. if (enterpriseRows.isNotEmpty()) {
  32. enterpriseRow = enterpriseRows.getRow(0);
  33. }
  34. }
  35. return enterpriseRow;
  36. }
  37. public long getEnterpriseId() throws YosException {
  38. Row row = getEnterpriseRow();
  39. if(row==null||row.isEmpty()){
  40. return 0;
  41. }
  42. return row.getLong("sys_enterpriseid");
  43. }
  44. public Row getEnterprise_HrRow() throws YosException {
  45. if (enterprise_HrRow == null) {
  46. Rows enterprise_HrRows = controller.dbConnect.runSqlQuery("select * from sys_enterprise_hr where siteid='" + getSiteId() + "' and userid=" + getUserId());
  47. if (enterprise_HrRows.isNotEmpty()) {
  48. enterprise_HrRow = enterprise_HrRows.getRow(0);
  49. }
  50. }
  51. return enterprise_HrRow;
  52. }
  53. public Row getAgentsRow() throws YosException {
  54. if (agentsRow == null) {
  55. Rows agentsRows = controller.dbConnect.runSqlQuery("select * from sa_agents where siteid='" + getSiteId() + "' and sys_enterpriseid=" + getEnterpriseId());
  56. if (agentsRows.isNotEmpty()) {
  57. agentsRow = agentsRows.getRow(0);
  58. }
  59. }
  60. return agentsRow;
  61. }
  62. public long getAgentsId() throws YosException {
  63. Row row = getAgentsRow();
  64. if (row==null||row.isEmpty()) {
  65. return 0;
  66. }
  67. return row.getLong("sa_agentsid");
  68. }
  69. public boolean isSaler() throws YosException {
  70. return controller.dbConnect.runSqlQuery("select *from sa_salearea_hr where siteid='" + getSiteId() + "' and hrid=" + controller.hrid).isNotEmpty();
  71. }
  72. /**
  73. * 获取当前企业的营销区域id
  74. */
  75. public ArrayList<Long> getSaleAreaIds() throws YosException {
  76. if (getEnterpriseId() == 0) {
  77. return new ArrayList<>();
  78. }
  79. Rows rows = controller.dbConnect.runSqlQuery("select distinct sa_saleareaid from sys_enterprise_tradefield where siteid='" + getSiteId() + "' and sys_enterpriseid=" + getEnterpriseId());
  80. return rows.toArrayList("sa_saleareaid", new ArrayList<>());
  81. }
  82. }