@@ -9,6 +9,7 @@ import com.ffii.fpsms.modules.master.web.models.MessageResponse | |||||
import com.ffii.fpsms.modules.master.web.models.NewItemRequest | import com.ffii.fpsms.modules.master.web.models.NewItemRequest | ||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
import org.springframework.transaction.annotation.Transactional | import org.springframework.transaction.annotation.Transactional | ||||
import java.io.IOException | |||||
import kotlin.jvm.optionals.getOrNull | import kotlin.jvm.optionals.getOrNull | ||||
@Service | @Service | ||||
@@ -26,6 +27,7 @@ open class ItemsService( | |||||
open fun getItem(id: Long): Items? { | open fun getItem(id: Long): Items? { | ||||
return itemsRepository.findById(id).getOrNull() | return itemsRepository.findById(id).getOrNull() | ||||
} | } | ||||
@Throws(IOException::class) | |||||
@Transactional | @Transactional | ||||
open fun saveItem(request: NewItemRequest): MessageResponse { | open fun saveItem(request: NewItemRequest): MessageResponse { | ||||
val type = itemTypeRepository.findById(request.typeId).get() | val type = itemTypeRepository.findById(request.typeId).get() | ||||
@@ -11,18 +11,18 @@ import org.springframework.web.bind.annotation.* | |||||
@RestController | @RestController | ||||
@RequestMapping("/items") | @RequestMapping("/items") | ||||
class ItemsController( | class ItemsController( | ||||
private val materialService: ItemsService | |||||
private val itemsService: ItemsService | |||||
) { | ) { | ||||
@GetMapping | @GetMapping | ||||
fun allItems(): List<Items> { | fun allItems(): List<Items> { | ||||
return materialService.allItems() | |||||
return itemsService.allItems() | |||||
} | } | ||||
@GetMapping("/details/{id}") | @GetMapping("/details/{id}") | ||||
fun getItems(@PathVariable id: Long): Items { | fun getItems(@PathVariable id: Long): Items { | ||||
return materialService.getItem(id) ?: throw NotFoundException() | |||||
return itemsService.getItem(id) ?: throw NotFoundException() | |||||
} | } | ||||
@PostMapping("/new") | @PostMapping("/new") | ||||
fun saveItem(@Valid @RequestBody newItem: NewItemRequest): MessageResponse { | fun saveItem(@Valid @RequestBody newItem: NewItemRequest): MessageResponse { | ||||
return materialService.saveItem(newItem) | |||||
return itemsService.saveItem(newItem) | |||||
} | } | ||||
} | } |
@@ -13,6 +13,5 @@ CREATE TABLE `qc_item` | |||||
`code` VARCHAR(30) NOT NULL, | `code` VARCHAR(30) NOT NULL, | ||||
`name` VARCHAR(30) NOT NULL, | `name` VARCHAR(30) NOT NULL, | ||||
`description` VARCHAR(100) NULL, | `description` VARCHAR(100) NULL, | ||||
`systemInput` TINYINT(1) NOT NULL, | |||||
PRIMARY KEY (`id`) | PRIMARY KEY (`id`) | ||||
); | ); |
@@ -0,0 +1,40 @@ | |||||
--liquibase formatted sql | |||||
--changeset derek:qc check | |||||
CREATE TABLE `qc_check` ( | |||||
`id` INT NOT NULL AUTO_INCREMENT, | |||||
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`createdBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`version` INT NOT NULL DEFAULT '0', | |||||
`modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`modifiedBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`deleted` TINYINT(1) NOT NULL DEFAULT '0', | |||||
`qcItemId` INT(1) NOT NULL, | |||||
`isRange` TINYINT(1) NOT NULL DEFAULT '0', | |||||
`description` VARCHAR(100) NULL, | |||||
`systemInput` TINYINT(1) NOT NULL DEFAULT '0', | |||||
`lowerLimit` DECIMAL(16,2) NULL, | |||||
`upperLimit` DECIMAL(16,2) NULL, | |||||
`itemId` INT NOT NULL, | |||||
PRIMARY KEY (`id`), | |||||
CONSTRAINT fk_check_qc_items FOREIGN KEY (`qcItemId`) REFERENCES `qc_item` (`id`), | |||||
CONSTRAINT fk_check_items FOREIGN KEY (`itemId`) REFERENCES `items` (`id`) | |||||
); | |||||
CREATE TABLE `qc_result` ( | |||||
`id` INT NOT NULL AUTO_INCREMENT, | |||||
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`createdBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`version` INT NOT NULL DEFAULT '0', | |||||
`modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`modifiedBy` VARCHAR(30) NULL DEFAULT NULL, | |||||
`deleted` TINYINT(1) NOT NULL DEFAULT '0', | |||||
itemId INT NOT NULL, | |||||
qcCheckId INT NOT NULL, | |||||
`recordDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`result_value` DECIMAL(16,2) NULL, | |||||
`result_bool` TINYINT(1) NULL, | |||||
`inspectorId` INT NOT NULL, | |||||
PRIMARY KEY (`id`), | |||||
CONSTRAINT fk_qc_check FOREIGN KEY (`qcCheckId`) REFERENCES `qc_check` (`id`) | |||||
); |