Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
8e6dc07b
Commit
8e6dc07b
authored
Jun 21, 2019
by
vikram singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added security in account,project,domain page
parent
547d800d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
7 deletions
+97
-7
AccountController.java
...n/java/com/nisum/myteam/controller/AccountController.java
+15
-3
DomainController.java
...in/java/com/nisum/myteam/controller/DomainController.java
+12
-3
IAccountService.java
src/main/java/com/nisum/myteam/service/IAccountService.java
+2
-0
IDomainService.java
src/main/java/com/nisum/myteam/service/IDomainService.java
+2
-0
AccountService.java
...in/java/com/nisum/myteam/service/impl/AccountService.java
+27
-0
DomainService.java
...ain/java/com/nisum/myteam/service/impl/DomainService.java
+26
-0
ProjectService.java
...in/java/com/nisum/myteam/service/impl/ProjectService.java
+13
-1
No files found.
src/main/java/com/nisum/myteam/controller/AccountController.java
View file @
8e6dc07b
...
@@ -81,9 +81,21 @@ public class AccountController {
...
@@ -81,9 +81,21 @@ public class AccountController {
}
}
@RequestMapping
(
value
=
"/accounts"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
// @RequestMapping(value = "/accounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public
ResponseEntity
<?>
getAccounts
(
HttpServletRequest
request
)
throws
MyTeamException
{
// public ResponseEntity<?> getAccounts(HttpServletRequest request) throws MyTeamException {
List
<
Map
<
Object
,
Object
>>
accountsList
=
accountService
.
getAccountsList
();
// List<Map<Object, Object>> accountsList = accountService.getAccountsList();
// log.info("The accounts list::" + accountsList);
//
// ResponseDetails getRespDetails = new ResponseDetails(new Date(), AccountStatus.GET_ACCOUNTS.getCode(), AccountStatus.GET_ACCOUNTS.getMessage(),
// "Accounts list", accountsList, request.getRequestURI(), "details", null);
//
// return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
//
// }
@RequestMapping
(
value
=
"/accountsByLoginId"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccounts
(
@RequestParam
(
"loginId"
)
String
loginId
,
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Map
<
Object
,
Object
>>
accountsList
=
accountService
.
getAccountsListByLoginId
(
loginId
);
log
.
info
(
"The accounts list::"
+
accountsList
);
log
.
info
(
"The accounts list::"
+
accountsList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
GET_ACCOUNTS
.
getCode
(),
AccountStatus
.
GET_ACCOUNTS
.
getMessage
(),
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
AccountStatus
.
GET_ACCOUNTS
.
getCode
(),
AccountStatus
.
GET_ACCOUNTS
.
getMessage
(),
...
...
src/main/java/com/nisum/myteam/controller/DomainController.java
View file @
8e6dc07b
...
@@ -81,11 +81,20 @@ public class DomainController {
...
@@ -81,11 +81,20 @@ public class DomainController {
}
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
// @RequestMapping(value = "/domains", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public
ResponseEntity
<?>
getDomains
(
HttpServletRequest
request
)
throws
MyTeamException
{
// public ResponseEntity<?> getDomains(HttpServletRequest request) throws MyTeamException {
//
// ResponseDetails getRespDetails = new ResponseDetails(new Date(), DomainStatus.GET_DOMIAINS.getCode(), DomainStatus.GET_DOMIAINS.getMessage(),
// "Domains list", domainService.getDomainsList(), request.getRequestURI(), "details", null);
//
// return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
// }
@RequestMapping
(
value
=
"/domainsByLoginId"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getDomains
(
@RequestParam
(
"loginId"
)
String
loginId
,
HttpServletRequest
request
)
throws
MyTeamException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
DomainStatus
.
GET_DOMIAINS
.
getCode
(),
DomainStatus
.
GET_DOMIAINS
.
getMessage
(),
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
DomainStatus
.
GET_DOMIAINS
.
getCode
(),
DomainStatus
.
GET_DOMIAINS
.
getMessage
(),
"Domains list"
,
domainService
.
getDomainsList
(
),
request
.
getRequestURI
(),
"details"
,
null
);
"Domains list"
,
domainService
.
getDomainsList
ByLoginId
(
loginId
),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/nisum/myteam/service/IAccountService.java
View file @
8e6dc07b
...
@@ -31,4 +31,6 @@ public interface IAccountService {
...
@@ -31,4 +31,6 @@ public interface IAccountService {
public
Account
getAccountByName
(
String
name
);
public
Account
getAccountByName
(
String
name
);
List
<
Map
<
Object
,
Object
>>
getAccountsListByLoginId
(
String
loginId
);
}
}
src/main/java/com/nisum/myteam/service/IDomainService.java
View file @
8e6dc07b
...
@@ -35,5 +35,7 @@ public interface IDomainService {
...
@@ -35,5 +35,7 @@ public interface IDomainService {
Domain
getDomainById
(
String
domainId
);
Domain
getDomainById
(
String
domainId
);
List
<
DomainVO
>
getDomainsListByLoginId
(
String
loginId
);
}
}
src/main/java/com/nisum/myteam/service/impl/AccountService.java
View file @
8e6dc07b
...
@@ -6,9 +6,12 @@ import com.nisum.myteam.model.dao.Employee;
...
@@ -6,9 +6,12 @@ import com.nisum.myteam.model.dao.Employee;
import
com.nisum.myteam.repository.AccountRepo
;
import
com.nisum.myteam.repository.AccountRepo
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IRoleService
;
import
com.nisum.myteam.service.IRoleService
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
...
@@ -32,6 +35,9 @@ public class AccountService implements IAccountService {
...
@@ -32,6 +35,9 @@ public class AccountService implements IAccountService {
@Autowired
@Autowired
private
IRoleService
roleService
;
private
IRoleService
roleService
;
@Autowired
private
IEmployeeService
employeeService
;
@Autowired
@Autowired
private
IEmployeeRoleService
empRoleService
;
private
IEmployeeRoleService
empRoleService
;
...
@@ -272,6 +278,27 @@ public class AccountService implements IAccountService {
...
@@ -272,6 +278,27 @@ public class AccountService implements IAccountService {
}
}
}
}
@Override
public
List
<
Map
<
Object
,
Object
>>
getAccountsListByLoginId
(
String
loginId
)
{
boolean
isAdmin
=
employeeService
.
getEmployeeById
(
loginId
).
getRole
().
equals
(
ApplicationRole
.
ADMIN
.
getRoleName
());
// List<Account> accounts
List
<
Map
<
Object
,
Object
>>
updatedAccountList
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
updatedEmployeeList
=
null
;
for
(
Account
account
:
accountRepo
.
findAll
())
{
updatedEmployeeList
=
new
ArrayList
<>();
for
(
Employee
employee
:
getEmployeeDetails
(
account
))
{
updatedEmployeeList
.
add
(
getEmployeeDetails
(
employee
));
}
if
(
updatedEmployeeList
.
stream
().
map
(
e
->
e
.
get
(
MyTeamUtils
.
EMPLOYEE_ID
)).
anyMatch
(
empId
->
empId
.
equals
(
loginId
))||
isAdmin
)
updatedAccountList
.
add
(
getAccuntDetails
(
account
,
updatedEmployeeList
));
}
return
updatedAccountList
;
}
...
...
src/main/java/com/nisum/myteam/service/impl/DomainService.java
View file @
8e6dc07b
...
@@ -9,9 +9,12 @@ import com.nisum.myteam.repository.DomainRepo;
...
@@ -9,9 +9,12 @@ import com.nisum.myteam.repository.DomainRepo;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IRoleService
;
import
com.nisum.myteam.service.IRoleService
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
@@ -39,6 +42,8 @@ public class DomainService implements IDomainService {
...
@@ -39,6 +42,8 @@ public class DomainService implements IDomainService {
@Autowired
@Autowired
private
IRoleService
roleService
;
private
IRoleService
roleService
;
@Autowired
private
IEmployeeService
employeeService
;
@Autowired
@Autowired
private
IEmployeeRoleService
empRoleService
;
private
IEmployeeRoleService
empRoleService
;
...
@@ -259,6 +264,27 @@ public class DomainService implements IDomainService {
...
@@ -259,6 +264,27 @@ public class DomainService implements IDomainService {
}
}
return
accIdsSet
;
return
accIdsSet
;
}
}
@Override
public
List
<
DomainVO
>
getDomainsListByLoginId
(
String
loginId
)
{
List
<
DomainVO
>
domainVOS
=
new
ArrayList
<>();
boolean
isAdmin
=
employeeService
.
getEmployeeById
(
loginId
).
getRole
().
equals
(
ApplicationRole
.
ADMIN
.
getRoleName
());
domainRepo
.
findAll
().
stream
().
filter
(
e
->
e
.
getDeliveryManagers
().
stream
().
anyMatch
(
empId
->
empId
.
equals
(
loginId
))||
isAdmin
).
forEach
(
domainPersisted
->
{
DomainVO
domainVO
=
new
DomainVO
();
domainVO
.
setId
(
domainPersisted
.
getId
().
toString
());
domainVO
.
setAccountId
(
domainPersisted
.
getAccountId
());
domainVO
.
setAccountName
(
accountService
.
getAccountById
(
domainPersisted
.
getAccountId
()).
getAccountName
());
domainVO
.
setDomainId
(
domainPersisted
.
getDomainId
());
domainVO
.
setDomainName
(
domainPersisted
.
getDomainName
());
domainVO
.
setStatus
(
domainPersisted
.
getStatus
());
domainVO
.
setDeliveryManagers
(
prepareEmployeeList
(
domainPersisted
));
domainVOS
.
add
(
domainVO
);
});
return
domainVOS
;
}
...
...
src/main/java/com/nisum/myteam/service/impl/ProjectService.java
View file @
8e6dc07b
...
@@ -339,10 +339,22 @@ public class ProjectService implements IProjectService {
...
@@ -339,10 +339,22 @@ public class ProjectService implements IProjectService {
List
<
Project
>
projectList
=
projectRepo
.
findByAccountIdIn
(
accountIdSet
);
List
<
Project
>
projectList
=
projectRepo
.
findByAccountIdIn
(
accountIdSet
);
for
(
Project
proj
:
projectList
)
{
for
(
Project
proj
:
projectList
)
{
addToProjectList
(
projectsList
,
proj
);
if
(
proj
.
getDeliveryLeadIds
().
stream
().
anyMatch
(
e
->
e
.
equals
(
empId
)))
addToProjectList
(
projectsList
,
proj
);
}
}
return
projectsList
;
return
projectsList
;
}
}
// @Override
// public List<HashMap<Object, Object>> getRoleBasedProjects(String empId) throws MyTeamException {
// List<HashMap<Object, Object>> projectsList = new ArrayList<HashMap<Object, Object>>();
// Set<String> accountIdSet = domainService.accountsAssignedToDeliveryLead(empId);
// List<Project> projectList = projectRepo.findByAccountIdIn(accountIdSet);
//
// for (Project proj : projectList) {
// addToProjectList(projectsList, proj);
// }
// return projectsList;
// }
@Override
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
{
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment