Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-smf-user
Commits
82c90817
Commit
82c90817
authored
3 years ago
by
nivetha
Browse files
Options
Download
Patches
Plain Diff
getAllUser API
parent
b68189e5
master
bulkupload
delete-user
delete-user-fix
increase_timeout
institute-district
maney-test
sessionTimeout
updateEmailContentforOTP
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/tarento/retail/model/mapper/SqlDataMapper.java
+62
-58
...n/java/com/tarento/retail/model/mapper/SqlDataMapper.java
with
62 additions
and
58 deletions
+62
-58
src/main/java/com/tarento/retail/model/mapper/SqlDataMapper.java
+
62
−
58
View file @
82c90817
...
...
@@ -25,7 +25,7 @@ import com.tarento.retail.model.UserDeviceToken;
import
com.tarento.retail.model.UserProfile
;
public
class
SqlDataMapper
{
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SqlDataMapper
.
class
);
public
class
UserMapper
implements
RowMapper
<
User
>
{
...
...
@@ -56,7 +56,7 @@ public class SqlDataMapper {
return
user
;
}
}
public
class
SimpleUserMapper
implements
RowMapper
<
User
>
{
public
User
mapRow
(
ResultSet
rs
,
int
rowNum
)
throws
SQLException
{
User
user
=
new
User
();
...
...
@@ -119,6 +119,29 @@ public class SqlDataMapper {
public
Map
<
Long
,
List
<
Role
>>
userRoleMap
=
new
HashMap
<>();
public
UserProfile
mapRow
(
ResultSet
rs
,
int
rowNum
)
throws
SQLException
{
if
(
userRoleMap
.
containsKey
(
rs
.
getLong
(
"id"
)))
{
List
<
Role
>
roleList
=
userRoleMap
.
get
(
rs
.
getLong
(
"id"
));
Role
role
=
new
Role
();
role
.
setId
(
rs
.
getLong
(
"role_id"
));
role
.
setName
(
rs
.
getString
(
"role_name"
));
role
.
setDescription
(
rs
.
getString
(
"description"
));
if
(
StringUtils
.
isNotBlank
(
rs
.
getString
(
"role_name"
)))
{
roleList
.
add
(
role
);
}
}
else
{
List
<
Role
>
roleList
=
new
ArrayList
<>();
Role
role
=
new
Role
();
role
.
setId
(
rs
.
getLong
(
"role_id"
));
role
.
setName
(
rs
.
getString
(
"role_name"
));
role
.
setDescription
(
rs
.
getString
(
"description"
));
if
(
StringUtils
.
isNotBlank
(
rs
.
getString
(
"role_name"
)))
{
roleList
.
add
(
role
);
}
userRoleMap
.
put
(
rs
.
getLong
(
"id"
),
roleList
);
}
if
(!
userMap
.
containsKey
(
rs
.
getLong
(
"id"
)))
{
UserProfile
user
=
new
UserProfile
();
user
.
setId
(
rs
.
getLong
(
"id"
));
...
...
@@ -144,94 +167,75 @@ public class SqlDataMapper {
user
.
setEmploymentType
(
rs
.
getString
(
"employment_type"
));
user
.
setTimeZone
(
rs
.
getString
(
"timezone"
));
userMap
.
put
(
rs
.
getLong
(
"id"
),
user
);
}
if
(
userRoleMap
.
containsKey
(
rs
.
getLong
(
"id"
)))
{
List
<
Role
>
roleList
=
userRoleMap
.
get
(
rs
.
getLong
(
"id"
));
Role
role
=
new
Role
();
role
.
setId
(
rs
.
getLong
(
"role_id"
));
role
.
setName
(
rs
.
getString
(
"role_name"
));
role
.
setDescription
(
rs
.
getString
(
"description"
));
if
(
StringUtils
.
isNotBlank
(
rs
.
getString
(
"role_name"
)))
{
roleList
.
add
(
role
);
}
userMap
.
get
(
rs
.
getLong
(
"id"
)).
setRoles
(
userRoleMap
.
get
(
rs
.
getLong
(
"id"
)));
}
else
{
List
<
Role
>
roleList
=
new
ArrayList
<>();
Role
role
=
new
Role
();
role
.
setId
(
rs
.
getLong
(
"role_id"
));
role
.
setName
(
rs
.
getString
(
"role_name"
));
role
.
setDescription
(
rs
.
getString
(
"description"
));
if
(
StringUtils
.
isNotBlank
(
rs
.
getString
(
"role_name"
)))
{
roleList
.
add
(
role
);
}
userRoleMap
.
put
(
rs
.
getLong
(
"id"
),
roleList
);
userMap
.
get
(
rs
.
getLong
(
"id"
)).
setRoles
(
userRoleMap
.
get
(
rs
.
getLong
(
"id"
)));
}
return
null
;
}
}
public
class
UserRoleActionMapper
implements
RowMapper
<
UserProfile
>
{
public
Map
<
Long
,
UserDto
>
userMap
=
new
HashMap
<>();
public
Map
<
Long
,
Map
<
Long
,
Role
>>
userRoleMap
=
new
HashMap
<>();
public
Map
<
Long
,
Map
<
Long
,
Action
>>
roleActionMap
=
new
HashMap
<>();
public
UserProfile
mapRow
(
ResultSet
rs
,
int
rowNum
)
throws
SQLException
{
if
(!
userMap
.
containsKey
(
rs
.
getLong
(
"userId"
)))
{
userMap
.
put
(
rs
.
getLong
(
"userId"
),
createUser
(
rs
));
if
(!
userMap
.
containsKey
(
rs
.
getLong
(
"userId"
)))
{
userMap
.
put
(
rs
.
getLong
(
"userId"
),
createUser
(
rs
));
Map
<
Long
,
Role
>
roleMap
=
new
HashMap
<>();
roleMap
.
put
(
rs
.
getLong
(
"roleId"
),
createRole
(
rs
));
userRoleMap
.
put
(
rs
.
getLong
(
"userId"
),
roleMap
);
roleMap
.
put
(
rs
.
getLong
(
"roleId"
),
createRole
(
rs
));
userRoleMap
.
put
(
rs
.
getLong
(
"userId"
),
roleMap
);
Map
<
Long
,
Action
>
actionMap
=
new
HashMap
<>();
actionMap
.
put
(
rs
.
getLong
(
"actionId"
),
createAction
(
rs
));
roleActionMap
.
put
(
rs
.
getLong
(
"roleId"
),
actionMap
);
}
else
{
roleActionMap
.
put
(
rs
.
getLong
(
"roleId"
),
actionMap
);
}
else
{
Map
<
Long
,
Role
>
roleMap
=
userRoleMap
.
get
(
rs
.
getLong
(
"userId"
));
if
(!
roleMap
.
containsKey
(
rs
.
getLong
(
"roleId"
)))
{
if
(!
roleMap
.
containsKey
(
rs
.
getLong
(
"roleId"
)))
{
roleMap
.
put
(
rs
.
getLong
(
"roleId"
),
createRole
(
rs
));
Map
<
Long
,
Action
>
actionMap
=
new
HashMap
<>();
actionMap
.
put
(
rs
.
getLong
(
"actionId"
),
createAction
(
rs
));
roleActionMap
.
put
(
rs
.
getLong
(
"roleId"
),
actionMap
);
}
else
{
roleActionMap
.
put
(
rs
.
getLong
(
"roleId"
),
actionMap
);
}
else
{
Map
<
Long
,
Action
>
actionMap
=
roleActionMap
.
get
(
rs
.
getLong
(
"roleId"
));
actionMap
.
put
(
rs
.
getLong
(
"actionId"
),
createAction
(
rs
));
}
}
return
null
;
return
null
;
}
private
Action
createAction
(
ResultSet
rs
)
{
Action
action
=
new
Action
();
try
{
private
Action
createAction
(
ResultSet
rs
)
{
Action
action
=
new
Action
();
try
{
action
.
setId
(
rs
.
getLong
(
"actionId"
));
action
.
setName
(
rs
.
getString
(
"actionName"
));
action
.
setUrl
(
rs
.
getString
(
"actionUrl"
));
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"Encountered an Exception while creating Action : "
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"Encountered an Exception while creating Action : "
+
e
.
getMessage
());
}
return
action
;
return
action
;
}
private
UserDto
createUser
(
ResultSet
rs
)
{
UserDto
userDto
=
new
UserDto
();
try
{
private
UserDto
createUser
(
ResultSet
rs
)
{
UserDto
userDto
=
new
UserDto
();
try
{
userDto
.
setId
(
rs
.
getLong
(
"userId"
));
userDto
.
setUserName
(
rs
.
getString
(
"username"
));
userDto
.
setEmailId
(
rs
.
getString
(
"userEmailId"
));
userDto
.
setOrgId
(
String
.
valueOf
(
rs
.
getLong
(
"userOrgId"
)));
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"Encountered an Exception while creating User : "
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"Encountered an Exception while creating User : "
+
e
.
getMessage
());
}
return
userDto
;
return
userDto
;
}
private
Role
createRole
(
ResultSet
rs
)
{
Role
role
=
new
Role
();
try
{
private
Role
createRole
(
ResultSet
rs
)
{
Role
role
=
new
Role
();
try
{
role
.
setId
(
rs
.
getLong
(
"roleId"
));
role
.
setName
(
rs
.
getString
(
"roleName"
));
role
.
setCode
(
rs
.
getString
(
"roleCode"
));
...
...
@@ -239,10 +243,10 @@ public class SqlDataMapper {
role
.
setAdmin
(
rs
.
getBoolean
(
"isOrgAdmin"
));
role
.
setSuperAdmin
(
rs
.
getBoolean
(
"isSuperAdmin"
));
role
.
setOrgId
(
rs
.
getLong
(
"roleOrgId"
));
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"Encountered an Exception while creating Role : "
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"Encountered an Exception while creating Role : "
+
e
.
getMessage
());
}
return
role
;
return
role
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets