Git Product home page Git Product logo

Comments (11)

qqxx6661 avatar qqxx6661 commented on September 16, 2024

感谢反馈,很好的一个场景,类似的问题我也碰到过。现在的逻辑,是在原函数执行后进行SpEL的解析的,主要是为了顺便把结果也一起处理了。现在思考下,感觉确实应该放在函数执行前解析会比较合适。晚点我抽空优化一下,如果有更新了在这里@你。

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

你要是急的话只能先用LogRecordContext临时撑一撑 :)

from log-record.

kangarap avatar kangarap commented on September 16, 2024

好的,作者有心了[抱拳]

from log-record.

huxxx avatar huxxx commented on September 16, 2024

如果有的场景需要在执行前解析,有的场景需要在执行后再解析呢。

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

如果有的场景需要在执行前解析,有的场景需要在执行后再解析呢。

其实是个权衡问题,目前来看碰到的业务场景,其实很多都和上方的case类似,要在执行前做解析,否则旧值得获取就只能靠手动传入。

当然,最完美的方案是把这个权利交给用户,给用户字段来配置,默认是在执行前解析。

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

作者你好,注解上的SpEL表达式执行顺序总是晚于被注解的整体方法执行的,有一种逻辑就会产生问题。 比如,有个方法是删除数据,参数只有一个ID,这种情况下需要通过id查到这条数据的信息,然后一起记录到日志。 但是现在的结果是,数据先被删除,然后SpEL函数去查数据时数据已经是null了。 看到您有个LogRecordContext的上下文,可以在方法体先查出来,但是这样子的话入侵太严重。 现在入参ID不变,不动入参,不能影响到前端。这种情况怎么处理比较好,后续会优化这种情况吗?

1.0.7 正式版本已经将解析前置到了函数执行前,之后考虑可以用户自定义前后,你可以试试了

from log-record.

kangarap avatar kangarap commented on September 16, 2024

@qqxx6661 嗯嗯,辛苦了!

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

美团的框架也提出了同样的ISSUE

建议:@ LogRecordAnnotation里只有函数放到整体方法执行之前执行,适应以下场景

mouzt/mzt-biz-log#17

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

v1.1.0版本支持自定义切面执行时机(方法执行前,方法执行后),默认方法执行后,可在每条注解上单独控制。

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

以下从README摘录:

在默认配置下,注解切面的逻辑在方法执行之后才会执行,这样会带来一个问题,如果在方法内部修改了方法参数,SpEL解析后取值就变成了改变后的值。

可以使用LogRecordContext写入旧值,避免这个问题,只是有一定代码侵入性。

为了满足一些特殊需求,注解中提供boolean参数executeBeforeFunc,若设置为true,则会在方法执行前先解析SpEL参数。 这样也会带来负作用,方法内写入的数值,比如自定义上下文,就不再参与SpEL解析了。

from log-record.

qqxx6661 avatar qqxx6661 commented on September 16, 2024

@huxxx @kangarap

from log-record.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.