PaymentMethodSqlDao.sql.stg

86 lines | 1.41 kB Blame History Raw Download
group PaymentMethodSqlDao: EntitySqlDao;



tableName() ::= "payment_methods"

historyTableName() ::= "payment_method_history"

andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"

tableFields(prefix) ::= <<
  <prefix>account_id
, <prefix>plugin_name
, <prefix>is_active
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
  :accountId
, :pluginName
, :isActive
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>


markPaymentMethodAsDeleted(id) ::= <<
update <tableName()>
set is_active = 0
, updated_by = :updatedBy
, updated_date = :createdDate
where  id = :id
<AND_CHECK_TENANT()>
;
>>

unmarkPaymentMethodAsDeleted(id) ::= <<
update <tableName()>
set is_active = 1
where  id = :id
, updated_by = :updatedBy
, updated_date = :createdDate
<AND_CHECK_TENANT()>
;
>>

getPaymentMethodIncludedDelete(accountId) ::= <<
select <allTableFields()>
from <tableName()>
where id = :id
;
>>

getByAccountId(accountId) ::= <<
select
<allTableFields()>
from <tableName()>
where account_id = :accountId
and is_active = 1
;
>>

getByAccountIdIncludedDelete(accountId) ::= <<
select
<allTableFields()>
from <tableName()>
where account_id = :accountId
;
>>

getByPluginName(pluginName, offset, rowCount) ::= <<
select SQL_CALC_FOUND_ROWS
<allTableFields()>
from <tableName()>
where plugin_name = :pluginName
and is_active = 1
order by record_id
limit :offset, :rowCount
;
>>