Open
Description
Firstly thank you very much to build such useful framework. I am using it in my project. I have a use case for data privilege, for the same statement different user role would take different data privilege strategies. eg:
select a, b, c from ta
if current use a normal user then the return result of column c should be maksed as "xxxx", in our project (sass, multi-tenancy), there are many cases.
if the framework supports hooks, then we can handle the logic in one place. right now we mix such logic every where. it's not a good practice.
thank you!
Metadata
Metadata
Assignees
Labels
No labels
Activity
jeffgbutler commentedon Apr 19, 2022
I'm going to add hooks to the library that will allow you to modify the generated SQL. I'm not sure that's what you are asking about however.
This library does not execute SQL - we defer that to either MyBatis or Spring. So if you need execution hooks, you will need to do it in those libraries. In MyBatis that would probably mean writing a plugin or interceptor - you can read about MyBatis plugins on this page: https://mybatis.org/mybatis-3/configuration.html
kcmvp commentedon Apr 20, 2022
yeath, that what I wanted for BeforeHook. , back to AfterHook (my case) is to modify the result.(eg encrypt).
in order to control the BeforeHook and AfterHook precisely, there should be a context I can pass a flag/variable in it. for example If set a variable/flag in context in BeforeHook for a sql, in the following AfterHook I can tell that's the very sql I am caring about by checking(and using) the flag/variable (eg, using it to encrypt the value)
generally speaking: our use case can fall into two categories
1: simply using BeforeHook to modify the sql
2: Using BeforeHook and AfterHook together to modify the returned the result.
Thank you quick reply very much!