| @@ -0,0 +1,31 @@ | |||||
| package com.ffii.fpsms.modules.master.entity | |||||
| import com.ffii.core.entity.BaseEntity | |||||
| import jakarta.persistence.CascadeType | |||||
| import jakarta.persistence.Column | |||||
| import jakarta.persistence.Entity | |||||
| import jakarta.persistence.JoinColumn | |||||
| import jakarta.persistence.JoinTable | |||||
| import jakarta.persistence.OneToMany | |||||
| import jakarta.persistence.Table | |||||
| import jakarta.validation.constraints.NotNull | |||||
| @Entity | |||||
| @Table(name = "qc_category") | |||||
| open class QcCategory : BaseEntity<Long>() { | |||||
| @NotNull | |||||
| @Column(name = "code") | |||||
| open var code: String? = null | |||||
| @NotNull | |||||
| @Column(name = "name") | |||||
| open var name: String? = null | |||||
| @OneToMany(cascade = [CascadeType.ALL]) | |||||
| @JoinTable( | |||||
| name = "qc_item_category", | |||||
| joinColumns = [JoinColumn(name = "qcCategoryId")], | |||||
| inverseJoinColumns = [JoinColumn(name = "qcItemId")] | |||||
| ) | |||||
| open var qcItems: MutableSet<QcItem> = mutableSetOf() | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| package com.ffii.fpsms.modules.master.entity | |||||
| import com.ffii.core.support.AbstractRepository | |||||
| import org.springframework.stereotype.Repository | |||||
| @Repository | |||||
| interface QcCategoryRepository : AbstractRepository<QcCategory, Long> { | |||||
| fun findAllByDeletedIsFalse(): List<QcCategory> | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| package com.ffii.fpsms.modules.master.entity | |||||
| import com.fasterxml.jackson.annotation.JsonBackReference | |||||
| import com.fasterxml.jackson.annotation.JsonManagedReference | |||||
| import com.ffii.core.entity.BaseEntity | |||||
| import com.ffii.core.entity.IdEntity | |||||
| import jakarta.persistence.Entity | |||||
| import jakarta.persistence.JoinColumn | |||||
| import jakarta.persistence.ManyToOne | |||||
| import jakarta.persistence.Table | |||||
| import jakarta.validation.constraints.NotNull | |||||
| @Entity | |||||
| @Table(name = "qc_item_category") | |||||
| open class QcItemCategory : IdEntity<Long>() { | |||||
| @NotNull | |||||
| @ManyToOne | |||||
| @JoinColumn(name = "qcCategoryId") | |||||
| open var qcCategory: QcCategory? = null | |||||
| @NotNull | |||||
| @ManyToOne | |||||
| @JoinColumn(name = "qcItemId") | |||||
| open var qcItem: QcItem? = null | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| package com.ffii.fpsms.modules.master.entity | |||||
| import com.ffii.core.support.AbstractRepository | |||||
| import org.springframework.stereotype.Repository | |||||
| @Repository | |||||
| interface QcItemCategoryRepository : AbstractRepository<QcItemCategory, Long> { | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.ffii.fpsms.modules.master.service | |||||
| import com.ffii.core.support.AbstractBaseEntityService | |||||
| import com.ffii.fpsms.modules.master.entity.QcCategory | |||||
| import com.ffii.fpsms.modules.master.entity.QcCategoryRepository | |||||
| import org.springframework.stereotype.Service | |||||
| @Service | |||||
| open class QcCategoryService( | |||||
| private val qcCategoryRepository: QcCategoryRepository | |||||
| ) { | |||||
| open fun allQcCategories(): List<QcCategory> { | |||||
| return qcCategoryRepository.findAllByDeletedIsFalse() | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| package com.ffii.fpsms.modules.master.web | |||||
| import com.ffii.fpsms.modules.master.entity.QcCategory | |||||
| import com.ffii.fpsms.modules.master.service.QcCategoryService | |||||
| import org.springframework.web.bind.annotation.GetMapping | |||||
| import org.springframework.web.bind.annotation.RequestMapping | |||||
| import org.springframework.web.bind.annotation.RestController | |||||
| @RestController | |||||
| @RequestMapping("/qcCategories") | |||||
| class QcCategoryController( | |||||
| private val qcCategoryService: QcCategoryService | |||||
| ) { | |||||
| @GetMapping | |||||
| fun allQcCategories(): List<QcCategory> { | |||||
| return qcCategoryService.allQcCategories() | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| --liquibase formatted sql | |||||
| --changeset cyril:qc_category | |||||
| CREATE TABLE `qc_category` | |||||
| ( | |||||
| `id` INT NOT NULL, | |||||
| `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', | |||||
| `code` VARCHAR(50) NOT NULL, | |||||
| `name` VARCHAR(50) NOT NULL, | |||||
| PRIMARY KEY (`id`) | |||||
| ); | |||||
| @@ -0,0 +1,22 @@ | |||||
| --liquibase formatted sql | |||||
| --changeset cyril:qc_item_category | |||||
| CREATE TABLE `qc_item_category` | |||||
| ( | |||||
| `id` INT NOT NULL, | |||||
| `qcItemId` INT NOT NULL, | |||||
| `qcCategoryId` INT NOT NULL, | |||||
| PRIMARY KEY (`id`), | |||||
| INDEX `FK_QC_ITEM_CATEGORY_ON_QCITEMID` (`qcItemId` ASC) VISIBLE, | |||||
| INDEX `FK_QC_ITEM_CATEGORY_ON_QCCATEGORYID` (`qcCategoryId` ASC) VISIBLE, | |||||
| CONSTRAINT `FK_QC_ITEM_CATEGORY_ON_QCITEMID` | |||||
| FOREIGN KEY (`qcItemId`) | |||||
| REFERENCES `qc_item` (`id`) | |||||
| ON DELETE RESTRICT | |||||
| ON UPDATE RESTRICT, | |||||
| CONSTRAINT `FK_QC_ITEM_CATEGORY_ON_QCCATEGORYID` | |||||
| FOREIGN KEY (`qcCategoryId`) | |||||
| REFERENCES `qc_category` (`id`) | |||||
| ON DELETE RESTRICT | |||||
| ON UPDATE RESTRICT | |||||
| ); | |||||