From 82ef3ebde0611c00e82406e250706a0bbd50110c Mon Sep 17 00:00:00 2001 From: "xiaozhe.ma" Date: Tue, 20 Aug 2024 14:49:35 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E9=81=B8=E6=8A=9EUI=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/core/config.py | 4 +- backend/app/db/crud.py | 28 +++++- backend/app/db/models.py | 12 ++- backend/app/db/schemas.py | 4 +- frontend/src/components/ActionSelect.vue | 105 +++++++++++++++++---- frontend/src/components/left/EventTree.vue | 9 +- frontend/src/pages/FlowChart.vue | 8 +- frontend/src/stores/flowEditor.ts | 3 + 8 files changed, 146 insertions(+), 27 deletions(-) diff --git a/backend/app/core/config.py b/backend/app/core/config.py index c644f96..5ee1e80 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -5,8 +5,10 @@ import base64 PROJECT_NAME = "KintoneAppBuilder" #SQLALCHEMY_DATABASE_URI = "postgres://maxz64:m@xz1205@alicornkintone.postgres.database.azure.com/postgres" -SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@kintonetooldb.postgres.database.azure.com/postgres" +#SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@kintonetooldb.postgres.database.azure.com/postgres" #SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@kintonetooldb.postgres.database.azure.com/unittest" +SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@kintonetooldb.postgres.database.azure.com/dev" +#SQLALCHEMY_DATABASE_URI = "postgres://kabAdmin:P@ssw0rd!@ktune-prod-db.postgres.database.azure.com/postgres" API_V1_STR = "/k/v1" API_V1_AUTH_KEY = "X-Cybozu-Authorization" diff --git a/backend/app/db/crud.py b/backend/app/db/crud.py index 2101ad9..d99c5b5 100644 --- a/backend/app/db/crud.py +++ b/backend/app/db/crud.py @@ -281,9 +281,35 @@ def get_events(db: Session): raise HTTPException(status_code=404, detail="Data not found") return events +def get_category(db:Session): + categorys=db.query(models.Category).all() + return categorys + def get_eventactions(db: Session,eventid: str): #eveactions = db.query(models.Action).join(models.EventAction,models.EventAction.actionid == models.Action.id ).join(models.Event,models.Event.id == models.EventAction.eventid).filter(models.Event.eventid == eventid).all() - eveactions = db.query(models.Action).join(models.EventAction,models.EventAction.actionid != models.Action.id and models.EventAction.eventid == eventid ).join(models.Event,models.Event.id == models.EventAction.eventid).filter(models.Event.eventid == eventid).all() + #category = get_category(db) + blackactions = ( + db.query(models.EventAction.actionid) + .filter(models.EventAction.eventid == eventid) + .subquery() + ) + eveactions = ( + db.query( + models.Action.id, + models.Action.name, + models.Action.title, + models.Action.subtitle, + models.Action.outputpoints, + models.Action.property, + models.Action.categoryid, + models.Action.nosort, + models.Category.categoryname) + .join(models.Category,models.Category.id == models.Action.categoryid) + .filter(models.Action.id.notin_(blackactions)) + .order_by(models.Category.nosort,models.Action.nosort) + .all() + ) + if not eveactions: raise HTTPException(status_code=404, detail="Data not found") return eveactions diff --git a/backend/app/db/models.py b/backend/app/db/models.py index ed5bae9..b49b0d3 100644 --- a/backend/app/db/models.py +++ b/backend/app/db/models.py @@ -42,6 +42,8 @@ class Action(Base): subtitle = Column(String(500)) outputpoints = Column(String) property = Column(String) + categoryid = Column(Integer,ForeignKey("category.id")) + nosort = Column(Integer) class Flow(Base): __tablename__ = "flow" @@ -95,7 +97,7 @@ class Event(Base): class EventAction(Base): __tablename__ = "eventaction" - eventid = Column(Integer,ForeignKey("event.id")) + eventid = Column(String(100),ForeignKey("event.eventid")) actionid = Column(Integer,ForeignKey("action.id")) @@ -115,4 +117,10 @@ class KintoneFormat(Base): typecolumn =Column(Integer) codecolumn =Column(Integer) field = Column(String(5000)) - trueformat = Column(String(10)) \ No newline at end of file + trueformat = Column(String(10)) + +class Category(Base): + __tablename__ = "category" + + categoryname = Column(String(20)) + nosort = Column(Integer) \ No newline at end of file diff --git a/backend/app/db/schemas.py b/backend/app/db/schemas.py index 08beedf..e03eea5 100644 --- a/backend/app/db/schemas.py +++ b/backend/app/db/schemas.py @@ -89,7 +89,9 @@ class Action(BaseModel): subtitle: str = None outputpoints: str = None property: str = None - + categoryid: int = None + nosort: int + categoryname : str =None class Config: orm_mode = True diff --git a/frontend/src/components/ActionSelect.vue b/frontend/src/components/ActionSelect.vue index 5e80ea9..3a38731 100644 --- a/frontend/src/components/ActionSelect.vue +++ b/frontend/src/components/ActionSelect.vue @@ -3,20 +3,46 @@
- - + + +