要符合java編程規範java
要符合sql語句的格式sql
public String getRuleCDCFilter(String cdcTable, String columnName) { StringBuilder b = new StringBuilder(); try { if (CommonConstant.ZPP_SHOP_ID == getMyShopId()) {// 這裏能夠加中配運營平臺的帳號權限 b.append(" "); } else {// 若是不是運營商平臺的用戶,則過濾店鋪id b.append(" INNER JOIN (") .append(" select DISTINCT cdc_id from bd_employee_rdc r_empc,bd_employee r_emp where r_emp.EMP_ID=r_empc.EMP_ID and r_emp.USER_NAME='") .append(ContextHolder.getLoginUserName()) .append("' ) as _r on _r.cdc_id =").append(cdcTable).append(". ").append(columnName); } } catch (Exception e) {// 若是異常,則表示用戶登陸失效,則查不出數據. b.append(" and 1=2 "); } return b.toString(); } /** * 獲取店鋪權限過濾字符串 過濾CDC、實物子庫 * * @param tableName * 須要過濾的表名 * @return * @throws Exception */ public String getRuleCDCAndAutalFilter(String cdcTable) { StringBuilder b = new StringBuilder(); try { if (CommonConstant.ZPP_SHOP_ID == getMyShopId()) {// 這裏能夠加中配運營平臺的帳號權限 b.append(" "); } else {// 若是不是運營商平臺的用戶,則過濾店鋪id b.append(" INNER JOIN (" + " SELECT DISTINCT ber.CDC_ID, ber.ACTUAL_INVENTORY_NAME " + " FROM bd_employee_rdc ber " + " INNER JOIN bd_employee be ON ber.EMP_ID = be.EMP_ID" + " WHERE be.USER_NAME = '" + ContextHolder.getLoginUserName() + "'" + " AND ber.SUBINVENTORY_CODE IS NOT NULL" + " ) as _r on (_r.CDC_ID=" + cdcTable + ".CDC_ID AND _r.ACTUAL_INVENTORY_NAME=" + cdcTable+".ACTUAL_INVENTORY_NAME) "); } } catch (Exception e) {// 若是異常,則表示用戶登陸失效,則查不出數據. b.append(" "); } return b.toString(); }
你能夠看到個人同事是否是不在乎這些細節,偶爾我也很糾結着這些個小問題,唉~!編程