import { GeneralService } from '../share/generalservice.js'

export class ProjectAddService {

  constructor() {
    this.generalService = new GeneralService()
  }

  async getProjectAdd(database, name) {
    const sql = `
      SELECT 
        prjseq,
        prjnam
      FROM ${database}.prjmst
      WHERE prjnam = $1
  `
    const params = [name]
    const result = await this.generalService.executeQueryParam(database, sql, params);
    return result
  }

  async getLatestProjectSeq(database) {
    const sql = `
      SELECT 
        prjseq
      FROM ${database}.prjmst
      WHERE prjseq=(SELECT max(prjseq) FROM ${database}.prjmst)
    `

    const params = []
    const result = await this.generalService.executeQueryParam(database, sql, params);
    return result
  }
}