1

I've reviewed these postings as they are similar but they gave me no help how to solve my problem probably because I'm very new to Angular and Spring:

The first page of my web app that everyone logs into and sees lists all the properties listed by the realty company. I want to modify this so that they only see their properties.

The angular controller is

angular.module('communitypropApp').controller('DashboardController,function($rootScope,$scope,$state,CommunityProperties){
$scope.$state=$state;
$scope.communityProperties=[];

$scope.loadAll=function(){
CommunityProperties.query(function(result){
$scope.communityProperites=result.content;
});
});

$scope.loadall();
});

Inside my CommunityPropertiesRestController.java file I have

import . . . 
@RestController
@RestMapping("/rest/api")
public class CommunityPropertiesRestController(
@Inject 
CommunityPropertyDataService communityPropertiesDataService;
@PostMapping(value="/communityProperties",produces=MediaType.Application_Json_value)
public ResponseEntity<Void> create{
. . . 
}

@GetMapping(value="/communityProperties/{id}",produces=MediaType.Application_Json_value)
public ResponseEntity<CommunityProperties> get(@PathVariable Long id, User user)
CommunityProperties communityProperties=communityPropertiesDataService.getCommunityPropertiesById(id);
return Optional.OfNullable(communityProperties.map(. . . )
}

@GetMapping(value = "/communityProperties",produces = MediatType.Application_Json_value) 
. . . 
} 
. . . (I added)
@GetMapping(value="/communityProperties/propertyowner", . . . 
.. . 
}

}

In CommunityPropertiesDataService.java I have

import . . . .

@Service
public class CommunityPropertiesDataService{
@Inject 
CommunityPropertyRepository communityPropertiesRepository;

public CommunityProperities create(. . . ){
. . . 
}

public CommunityProperties getCommunityPropertiesById(. . . ){
. . . 
}

public Page<CommunityProperties> getAll(. . . ){
. . . 
}

. . . . 

}

There is a community-properties.service.js which I have

'use strict';
angular.module('communitypropertiesApp').factory('CommunityProperty',function($resource){
return $resource('/rest/api/communityProperties/:id',{},{
'query': { method: 'GET',
transformResponse: function (data){
data = angular.fromJson(data);
return data;
}},


'get': {
method: 'GET',
transformResponse: function (data){
data=angular.fromJson(data);
return data;
}
},  
. . . 
}),
});

I added to this file:

angular.module('communitypropertiesApp').factory('CommunityPropertiesOwner',function($resource){
return $resource('/rest/api/communityProperties/propertyowner"',{},{
'query': { method: 'GET',
transformResponse: function (data){
data = angular.fromJson(data);
return data;
}},

'get': {
method: 'GET',
transformResponse: function (data){
data=angular.fromJson(data);
return data;
}
},
. . . 
}),
});

I cannot "hijack" the /communityproperties/ web service or the communityproperties/{id} web service as they are used elsewhere. So I don't know how to add to this to get only the logged in user's properties. What am I missing here?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.