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:
39
user-management/api/controllers/partnerController.js
Normal file
39
user-management/api/controllers/partnerController.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const partnerModel = require('../models/partnerModel');
|
||||
|
||||
async function list(req, res) {
|
||||
try {
|
||||
const { search, is_active } = req.query;
|
||||
const rows = await partnerModel.findAll({
|
||||
search,
|
||||
is_active: is_active !== undefined ? is_active === 'true' || is_active === '1' : undefined
|
||||
});
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('Partner list error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
async function getById(req, res) {
|
||||
try {
|
||||
const company = await partnerModel.findById(req.params.id);
|
||||
if (!company) return res.status(404).json({ success: false, error: '업체를 찾을 수 없습니다' });
|
||||
const workers = await partnerModel.findWorkersByCompany(req.params.id);
|
||||
res.json({ success: true, data: { ...company, workers } });
|
||||
} catch (err) {
|
||||
console.error('Partner get error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
async function listWorkers(req, res) {
|
||||
try {
|
||||
const rows = await partnerModel.findWorkersByCompany(req.params.id);
|
||||
res.json({ success: true, data: rows });
|
||||
} catch (err) {
|
||||
console.error('Workers list error:', err);
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { list, getById, listWorkers };
|
||||
Reference in New Issue
Block a user