현재 최신 버전에서는 제한적으로만 플러그인을 개발할 수 있습니다.
백엔드를 참고하여 자신의 환경에 맞는 백엔드를 설치해주세요
git clone https://github.com/PDA-PRO/COCO_Front_End.git
cd COCO_Front_End/coco
npm install
npm start
백엔드 설치시 생성된 plugin 폴더의 interfase.py를 구현하여 플러그인을 개발합니다.
- 원하는 이름의 플러그인 폴더를
plugin폴더에 생성해주세요
mkdir ./new_plugin- 새롭게 생성된 플러그인 폴더에
new_plugin_templat폴더에 있는 모든 파일을 옮겨주세요
config.py: 플러그인의 설정값을 관리합니다.requirements.txt: 플러그인의 종속패키지를 관리합니다.main.py: 플러그인의 동작, db, 엔드포인드를 관리합니다.README.md: 플러그인의 간략한 소개문입니다.
-
main.py를 구현합니다.-
플러그인 db 조작
- Plugin.read_all(cls,db_cursor:DBCursor)->list
ai 플러그인 db 저장소에서 모든 튜플 조회 params - db_cursor : db 조작을 위한 curosor사용예시
- Plugin.read_all(db_cursor)
- Plugin.read(cls,db_cursor:DBCursor,**key):
ai 플러그인 db 저장소에서 특정 튜플 조회 params - db_cursor : db 조작을 위한 curosor - key : 조회할 튜플의 모든 키값, 만약 키가 2개라면 2개의 키의 값 필요사용예시
- Plugin.read(db_cursor,sub_id=2)#키네임이 sub_id이고 찾는 튜플의 키값이 2인경우 - Plugin.read(db_cursor,status=2,id=2)#키네임이 sub_id,id이고 찾는 튜플의 키값이 2,2인경우
- Plugin.create(cls,db_cursor:DBCursor,tableModel_obj):
ai 플러그인 db 저장소에서 튜플 생성 params - db_cursor : db 조작을 위한 curosor - tuple : Plugin.TableModel 객체사용예시
new_tuple=Plugin.TableModel(sub_id=sub_id,status=4) Plugin.create(db_cursor,new_wpc)
-
기존 coco db 조작
-
endpoint 추가
아래와 같이endpoint접두사를 가진 새로운static함수를 클래스 내부에 만들경우router_path/method의 엔드포인트가 생성됩니다.@staticmethod def endpoint_method(): pass
-
endpoint 동적 on/off
아래와 같이 endpoint_method의 상단에Plugin.enable_onoff를 추가하여 동적 on/off를 적용합니다.@staticmethod def endpoint_method(): Plugin.enable_onoff(db_cursor)
-
React JS를 활용하여 컴포넌트를 개발하고 백엔드 API와 연동합니다.