| | |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.apache.poi.hssf.record.DVALRecord; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.utils.AuthUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.springblade.core.secure.utils.AuthUtil.getUserRole; |
| | | |
| | |
| | | */ |
| | | private List<String> gridCodeList = new ArrayList<>(); |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private String str = null; |
| | | |
| | | public List<String> getRegionChildCodesList() { |
| | | return regionChildCodesList; |
| | | } |
| | |
| | | |
| | | public List<String> getGridCodeList() { |
| | | return gridCodeList; |
| | | } |
| | | |
| | | public String getStr() { |
| | | return str; |
| | | } |
| | | |
| | | public <U> CommonParamSet invoke(Class<U> clazz, T t) { |
| | |
| | | roleNameField.set(t, roleName); |
| | | // 网格员角色 |
| | | if (roleName.equals("wgy")) { |
| | | gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId()); |
| | | gridCodeList = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(),communityCode,roleName); |
| | | } |
| | | } |
| | | // 特定账号设置 |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 设置对应的属性值 |
| | | * @param clazz |
| | | * @param t |
| | | * @param list 字段属性集合 |
| | | * @param pre 字段拼接 |
| | | * @return |
| | | */ |
| | | public <U> CommonParamSet setFieldValue(Class<U> clazz, T t,List<String> list,String pre) { |
| | | //获取传入对象信息 |
| | | U u = clazz.cast(t); |
| | | try { |
| | | StringBuilder builder = new StringBuilder(pre); |
| | | for (String fieldName : list) { |
| | | if (!fieldName.equals("tableName")) { |
| | | if (fieldName.equals("tableId")) { |
| | | fieldName = "id"; |
| | | } |
| | | Field field = u.getClass().getDeclaredField(fieldName); |
| | | field.setAccessible(true); |
| | | builder.append(field.get(t).toString()).append(","); |
| | | } |
| | | } |
| | | String toString = builder.toString(); |
| | | str = toString.substring(0,toString.length()-1); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 设置对应的属性值 |
| | | * @param clazz |
| | | * @param t |
| | | * @param list 字段属性集合 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | public <U> CommonParamSet setFieldValueByMap(Class<U> clazz, T t, List<String> list, Map<String,Object> map) { |
| | | //获取传入对象信息 |
| | | U u = clazz.cast(t); |
| | | try { |
| | | for (String fieldName : list) { |
| | | if (!fieldName.equals("tableName")){ |
| | | if (fieldName.equals("tableId")){ |
| | | fieldName = "id"; |
| | | } |
| | | Field field = u.getClass().getDeclaredField(fieldName); |
| | | field.setAccessible(true); |
| | | String value = field.get(t).toString(); |
| | | if (fieldName.equals("id")){ |
| | | fieldName = "tableId"; |
| | | } |
| | | map.put(fieldName,value); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | |
| | | } |