package restcontroller; import common.Controller; import common.UserInfo; import common.YosException; import common.data.Row; import common.data.Rows; import java.util.ArrayList; public class ClientUserInfo extends UserInfo { public ClientUserInfo(Controller controller) { super(controller); } public static Row setLoginReturn(long usersiteid, Row userrow) { return userrow; } private Row hrRow = null; private Row enterpriseRow = null; private Row enterprise_HrRow = null; private Row agentsRow = null; public Row getHrRow() throws YosException { if (hrRow == null) { Rows hrRows = controller.dbConnect.runSqlQuery("select * from sys_hr where siteid='" + getSiteId() + "' and userid=" + getUserId()); if (hrRows.isNotEmpty()) { hrRow = hrRows.getRow(0); } } return hrRow; } public Row getEnterpriseRow() throws YosException { if (enterpriseRow == null) { 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)"); if (enterpriseRows.isNotEmpty()) { enterpriseRow = enterpriseRows.getRow(0); } } return enterpriseRow; } public long getEnterpriseId() throws YosException { Row row = getEnterpriseRow(); if(row==null||row.isEmpty()){ return 0; } return row.getLong("sys_enterpriseid"); } public Row getEnterprise_HrRow() throws YosException { if (enterprise_HrRow == null) { Rows enterprise_HrRows = controller.dbConnect.runSqlQuery("select * from sys_enterprise_hr where siteid='" + getSiteId() + "' and userid=" + getUserId()); if (enterprise_HrRows.isNotEmpty()) { enterprise_HrRow = enterprise_HrRows.getRow(0); } } return enterprise_HrRow; } public Row getAgentsRow() throws YosException { if (agentsRow == null) { Rows agentsRows = controller.dbConnect.runSqlQuery("select * from sa_agents where siteid='" + getSiteId() + "' and sys_enterpriseid=" + getEnterpriseId()); if (agentsRows.isNotEmpty()) { agentsRow = agentsRows.getRow(0); } } return agentsRow; } public long getAgentsId() throws YosException { Row row = getAgentsRow(); if (row==null||row.isEmpty()) { return 0; } return row.getLong("sa_agentsid"); } public boolean isSaler() throws YosException { return controller.dbConnect.runSqlQuery("select *from sa_salearea_hr where siteid='" + getSiteId() + "' and hrid=" + controller.hrid).isNotEmpty(); } /** * 获取当前企业的营销区域id */ public ArrayList getSaleAreaIds() throws YosException { if (getEnterpriseId() == 0) { return new ArrayList<>(); } Rows rows = controller.dbConnect.runSqlQuery("select distinct sa_saleareaid from sys_enterprise_tradefield where siteid='" + getSiteId() + "' and sys_enterpriseid=" + getEnterpriseId()); return rows.toArrayList("sa_saleareaid", new ArrayList<>()); } }