Add COnstructor
This commit is contained in:
parent
61002ffa45
commit
15af81b45e
|
|
@ -1,31 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
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> { }
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,6 @@ spring.servlet.multipart.max-request-size=10MB
|
|||
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/appvehownserver
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=0cscadmin1
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
|
||||
spring.jpa.show-sql=true
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
spring.profiles.active=@profiles.active@
|
||||
|
||||
spring.datasource.username=@mysql.user@
|
||||
spring.datasource.password=@mysql.password@
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=ODP123qweasdyxc
|
||||
|
||||
#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.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/appvehownserver
|
||||
spring.datasource.hikari.maximum-pool-size=100
|
||||
server.port=8081
|
||||
spring.datasource.hikari.auto-commit=true
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
new AntPathRequestMatcher("/login/**"),
|
||||
new AntPathRequestMatcher("/devices/**"),
|
||||
new AntPathRequestMatcher("/vehicles/**"),
|
||||
new AntPathRequestMatcher("/languages/**"),
|
||||
new AntPathRequestMatcher("/signup/**")
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,21 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("languages")
|
||||
public class LanguageController {
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<LanguageDto> showLanguages(){
|
||||
throw new UnsupportedOperationException();
|
||||
public ResponseEntity<List<LanguageDto>> showLanguages(){
|
||||
|
||||
List<LanguageDto> result = new ArrayList<>();
|
||||
result.add(new LanguageDto("en", "English"));
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,5 @@ public class UserVehicleRegistrationDto extends AbstractBaseDto {
|
|||
private String licensePlate;
|
||||
private String brandId;
|
||||
private String modelId;
|
||||
private String propulsionType;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue