Package com.github.dactiv.showcase.entity.foundation.audit

Examples of com.github.dactiv.showcase.entity.foundation.audit.OperatingRecord


   */
  @ResponseBody
  @RequestMapping("send-error")
  public String sendError(@RequestParam("id")String id) {

    OperatingRecord value = systemAuditManager.getOperatingRecord(id);
    Hibernate.initialize(value);
    Map<String, OperatingRecord> model = Collections.singletonMap("entity", value);
   
    try {
      javaMailService.sendByTemplate(mailReceive, "base-curd-project",
View Full Code Here


  private SystemAuditManager systemAuditManager;
 
  @Test
  @Transactional
  public void testInsertOperatingRecord() {
    OperatingRecord or = new OperatingRecord();
   
    or.setStartDate(new Date());
    or.setIp("127.0.0.1");
    or.setMethod("com.github.dactiv.showcase.test.manager.foundation.audit.OperatingRecordManager.testSaveOperatingRecord()");
    or.setOperatingTarget("account/user/view");
    or.setState(OperatingState.Success.getValue());
   
    or.setFkUserId("SJDK3849CKMS3849DJCK2039ZMSK0026");
    or.setUsername("admin");
    or.setEndDate(new Date());
   
    int beforeRow = countRowsInTable("TB_OPERATING_RECORD");
    systemAuditManager.insertOperatingRecord(or);
    getSessionFactory().getCurrentSession().flush();
    int afterRow = countRowsInTable("TB_OPERATING_RECORD");
View Full Code Here

   
    Method method = ((MethodSignature)point.getSignature()).getMethod();
   
    OperatingAudit audit = ReflectionUtils.getAnnotation(method, OperatingAudit.class);
   
    OperatingRecord record = new OperatingRecord();
    record.setStartDate(new Date());
    record.setMethod(method.getName());

    HttpServletRequest request = SpringMvcHolder.getRequest();
    StringBuffer sb = new StringBuffer();
   
    if(request != null) {
      record.setIp(getIpAddress(request));
      record.setOperatingTarget(request.getRequestURI());
      //获取本次提交的参数
      Map<String, Object> parameter = request.getParameterMap();
     
      if (parameter.size() > 0) {

        sb.append("<h2>request参数</h2>").append("<hr>");
        //逐个循环参数和值添加到操作记录参数的描述字段中
        for(Entry<String, Object> entry : parameter.entrySet()) {
          sb.append("<p>").
             append(entry.getKey()).
             append(":").
             append("<p>").
             append("<strong class='text-info'>").
             append(getParameterValue(entry.getValue())).
             append("</strong>").
             append("</p>");
        }
       
        sb.append("<hr>");
      }
    }
   
    //获取当前SessionVariable,通过该变量获取当前用户
    SessionVariable sessionVariable = SystemVariableUtils.getSessionVariable();
    //如果SessionVariable等于null,表示用户未登录,但一样要记录操作
    if (sessionVariable != null) {
      record.setFkUserId(sessionVariable.getUser().getId());
      record.setUsername(sessionVariable.getUser().getUsername());
    }
   
    String function = audit.function();
    String module = "";
   
    if (StringUtils.isEmpty(audit.value())) {
      OperatingAudit classAnnotation = ReflectionUtils.getAnnotation(method.getDeclaringClass(),OperatingAudit.class);
      module = classAnnotation == null ? "" : classAnnotation.value();
    }
   
    record.setFunction(function);
    record.setModule(module);
   
    Object reaultValue = null;
   
    try {
      reaultValue = point.proceed();
      record.setState(OperatingState.Success.getValue());
    } catch (Throwable e) {
      record.setState(OperatingState.Fail.getValue());
     
      StringWriter outputStream = new StringWriter();
      PrintWriter printWriter = new PrintWriter(outputStream);
     
      e.printStackTrace(printWriter);
     
      String message = StringUtils.replace(outputStream.toString(), ">", "&gt;");
      message = StringUtils.replace(message, "<", "&lt;");
      message = StringUtils.replace(message, "\r\n", "<br>");
     
      sb.append("<h2>异常信息</h2>").append("<hr>").append(message).append("<hr>");
      request.setAttribute("record", record);
      throw e;
    } finally {
      record.setEndDate(new Date());
      record.setRemark(sb.toString());
      systemAuditManager.insertOperatingRecord(record);
    }
   
    return reaultValue;
   
View Full Code Here

TOP

Related Classes of com.github.dactiv.showcase.entity.foundation.audit.OperatingRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.