-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
910 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
@File : host_api.py | ||
@Date : 2023-07-29 | ||
""" | ||
from flask import request, g | ||
|
||
from domain_admin.model.host_model import HostModel | ||
|
||
|
||
def add_host(): | ||
current_user_id = g.user_id | ||
|
||
host = request.json['host'] | ||
user = request.json['user'] | ||
password = request.json['password'] | ||
|
||
row = HostModel.create( | ||
user_id=current_user_id, | ||
host=host, | ||
user=user, | ||
password=password, | ||
) | ||
|
||
return row | ||
|
||
|
||
def update_host_by_id(): | ||
current_user_id = g.user_id | ||
|
||
host_id = request.json['host_id'] | ||
host = request.json['host'] | ||
user = request.json['user'] | ||
password = request.json['password'] | ||
|
||
HostModel.update( | ||
host=host, | ||
user=user, | ||
password=password, | ||
).where( | ||
HostModel.id == host_id | ||
).execute() | ||
|
||
def get_host_by_id(): | ||
host_id = request.json['host_id'] | ||
|
||
return HostModel.get_by_id(host_id) | ||
|
||
def get_host_list(): | ||
""" | ||
主机列表 | ||
:return: | ||
""" | ||
|
||
current_user_id = g.user_id | ||
|
||
page = request.json.get('page', 1) | ||
size = request.json.get('size', 10) | ||
keyword = request.json.get('keyword') | ||
|
||
query = HostModel.select().where( | ||
HostModel.user_id == current_user_id | ||
) | ||
|
||
if keyword: | ||
query.where(HostModel.host.contains(keyword)) | ||
|
||
total = query.count() | ||
|
||
rows = query.order_by( | ||
HostModel.create_time.desc(), | ||
HostModel.id.desc() | ||
).paginate(page, size) | ||
|
||
return { | ||
'list': rows, | ||
'total': total, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
@File : migrate_158_to_159.py | ||
@Date : 2023-06-30 | ||
cmd: | ||
$ python domain_admin/migrate/migrate_158_to_159.py | ||
""" | ||
from __future__ import print_function, unicode_literals, absolute_import, division | ||
|
||
from domain_admin.migrate import migrate_common | ||
from domain_admin.model.base_model import db | ||
from domain_admin.model.domain_info_model import DomainInfoModel | ||
from domain_admin.model.issue_certificate_model import IssueCertificateModel | ||
from domain_admin.model.user_model import UserModel | ||
|
||
|
||
def execute_migrate(): | ||
""" | ||
版本升级 1.5.8 => 1.5.9 | ||
:return: | ||
""" | ||
migrator = migrate_common.get_migrator(db) | ||
|
||
migrate_rows = [ | ||
# add column | ||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.challenge_type.name, | ||
IssueCertificateModel.challenge_type), | ||
|
||
# add column | ||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.deploy_host_id.name, | ||
IssueCertificateModel.deploy_host_id | ||
), | ||
|
||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.deploy_verify_path.name, | ||
IssueCertificateModel.deploy_verify_path | ||
), | ||
|
||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.deploy_key_file.name, | ||
IssueCertificateModel.deploy_key_file | ||
), | ||
|
||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.deploy_fullchain_file.name, | ||
IssueCertificateModel.deploy_fullchain_file | ||
), | ||
|
||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.deploy_reloadcmd.name, | ||
IssueCertificateModel.deploy_reloadcmd | ||
), | ||
|
||
migrator.add_column( | ||
IssueCertificateModel._meta.table_name, | ||
IssueCertificateModel.is_auto_renew.name, | ||
IssueCertificateModel.is_auto_renew | ||
), | ||
] | ||
|
||
migrate_common.try_execute_migrate(migrate_rows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.