refactor/added new method getNotPersonalUserAttributes and add isPersonal to getPersonalUserAttributes method

This commit is contained in:
hongwei 2023-05-25 21:16:59 +08:00
parent 2128e4ccd4
commit 046d756412
7 changed files with 29 additions and 13 deletions

View File

@ -1896,8 +1896,8 @@ object NewStyle extends MdcLoggable{
}
}
def getMyPersonalUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[List[UserAttribute]] = {
Connector.connector.vend.getMyPersonalUserAttributes(
def getPersonalUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[List[UserAttribute]] = {
Connector.connector.vend.getPersonalUserAttributes(
userId: String, callContext: Option[CallContext]
) map {
i => (connectorEmptyResponse(i._1, callContext), i._2)

View File

@ -8765,7 +8765,7 @@ trait APIMethods400 {
case "my" :: "user" :: "attributes" :: Nil JsonGet _ => {
cc =>
for {
(attributes, callContext) <- NewStyle.function.getMyPersonalUserAttributes(cc.userId, cc.callContext)
(attributes, callContext) <- NewStyle.function.getPersonalUserAttributes(cc.userId, cc.callContext)
} yield {
(JSONFactory400.createUserAttributesJson(attributes), HttpCode.`200`(callContext))
}
@ -8887,7 +8887,7 @@ trait APIMethods400 {
case "my" :: "user" :: "attributes" :: userAttributeId :: Nil JsonPut json -> _=> {
cc =>
for {
(attributes, callContext) <- NewStyle.function.getMyPersonalUserAttributes(cc.userId, cc.callContext)
(attributes, callContext) <- NewStyle.function.getPersonalUserAttributes(cc.userId, cc.callContext)
failMsg = s"$UserAttributeNotFound"
_ <- NewStyle.function.tryons(failMsg, 400, callContext) {
attributes.exists(_.userAttributeId == userAttributeId)

View File

@ -2260,7 +2260,7 @@ trait Connector extends MdcLoggable {
def getUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] =
Future{(Failure(setUnimplementedError), callContext)}
def getMyPersonalUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] =
def getPersonalUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] =
Future{(Failure(setUnimplementedError), callContext)}
def getUserAttributesByUsers(userIds: List[String], callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] =

View File

@ -219,6 +219,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
val userAttributeName = s"TRANSACTION_REQUESTS_PAYMENT_LIMIT_${currency}_" + transactionRequestType.toUpperCase
val userAttributes = UserAttribute.findAll(
By(UserAttribute.UserId, userId),
By(UserAttribute.IsPersonal, false),
OrderBy(UserAttribute.createdAt, Descending)
)
val userAttributeValue = userAttributes.find(_.name == userAttributeName).map(_.value)
@ -4078,8 +4079,8 @@ object LocalMappedConnector extends Connector with MdcLoggable {
UserAttributeProvider.userAttributeProvider.vend.getUserAttributesByUser(userId: String) map {(_, callContext)}
}
override def getMyPersonalUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] = {
UserAttributeProvider.userAttributeProvider.vend.getMyPersonalUserAttributes(userId: String) map {(_, callContext)}
override def getPersonalUserAttributes(userId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] = {
UserAttributeProvider.userAttributeProvider.vend.getPersonalUserAttributes(userId: String) map {(_, callContext)}
}
override def getUserAttributesByUsers(userIds: List[String], callContext: Option[CallContext]): OBPReturnType[Box[List[UserAttribute]]] = {
UserAttributeProvider.userAttributeProvider.vend.getUserAttributesByUsers(userIds) map {(_, callContext)}

View File

@ -19,8 +19,11 @@ object RemotedataUserAttribute extends ObpActorInit with UserAttributeProvider {
override def getUserAttributesByUser(userId: String): Future[Box[List[UserAttribute]]] =
(actor ? cc.getUserAttributesByUser(userId)).mapTo[Box[List[UserAttribute]]]
override def getMyPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]] =
(actor ? cc.getMyPersonalUserAttributes(userId)).mapTo[Box[List[UserAttribute]]]
override def getPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]] =
(actor ? cc.getPersonalUserAttributes(userId)).mapTo[Box[List[UserAttribute]]]
override def getNotPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]] =
(actor ? cc.getNotPersonalUserAttributes(userId)).mapTo[Box[List[UserAttribute]]]
override def getUserAttributesByUsers(userIds: List[String]): Future[Box[List[UserAttribute]]] =
(actor ? cc.getUserAttributesByUsers(userIds)).mapTo[Box[List[UserAttribute]]]

View File

@ -20,11 +20,21 @@ object MappedUserAttributeProvider extends UserAttributeProvider {
UserAttribute.findAll(By(UserAttribute.UserId, userId))
)
}
override def getMyPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]] = Future {
override def getPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]] = Future {
tryo(
UserAttribute.findAll(
By(UserAttribute.UserId, userId),
By(UserAttribute.IsPersonal, true)
By(UserAttribute.IsPersonal, true),
OrderBy(UserAttribute.createdAt, Descending)
)
)
}
override def getNotPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]] = Future {
tryo(
UserAttribute.findAll(
By(UserAttribute.UserId, userId),
By(UserAttribute.IsPersonal, false),
OrderBy(UserAttribute.createdAt, Descending)
)
)
}

View File

@ -38,7 +38,8 @@ trait UserAttributeProvider {
private val logger = Logger(classOf[UserAttributeProvider])
def getUserAttributesByUser(userId: String): Future[Box[List[UserAttribute]]]
def getMyPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]]
def getPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]]
def getNotPersonalUserAttributes(userId: String): Future[Box[List[UserAttribute]]]
def getUserAttributesByUsers(userIds: List[String]): Future[Box[List[UserAttribute]]]
def deleteUserAttribute(userAttributeId: String): Future[Box[Boolean]]
def createOrUpdateUserAttribute(userId: String,
@ -52,7 +53,8 @@ trait UserAttributeProvider {
class RemotedataUserAttributeCaseClasses {
case class getUserAttributesByUser(userId: String)
case class getMyPersonalUserAttributes(userId: String)
case class getPersonalUserAttributes(userId: String)
case class getNotPersonalUserAttributes(userId: String)
case class deleteUserAttribute(userAttributeId: String)
case class getUserAttributesByUsers(userIds: List[String])
case class createOrUpdateUserAttribute(userId: String,