| | |
| | | Class<?> entityClass = entity.getClass(); |
| | | Method setMt = null ; |
| | | try{ |
| | | // 判断主键是id还是userId |
| | | // 添加用户时userId为自动生成主键。roleId存在时是为用户绑角色 |
| | | String jsonString = JSONObject.toJSONString(entity, JSONWriter.Feature.WriteMapNullValue); |
| | | JSONObject jsonObject = JSONObject.parseObject(jsonString); |
| | | if(jsonObject.containsKey("userId")) { |
| | | if(jsonObject.containsKey("userId") && !jsonObject.containsKey("roleId")) { |
| | | setMt = entityClass.getMethod(BASE_FIELD_SET_PRIMARY_KEY_FUNTION_NAME2, Long.class) ; |
| | | }else { |
| | | //有一些实体没有id,例如中间表 |