@@ -0,0 +1,32 @@ | |||||
package com.ffii.tsms.modules.data.entity | |||||
import com.ffii.core.entity.IdEntity | |||||
import jakarta.persistence.Column | |||||
import jakarta.persistence.Entity | |||||
import jakarta.persistence.Table | |||||
import jakarta.validation.constraints.NotNull | |||||
import org.hibernate.proxy.HibernateProxy | |||||
@Entity | |||||
@Table(name = "building_type") | |||||
open class BuildingType : IdEntity<Long>() { | |||||
@NotNull | |||||
@Column(name = "name") | |||||
open var name: String? = null | |||||
final override fun equals(other: Any?): Boolean { | |||||
if (this === other) return true | |||||
if (other == null) return false | |||||
val oEffectiveClass = | |||||
if (other is HibernateProxy) other.hibernateLazyInitializer.persistentClass else other.javaClass | |||||
val thisEffectiveClass = | |||||
if (this is HibernateProxy) this.hibernateLazyInitializer.persistentClass else this.javaClass | |||||
if (thisEffectiveClass != oEffectiveClass) return false | |||||
other as BuildingType | |||||
return id != null && id == other.id | |||||
} | |||||
final override fun hashCode(): Int = | |||||
if (this is HibernateProxy) this.hibernateLazyInitializer.persistentClass.hashCode() else javaClass.hashCode() | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ffii.tsms.modules.data.entity | |||||
import com.ffii.core.entity.IdEntity | |||||
import jakarta.persistence.Column | |||||
import jakarta.persistence.Entity | |||||
import jakarta.persistence.Table | |||||
import jakarta.validation.constraints.NotNull | |||||
@Entity | |||||
@Table(name = "contract_type") | |||||
open class ContractType : IdEntity<Long>() { | |||||
@NotNull | |||||
@Column(name = "name") | |||||
open var name: String? = null | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ffii.tsms.modules.data.entity | |||||
import com.ffii.core.entity.IdEntity | |||||
import jakarta.persistence.Column | |||||
import jakarta.persistence.Entity | |||||
import jakarta.persistence.Table | |||||
import jakarta.validation.constraints.NotNull | |||||
@Entity | |||||
@Table(name = "funding_type") | |||||
open class FundingType : IdEntity<Long>() { | |||||
@NotNull | |||||
@Column(name = "name") | |||||
open var name: String? = null | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ffii.tsms.modules.data.entity | |||||
import com.ffii.core.entity.IdEntity | |||||
import jakarta.persistence.Column | |||||
import jakarta.persistence.Entity | |||||
import jakarta.persistence.Table | |||||
import jakarta.validation.constraints.NotNull | |||||
@Entity | |||||
@Table(name = "location") | |||||
open class Location : IdEntity<Long>() { | |||||
@NotNull | |||||
@Column(name = "name") | |||||
open var name: String? = null | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ffii.tsms.modules.data.entity | |||||
import com.ffii.core.entity.IdEntity | |||||
import jakarta.persistence.Column | |||||
import jakarta.persistence.Entity | |||||
import jakarta.persistence.Table | |||||
import jakarta.validation.constraints.NotNull | |||||
@Entity | |||||
@Table(name = "service_type") | |||||
open class ServiceType : IdEntity<Long>() { | |||||
@NotNull | |||||
@Column(name = "name") | |||||
open var name: String? = null | |||||
} |
@@ -0,0 +1,32 @@ | |||||
package com.ffii.tsms.modules.data.entity | |||||
import com.ffii.core.entity.IdEntity | |||||
import jakarta.persistence.Column | |||||
import jakarta.persistence.Entity | |||||
import jakarta.persistence.Table | |||||
import jakarta.validation.constraints.NotNull | |||||
import org.hibernate.proxy.HibernateProxy | |||||
@Entity | |||||
@Table(name = "work_nature") | |||||
open class WorkNature : IdEntity<Long>() { | |||||
@NotNull | |||||
@Column(name = "name") | |||||
open var name: String? = null | |||||
final override fun equals(other: Any?): Boolean { | |||||
if (this === other) return true | |||||
if (other == null) return false | |||||
val oEffectiveClass = | |||||
if (other is HibernateProxy) other.hibernateLazyInitializer.persistentClass else other.javaClass | |||||
val thisEffectiveClass = | |||||
if (this is HibernateProxy) this.hibernateLazyInitializer.persistentClass else this.javaClass | |||||
if (thisEffectiveClass != oEffectiveClass) return false | |||||
other as WorkNature | |||||
return id != null && id == other.id | |||||
} | |||||
final override fun hashCode(): Int = | |||||
if (this is HibernateProxy) this.hibernateLazyInitializer.persistentClass.hashCode() else javaClass.hashCode() | |||||
} |
@@ -10,13 +10,13 @@ interface StaffSearchInfo { | |||||
val staffId: String? | val staffId: String? | ||||
val name: String? | val name: String? | ||||
@get:Value("#{target.team.code}") | |||||
@get:Value("#{target.team?.code}") | |||||
val team: String? | val team: String? | ||||
@get:Value("#{target.grade.name}") | |||||
@get:Value("#{target.grade?.name}") | |||||
val grade: String? | val grade: String? | ||||
@get:Value("#{target.currentPosition.name}") | |||||
@get:Value("#{target.currentPosition?.name}") | |||||
val currentPosition: String? | val currentPosition: String? | ||||
} | } |
@@ -1,97 +1,96 @@ | |||||
package com.ffii.tsms.modules.data.service | |||||
import com.ffii.tsms.modules.data.entity.Staff | |||||
import com.ffii.tsms.modules.data.entity.StaffRepository | |||||
import com.ffii.tsms.modules.user.entity.UserRepository | |||||
import com.ffii.tsms.modules.data.entity.PositionRepository | |||||
import com.ffii.tsms.modules.data.entity.CompanyRepository | |||||
import com.ffii.tsms.modules.data.entity.GradeRepository | |||||
import com.ffii.tsms.modules.data.entity.TeamRepository | |||||
import com.ffii.tsms.modules.data.entity.SkillRepository | |||||
import com.ffii.tsms.modules.data.entity.SalaryEffectiveRepository | |||||
import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||||
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||||
import com.ffii.tsms.modules.project.web.models.NewStaffRequest | |||||
// import com.ffii.tsms.modules.data.web.models.NewStaffRequest | |||||
import org.springframework.stereotype.Service | |||||
import com.ffii.core.support.JdbcDao; | |||||
import com.ffii.core.support.AbstractBaseEntityService; | |||||
@Service | |||||
public final class StaffsService( | |||||
private val staffRepository: StaffRepository, | |||||
private val userRepository: UserRepository, | |||||
private val positionRepository: PositionRepository, | |||||
private val companyRepository: CompanyRepository, | |||||
private val gradeRepository: GradeRepository, | |||||
private val teamRepository: TeamRepository, | |||||
private val skillRepository: SkillRepository, | |||||
private val salaryEffectiveRepository: SalaryEffectiveRepository, | |||||
private val departmentRepository: DepartmentRepository, | |||||
private val jdbcDao: JdbcDao, | |||||
) { | |||||
fun getTeamLeads(): List<Staff> { | |||||
// TODO: Replace with actual logic and make a projection instead of returning all fields | |||||
return staffRepository.findAll() | |||||
} | |||||
fun allStaff(): List<StaffSearchInfo> { | |||||
return staffRepository.findStaffSearchInfoBy(); | |||||
} | |||||
// fun fetchStaffList(args: Map<String, Any>): List<Map<String, Any>> { | |||||
// val sql = StringBuilder("select" | |||||
// + " s.*," | |||||
// + " date_format(s.created, '%Y-%m-%d') as created," | |||||
// + " date_format(s.departDate, '%Y-%m-%d') as departDate," | |||||
// + " date_format(s.joinDate, '%Y-%m-%d') as joinDate" | |||||
// + " from staff s" | |||||
// + " where s.deleted = false" | |||||
// ) | |||||
// if (args != null) { | |||||
// if (args.containsKey("staffId")) | |||||
// sql.append(" AND s.staffId = :staffId "); | |||||
// } | |||||
// return jdbcDao.queryForList(sql.toString(), args) | |||||
// } | |||||
fun saveStaff(req: NewStaffRequest): Staff { | |||||
val user = userRepository.findById(req.userId).orElseThrow() | |||||
val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() | |||||
val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() | |||||
val company = companyRepository.findById(req.companyId).orElseThrow() | |||||
val grade = gradeRepository.findById(req.gradeId).orElseThrow() | |||||
val team = teamRepository.findById(req.teamId).orElseThrow() | |||||
val skill = skillRepository.findById(req.skillSetId).orElseThrow() | |||||
val salaryEffective = salaryEffectiveRepository.findById(req.salaryEffId).orElseThrow() | |||||
val department = departmentRepository.findById(req.departmentId).orElseThrow() | |||||
// // TODO: Add tasks, milestones, allocated | |||||
val staff = Staff().apply { | |||||
joinDate = req.joinDate | |||||
name = req.name | |||||
staffId = req.staffId | |||||
phone1 = req.phone1 | |||||
phone2 = req.phone2 | |||||
email = req.email | |||||
emergContactName = req.emergContactName | |||||
emergContactPhone = req.emergContactPhone | |||||
employType = req.employType | |||||
departDate = req.departDate | |||||
departReason = req.departReason | |||||
remark = req.remark | |||||
this.user = user | |||||
this.currentPosition = currentPosition | |||||
this.joinPosition = joinPosition | |||||
this.company = company | |||||
this.grade = grade | |||||
this.team = team | |||||
this.skill = skill | |||||
this.salaryEffective = salaryEffective | |||||
this.department = department | |||||
} | |||||
return staffRepository.save(staff) | |||||
} | |||||
package com.ffii.tsms.modules.data.service | |||||
import com.ffii.tsms.modules.data.entity.Staff | |||||
import com.ffii.tsms.modules.data.entity.StaffRepository | |||||
import com.ffii.tsms.modules.user.entity.UserRepository | |||||
import com.ffii.tsms.modules.data.entity.PositionRepository | |||||
import com.ffii.tsms.modules.data.entity.CompanyRepository | |||||
import com.ffii.tsms.modules.data.entity.GradeRepository | |||||
import com.ffii.tsms.modules.data.entity.TeamRepository | |||||
import com.ffii.tsms.modules.data.entity.SkillRepository | |||||
import com.ffii.tsms.modules.data.entity.SalaryEffectiveRepository | |||||
import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||||
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||||
import com.ffii.tsms.modules.project.web.models.NewStaffRequest | |||||
// import com.ffii.tsms.modules.data.web.models.NewStaffRequest | |||||
import org.springframework.stereotype.Service | |||||
import com.ffii.core.support.JdbcDao; | |||||
import com.ffii.core.support.AbstractBaseEntityService; | |||||
@Service | |||||
public final class StaffsService( | |||||
private val staffRepository: StaffRepository, | |||||
private val userRepository: UserRepository, | |||||
private val positionRepository: PositionRepository, | |||||
private val companyRepository: CompanyRepository, | |||||
private val gradeRepository: GradeRepository, | |||||
private val teamRepository: TeamRepository, | |||||
private val skillRepository: SkillRepository, | |||||
private val salaryEffectiveRepository: SalaryEffectiveRepository, | |||||
private val departmentRepository: DepartmentRepository, | |||||
private val jdbcDao: JdbcDao, | |||||
) { | |||||
fun getTeamLeads(): List<StaffSearchInfo> { | |||||
// TODO: Replace with actual logic and make a projection instead of returning all fields | |||||
return staffRepository.findStaffSearchInfoBy() | |||||
} | |||||
fun allStaff(): List<StaffSearchInfo> { | |||||
return staffRepository.findStaffSearchInfoBy(); | |||||
} | |||||
// fun fetchStaffList(args: Map<String, Any>): List<Map<String, Any>> { | |||||
// val sql = StringBuilder("select" | |||||
// + " s.*," | |||||
// + " date_format(s.created, '%Y-%m-%d') as created," | |||||
// + " date_format(s.departDate, '%Y-%m-%d') as departDate," | |||||
// + " date_format(s.joinDate, '%Y-%m-%d') as joinDate" | |||||
// + " from staff s" | |||||
// + " where s.deleted = false" | |||||
// ) | |||||
// if (args != null) { | |||||
// if (args.containsKey("staffId")) | |||||
// sql.append(" AND s.staffId = :staffId "); | |||||
// } | |||||
// return jdbcDao.queryForList(sql.toString(), args) | |||||
// } | |||||
fun saveStaff(req: NewStaffRequest): Staff { | |||||
val user = userRepository.findById(req.userId).orElseThrow() | |||||
val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() | |||||
val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() | |||||
val company = companyRepository.findById(req.companyId).orElseThrow() | |||||
val grade = gradeRepository.findById(req.gradeId).orElseThrow() | |||||
val team = teamRepository.findById(req.teamId).orElseThrow() | |||||
val skill = skillRepository.findById(req.skillSetId).orElseThrow() | |||||
val salaryEffective = salaryEffectiveRepository.findById(req.salaryEffId).orElseThrow() | |||||
val department = departmentRepository.findById(req.departmentId).orElseThrow() | |||||
// // TODO: Add tasks, milestones, allocated | |||||
val staff = Staff().apply { | |||||
joinDate = req.joinDate | |||||
name = req.name | |||||
staffId = req.staffId | |||||
phone1 = req.phone1 | |||||
phone2 = req.phone2 | |||||
email = req.email | |||||
emergContactName = req.emergContactName | |||||
emergContactPhone = req.emergContactPhone | |||||
employType = req.employType | |||||
departDate = req.departDate | |||||
departReason = req.departReason | |||||
remark = req.remark | |||||
this.user = user | |||||
this.currentPosition = currentPosition | |||||
this.joinPosition = joinPosition | |||||
this.company = company | |||||
this.grade = grade | |||||
this.team = team | |||||
this.skill = skill | |||||
this.salaryEffective = salaryEffective | |||||
this.department = department | |||||
} | |||||
return staffRepository.save(staff) | |||||
} | |||||
} | } |
@@ -1,48 +1,43 @@ | |||||
package com.ffii.tsms.modules.data.web | |||||
import com.ffii.tsms.modules.data.entity.Staff | |||||
import com.ffii.tsms.modules.data.service.StaffsService | |||||
import org.springframework.web.bind.annotation.GetMapping | |||||
import org.springframework.web.bind.annotation.RequestMapping | |||||
import org.springframework.web.bind.annotation.RestController | |||||
import org.springframework.web.bind.annotation.PostMapping | |||||
import org.springframework.web.bind.annotation.RequestBody | |||||
import com.ffii.tsms.modules.project.web.models.NewStaffRequest | |||||
import jakarta.validation.Valid | |||||
import org.springframework.web.bind.annotation.* | |||||
import jakarta.servlet.http.HttpServletRequest; | |||||
import com.ffii.core.utils.CriteriaArgsBuilder; | |||||
import com.ffii.core.response.IdRes; | |||||
import com.ffii.core.response.RecordsRes; | |||||
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||||
@RestController | |||||
@RequestMapping("/staffs") | |||||
class StaffsController(private val staffsService: StaffsService) { | |||||
@GetMapping("/teamLeads") | |||||
fun teamLeads(): List<Staff> { | |||||
return staffsService.getTeamLeads() | |||||
} | |||||
@GetMapping | |||||
fun allStaff(): List<StaffSearchInfo> { | |||||
return staffsService.allStaff() | |||||
} | |||||
@GetMapping("/list") | |||||
fun list(): List<Staff> { | |||||
return staffsService.getTeamLeads() | |||||
} | |||||
@PostMapping("/new") | |||||
fun saveStaff(@Valid @RequestBody newStaff: NewStaffRequest): Staff { | |||||
return staffsService.saveStaff(newStaff) | |||||
} | |||||
// @GetMapping("/newlist") | |||||
// fun list(request: HttpServletRequest): RecordsRes<Map<String, Any>> { | |||||
// return RecordsRes(staffsService.fetchStaffList( | |||||
// CriteriaArgsBuilder.withRequest(request) | |||||
// .addString("staffId") | |||||
// .build() | |||||
// )) | |||||
// } | |||||
package com.ffii.tsms.modules.data.web | |||||
import com.ffii.tsms.modules.data.entity.Staff | |||||
import com.ffii.tsms.modules.data.service.StaffsService | |||||
import org.springframework.web.bind.annotation.GetMapping | |||||
import org.springframework.web.bind.annotation.RequestMapping | |||||
import org.springframework.web.bind.annotation.RestController | |||||
import org.springframework.web.bind.annotation.PostMapping | |||||
import org.springframework.web.bind.annotation.RequestBody | |||||
import com.ffii.tsms.modules.project.web.models.NewStaffRequest | |||||
import jakarta.validation.Valid | |||||
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||||
@RestController | |||||
@RequestMapping("/staffs") | |||||
class StaffsController(private val staffsService: StaffsService) { | |||||
@GetMapping("/teamLeads") | |||||
fun teamLeads(): List<StaffSearchInfo> { | |||||
return staffsService.getTeamLeads() | |||||
} | |||||
@GetMapping | |||||
fun allStaff(): List<StaffSearchInfo> { | |||||
return staffsService.allStaff() | |||||
} | |||||
// @GetMapping("/list") | |||||
// fun list(): List<Staff> { | |||||
// return staffsService.getTeamLeads() | |||||
// } | |||||
@PostMapping("/new") | |||||
fun saveStaff(@Valid @RequestBody newStaff: NewStaffRequest): Staff { | |||||
return staffsService.saveStaff(newStaff) | |||||
} | |||||
// @GetMapping("/newlist") | |||||
// fun list(request: HttpServletRequest): RecordsRes<Map<String, Any>> { | |||||
// return RecordsRes(staffsService.fetchStaffList( | |||||
// CriteriaArgsBuilder.withRequest(request) | |||||
// .addString("staffId") | |||||
// .build() | |||||
// )) | |||||
// } | |||||
} | } |
@@ -1,8 +1,7 @@ | |||||
package com.ffii.tsms.modules.project.entity | package com.ffii.tsms.modules.project.entity | ||||
import com.ffii.core.entity.BaseEntity | import com.ffii.core.entity.BaseEntity | ||||
import com.ffii.tsms.modules.data.entity.Customer | |||||
import com.ffii.tsms.modules.data.entity.Staff | |||||
import com.ffii.tsms.modules.data.entity.* | |||||
import jakarta.persistence.* | import jakarta.persistence.* | ||||
import jakarta.validation.constraints.NotNull | import jakarta.validation.constraints.NotNull | ||||
import java.time.LocalDate | import java.time.LocalDate | ||||
@@ -60,4 +59,39 @@ open class Project : BaseEntity<Long>() { | |||||
@Column(name = "billStatus") | @Column(name = "billStatus") | ||||
open var billStatus: Boolean? = null | open var billStatus: Boolean? = null | ||||
@Column(name = "expectedTotalFee") | |||||
open var expectedTotalFee: Double? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "serviceTypeId") | |||||
open var serviceType: ServiceType? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "fundingTypeId") | |||||
open var fundingType: FundingType? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "contractTypeId") | |||||
open var contractType: ContractType? = null | |||||
@ManyToOne | |||||
@JoinColumn(name = "locationId") | |||||
open var location: Location? = null | |||||
@ManyToMany | |||||
@JoinTable( | |||||
name = "project_buildingTypes", | |||||
joinColumns = [JoinColumn(name = "projectId")], | |||||
inverseJoinColumns = [JoinColumn(name = "buildingTypesId")] | |||||
) | |||||
open var buildingTypes: MutableSet<BuildingType> = mutableSetOf() | |||||
@ManyToMany | |||||
@JoinTable( | |||||
name = "project_workNatures", | |||||
joinColumns = [JoinColumn(name = "projectId")], | |||||
inverseJoinColumns = [JoinColumn(name = "workNaturesId")] | |||||
) | |||||
open var workNatures: MutableSet<WorkNature> = mutableSetOf() | |||||
} | } |
@@ -1,7 +1,7 @@ | |||||
package com.ffii.tsms.modules.project.entity; | package com.ffii.tsms.modules.project.entity; | ||||
import com.ffii.core.support.AbstractRepository | import com.ffii.core.support.AbstractRepository | ||||
import com.ffii.tsms.modules.data.entity.projections.ProjectSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | |||||
interface ProjectRepository : AbstractRepository<Project, Long> { | interface ProjectRepository : AbstractRepository<Project, Long> { | ||||
fun findProjectSearchInfoBy(): List<ProjectSearchInfo> | fun findProjectSearchInfoBy(): List<ProjectSearchInfo> |
@@ -1,4 +1,4 @@ | |||||
package com.ffii.tsms.modules.data.entity.projections | |||||
package com.ffii.tsms.modules.project.entity.projections | |||||
import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||
@@ -1,14 +1,13 @@ | |||||
package com.ffii.tsms.modules.project.service | package com.ffii.tsms.modules.project.service | ||||
import com.ffii.tsms.modules.data.entity.StaffRepository | import com.ffii.tsms.modules.data.entity.StaffRepository | ||||
import com.ffii.tsms.modules.data.entity.projections.ProjectSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | |||||
import com.ffii.tsms.modules.data.service.CustomerService | import com.ffii.tsms.modules.data.service.CustomerService | ||||
import com.ffii.tsms.modules.project.entity.Project | import com.ffii.tsms.modules.project.entity.Project | ||||
import com.ffii.tsms.modules.project.entity.ProjectCategory | import com.ffii.tsms.modules.project.entity.ProjectCategory | ||||
import com.ffii.tsms.modules.project.entity.ProjectCategoryRepository | import com.ffii.tsms.modules.project.entity.ProjectCategoryRepository | ||||
import com.ffii.tsms.modules.project.entity.ProjectRepository | import com.ffii.tsms.modules.project.entity.ProjectRepository | ||||
import com.ffii.tsms.modules.project.web.models.NewProjectRequest | import com.ffii.tsms.modules.project.web.models.NewProjectRequest | ||||
import com.ffii.tsms.modules.project.web.models.SaveCustomerRequest | |||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
@Service | @Service | ||||
@@ -1,6 +1,6 @@ | |||||
package com.ffii.tsms.modules.project.web | package com.ffii.tsms.modules.project.web | ||||
import com.ffii.tsms.modules.data.entity.projections.ProjectSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | |||||
import com.ffii.tsms.modules.project.entity.Project | import com.ffii.tsms.modules.project.entity.Project | ||||
import com.ffii.tsms.modules.project.entity.ProjectCategory | import com.ffii.tsms.modules.project.entity.ProjectCategory | ||||
import com.ffii.tsms.modules.project.service.ProjectsService | import com.ffii.tsms.modules.project.service.ProjectsService | ||||
@@ -0,0 +1,27 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:service_type | |||||
CREATE TABLE service_type ( | |||||
id INT NOT NULL AUTO_INCREMENT, | |||||
name VARCHAR(255) NOT NULL, | |||||
CONSTRAINT pk_service_type PRIMARY KEY (id) | |||||
); | |||||
INSERT | |||||
INTO | |||||
service_type | |||||
(name) | |||||
VALUES | |||||
('Audit'), | |||||
('Cost Management'), | |||||
('Direct Contract'), | |||||
('Due Diligence'), | |||||
('Estimate'), | |||||
('Expert Report'), | |||||
('Feasibility'), | |||||
('Final Account'), | |||||
('Full QS Services'), | |||||
('Joint Venture'), | |||||
('Measurement'), | |||||
('Post Contract'), | |||||
('Sub-Consultants'); |
@@ -0,0 +1,17 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:funding_type | |||||
CREATE TABLE funding_type ( | |||||
id INT NOT NULL AUTO_INCREMENT, | |||||
name VARCHAR(255) NOT NULL, | |||||
CONSTRAINT pk_funding_type PRIMARY KEY (id) | |||||
); | |||||
INSERT | |||||
INTO | |||||
funding_type | |||||
(name) | |||||
VALUES | |||||
('Government'), | |||||
('Private'), | |||||
('Subvented'); |
@@ -0,0 +1,19 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:contract_type | |||||
CREATE TABLE contract_type ( | |||||
id INT NOT NULL AUTO_INCREMENT, | |||||
name VARCHAR(255) NOT NULL, | |||||
CONSTRAINT pk_contract_type PRIMARY KEY (id) | |||||
); | |||||
INSERT | |||||
INTO | |||||
contract_type | |||||
(name) | |||||
VALUES | |||||
('Bills of Quantities'), | |||||
('Design and Build'), | |||||
('Schedule of Rate'), | |||||
('Specification Drawings'), | |||||
('Term Contract'); |
@@ -0,0 +1,18 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:location | |||||
CREATE TABLE location ( | |||||
id INT NOT NULL AUTO_INCREMENT, | |||||
name VARCHAR(255) NOT NULL, | |||||
CONSTRAINT pk_location PRIMARY KEY (id) | |||||
); | |||||
INSERT | |||||
INTO | |||||
location | |||||
(name) | |||||
VALUES | |||||
('Hong Kong'), | |||||
('China'), | |||||
('Macau'), | |||||
('Others'); |
@@ -0,0 +1,30 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:building_type | |||||
CREATE TABLE building_type ( | |||||
id INT NOT NULL AUTO_INCREMENT, | |||||
name VARCHAR(255) NOT NULL, | |||||
CONSTRAINT pk_building_type PRIMARY KEY (id) | |||||
); | |||||
INSERT | |||||
INTO | |||||
building_type | |||||
(name) | |||||
VALUES | |||||
('Residential'), | |||||
('Office'), | |||||
('Commercial'), | |||||
('Hotel & Resort'), | |||||
('Entertainment & Leisure'), | |||||
('Hospital'), | |||||
('School'), | |||||
('Post Secondary College'), | |||||
('Industrial'), | |||||
('Data Center'), | |||||
('Open Space'), | |||||
('Civil Engineering'), | |||||
('Electricity'), | |||||
('Public Transportation'), | |||||
('Retail'), | |||||
('Others'); |
@@ -0,0 +1,21 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:work_nature | |||||
CREATE TABLE work_nature ( | |||||
id INT NOT NULL AUTO_INCREMENT, | |||||
name VARCHAR(255) NOT NULL, | |||||
CONSTRAINT pk_work_nature PRIMARY KEY (id) | |||||
); | |||||
INSERT | |||||
INTO | |||||
work_nature | |||||
(name) | |||||
VALUES | |||||
('New Capital Works'), | |||||
('Maintenance Term Contract'), | |||||
('Addition and Alteration'), | |||||
('Civil Works'), | |||||
('Fitting Out Works'), | |||||
('Revitalization'), | |||||
('Others'); |
@@ -0,0 +1,10 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:update_project_category | |||||
UPDATE | |||||
project_category | |||||
SET | |||||
name = 'Awarded Project' | |||||
WHERE | |||||
id = 2 | |||||
; |
@@ -0,0 +1,4 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:update_project_expected_total_fee | |||||
ALTER TABLE project ADD expectedTotalFee DOUBLE NULL; |
@@ -0,0 +1,32 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset wayne:update_project_types | |||||
ALTER TABLE project ADD serviceTypeId INT NULL, ADD fundingTypeId INT NULL, ADD contractTypeId INT NULL, ADD locationId INT NULL; | |||||
ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_CONTRACTTYPEID FOREIGN KEY (contractTypeId) REFERENCES contract_type (id); | |||||
ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_FUNDINGTYPEID FOREIGN KEY (fundingTypeId) REFERENCES funding_type (id); | |||||
ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_LOCATIONID FOREIGN KEY (locationId) REFERENCES location (id); | |||||
ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_SERVICETYPEID FOREIGN KEY (serviceTypeId) REFERENCES service_type (id); | |||||
CREATE TABLE project_buildingTypes ( | |||||
buildingTypesId INT NOT NULL, | |||||
projectId INT NOT NULL, | |||||
CONSTRAINT pk_project_buildingtypes PRIMARY KEY (buildingTypesId, projectId) | |||||
); | |||||
CREATE TABLE project_workNatures ( | |||||
projectId INT NOT NULL, | |||||
workNaturesId INT NOT NULL, | |||||
CONSTRAINT pk_project_worknatures PRIMARY KEY (projectId, workNaturesId) | |||||
); | |||||
ALTER TABLE project_workNatures ADD CONSTRAINT fk_prowor_on_project FOREIGN KEY (projectId) REFERENCES project (id); | |||||
ALTER TABLE project_workNatures ADD CONSTRAINT fk_prowor_on_work_nature FOREIGN KEY (workNaturesId) REFERENCES work_nature (id); | |||||
ALTER TABLE project_buildingTypes ADD CONSTRAINT fk_probui_on_building_type FOREIGN KEY (buildingTypesId) REFERENCES building_type (id); | |||||
ALTER TABLE project_buildingTypes ADD CONSTRAINT fk_probui_on_project FOREIGN KEY (projectId) REFERENCES project (id); |