Package net.lightapi.portal.db
Class PortalDbProviderImpl
- java.lang.Object
-
- net.lightapi.portal.db.PortalDbProviderImpl
-
- All Implemented Interfaces:
com.networknt.db.provider.DbProvider,PortalDbProvider
public class PortalDbProviderImpl extends Object implements PortalDbProvider
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTH_CODE_CACHEstatic StringGENERIC_EXCEPTIONstatic StringINSERT_NOTIFICATIONstatic StringOBJECT_NOT_FOUNDstatic StringSQL_EXCEPTIONstatic StringUPDATE_NONCE
-
Constructor Summary
Constructors Constructor Description PortalDbProviderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.networknt.monad.Result<String>cancelOrder(OrderCancelledEvent event)com.networknt.monad.Result<String>changePassword(PasswordChangedEvent event)update user_t to change the password by emailcom.networknt.monad.Result<String>confirmUser(UserConfirmedEvent event)check the input token with the saved token in user_t table to ensure match.com.networknt.monad.Result<String>createClient(MarketClientCreatedEvent event)com.networknt.monad.Result<String>createConfig(ConfigCreatedEvent event)com.networknt.monad.Result<String>createHost(HostCreatedEvent event)com.networknt.monad.Result<String>createMarketCode(MarketCodeCreatedEvent event)com.networknt.monad.Result<String>createOrder(OrderCreatedEvent event)com.networknt.monad.Result<String>createService(MarketServiceCreatedEvent event)com.networknt.monad.Result<String>createSocialUser(SocialUserCreatedEvent event)check the email, user_id is unique.com.networknt.monad.Result<String>createUser(UserCreatedEvent event)check the email, user_id, taiji_wallet is unique.com.networknt.monad.Result<String>deleteClient(MarketClientDeletedEvent event)com.networknt.monad.Result<String>deleteConfig(ConfigDeletedEvent event)com.networknt.monad.Result<String>deleteHost(HostDeletedEvent event)com.networknt.monad.Result<String>deleteMarketCode(MarketCodeDeletedEvent event)com.networknt.monad.Result<String>deletePayment(PaymentDeletedEvent event)com.networknt.monad.Result<String>deleteService(MarketServiceDeletedEvent event)com.networknt.monad.Result<String>deleteUser(UserDeletedEvent event)delete user from user_t table and all other tables related to this user.com.networknt.monad.Result<String>deliverOrder(OrderDeliveredEvent event)com.networknt.monad.Result<String>forgetPassword(PasswordForgotEvent event)update user_t for the forget password token by emailvoidinsertNotification(Connection conn, String email, long nonce, String json, boolean flag, String error)insert notification into database within the same transaction as conn is passed in.com.networknt.monad.Result<Map<String,Object>>queryClientByClientId(String clientId)com.networknt.monad.Result<Map<String,Object>>queryClientByHostAppId(String host_id, String applicationId)com.networknt.monad.Result<Map<String,Object>>queryConfig()com.networknt.monad.Result<Map<String,Object>>queryConfigById(String configId)com.networknt.monad.Result<Map<String,Object>>queryCurrentHostKey(String hostId)com.networknt.monad.Result<String>queryEmailByWallet(String wallet)com.networknt.monad.Result<Map<String,Object>>queryHostByHost(String host)com.networknt.monad.Result<Map<String,Object>>queryHostById(String id)com.networknt.monad.Result<Map<String,Object>>queryHostByOwner(String owner)com.networknt.monad.Result<Map<String,Object>>queryLongLiveHostKey(String hostId)com.networknt.monad.Result<String>queryMarketCode(String authCode)com.networknt.monad.Result<Integer>queryNonceByEmail(String email)com.networknt.monad.Result<String>queryUserByEmail(String email)com.networknt.monad.Result<String>queryUserById(String userId)com.networknt.monad.Result<String>queryUserByWallet(String wallet)com.networknt.monad.Result<String>resetPassword(PasswordResetEvent event)update user_t to reset the password by emailcom.networknt.monad.Result<String>sendPrivateMessage(PrivateMessageSentEvent event)send private message to user.com.networknt.monad.Result<String>updateClient(MarketClientUpdatedEvent event)com.networknt.monad.Result<String>updateConfig(ConfigUpdatedEvent event)com.networknt.monad.Result<String>updateHost(HostUpdatedEvent event)intupdateNonce(Connection conn, long nonce, String email)update nonce in user_t to reflect the latest event nonce.com.networknt.monad.Result<String>updatePayment(PaymentUpdatedEvent event)com.networknt.monad.Result<String>updateService(MarketServiceUpdatedEvent event)com.networknt.monad.Result<String>updateUser(UserUpdatedEvent event)update user if it exists in database.com.networknt.monad.Result<String>updateUserRoles(UserRolesUpdatedEvent event)update user roles by email in user_t table
-
-
-
Field Detail
-
AUTH_CODE_CACHE
public static final String AUTH_CODE_CACHE
- See Also:
- Constant Field Values
-
SQL_EXCEPTION
public static final String SQL_EXCEPTION
- See Also:
- Constant Field Values
-
GENERIC_EXCEPTION
public static final String GENERIC_EXCEPTION
- See Also:
- Constant Field Values
-
OBJECT_NOT_FOUND
public static final String OBJECT_NOT_FOUND
- See Also:
- Constant Field Values
-
INSERT_NOTIFICATION
public static final String INSERT_NOTIFICATION
- See Also:
- Constant Field Values
-
UPDATE_NONCE
public static final String UPDATE_NONCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
queryUserByEmail
public com.networknt.monad.Result<String> queryUserByEmail(String email)
- Specified by:
queryUserByEmailin interfacePortalDbProvider
-
queryUserById
public com.networknt.monad.Result<String> queryUserById(String userId)
- Specified by:
queryUserByIdin interfacePortalDbProvider
-
queryUserByWallet
public com.networknt.monad.Result<String> queryUserByWallet(String wallet)
- Specified by:
queryUserByWalletin interfacePortalDbProvider
-
queryEmailByWallet
public com.networknt.monad.Result<String> queryEmailByWallet(String wallet)
- Specified by:
queryEmailByWalletin interfacePortalDbProvider
-
insertNotification
public void insertNotification(Connection conn, String email, long nonce, String json, boolean flag, String error) throws SQLException
insert notification into database within the same transaction as conn is passed in.- Parameters:
conn- The connection to the databaseemail- The email address of the usernonce- The nonce of the notificationjson- The json string of the eventflag- The flag of the notificationerror- The error message of the notification- Throws:
SQLException- when there is an error in the database access
-
updateNonce
public int updateNonce(Connection conn, long nonce, String email) throws SQLException
update nonce in user_t to reflect the latest event nonce.- Parameters:
conn- The connection to the databaseemail- The email address of the usernonce- The nonce of the notification- Returns:
- the number of rows updated
- Throws:
SQLException- when there is an error in the database access
-
createUser
public com.networknt.monad.Result<String> createUser(UserCreatedEvent event)
check the email, user_id, taiji_wallet is unique. if not, write an error notification. If yes, insert the user into database and write a success notification.- Specified by:
createUserin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
queryNonceByEmail
public com.networknt.monad.Result<Integer> queryNonceByEmail(String email)
- Specified by:
queryNonceByEmailin interfacePortalDbProvider
-
confirmUser
public com.networknt.monad.Result<String> confirmUser(UserConfirmedEvent event)
check the input token with the saved token in user_t table to ensure match. If matched, update the verified to true and nonce in the user_t table and a success notification. If not matched, write an error notification.- Specified by:
confirmUserin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
createSocialUser
public com.networknt.monad.Result<String> createSocialUser(SocialUserCreatedEvent event)
check the email, user_id is unique. if not, write an error notification. If yes, insert the user into database and write a success notification.- Specified by:
createSocialUserin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
updateUser
public com.networknt.monad.Result<String> updateUser(UserUpdatedEvent event)
update user if it exists in database.- Specified by:
updateUserin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
deleteUser
public com.networknt.monad.Result<String> deleteUser(UserDeletedEvent event)
delete user from user_t table and all other tables related to this user.- Specified by:
deleteUserin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
updateUserRoles
public com.networknt.monad.Result<String> updateUserRoles(UserRolesUpdatedEvent event)
update user roles by email in user_t table- Specified by:
updateUserRolesin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
forgetPassword
public com.networknt.monad.Result<String> forgetPassword(PasswordForgotEvent event)
update user_t for the forget password token by email- Specified by:
forgetPasswordin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
resetPassword
public com.networknt.monad.Result<String> resetPassword(PasswordResetEvent event)
update user_t to reset the password by email- Specified by:
resetPasswordin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
changePassword
public com.networknt.monad.Result<String> changePassword(PasswordChangedEvent event)
update user_t to change the password by email- Specified by:
changePasswordin interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
updatePayment
public com.networknt.monad.Result<String> updatePayment(PaymentUpdatedEvent event)
- Specified by:
updatePaymentin interfacePortalDbProvider
-
deletePayment
public com.networknt.monad.Result<String> deletePayment(PaymentDeletedEvent event)
- Specified by:
deletePaymentin interfacePortalDbProvider
-
createOrder
public com.networknt.monad.Result<String> createOrder(OrderCreatedEvent event)
- Specified by:
createOrderin interfacePortalDbProvider
-
cancelOrder
public com.networknt.monad.Result<String> cancelOrder(OrderCancelledEvent event)
- Specified by:
cancelOrderin interfacePortalDbProvider
-
deliverOrder
public com.networknt.monad.Result<String> deliverOrder(OrderDeliveredEvent event)
- Specified by:
deliverOrderin interfacePortalDbProvider
-
sendPrivateMessage
public com.networknt.monad.Result<String> sendPrivateMessage(PrivateMessageSentEvent event)
send private message to user. Update the nonce of the from user and insert a message to message_t table. Send a notification to the from user about the event processing result.- Specified by:
sendPrivateMessagein interfacePortalDbProvider- Parameters:
event- event that is created by user service- Returns:
- result of email
-
createClient
public com.networknt.monad.Result<String> createClient(MarketClientCreatedEvent event)
- Specified by:
createClientin interfacePortalDbProvider
-
updateClient
public com.networknt.monad.Result<String> updateClient(MarketClientUpdatedEvent event)
- Specified by:
updateClientin interfacePortalDbProvider
-
deleteClient
public com.networknt.monad.Result<String> deleteClient(MarketClientDeletedEvent event)
- Specified by:
deleteClientin interfacePortalDbProvider
-
queryClientByClientId
public com.networknt.monad.Result<Map<String,Object>> queryClientByClientId(String clientId)
- Specified by:
queryClientByClientIdin interfacePortalDbProvider
-
queryClientByHostAppId
public com.networknt.monad.Result<Map<String,Object>> queryClientByHostAppId(String host_id, String applicationId)
- Specified by:
queryClientByHostAppIdin interfacePortalDbProvider
-
createService
public com.networknt.monad.Result<String> createService(MarketServiceCreatedEvent event)
- Specified by:
createServicein interfacePortalDbProvider
-
updateService
public com.networknt.monad.Result<String> updateService(MarketServiceUpdatedEvent event)
- Specified by:
updateServicein interfacePortalDbProvider
-
deleteService
public com.networknt.monad.Result<String> deleteService(MarketServiceDeletedEvent event)
- Specified by:
deleteServicein interfacePortalDbProvider
-
createMarketCode
public com.networknt.monad.Result<String> createMarketCode(MarketCodeCreatedEvent event)
- Specified by:
createMarketCodein interfacePortalDbProvider
-
deleteMarketCode
public com.networknt.monad.Result<String> deleteMarketCode(MarketCodeDeletedEvent event)
- Specified by:
deleteMarketCodein interfacePortalDbProvider
-
queryMarketCode
public com.networknt.monad.Result<String> queryMarketCode(String authCode)
- Specified by:
queryMarketCodein interfacePortalDbProvider
-
createHost
public com.networknt.monad.Result<String> createHost(HostCreatedEvent event)
- Specified by:
createHostin interfacePortalDbProvider
-
updateHost
public com.networknt.monad.Result<String> updateHost(HostUpdatedEvent event)
- Specified by:
updateHostin interfacePortalDbProvider
-
deleteHost
public com.networknt.monad.Result<String> deleteHost(HostDeletedEvent event)
- Specified by:
deleteHostin interfacePortalDbProvider
-
queryHostByHost
public com.networknt.monad.Result<Map<String,Object>> queryHostByHost(String host)
- Specified by:
queryHostByHostin interfacePortalDbProvider
-
queryHostById
public com.networknt.monad.Result<Map<String,Object>> queryHostById(String id)
- Specified by:
queryHostByIdin interfacePortalDbProvider
-
queryHostByOwner
public com.networknt.monad.Result<Map<String,Object>> queryHostByOwner(String owner)
- Specified by:
queryHostByOwnerin interfacePortalDbProvider
-
createConfig
public com.networknt.monad.Result<String> createConfig(ConfigCreatedEvent event)
- Specified by:
createConfigin interfacePortalDbProvider
-
updateConfig
public com.networknt.monad.Result<String> updateConfig(ConfigUpdatedEvent event)
- Specified by:
updateConfigin interfacePortalDbProvider
-
deleteConfig
public com.networknt.monad.Result<String> deleteConfig(ConfigDeletedEvent event)
- Specified by:
deleteConfigin interfacePortalDbProvider
-
queryConfig
public com.networknt.monad.Result<Map<String,Object>> queryConfig()
- Specified by:
queryConfigin interfacePortalDbProvider
-
queryConfigById
public com.networknt.monad.Result<Map<String,Object>> queryConfigById(String configId)
- Specified by:
queryConfigByIdin interfacePortalDbProvider
-
queryCurrentHostKey
public com.networknt.monad.Result<Map<String,Object>> queryCurrentHostKey(String hostId)
- Specified by:
queryCurrentHostKeyin interfacePortalDbProvider
-
queryLongLiveHostKey
public com.networknt.monad.Result<Map<String,Object>> queryLongLiveHostKey(String hostId)
- Specified by:
queryLongLiveHostKeyin interfacePortalDbProvider
-
-