feat: tkpurchase 시스템 Phase 1 - 협력업체 마스터 + 당일 방문 관리
신규 독립 시스템 tkpurchase (구매/방문 관리) 구축: - 협력업체 CRUD + 소속 작업자 관리 (마스터 데이터 소유) - 당일 방문 등록/체크인/체크아웃 + 일괄 마감 - 업체 자동완성, CSV 내보내기, 집계 통계 - 자정 자동 체크아웃 (node-cron) - tkuser 협력업체 읽기 전용 탭 + 권한 그리드(tkpurchase-perms) 추가 - docker-compose에 tkpurchase-api/web 서비스 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
29
user-management/api/models/partnerModel.js
Normal file
29
user-management/api/models/partnerModel.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { getPool } = require('./userModel');
|
||||
|
||||
async function findAll({ search, is_active } = {}) {
|
||||
const db = getPool();
|
||||
let sql = 'SELECT * FROM partner_companies WHERE 1=1';
|
||||
const params = [];
|
||||
if (is_active !== undefined) { sql += ' AND is_active = ?'; params.push(is_active); }
|
||||
if (search) { sql += ' AND (company_name LIKE ? OR business_number LIKE ?)'; params.push(`%${search}%`, `%${search}%`); }
|
||||
sql += ' ORDER BY company_name';
|
||||
const [rows] = await db.query(sql, params);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function findById(id) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query('SELECT * FROM partner_companies WHERE id = ?', [id]);
|
||||
return rows[0] || null;
|
||||
}
|
||||
|
||||
async function findWorkersByCompany(companyId) {
|
||||
const db = getPool();
|
||||
const [rows] = await db.query(
|
||||
'SELECT * FROM partner_workers WHERE company_id = ? ORDER BY is_team_leader DESC, worker_name',
|
||||
[companyId]
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
module.exports = { findAll, findById, findWorkersByCompany };
|
||||
Reference in New Issue
Block a user