sso_users.user_id를 단일 식별자로 통합. JWT에서 worker_id 제거, department_id/is_production 추가. 백엔드 15개 모델, 11개 컨트롤러, 4개 서비스, 7개 라우트, 프론트엔드 32+ JS/11+ HTML 변환. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
228 lines
6.5 KiB
JavaScript
228 lines
6.5 KiB
JavaScript
/**
|
|
* @swagger
|
|
* tags:
|
|
* name: Workers
|
|
* description: 작업자 관리 API
|
|
*/
|
|
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const workerController = require('../controllers/workerController');
|
|
|
|
/**
|
|
* @swagger
|
|
* /api/workers:
|
|
* post:
|
|
* tags: [Workers]
|
|
* summary: 작업자 생성
|
|
* description: 새로운 작업자를 생성합니다.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* required:
|
|
* - worker_name
|
|
* properties:
|
|
* worker_name:
|
|
* type: string
|
|
* example: "김철수"
|
|
* position:
|
|
* type: string
|
|
* example: "용접공"
|
|
* department:
|
|
* type: string
|
|
* example: "생산부"
|
|
* phone:
|
|
* type: string
|
|
* example: "010-1234-5678"
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* example: "worker@technicalkorea.com"
|
|
* responses:
|
|
* 201:
|
|
* description: 작업자 생성 성공
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/SuccessResponse'
|
|
* 400:
|
|
* description: 잘못된 요청
|
|
* 401:
|
|
* description: 인증 필요
|
|
* 500:
|
|
* description: 서버 오류
|
|
* get:
|
|
* tags: [Workers]
|
|
* summary: 전체 작업자 조회
|
|
* description: 모든 작업자 목록을 조회합니다.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* 200:
|
|
* description: 작업자 목록 조회 성공
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* success:
|
|
* type: boolean
|
|
* example: true
|
|
* message:
|
|
* type: string
|
|
* example: "작업자 목록 조회 성공"
|
|
* data:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Worker'
|
|
* meta:
|
|
* type: object
|
|
* properties:
|
|
* count:
|
|
* type: integer
|
|
* example: 10
|
|
* 401:
|
|
* description: 인증 필요
|
|
* 500:
|
|
* description: 서버 오류
|
|
*/
|
|
router.post('/', workerController.createWorker);
|
|
router.get('/', workerController.getAllWorkers);
|
|
|
|
/**
|
|
* @swagger
|
|
* /api/workers/{user_id}:
|
|
* get:
|
|
* tags: [Workers]
|
|
* summary: 특정 작업자 조회
|
|
* description: ID로 특정 작업자 정보를 조회합니다.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: user_id
|
|
* required: true
|
|
* schema:
|
|
* type: integer
|
|
* description: 작업자 ID
|
|
* responses:
|
|
* 200:
|
|
* description: 작업자 조회 성공
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* success:
|
|
* type: boolean
|
|
* example: true
|
|
* message:
|
|
* type: string
|
|
* example: "작업자 조회 성공"
|
|
* data:
|
|
* $ref: '#/components/schemas/Worker'
|
|
* 400:
|
|
* description: 잘못된 작업자 ID
|
|
* 401:
|
|
* description: 인증 필요
|
|
* 404:
|
|
* description: 작업자를 찾을 수 없음
|
|
* 500:
|
|
* description: 서버 오류
|
|
* put:
|
|
* tags: [Workers]
|
|
* summary: 작업자 정보 수정
|
|
* description: 작업자 정보를 수정합니다.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: user_id
|
|
* required: true
|
|
* schema:
|
|
* type: integer
|
|
* description: 작업자 ID
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* worker_name:
|
|
* type: string
|
|
* example: "김철수"
|
|
* position:
|
|
* type: string
|
|
* example: "용접공"
|
|
* department:
|
|
* type: string
|
|
* example: "생산부"
|
|
* phone:
|
|
* type: string
|
|
* example: "010-1234-5678"
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* example: "worker@technicalkorea.com"
|
|
* responses:
|
|
* 200:
|
|
* description: 작업자 수정 성공
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/SuccessResponse'
|
|
* 400:
|
|
* description: 잘못된 요청
|
|
* 401:
|
|
* description: 인증 필요
|
|
* 404:
|
|
* description: 작업자를 찾을 수 없음
|
|
* 500:
|
|
* description: 서버 오류
|
|
* delete:
|
|
* tags: [Workers]
|
|
* summary: 작업자 삭제
|
|
* description: 작업자를 삭제합니다.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: user_id
|
|
* required: true
|
|
* schema:
|
|
* type: integer
|
|
* description: 작업자 ID
|
|
* responses:
|
|
* 200:
|
|
* description: 작업자 삭제 성공
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* success:
|
|
* type: boolean
|
|
* example: true
|
|
* message:
|
|
* type: string
|
|
* example: "작업자가 성공적으로 삭제되었습니다."
|
|
* 400:
|
|
* description: 잘못된 작업자 ID
|
|
* 401:
|
|
* description: 인증 필요
|
|
* 404:
|
|
* description: 작업자를 찾을 수 없음
|
|
* 500:
|
|
* description: 서버 오류
|
|
*/
|
|
router.get('/:user_id', workerController.getWorkerById);
|
|
router.put('/:user_id', workerController.updateWorker);
|
|
router.delete('/:user_id', workerController.removeWorker);
|
|
|
|
module.exports = router; |