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
87dbd1f2
Commit
87dbd1f2
authored
May 03, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added methods for Accounts and Domains
parent
1828c372
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
338 additions
and
270 deletions
+338
-270
AccountController.java
...n/java/com/nisum/myteam/controller/AccountController.java
+46
-25
DomainController.java
...in/java/com/nisum/myteam/controller/DomainController.java
+13
-8
Account.java
src/main/java/com/nisum/myteam/model/Account.java
+4
-3
Domain.java
src/main/java/com/nisum/myteam/model/Domain.java
+4
-1
AccountRepo.java
src/main/java/com/nisum/myteam/repository/AccountRepo.java
+1
-1
IAccountService.java
src/main/java/com/nisum/myteam/service/IAccountService.java
+7
-0
AccountService.java
...in/java/com/nisum/myteam/service/impl/AccountService.java
+248
-230
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+15
-2
No files found.
src/main/java/com/nisum/myteam/controller/AccountController.java
View file @
87dbd1f2
package
com
.
nisum
.
myteam
.
controller
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.Account
;
import
com.nisum.myteam.service.IAccountService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Slf4j
@RestController
...
...
@@ -47,7 +37,7 @@ public class AccountController {
Account
accountPersisted
=
accountService
.
createAccount
(
account
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Account has been created"
,
"
status
description"
,
null
,
request
.
getContextPath
(),
"details"
,
accountPersisted
);
"
Account
description"
,
null
,
request
.
getContextPath
(),
"details"
,
accountPersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
...
...
@@ -133,5 +123,36 @@ public class AccountController {
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
accountsList
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/accounts/accountId/{accId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccountName
(
@PathVariable
(
"accId"
)
String
accountId
,
HttpServletRequest
request
)
throws
MyTeamException
{
log
.
info
(
"Serving the Account Name Get action: accountId:"
+
accountId
);
if
(
accountId
!=
null
&&
!
""
.
equalsIgnoreCase
(
accountId
))
{
boolean
isAccountExists
=
accountService
.
isAccountExists
(
accountId
);
log
.
info
(
"is Account exists with the name "
+
isAccountExists
);
if
(
isAccountExists
)
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the account Name successfully"
,
"Account Name"
,
accountService
.
getAccountById
(
accountId
),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Account Does Not Exists"
,
"Account Name"
,
null
,
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Please provide Valid account Id"
,
"Account Name"
,
null
,
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/controller/DomainController.java
View file @
87dbd1f2
...
...
@@ -64,14 +64,6 @@ public class DomainController {
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getDomains
(
HttpServletRequest
request
)
throws
MyTeamException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Retrieved the domains successfully"
,
"Domains list"
,
domainService
.
getDomainsList
(),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
...
...
@@ -104,6 +96,16 @@ public class DomainController {
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getDomains
(
HttpServletRequest
request
)
throws
MyTeamException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Retrieved the domains successfully"
,
"Domains list"
,
domainService
.
getDomainsList
(),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
//getting domains list under accountId which is an active.
@RequestMapping
(
value
=
"/domains/{accountId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domain
>>
getDomains
(
@PathVariable
(
"accountId"
)
String
accountId
)
throws
MyTeamException
{
...
...
@@ -112,4 +114,7 @@ public class DomainController {
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/model/Account.java
View file @
87dbd1f2
...
...
@@ -17,6 +17,7 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.bson.types.ObjectId
;
@Setter
@Getter
...
...
@@ -28,10 +29,10 @@ public class Account implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
// private ObjectId id;
@Id
private
ObjectId
id
;
@NotNull
private
String
accountId
;
@NotNull
@Size
(
min
=
2
,
max
=
50
,
message
=
"Name should have atlast 2 and less than 50 characters"
)
...
...
src/main/java/com/nisum/myteam/model/Domain.java
View file @
87dbd1f2
...
...
@@ -15,6 +15,7 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.ToString
;
import
org.bson.types.ObjectId
;
@Setter
@Getter
...
...
@@ -26,7 +27,9 @@ public class Domain implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
// private ObjectId id;
//private ObjectId id;
@Id
private
String
domainId
;
@NotNull
...
...
src/main/java/com/nisum/myteam/repository/AccountRepo.java
View file @
87dbd1f2
...
...
@@ -15,4 +15,4 @@ public interface AccountRepo extends MongoRepository<Account, String> {
List
<
Account
>
findByaccountNameAndAccountId
(
String
accountName
,
String
accountId
);
Account
findByAccountNameIgnoreCase
(
String
accountName
);
}
\ No newline at end of file
}
src/main/java/com/nisum/myteam/service/IAccountService.java
View file @
87dbd1f2
...
...
@@ -16,6 +16,10 @@ public interface IAccountService {
Account
updateAccount
(
Account
account
)
throws
MyTeamException
;
boolean
isAccountExists
(
Account
account
);
boolean
isAccountExists
(
String
accountId
);
public
Account
getAccountById
(
String
accountId
);
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
...
...
@@ -25,4 +29,7 @@ public interface IAccountService {
public
List
<
Account
>
getAccountsAll
()
throws
MyTeamException
;
}
src/main/java/com/nisum/myteam/service/impl/AccountService.java
View file @
87dbd1f2
This diff is collapsed.
Click to expand it.
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
87dbd1f2
...
...
@@ -39,6 +39,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public
class
EmployeeService
implements
IEmployeeService
{
@Autowired
private
EmployeeRepo
employeeRepo
;
...
...
@@ -196,7 +198,11 @@ public class EmployeeService implements IEmployeeService {
@Override
public
Employee
getEmployeeById
(
String
employeeId
)
{
return
employeeRepo
.
findByEmployeeId
(
employeeId
);
log
.
info
(
"The employeeId::"
+
employeeId
);
Employee
employee
=
employeeRepo
.
findByEmployeeId
(
employeeId
);
log
.
info
(
"Employee Found in Repo::"
+
employee
);
return
employee
;
}
@Override
...
...
@@ -296,7 +302,14 @@ public class EmployeeService implements IEmployeeService {
@Override
public
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
)
{
boolean
flag
=
false
;
String
role
=
getEmployeeById
(
empId
).
getRole
();
log
.
info
(
"The employeeId::"
+
empId
);
Employee
employee
=
getEmployeeById
(
empId
);
log
.
info
(
"Employee::::in EmployeeService::"
+
employee
);
String
role
=
employee
.
getRole
();
log
.
info
(
"The employee role::"
+
role
);
if
(
null
!=
role
&&
""
!=
role
&&
!
"Admin"
.
equalsIgnoreCase
(
role
))
{
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
...
...
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