add active ,onwer in domain
This commit is contained in:
@@ -277,7 +277,7 @@ def get_flows_by_app(db: Session,domainurl: str, appid: str):
|
||||
raise Exception("Data not found")
|
||||
return flows
|
||||
|
||||
def create_domain(db: Session, domain: schemas.DomainBase,userid:int):
|
||||
def create_domain(db: Session, domain: schemas.DomainIn,userid:int):
|
||||
domain.encrypt_kintonepwd()
|
||||
db_domain = models.Domain(
|
||||
tenantid = domain.tenantid,
|
||||
@@ -286,7 +286,8 @@ def create_domain(db: Session, domain: schemas.DomainBase,userid:int):
|
||||
kintoneuser=domain.kintoneuser,
|
||||
kintonepwd=domain.kintonepwd,
|
||||
createuserid = userid,
|
||||
updateuserid = userid
|
||||
updateuserid = userid,
|
||||
ownerid = domain.ownerid
|
||||
)
|
||||
db.add(db_domain)
|
||||
db.flush()
|
||||
@@ -305,7 +306,7 @@ def delete_domain(db: Session,id: int):
|
||||
|
||||
|
||||
def edit_domain(
|
||||
db: Session, domain: schemas.DomainBase,userid:int
|
||||
db: Session, domain: schemas.DomainIn,userid:int
|
||||
) -> schemas.Domain:
|
||||
domain.encrypt_kintonepwd()
|
||||
db_domain = db.query(models.Domain).get(domain.id)
|
||||
@@ -317,7 +318,7 @@ def edit_domain(
|
||||
db_domain.kintoneuser=domain.kintoneuser
|
||||
db_domain.kintonepwd = domain.kintonepwd
|
||||
db_domain.updateuserid = userid
|
||||
db_domain.update_time = datetime.now
|
||||
db_domain.ownerid = domain.ownerid
|
||||
db.add(db_domain)
|
||||
db.commit()
|
||||
db.refresh(db_domain)
|
||||
|
||||
@@ -158,8 +158,11 @@ class Domain(Base):
|
||||
return decrypted_pwd
|
||||
createuserid = Column(Integer,ForeignKey("user.id"))
|
||||
updateuserid = Column(Integer,ForeignKey("user.id"))
|
||||
ownerid = Column(Integer,ForeignKey("user.id"))
|
||||
createuser = relationship('User',foreign_keys=[createuserid])
|
||||
updateuser = relationship('User',foreign_keys=[updateuserid])
|
||||
owner = relationship('User',foreign_keys=[ownerid])
|
||||
is_active = Column(Boolean, default=True)
|
||||
|
||||
class UserDomain(Base):
|
||||
__tablename__ = "userdomain"
|
||||
|
||||
@@ -143,13 +143,15 @@ class Flow(Base):
|
||||
class ConfigDict:
|
||||
orm_mode = True
|
||||
|
||||
class DomainBase(BaseModel):
|
||||
class DomainIn(BaseModel):
|
||||
id: int
|
||||
tenantid: str
|
||||
name: str
|
||||
url: str
|
||||
kintoneuser: str
|
||||
kintonepwd: str
|
||||
is_active: bool
|
||||
ownerid:int
|
||||
|
||||
def encrypt_kintonepwd(self):
|
||||
encrypted_pwd = chacha20Encrypt(self.kintonepwd)
|
||||
@@ -162,6 +164,8 @@ class Domain(Base):
|
||||
url: str
|
||||
kintoneuser: str
|
||||
kintonepwd: str
|
||||
is_active: bool
|
||||
owner:UserOut
|
||||
class ConfigDict:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user