标签:java 审计
//前台修改内容审计 private void insertSampleShenJiMethod(Sample sample, Sample sample_fenku, StringBuffer sb, List<String> mobans) { // 前台登记审计 Field oldFields[] = sample_fenku.getClass().getDeclaredFields();// 获取两个类中所有的属性 Field newFields[] = sample.getClass().getDeclaredFields();// 获取两个类中所有的属性 if(null!=sample_fenku.getDue_date()){ sample_fenku.setDue_date(sample_fenku.getDue_date().substring(0, 10)); } if(null!=sample_fenku.getX_receivedate()){ sample_fenku.setX_receivedate(sample_fenku.getX_receivedate().substring(0, 10)); } for (int i = 0; i < oldFields.length; i++) { Field oldField = oldFields[i]; // 设置成可以操作private的变量 oldField.setAccessible(true); for (int j = 0; j < newFields.length; j++) { Field newField = newFields[j]; newField.setAccessible(true); if (mobans.contains(oldField.getName())) { // 是否是同一个属性 if (oldField.getName().equals(newField.getName()) && !oldField.getName().equals("changed_on") && !oldField.getName().equals("login_by") ) { // 两个值是否相等 try { if (null != oldField.get(sample_fenku) && null != newField.get(sample)) { if (!oldField.get(sample_fenku).equals( newField.get(sample))) { sb.append(oldField.getName() + ":" + oldField.get(sample_fenku) + " →" + newField.get(sample) + "<br/>"); } else { } } if (null == oldField.get(sample_fenku) && null != newField.get(sample) &&!"".equals(newField.get(sample))) { if(!"".equals(newField.get(sample))){ sb.append(oldField.getName() + ":" + oldField.get(sample_fenku) + " →" + newField.get(sample) + "<br/>"); } } if (null != oldField.get(sample_fenku) && null == newField.get(sample)) { } } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } Sample_shenji sampleshenji = new Sample_shenji(); Date date = new Date(); sampleshenji.setName(sample.getLogin_by()); sampleshenji.setTime(FORMAT_LONG.format(date)); sampleshenji.setSample_number(sample.getSample_number()); sampleshenji.setText_id(sample.getText_id()); sampleshenji.setContent(sb.toString()); insertSampleshenji(sampleshenji); }
本文出自 “大话程序” 博客,请务必保留此出处http://houqida.blog.51cto.com/8877896/1588130
标签:java 审计
原文地址:http://houqida.blog.51cto.com/8877896/1588130