fixed getLanguages method
This commit is contained in:
parent
49a97c3b53
commit
6839100d26
Binary file not shown.
Binary file not shown.
|
|
@ -117,4 +117,8 @@ public class CustomerService {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Optional<UserEntity> findCustomer(Long id) {
|
||||
return userRepository.findById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ package eu.csc.ODPAppVehOwnServer.controller.customer;
|
|||
|
||||
import eu.csc.ODPAppVehOwnServer.controller.AbstractRestController;
|
||||
import eu.csc.ODPAppVehOwnServer.models.MessageDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.data.CustomerProfileDto;
|
||||
import eu.csc.ODPAppVehOwnServer.persistence.services.CustomerService;
|
||||
import lombok.var;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
|
|
@ -24,11 +24,22 @@ public class CustomerController extends AbstractRestController {
|
|||
|
||||
@PostMapping
|
||||
@RequestMapping("/vehicle/unregister/{vin}")
|
||||
public ResponseEntity<MessageDto> registerCustomerVehicle(@PathVariable String vin){
|
||||
public ResponseEntity<MessageDto> registerCustomerVehicle(@PathVariable String vin) {
|
||||
logger.info("unregistering vin from customer");
|
||||
boolean done =customerService.unregisterVehicle(getLoggedInWebUserId(), vin);
|
||||
boolean done = customerService.unregisterVehicle(getLoggedInWebUserId(), vin);
|
||||
|
||||
return getSuccessResponse(new MessageDto(42, "deleted: " + done));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@RequestMapping("/profile")
|
||||
public ResponseEntity<CustomerProfileDto> fetchCustomerProfile() {
|
||||
|
||||
if (getLoggedInWebUserId() == null)
|
||||
throw new EntityNotFoundException();
|
||||
|
||||
var user = customerService.findCustomer(getLoggedInWebUserId());
|
||||
return getSuccessResponse(dtoMapper.mapCustomerProfileToDto(user.get()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("customer/mobilephones")
|
||||
@RequestMapping("/customer/mobilephones")
|
||||
public class MobilePhoneController extends AbstractRestController {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MobilePhoneController.class.getSimpleName());
|
||||
|
|
@ -22,9 +22,11 @@ public class MobilePhoneController extends AbstractRestController {
|
|||
|
||||
@PostMapping
|
||||
public ResponseEntity<CustomerMobilePhoneDto> registerCustomerDevice(@RequestBody CustomerMobilePhoneDto body) {
|
||||
Long userId = getLoggedInWebUserId();
|
||||
|
||||
|
||||
var entity = customerService.registerMobilePhone(body.getName(), body.getIdentifier(), getLoggedInWebUserId());
|
||||
var entity = customerService
|
||||
.registerMobilePhone(body.getName(), body.getIdentifier(), getLoggedInWebUserId());
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ package eu.csc.ODPAppVehOwnServer.mapper;
|
|||
|
||||
|
||||
import eu.csc.ODPAppVehOwnServer.models.VehicleBrandDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.data.CustomerProfileDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.data.DeviceDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.data.LanguageDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.data.PropulsionTypeDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.regist.CustomerDeviceDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.regist.CustomerVehicleDto;
|
||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.UserEntity;
|
||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerDeviceEntity;
|
||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerVehicleEntity;
|
||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceEntity;
|
||||
|
|
@ -121,4 +123,17 @@ public class DtoMapper {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CustomerProfileDto mapCustomerProfileToDto(UserEntity user) {
|
||||
CustomerProfileDto result = new CustomerProfileDto();
|
||||
|
||||
result.setId(user.getId());
|
||||
result.setEmail(user.getEmail());
|
||||
result.setFirstname(user.getFirstname());
|
||||
result.setLastname(user.getLastname());
|
||||
result.setStreet(user.getStreet());
|
||||
result.setPhone(user.getPhone());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package eu.csc.ODPAppVehOwnServer.client.service;
|
||||
|
||||
import eu.csc.ODPAppVehOwnServer.models.MessageDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.data.CustomerProfileDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.regist.CustomerDeviceDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.regist.CustomerVehicleDto;
|
||||
import eu.csc.ODPAppVehOwnServer.models.regist.UserVehicleRegistrationDto;
|
||||
|
|
@ -19,6 +20,9 @@ public interface CustomerService extends IApiService{
|
|||
@GET("/api/reg/vehicles")
|
||||
Call<List<CustomerVehicleDto>> listCustomerVehicle();
|
||||
|
||||
@GET("/api/customer/profile")
|
||||
Call<CustomerProfileDto> fetchCustomerProfile();
|
||||
|
||||
@POST("/api/reg/vehicles")
|
||||
Call<CustomerVehicleDto> registerUserVehicle(@Body UserVehicleRegistrationDto body);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,4 +14,9 @@ public class CustomerProfileDto extends AbstractServerDto {
|
|||
|
||||
private String password;
|
||||
private String email;
|
||||
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String phone;
|
||||
private String street;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue