浏览代码

add qc category

create_edit_user
cyril.tsui 4 个月前
父节点
当前提交
81b17533db
共有 8 个文件被更改,包括 144 次插入0 次删除
  1. +31
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/QcCategory.kt
  2. +9
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/QcCategoryRepository.kt
  3. +25
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/QcItemCategory.kt
  4. +8
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/QcItemCategoryRepository.kt
  5. +15
    -0
      src/main/java/com/ffii/fpsms/modules/master/service/QcCategoryService.kt
  6. +18
    -0
      src/main/java/com/ffii/fpsms/modules/master/web/QcCategoryController.kt
  7. +16
    -0
      src/main/resources/db/changelog/changes/20250310_01_cyril/02_qc_category.sql
  8. +22
    -0
      src/main/resources/db/changelog/changes/20250310_01_cyril/03_qc_item_category.sql

+ 31
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/QcCategory.kt 查看文件

@@ -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()
}

+ 9
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/QcCategoryRepository.kt 查看文件

@@ -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>
}

+ 25
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/QcItemCategory.kt 查看文件

@@ -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
}

+ 8
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/QcItemCategoryRepository.kt 查看文件

@@ -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> {
}

+ 15
- 0
src/main/java/com/ffii/fpsms/modules/master/service/QcCategoryService.kt 查看文件

@@ -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()
}
}

+ 18
- 0
src/main/java/com/ffii/fpsms/modules/master/web/QcCategoryController.kt 查看文件

@@ -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()
}
}

+ 16
- 0
src/main/resources/db/changelog/changes/20250310_01_cyril/02_qc_category.sql 查看文件

@@ -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`)
);

+ 22
- 0
src/main/resources/db/changelog/changes/20250310_01_cyril/03_qc_item_category.sql 查看文件

@@ -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
);

正在加载...
取消
保存