.gitignore update
This commit is contained in:
parent
7a32926395
commit
261a47068a
|
|
@ -1,5 +1,13 @@
|
||||||
# SETUP
|
# SETUP
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Mongo DB
|
||||||
|
- MySql DB
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
docker run -d -p 27017:27017 --name test-mongo mongo:latest
|
||||||
|
|
||||||
- Add following in settings.xml (MAVEN)
|
- Add following in settings.xml (MAVEN)
|
||||||
|
|
||||||
|
|
@ -8,7 +16,9 @@
|
||||||
<mysql.user>root</mysql.user>
|
<mysql.user>root</mysql.user>
|
||||||
<mysql.password>0cscadmin1</mysql.password>
|
<mysql.password>0cscadmin1</mysql.password>
|
||||||
|
|
||||||
|
<mongo.port>27017</mongo.port>
|
||||||
|
<mongo.host>localhost</mongo.host>
|
||||||
|
<mongo.database>vehownserver</mongo.database>
|
||||||
|
|
||||||
## Shell
|
## Shell
|
||||||
i_set_loc C:\Users\yanni\Desktop\dev\priv\ODP-AppVehOwnServer\doc\data
|
i_set_loc C:\Users\yanni\Desktop\dev\priv\ODP-AppVehOwnServer\doc\data
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"locale": "en",
|
||||||
|
"name": "English",
|
||||||
|
"isStandard": true
|
||||||
|
}
|
||||||
|
]
|
||||||
Binary file not shown.
|
|
@ -21,6 +21,8 @@ public class UserEntity extends AbstractEntity{
|
||||||
|
|
||||||
private String firstname;
|
private String firstname;
|
||||||
private String lastname;
|
private String lastname;
|
||||||
|
private String phone;
|
||||||
|
private String street;
|
||||||
|
|
||||||
@Column(nullable = false, unique = true)
|
@Column(nullable = false, unique = true)
|
||||||
private String email;
|
private String email;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.entity.customer;
|
||||||
|
|
||||||
|
public class CustomerConfigurationFileEntity {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.entity.customer;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "tcustomer_mobile_phones")
|
||||||
|
public class CustomerMobilePhoneEntity extends AbstractCustomerEntity{
|
||||||
|
|
||||||
|
@Column(unique = true, nullable = false)
|
||||||
|
private String identifier;
|
||||||
|
|
||||||
|
@Column(nullable = true)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(unique = true, nullable = true)
|
||||||
|
private String accessToken;
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,7 @@ public class DeviceEntity extends AbstractEntity {
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
private String manufacturer;
|
private String manufacturer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.entity.data;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.AbstractEntity;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "tlanguages")
|
||||||
|
public class LanguageEntity extends AbstractEntity {
|
||||||
|
|
||||||
|
private String locale;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
@Column(nullable = false, name = "is_standard")
|
||||||
|
private boolean isStandard;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -28,6 +28,8 @@ public class VehicleModelEntity extends AbstractEntity {
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Column(nullable = true)
|
||||||
|
private String imageName;
|
||||||
|
|
||||||
public void setBrand(VehicleBrandEntity brand) {
|
public void setBrand(VehicleBrandEntity brand) {
|
||||||
this.brand = brand;
|
this.brand = brand;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.entity.mongo;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.pub.FilesTypes;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bson.types.Binary;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Document(collection = "files")
|
||||||
|
public class FilesMongo {
|
||||||
|
@Id
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private Binary image;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private FilesTypes imageType;
|
||||||
|
|
||||||
|
public FilesMongo(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.entity.pub;
|
||||||
|
|
||||||
|
public enum FilesTypes {
|
||||||
|
|
||||||
|
PNG,
|
||||||
|
JPEG,
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.respository;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerMobilePhoneEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CustomerMobilePhoneRepository extends JpaRepository<CustomerMobilePhoneEntity, Long> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.respository;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceEntity;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.LanguageEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface LanguageRepository extends JpaRepository<LanguageEntity, Long> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.respository.mongo;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.mongo.FilesMongo;
|
||||||
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface FilesRepository extends MongoRepository<FilesMongo, String> { }
|
||||||
|
|
@ -2,12 +2,13 @@ package eu.csc.ODPAppVehOwnServer.persistence.services;
|
||||||
|
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.UserEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.UserEntity;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerDeviceEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerDeviceEntity;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerMobilePhoneEntity;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerVehicleEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.customer.CustomerVehicleEntity;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceArticleEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.respository.CustomerDeviceRepository;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.respository.CustomerMobilePhoneRepository;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.respository.*;
|
import eu.csc.ODPAppVehOwnServer.persistence.respository.CustomerVehicleRepository;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.respository.UserRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -25,18 +26,19 @@ public class CustomerService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerMobilePhoneRepository customerMobilePhoneRepository;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerVehicleRepository customerVehicleRepository;
|
private CustomerVehicleRepository customerVehicleRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerDeviceRepository customerDeviceRepository;
|
private CustomerDeviceRepository customerDeviceRepository;
|
||||||
|
|
||||||
public List<UserEntity> findAll() {
|
public List<UserEntity> findAll() {
|
||||||
|
|
||||||
|
return userRepository.findAll();
|
||||||
|
|
||||||
return userRepository.findAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity addCustomer(String email, String password) {
|
public UserEntity addCustomer(String email, String password) {
|
||||||
|
|
@ -50,7 +52,7 @@ public class CustomerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private UserEntity mapUser(String email, String password, String firstname, String lastname){
|
private UserEntity mapUser(String email, String password, String firstname, String lastname) {
|
||||||
var user = new UserEntity();
|
var user = new UserEntity();
|
||||||
|
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
|
|
@ -69,7 +71,7 @@ public class CustomerService {
|
||||||
return customerDeviceRepository.findAllByUser_id(userId);
|
return customerDeviceRepository.findAllByUser_id(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomerDeviceEntity registerDevice(Long userId, String serialnumber){
|
public CustomerDeviceEntity registerDevice(Long userId, String serialnumber) {
|
||||||
|
|
||||||
var deviceArticle = deviceService.findOrThrowBySerialnumber(serialnumber);
|
var deviceArticle = deviceService.findOrThrowBySerialnumber(serialnumber);
|
||||||
|
|
||||||
|
|
@ -89,4 +91,17 @@ public class CustomerService {
|
||||||
public Optional<UserEntity> findByEmail(String email) {
|
public Optional<UserEntity> findByEmail(String email) {
|
||||||
return userRepository.findOneByEmail(email);
|
return userRepository.findOneByEmail(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomerMobilePhoneEntity registerMobilePhone(String name, String identifier, Long customerId) {
|
||||||
|
|
||||||
|
CustomerMobilePhoneEntity item = new CustomerMobilePhoneEntity();
|
||||||
|
item.setIdentifier(identifier);
|
||||||
|
item.setName(name);
|
||||||
|
item.setUser_id(customerId);
|
||||||
|
|
||||||
|
item.setAccessToken(utilsService.generateAccessToken());
|
||||||
|
|
||||||
|
|
||||||
|
return customerMobilePhoneRepository.save(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.persistence.services;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.mongo.FilesMongo;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.respository.mongo.FilesRepository;
|
||||||
|
import org.bson.BsonBinarySubType;
|
||||||
|
import org.bson.types.Binary;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FilesService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FilesRepository photoRepo;
|
||||||
|
|
||||||
|
public String addPhoto(String title, MultipartFile file) throws IOException {
|
||||||
|
var photo = new FilesMongo(title);
|
||||||
|
photo.setImage(
|
||||||
|
new Binary(BsonBinarySubType.BINARY, file.getBytes()));
|
||||||
|
photo = photoRepo.insert(photo); return photo.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilesMongo getPhoto(String id) {
|
||||||
|
return photoRepo.findById(id).get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,6 +30,8 @@ return ""+year + month + date + serialNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String generateAccessToken() {
|
||||||
|
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
pom.xml
16
pom.xml
|
|
@ -50,6 +50,22 @@
|
||||||
<version>3.12.0</version>
|
<version>3.12.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@ spring.profiles.active=@profiles.active@
|
||||||
|
|
||||||
spring.datasource.username=@mysql.user@
|
spring.datasource.username=@mysql.user@
|
||||||
spring.datasource.password=@mysql.password@
|
spring.datasource.password=@mysql.password@
|
||||||
|
|
||||||
|
#Mongo Db
|
||||||
|
spring.data.mongodb.host=@mongo.host@
|
||||||
|
spring.data.mongodb.port=@mongo.port@
|
||||||
|
spring.data.mongodb.database=@mongo.database@
|
||||||
|
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
|
||||||
|
|
||||||
spring.datasource.hikari.maximum-pool-size=100
|
spring.datasource.hikari.maximum-pool-size=100
|
||||||
server.port=8081
|
server.port=8081
|
||||||
spring.datasource.hikari.auto-commit=true
|
spring.datasource.hikari.auto-commit=true
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ public abstract class AbstractRestController {
|
||||||
return (LoggedInWebUserDetails) getLoggedInUser().getPrincipal();
|
return (LoggedInWebUserDetails) getLoggedInUser().getPrincipal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Long getLoggedInWebUserId(){
|
||||||
|
LoggedInWebUserDetails user = (LoggedInWebUserDetails) getLoggedInUser().getPrincipal();
|
||||||
|
|
||||||
|
return user.getUserId();
|
||||||
|
}
|
||||||
|
|
||||||
//region ExceptionHandling
|
//region ExceptionHandling
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -59,6 +65,10 @@ public abstract class AbstractRestController {
|
||||||
public ResponseEntity handlePersistenceNotFoundException(PersistenceException ex) {
|
public ResponseEntity handlePersistenceNotFoundException(PersistenceException ex) {
|
||||||
return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
@ExceptionHandler(UnsupportedOperationException.class)
|
||||||
|
public ResponseEntity handleUnsupportedOperationException(UnsupportedOperationException ex) {
|
||||||
|
return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.controller.customer;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.controller.AbstractRestController;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/customer/")
|
||||||
|
public class CustomerController extends AbstractRestController {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(CustomerController.class.getSimpleName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.controller.customer;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.controller.AbstractRestController;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.models.regist.CustomerMobilePhoneDto;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.services.CustomerService;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.persistence.services.DeviceService;
|
||||||
|
import lombok.var;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("customer/mobilephones")
|
||||||
|
public class MobilePhoneController extends AbstractRestController {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(MobilePhoneController.class.getSimpleName());
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerService customerService;
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<CustomerMobilePhoneDto> registerCustomerDevice(@RequestBody CustomerMobilePhoneDto body) {
|
||||||
|
|
||||||
|
|
||||||
|
var entity = customerService.registerMobilePhone(body.getName(), body.getIdentifier(), getLoggedInWebUserId());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -65,8 +65,11 @@ public class VehicleController {
|
||||||
produces = MediaType.IMAGE_JPEG_VALUE)
|
produces = MediaType.IMAGE_JPEG_VALUE)
|
||||||
public void getImage(HttpServletResponse response, @PathVariable String brandId) throws IOException {
|
public void getImage(HttpServletResponse response, @PathVariable String brandId) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var imgFile = storageService.loadAsResource("images", "ford.jpeg");
|
var imgFile = storageService.loadAsResource("images", "ford.jpeg");
|
||||||
|
|
||||||
|
//if(imgFile.)
|
||||||
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
|
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
|
||||||
StreamUtils.copy(imgFile.getInputStream(), response.getOutputStream());
|
StreamUtils.copy(imgFile.getInputStream(), response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,14 @@ public class RegistrationController {
|
||||||
user.setEmail(signUpDto.getEmail());
|
user.setEmail(signUpDto.getEmail());
|
||||||
user.setPassword(passwordEncoder.encode(signUpDto.getPassword()));
|
user.setPassword(passwordEncoder.encode(signUpDto.getPassword()));
|
||||||
|
|
||||||
|
user.setPhone(signUpDto.getPhone());
|
||||||
|
user.setStreet(signUpDto.getStreet());
|
||||||
|
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
|
|
||||||
return new ResponseEntity<>("User registered successfully", HttpStatus.OK);
|
|
||||||
|
|
||||||
|
return new ResponseEntity<>(user.getId(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ public class VehicleRegistrationController extends AbstractRestController {
|
||||||
|
|
||||||
|
|
||||||
result.add(mapped);
|
result.add(mapped);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok(result);
|
return ResponseEntity.ok(result);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import java.util.function.Function;
|
||||||
public class JwtTokenService {
|
public class JwtTokenService {
|
||||||
|
|
||||||
private final String secret;
|
private final String secret;
|
||||||
|
|
||||||
private final Long expiration;
|
private final Long expiration;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package eu.csc.ODPAppVehOwnServer.web.clients;
|
package eu.csc.ODPAppVehOwnServer.web.clients;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.clients.VehOwnAppClient;
|
import eu.csc.ODPAppVehOwnServer.client.clients.VehOwnAppClient;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.client.service.AuthenticationService;
|
||||||
import eu.csc.ODPAppVehOwnServer.models.regist.UserVehicleRegistrationDto;
|
import eu.csc.ODPAppVehOwnServer.models.regist.UserVehicleRegistrationDto;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceArticleEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceArticleEntity;
|
||||||
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceEntity;
|
import eu.csc.ODPAppVehOwnServer.persistence.entity.data.DeviceEntity;
|
||||||
|
|
@ -24,6 +26,8 @@ public abstract class AbstractClientTester {
|
||||||
protected String url;
|
protected String url;
|
||||||
protected VehOwnAppClient client;
|
protected VehOwnAppClient client;
|
||||||
|
|
||||||
|
protected AuthenticationService authenticationService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected GsonService gsonService;
|
protected GsonService gsonService;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.csc.ODPAppVehOwnServer.web.clients;
|
package eu.csc.ODPAppVehOwnServer.web.clients;
|
||||||
|
|
||||||
|
import com.mysql.cj.xdevapi.Client;
|
||||||
import eu.csc.ODPAppVehOwnServer.ODPAppVehOwnServerApplication;
|
import eu.csc.ODPAppVehOwnServer.ODPAppVehOwnServerApplication;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.models.UserRegistrationDto;
|
||||||
import eu.csc.ODPAppVehOwnServer.models.regist.UserVehicleRegistrationDto;
|
import eu.csc.ODPAppVehOwnServer.models.regist.UserVehicleRegistrationDto;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
|
@ -25,6 +27,9 @@ public class CustomerClientTester extends AbstractClientTester{
|
||||||
this.initUser();
|
this.initUser();
|
||||||
|
|
||||||
this.url = "http://localhost:" + port;
|
this.url = "http://localhost:" + port;
|
||||||
|
|
||||||
|
this.authenticationService =
|
||||||
|
ClientFactory.createAuthenticationService(this.url);
|
||||||
this.token = ClientFactory.authenticate(url, this.user, this.password).body().getToken();
|
this.token = ClientFactory.authenticate(url, this.user, this.password).body().getToken();
|
||||||
client = ClientFactory.createVehOwnAppClient(this.url, this.token);
|
client = ClientFactory.createVehOwnAppClient(this.url, this.token);
|
||||||
|
|
||||||
|
|
@ -38,6 +43,25 @@ public class CustomerClientTester extends AbstractClientTester{
|
||||||
Assertions.assertNotNull(this.client);
|
Assertions.assertNotNull(this.client);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testRegistration() throws IOException {
|
||||||
|
UserRegistrationDto customerA = new UserRegistrationDto();
|
||||||
|
customerA.setEmail("A@A.A");
|
||||||
|
customerA.setPassword("yannyann1");
|
||||||
|
|
||||||
|
var result = Assertions.assertDoesNotThrow(() -> authenticationService.registerCustomer(customerA).execute());
|
||||||
|
|
||||||
|
Assertions.assertNotNull(result.body());
|
||||||
|
var result2 = Assertions.assertDoesNotThrow(() -> authenticationService.registerCustomer(customerA).execute());
|
||||||
|
|
||||||
|
Assertions.assertNull(result2.body());
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(result2.errorBody().string());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.shell;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.shell.standard.ShellComponent;
|
||||||
|
|
||||||
|
@ShellComponent
|
||||||
|
public class InitCommands extends BaseCommands{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
|
|
@ -4,6 +4,7 @@ package eu.csc.ODPAppVehOwnServer.client.clients;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
import eu.csc.ODPAppVehOwnServer.client.ClientFactory;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.exceptions.NotAuthenticatedException;
|
import eu.csc.ODPAppVehOwnServer.client.exceptions.NotAuthenticatedException;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.models.CallResponse;
|
import eu.csc.ODPAppVehOwnServer.client.models.CallResponse;
|
||||||
|
import eu.csc.ODPAppVehOwnServer.client.service.AuthenticationService;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.service.ClientService;
|
import eu.csc.ODPAppVehOwnServer.client.service.ClientService;
|
||||||
import eu.csc.ODPAppVehOwnServer.client.service.CustomerService;
|
import eu.csc.ODPAppVehOwnServer.client.service.CustomerService;
|
||||||
import eu.csc.ODPAppVehOwnServer.models.VehicleBrandDto;
|
import eu.csc.ODPAppVehOwnServer.models.VehicleBrandDto;
|
||||||
|
|
@ -26,6 +27,8 @@ public class VehOwnAppClient extends AbstractClient implements IDataClient {
|
||||||
private final CustomerService customerService;
|
private final CustomerService customerService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//region Constructors
|
//region Constructors
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,6 +43,7 @@ public class VehOwnAppClient extends AbstractClient implements IDataClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public VehOwnAppClient(String url, String user, String password) {
|
public VehOwnAppClient(String url, String user, String password) {
|
||||||
|
|
||||||
this.customerService = ClientFactory.createService(url, CustomerService.class, user, password);
|
this.customerService = ClientFactory.createService(url, CustomerService.class, user, password);
|
||||||
|
|
||||||
this.clientService = ClientFactory.createService(url, ClientService.class, user, password);
|
this.clientService = ClientFactory.createService(url, ClientService.class, user, password);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ import retrofit2.http.POST;
|
||||||
public interface AuthenticationService {
|
public interface AuthenticationService {
|
||||||
|
|
||||||
@POST("/api/login")
|
@POST("/api/login")
|
||||||
Call<JWTTokenResponse> login(@Body AuthenticationRequest request);
|
Call<JWTTokenResponse> login(@Body AuthenticationRequest body);
|
||||||
|
|
||||||
|
|
||||||
|
@POST("/api/signup")
|
||||||
|
Call<Long> registerCustomer(@Body UserRegistrationDto body);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,17 @@
|
||||||
package eu.csc.ODPAppVehOwnServer.models;
|
package eu.csc.ODPAppVehOwnServer.models;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
public class AbstractBaseDto implements Serializable {
|
public class AbstractBaseDto implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,8 @@ public class UserRegistrationDto extends AbstractBaseDto{
|
||||||
private String firstname;
|
private String firstname;
|
||||||
private String lastname;
|
private String lastname;
|
||||||
private String email;
|
private String email;
|
||||||
|
private String phone;
|
||||||
|
private String street;
|
||||||
|
private String city;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
package eu.csc.ODPAppVehOwnServer.models.base;
|
package eu.csc.ODPAppVehOwnServer.models.base;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public abstract class AbstractServerDto {
|
public abstract class AbstractServerDto {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,10 @@ public class PropulsionTypeDto extends AbstractServerDto {
|
||||||
private String propulsionId;
|
private String propulsionId;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
public PropulsionTypeDto(Long id, String propulsionId, String name){
|
||||||
|
super(id);
|
||||||
|
this.propulsionId = propulsionId;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package eu.csc.ODPAppVehOwnServer.models.regist;
|
||||||
|
|
||||||
|
import eu.csc.ODPAppVehOwnServer.models.AbstractBaseDto;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
public class CustomerMobilePhoneDto extends AbstractBaseDto {
|
||||||
|
|
||||||
|
private String identifier;
|
||||||
|
private String name;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue