ooTwToo
V2EX  ›  Java

Java 日志持久化的困惑

  •  
  •   ooTwToo · Aug 25, 2016 · 3834 views
    This topic created in 3564 days ago, the information mentioned may be changed or developed.

    所有 CRUD 都需要进行入库,其中出现报错(包含业务逻辑)回滚。

    数据库需要记录的数据: createTime IP UA UserName ID 操作类型(CRUD) 操作详情(例如:修改了 id 为 xxx 的商品、删除了 id 为 xxx 的商品、修改了 id 为 xxx 的商品)

    困惑: 其中一部分数据在 Controller 另一部分则在 Service 中。想过使用 AOP 来做,但无法验证业务逻辑,例如删除一条被使用的记录。而且 JoinPoint 里的参数也是不确定的。

    想问一下大家该怎么设计,低耦合且不想一条条手动记录

    5 replies    2016-09-07 09:14:45 +08:00
    letitbesqzr
        1
    letitbesqzr  
       Aug 25, 2016   ❤️ 1
    我们业务日志 还是手动操作,但是用 hibernate event 做了一个详细的 sql 执行增删改日志记录...
    ooTwToo
        2
    ooTwToo  
    OP
       Aug 25, 2016   ❤️ 1
    @letitbesqzr 感谢,目前是用 ApplicationEvent 来做的。 如果要做到很详细的话,还是得手动记录。
    letitbesqzr
        3
    letitbesqzr  
       Aug 25, 2016
    @ooTwToo 看了下 ApplicationEvent ,感觉不错。
    teemoer
        4
    teemoer  
       Aug 29, 2016
    @letitbesqzr = = 又看到你了
    Yunonam
        5
    Yunonam  
       Sep 7, 2016
    雖然不明就裡,但是看到你的頭像,我決定還是回復一下。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2745 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 15:04 · PVG 23:04 · LAX 08:04 · JFK 11:04
    ♥ Do have faith in what you're doing.