diff --git a/core/pom.xml b/core/pom.xml index 6bb308682acd979bbb40c1ac857390da9efaaddf..3e81025945113bc3593a7d46d7f966e019c54cad 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -14,7 +14,7 @@ <dependencies> <dependency> <groupId>cz.muni.fi.pa165</groupId> - <artifactId>model</artifactId> + <artifactId>models</artifactId> <version>0.0.1-SNAPSHOT</version> <scope>compile</scope> </dependency> @@ -53,6 +53,23 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> + <plugin> + <groupId>org.springdoc</groupId> + <artifactId>springdoc-openapi-maven-plugin</artifactId> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <configuration> + <apiDocsUrl>http://localhost:8080/openapi.yaml</apiDocsUrl> + <outputFileName>openapi.yaml</outputFileName> + <outputDir>..</outputDir> + </configuration> + </plugin> </plugins> </build> </project> \ No newline at end of file diff --git a/core/src/main/java/cz/muni/fi/pa165/core/DataInitializer.java b/core/src/main/java/cz/muni/fi/pa165/core/DataInitializer.java index 2f208731fc8bcf11dd0ae077717946ead1f069c1..9045d5fea33532cc352cd2eaff82a0d480c8c3cc 100644 --- a/core/src/main/java/cz/muni/fi/pa165/core/DataInitializer.java +++ b/core/src/main/java/cz/muni/fi/pa165/core/DataInitializer.java @@ -1,5 +1,9 @@ package cz.muni.fi.pa165.core; +import cz.muni.fi.pa165.core.device.Device; +import cz.muni.fi.pa165.core.device.DeviceService; +import cz.muni.fi.pa165.core.smartmeter.SmartMeter; +import cz.muni.fi.pa165.core.smartmeter.SmartMeterService; import cz.muni.fi.pa165.core.user.User; import cz.muni.fi.pa165.core.user.UserService; import cz.muni.fi.pa165.core.user.UserType; @@ -11,19 +15,45 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor @Component public class DataInitializer implements ApplicationRunner { - private final UserService userService; + private final UserService userService; + private final DeviceService deviceService; + private final SmartMeterService smartMeterService; - @Override - public void run(ApplicationArguments args) throws Exception { - User user = - User.builder() - .email("test@email.com") - .firstName("John") - .lastName("Doe") - .username("johnD") - .password("password") - .userType(UserType.ADMIN) - .build(); - userService.create(user); - } + @Override + public void run(ApplicationArguments args) throws Exception { + SeedUsers(); + SeedDevice(); + SeedSmartMeter(); + } + + private void SeedUsers(){ + User user = User.builder() + .email("test@email.com") + .firstName("John") + .lastName("Doe") + .username("johnD") + .password("password") + .userType(UserType.ADMIN) + .build(); + userService.create(user); + } + + private void SeedDevice(){ + Device device = Device.builder() + .name("device01") + .build(); + deviceService.create(device); + } + + private void SeedSmartMeter(){ + Device device = Device.builder() + .name("device02") + .build(); + deviceService.create(device); + + SmartMeter smartMeter = SmartMeter.builder() + .device(device) + .build(); + smartMeterService.create(smartMeter); + } } diff --git a/core/src/main/java/cz/muni/fi/pa165/core/common/DomainService.java b/core/src/main/java/cz/muni/fi/pa165/core/common/DomainService.java index 5e2b621bdf7319587073610c97185779b9070017..d97b39e7fb0963cafade5978df7f5428edd6c83e 100644 --- a/core/src/main/java/cz/muni/fi/pa165/core/common/DomainService.java +++ b/core/src/main/java/cz/muni/fi/pa165/core/common/DomainService.java @@ -1,29 +1,43 @@ package cz.muni.fi.pa165.core.common; +import jakarta.persistence.EntityNotFoundException; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + public abstract class DomainService<T extends DomainObject> { - public static final int DEFAULT_PAGE_SIZE = 10; + public static final int DEFAULT_PAGE_SIZE = 10; + + public abstract JpaRepository<T, String> getRepository(); - public abstract JpaRepository<T, String> getRepository(); + @Transactional + public T create(T entity) { + return getRepository().save(entity); + } - @Transactional - public T create(T entity) { - return getRepository().save(entity); - } + @Transactional(readOnly = true) + public Page<T> findAllPageable(Pageable pageable) { + return getRepository().findAll(pageable); + } - @Transactional(readOnly = true) - public Page<T> findAll(Pageable pageable) { - return getRepository().findAll(pageable); - } + @Transactional(readOnly = true) + public List<T> findAll() { + return getRepository().findAll(); + } - @Transactional(readOnly = true) - public Page<T> findAll(int page) { - return getRepository().findAll(PageRequest.of(page, DEFAULT_PAGE_SIZE)); - } + @Transactional(readOnly = true) + public Page<T> findAllPageableInt(int page) { + return getRepository().findAll(PageRequest.of(page, DEFAULT_PAGE_SIZE)); + } + + @Transactional(readOnly = true) + public T findById(String id){ + return getRepository().findById(id).orElseThrow(() -> new EntityNotFoundException("Entity with '"+ id + "' not found.")); + } } + diff --git a/core/src/main/java/cz/muni/fi/pa165/core/device/.gitkeep b/core/src/main/java/cz/muni/fi/pa165/core/device/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/core/src/main/java/cz/muni/fi/pa165/core/device/Device.java b/core/src/main/java/cz/muni/fi/pa165/core/device/Device.java new file mode 100644 index 0000000000000000000000000000000000000000..86355f2ad3a801e7c82fb9f197219780e2bd571a --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/device/Device.java @@ -0,0 +1,30 @@ +package cz.muni.fi.pa165.core.device; + +import cz.muni.fi.pa165.core.common.DomainObject; +import cz.muni.fi.pa165.core.smartmeter.SmartMeter; +import jakarta.persistence.Entity; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import lombok.*; + +import java.util.List; + +@Getter +@Setter +@Entity +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "domain_device") +public class Device extends DomainObject { + + private String name; + + @OneToMany + private List<SmartMeter> smartMeterList; + // Manufacturer + // private Manufacturer manufacturer; + + // Company ?? + // private Company company; +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceController.java b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceController.java new file mode 100644 index 0000000000000000000000000000000000000000..dc4cfc8280b2a4df35374206bef456595c4cc1f1 --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceController.java @@ -0,0 +1,77 @@ +package cz.muni.fi.pa165.core.device; + +import cz.muni.fi.pa165.model.dto.device.DeviceCreateDto; +import cz.muni.fi.pa165.model.dto.device.DeviceDto; +import cz.muni.fi.pa165.model.dto.device.DeviceUpdateDto; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/api/device") +public class DeviceController { + + private final DeviceService deviceService; + + private final DeviceMapper mapper; + + @Autowired + public DeviceController(DeviceService deviceService, DeviceMapper mapper) { + this.deviceService = deviceService; + this.mapper = mapper; + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Get all devices pageable", + description = """ + ......... + """) + @GetMapping("pageable") + public List<DeviceDto> findAllPageable(Pageable pageable){ + return mapper.toDtoList((List<Device>) deviceService.findAllPageable(pageable)); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Get all devices", + description = """ + ......... + """) + @CrossOrigin(origins = "*") + @GetMapping// CORS headers needed for JavaScript clients + public List<DeviceDto> findAll(){ + return mapper.toDtoList(deviceService.findAll()); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Get device by id", + description = """ + ......... + """) + @GetMapping("/{id}") + public DeviceDto find(@PathVariable String id) { + return mapper.toDto(deviceService.findById(id)); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Create device", + description = """ + ......... + """) + @PostMapping + public DeviceDto create(@RequestBody DeviceCreateDto deviceDto) { + return mapper.toDto(deviceService.create(mapper.fromCreateDto(deviceDto))); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Update device", + description = """ + ......... + """) + @PutMapping + public DeviceDto update(@RequestBody DeviceUpdateDto deviceDto) { + return mapper.toDto(deviceService.create(mapper.fromUpdateDto(deviceDto))); + } +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceMapper.java b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..31e8b7fff1ebf21fb51d4549a2451bd7146bfefb --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceMapper.java @@ -0,0 +1,15 @@ +package cz.muni.fi.pa165.core.device; + +import cz.muni.fi.pa165.core.common.DomainMapper; +import cz.muni.fi.pa165.core.user.User; +import cz.muni.fi.pa165.model.dto.device.DeviceCreateDto; +import cz.muni.fi.pa165.model.dto.device.DeviceDto; +import cz.muni.fi.pa165.model.dto.device.DeviceUpdateDto; +import cz.muni.fi.pa165.model.dto.user.UserCreateDto; +import org.mapstruct.Mapper; + +@Mapper +public interface DeviceMapper extends DomainMapper<Device, DeviceDto> { + Device fromCreateDto(DeviceCreateDto dto); + Device fromUpdateDto(DeviceUpdateDto dto); +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceRepository.java b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..ac3cfa69da98780554904caa2e824652fef02e42 --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceRepository.java @@ -0,0 +1,18 @@ +package cz.muni.fi.pa165.core.device; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DeviceRepository extends JpaRepository<Device, String> { + @Modifying + @Query("UPDATE Device d set d.name= :#{#device.name} where d.id = :#{#device.id}") + Optional<Device> update(@Param("device") Device device); +} + + diff --git a/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceService.java b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceService.java new file mode 100644 index 0000000000000000000000000000000000000000..cd1e80d90a2d8feac6ad0b604b20109c6ef00027 --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/device/DeviceService.java @@ -0,0 +1,37 @@ +package cz.muni.fi.pa165.core.device; + +import cz.muni.fi.pa165.core.common.DomainService; +import jakarta.persistence.EntityNotFoundException; +import lombok.Getter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Optional; + +@Service +public class DeviceService extends DomainService<Device> { + + @Getter + private final DeviceRepository repository; + + @Autowired + public DeviceService(DeviceRepository deviceRepository){ + repository = deviceRepository; + } + + @Transactional(readOnly = true) + public Device findById(String id){ + return repository.findById(id) + .orElseThrow(() -> new EntityNotFoundException("Device with '" + id + "' not found")); + } + + @Transactional + public Device update(Device device){ + return repository.update(device) + .orElseThrow(() -> new EntityNotFoundException("Device with '" + device.getId() + "' not found")); + } +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/.gitkeep b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeter.java b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeter.java new file mode 100644 index 0000000000000000000000000000000000000000..398de21fdf505f0634fbfe0a62b97640608f6854 --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeter.java @@ -0,0 +1,21 @@ +package cz.muni.fi.pa165.core.smartmeter; + +import cz.muni.fi.pa165.core.common.DomainObject; +import cz.muni.fi.pa165.core.device.Device; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.*; + +@Getter +@Setter +@Entity +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "domain_smartMeter") +public class SmartMeter extends DomainObject { + @ManyToOne + private Device device; + private String smartMeterIdentityNumber =getId(); +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterController.java b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterController.java new file mode 100644 index 0000000000000000000000000000000000000000..d8a077efd58aa777b319b22bef14e8db1a113fa7 --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterController.java @@ -0,0 +1,65 @@ +package cz.muni.fi.pa165.core.smartmeter; + +import cz.muni.fi.pa165.model.dto.smartDevice.SmartMeterCreateDto; +import cz.muni.fi.pa165.model.dto.smartDevice.SmartMeterDto; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/api/smart-meter") +public class SmartMeterController { + private final SmartMeterService smartMeterService; + private final SmartMeterMapper mapper; + + @Autowired + public SmartMeterController(SmartMeterService smartMeterService, SmartMeterMapper mapper) { + this.smartMeterService = smartMeterService; + this.mapper = mapper; + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Get all smartMeter pageable", + description = """ + ......... + """) + @GetMapping("pageable") + public List<SmartMeterDto> findAllPageable(Pageable pageable){ + return mapper.toDtoList((List<SmartMeter>) smartMeterService.findAllPageable(pageable)); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Get all smartMeters", + description = """ + ......... + """) + @CrossOrigin(origins = "*") + @GetMapping// CORS headers needed for JavaScript clients + public List<SmartMeterDto> findAll(){ + return mapper.toDtoList(smartMeterService.findAll()); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Get smartMeter by id", + description = """ + ......... + """) + @GetMapping("/{id}") + public SmartMeterDto find(@PathVariable String id) { + return mapper.toDto(smartMeterService.findById(id)); + } + + @Operation( // metadata for inclusion into OpenAPI document + summary = "Create smartMeter", + description = """ + ......... + """) + @PostMapping + public SmartMeterDto create(@RequestBody SmartMeterCreateDto smartMeterDto) { + return mapper.toDto(smartMeterService.create(mapper.fromCreateDto(smartMeterDto))); + } + +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterMapper.java b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..bd07d9d422f05746de280261270af26c8164522c --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterMapper.java @@ -0,0 +1,30 @@ +package cz.muni.fi.pa165.core.smartmeter; + +import cz.muni.fi.pa165.core.common.DomainMapper; +import cz.muni.fi.pa165.core.device.Device; +import cz.muni.fi.pa165.model.dto.device.DeviceCreateDto; +import cz.muni.fi.pa165.model.dto.device.DeviceDto; +import cz.muni.fi.pa165.model.dto.device.DeviceUpdateDto; +import cz.muni.fi.pa165.model.dto.smartDevice.SmartMeterCreateDto; +import cz.muni.fi.pa165.model.dto.smartDevice.SmartMeterDto; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +import java.util.List; + +@Mapper +public interface SmartMeterMapper extends DomainMapper<SmartMeter, SmartMeterDto> { + @Mapping(source = "deviceDto", target = "device") + SmartMeter fromCreateDto(SmartMeterCreateDto dto); + + @Mapping(source = "deviceDto", target = "device") + SmartMeter fromDto(SmartMeterDto dto); + + @Mapping(source = "device", target = "deviceDto") + SmartMeterDto toDto(SmartMeter entity); + + @Mapping(source = "device", target = "deviceDto") + List<SmartMeterDto> toDtoList(List<SmartMeter> entities); + + +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterRepository.java b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..2f2b5288cbefd1b229befaa3cd82dc2be08f28ea --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterRepository.java @@ -0,0 +1,14 @@ +package cz.muni.fi.pa165.core.smartmeter; + +import cz.muni.fi.pa165.core.device.Device; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface SmartMeterRepository extends JpaRepository<SmartMeter, String> { +} diff --git a/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterService.java b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterService.java new file mode 100644 index 0000000000000000000000000000000000000000..1735396a12814a35f3ab564df1ba564498e5d07c --- /dev/null +++ b/core/src/main/java/cz/muni/fi/pa165/core/smartmeter/SmartMeterService.java @@ -0,0 +1,26 @@ +package cz.muni.fi.pa165.core.smartmeter; + +import cz.muni.fi.pa165.core.common.DomainService; +import cz.muni.fi.pa165.core.device.Device; +import jakarta.persistence.EntityNotFoundException; +import lombok.Getter; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class SmartMeterService extends DomainService<SmartMeter> { + + @Getter + private final SmartMeterRepository repository; + + public SmartMeterService(SmartMeterRepository smartMeterRepository) { + this.repository = smartMeterRepository; + } + + @Transactional(readOnly = true) + public SmartMeter findSmartMeterById(String id){ + return repository.findById(id) + .orElseThrow(() -> new EntityNotFoundException("SmartMeter with '" + id + "' not found")); + } +} diff --git a/core/src/main/resources/application.yml b/core/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..f062a9f94775452e30c68582e659bd880312bd91 --- /dev/null +++ b/core/src/main/resources/application.yml @@ -0,0 +1,24 @@ +# see https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html +server: + error: + include-message: always +logging: + level: + root: warn + cz: + muni: debug + org: + springframework: + web: info +spring: + mvc: + log-request-details: true + +springdoc: + # https://springdoc.org/properties.html#_springdoc_openapi_core_properties + api-docs: + path: /openapi + # https://springdoc.org/properties.html#_swagger_ui_properties + swagger-ui: + path: /swagger-ui.html + tryItOutEnabled: true diff --git a/model/pom.xml b/model/pom.xml index c5662a97f9ff213bdba277f6649839dcfb5fac85..f6debeff0017e9cf8b25c571c30739a08b3e5605 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -8,7 +8,7 @@ <version>0.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>model</artifactId> + <artifactId>models</artifactId> <name>models</name> <description>Library for smart energy management system with domain model objects</description> <properties> diff --git a/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceCreateDto.java b/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceCreateDto.java new file mode 100644 index 0000000000000000000000000000000000000000..7c6c1904774a617e16181d85a8310375b9ef903a --- /dev/null +++ b/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceCreateDto.java @@ -0,0 +1,8 @@ +package cz.muni.fi.pa165.model.dto.device; + +import cz.muni.fi.pa165.model.dto.common.DomainObjectDto; + +public class DeviceCreateDto extends DomainObjectDto { + + public String name; +} diff --git a/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceDto.java b/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceDto.java new file mode 100644 index 0000000000000000000000000000000000000000..a4f43c0b09e27ed637bc583298d612f04efdea01 --- /dev/null +++ b/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceDto.java @@ -0,0 +1,8 @@ +package cz.muni.fi.pa165.model.dto.device; + +import cz.muni.fi.pa165.model.dto.common.DomainObjectDto; + +public class DeviceDto extends DomainObjectDto { + + public String name; +} diff --git a/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceUpdateDto.java b/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceUpdateDto.java new file mode 100644 index 0000000000000000000000000000000000000000..914b20a8a8a80348f17b7dd5ea73433d20adb0b4 --- /dev/null +++ b/model/src/main/java/cz/muni/fi/pa165/model/dto/device/DeviceUpdateDto.java @@ -0,0 +1,8 @@ +package cz.muni.fi.pa165.model.dto.device; + +import cz.muni.fi.pa165.model.dto.common.DomainObjectDto; + +public class DeviceUpdateDto extends DomainObjectDto { + + public String name; +} diff --git a/model/src/main/java/cz/muni/fi/pa165/model/dto/smartDevice/SmartMeterCreateDto.java b/model/src/main/java/cz/muni/fi/pa165/model/dto/smartDevice/SmartMeterCreateDto.java new file mode 100644 index 0000000000000000000000000000000000000000..435827427dac831e02230d70ffcf7c859baacb65 --- /dev/null +++ b/model/src/main/java/cz/muni/fi/pa165/model/dto/smartDevice/SmartMeterCreateDto.java @@ -0,0 +1,9 @@ +package cz.muni.fi.pa165.model.dto.smartDevice; + +import cz.muni.fi.pa165.model.dto.common.DomainObjectDto; +import cz.muni.fi.pa165.model.dto.device.DeviceDto; + +public class SmartMeterCreateDto extends DomainObjectDto { + public String name; + public DeviceDto deviceDto; +} diff --git a/model/src/main/java/cz/muni/fi/pa165/model/dto/smartDevice/SmartMeterDto.java b/model/src/main/java/cz/muni/fi/pa165/model/dto/smartDevice/SmartMeterDto.java new file mode 100644 index 0000000000000000000000000000000000000000..9dc74278f0777a2cb2e9a3b51841c2a3f970f7de --- /dev/null +++ b/model/src/main/java/cz/muni/fi/pa165/model/dto/smartDevice/SmartMeterDto.java @@ -0,0 +1,9 @@ +package cz.muni.fi.pa165.model.dto.smartDevice; + +import cz.muni.fi.pa165.model.dto.common.DomainObjectDto; +import cz.muni.fi.pa165.model.dto.device.DeviceDto; + +public class SmartMeterDto extends DomainObjectDto { + public String name; + public DeviceDto deviceDto; +} diff --git a/pom.xml b/pom.xml index c373bf046a005afb8dc65a046afacbf3070f5cb9..94bc7a50e4efcf73eb22e0321bdabccf9e87de7d 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,18 @@ <version>${lombok.version}</version> </dependency> + <dependency> + <groupId>org.openapitools</groupId> + <artifactId>jackson-databind-nullable</artifactId> + <version>0.2.6</version> + </dependency> + + <dependency> + <groupId>org.springdoc</groupId> + <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> + <version>2.0.2</version> + </dependency> + </dependencies> <build> @@ -116,6 +128,16 @@ </excludes> </configuration> </plugin> + <plugin> + <groupId>org.openapitools</groupId> + <artifactId>openapi-generator-maven-plugin</artifactId> + <version>6.4.0</version> + </plugin> + <plugin> + <groupId>org.springdoc</groupId> + <artifactId>springdoc-openapi-maven-plugin</artifactId> + <version>1.4</version> + </plugin> </plugins> </pluginManagement> </build>