Commit b6f5ec3d authored by Prayas Jain's avatar Prayas Jain

Url Refactored in Accounts and Assign Role Controller

parent 62eb6ba1
...@@ -40,10 +40,10 @@ public class EmployeeController { ...@@ -40,10 +40,10 @@ public class EmployeeController {
private IEmployeeRoleService employeeRoleService; private IEmployeeRoleService employeeRoleService;
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employees/{empId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createEmployee(@Valid @RequestBody Employee employeeReq, public ResponseEntity<?> createEmployee( @RequestBody Employee employeeReq,
@PathVariable(value = "empId") String loginEmpId, HttpServletRequest request) throws MyTeamException { @PathVariable(value = "empId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
if (!empService.isEmployeeExistsById(loginEmpId)) { if (empService.isEmployeeExistsById(loginEmpId)) {
Employee employeePersisted = empService.createEmployee(employeeReq, loginEmpId); Employee employeePersisted = empService.createEmployee(employeeReq, loginEmpId);
ResponseDetails createRespDetails = new ResponseDetails(new Date(), 901, "Employee has been created", ResponseDetails createRespDetails = new ResponseDetails(new Date(), 901, "Employee has been created",
......
...@@ -72,12 +72,12 @@ public class Employee implements Serializable { ...@@ -72,12 +72,12 @@ public class Employee implements Serializable {
@ExcelCellName("Skills") @ExcelCellName("Skills")
private String technologyKnown; private String technologyKnown;
@NotBlank
@Pattern(regexp="(^$|[0-9]{10})",message="Invalid mobile number") @Pattern(regexp="(^$|[0-9]{10})",message="Invalid mobile number")
@ExcelCellName("Primary Mobile") @ExcelCellName("Primary Mobile")
private String mobileNumber; private String mobileNumber;
@NotBlank
@Pattern(regexp="(^$|[0-9]{10})",message="Invalid alternate mobile number") @Pattern(regexp="(^$|[0-9]{10})",message="Invalid alternate mobile number")
@ExcelCellName("Alternate Mobile") @ExcelCellName("Alternate Mobile")
private String alternateMobileNumber; private String alternateMobileNumber;
......
...@@ -56,7 +56,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -56,7 +56,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
$scope.gridOptions.data=response.data; $scope.gridOptions.data=response.data.records;
myFactory.setAccounts(response.data); myFactory.setAccounts(response.data);
for(i=0;i<response.data.length;i++){ for(i=0;i<response.data.length;i++){
if(response.data[i].status == 'Y'){ if(response.data[i].status == 'Y'){
...@@ -112,7 +112,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -112,7 +112,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
function deleteAccountRole(accountId){ function deleteAccountRole(accountId){
var req = { var req = {
method : 'DELETE', method : 'DELETE',
url : appConfig.appUri+ "accounts?accountId="+accountId url : appConfig.appUri+ "accounts/"+accountId
} }
$http(req).then(function mySuccess(response) { $http(req).then(function mySuccess(response) {
$scope.result = "Success"; $scope.result = "Success";
...@@ -171,7 +171,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -171,7 +171,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$scope.getDeliveryManagers = function(){ $scope.getDeliveryManagers = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getEmployeesToTeam" url : appConfig.appUri + "/employees/active/sortByName"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.managerDetails=response.data; $scope.managerDetails=response.data;
}, function myError(response) { }, function myError(response) {
...@@ -359,7 +359,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -359,7 +359,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
addOrUpdateAccount = function(record,action,flag){ addOrUpdateAccount = function(record,action,flag){
var urlRequest = ""; var urlRequest = "";
if(action == "Add" || action == "Update"){ if(action == "Add" || action == "Update"){
urlRequest = appConfig.appUri+"account/accounts?action="+flag ; urlRequest = appConfig.appUri+"accounts?action="+flag ;
} }
var req = { var req = {
method : 'POST', method : 'POST',
......
...@@ -102,7 +102,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -102,7 +102,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.getUserRoles = function(){ $scope.getUserRoles = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "user/getEmployeeByStatus?status="+$scope.status url : appConfig.appUri + "employees/?status="+$scope.status
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
if(response.data.length > 10){ if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
...@@ -116,7 +116,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -116,7 +116,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
else{ else{
$scope.gridOptions.columnDefs[6].visible = true; $scope.gridOptions.columnDefs[6].visible = true;
} }
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
...@@ -126,9 +126,9 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -126,9 +126,9 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.getOrgEmps = function(){ $scope.getOrgEmps = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "user/getUserRoles" url : appConfig.appUri + "employees/active"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptionsOrgView.data = response.data; $scope.gridOptionsOrgView.data = response.data.records;
if(response.data.length > 10){ if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
...@@ -189,7 +189,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -189,7 +189,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
function deleteUserRole(empId){ function deleteUserRole(empId){
var req = { var req = {
method : 'DELETE', method : 'DELETE',
url : appConfig.appUri+ "user/deleteEmployee?empId="+empId url : appConfig.appUri+ "employees/"+empId
} }
$http(req).then(function mySuccess(response) { $http(req).then(function mySuccess(response) {
$scope.result = response.data; $scope.result = response.data;
...@@ -626,10 +626,10 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -626,10 +626,10 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
function addOrUpdateRole(record, action){ function addOrUpdateRole(record, action){
var empId = myFactory.getEmpId(); var empId = myFactory.getEmpId();
var urlRequest = ""; var urlRequest = "";
if(action == "Add"){ if(action == " "){
urlRequest = appConfig.appUri+ "user/assignEmployeeRole?empId="+empId; urlRequest = appConfig.appUri+ "employees/"+empId;
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "user/updateEmployeeRole?empId="+empId; urlRequest = appConfig.appUri+ "employees/"+empId;
} }
var req = { var req = {
method : 'POST', method : 'POST',
......
...@@ -31,9 +31,9 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -31,9 +31,9 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
function getUserRole(profile){ function getUserRole(profile){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "employees?emailId="+profile.getEmail() url : appConfig.appUri + "employees/emailId/"+profile.getEmail()
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
var result = response.data; var result = response.data.records;
if(result == "" || result.length == 0){ if(result == "" || result.length == 0){
showRegisterEmployeeScreen(profile); showRegisterEmployeeScreen(profile);
}else{ }else{
...@@ -78,9 +78,9 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -78,9 +78,9 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
function getAllLocations(){ function getAllLocations(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "employees/locations/" url : appConfig.appUri +"/organization/locations/"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
myFactory.setLocations(response.data); myFactory.setLocations(response.data.records);
}, function myError(response) { }, function myError(response) {
}); });
...@@ -93,6 +93,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -93,6 +93,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
myFactory.setAccounts(response.data); myFactory.setAccounts(response.data);
}, function myError(response) { }, function myError(response) {
}); });
}; };
function showRegisterEmployeeScreen(profile){ function showRegisterEmployeeScreen(profile){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment