mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-21 15:10:22 +00:00
update user
This commit is contained in:
parent
41b41822d6
commit
9520c98eb6
7 changed files with 99 additions and 11 deletions
|
@ -7,7 +7,7 @@ WORKDIR /usr/src/app
|
|||
# Copy source and install pip dpendencies
|
||||
COPY api ./api
|
||||
COPY static ./static
|
||||
COPY requirements.txt main.py ./
|
||||
COPY requirements.txt main.py database.sqlite ./
|
||||
RUN apt update
|
||||
|
||||
# Install supervisords
|
||||
|
|
10
appmanage/api/model/user.py
Normal file
10
appmanage/api/model/user.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
class User(BaseModel):
|
||||
user_type: str
|
||||
user_name: str
|
||||
password: str
|
||||
nick_name: str
|
||||
create_time: datetime
|
||||
update_tiem: datetime
|
19
appmanage/api/service/db.py
Normal file
19
appmanage/api/service/db.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
from api.model.user import User
|
||||
import sqlite3
|
||||
|
||||
conn = sqlite3.connect('/usr/src/app/database.sqlite')
|
||||
cursor = conn.cursor()
|
||||
|
||||
|
||||
def AppUpdateUser(user_name, password):
|
||||
sql = "UPDATE user SET password=" + password + " WHERE user_name=" + user_name
|
||||
cursor.execute(sql)
|
||||
conn.commit()
|
||||
|
||||
def AppSearchUsers(user_type):
|
||||
sql = "SELECT * FROM user WHERE user_type=" + user_type
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchall()
|
||||
return result
|
|
@ -7,7 +7,7 @@ import os, io, sys, platform, shutil, time, subprocess, json, datetime
|
|||
|
||||
from api.model.app import App
|
||||
from api.model.response import Response
|
||||
from api.service import manage
|
||||
from api.service import manage, db
|
||||
from api.utils import shell_execute, const
|
||||
from api.utils.common_log import myLogger
|
||||
from api.exception.command_exception import CommandException
|
||||
|
@ -425,6 +425,51 @@ def AppAutoUpdate(request: Request,auto_update: Optional[str] = Query(default=No
|
|||
|
||||
return response
|
||||
|
||||
@router.api_route("/AppSearchUsers", methods=["GET", "POST"], summary="获取appstore用户信息", response_model=Response, response_description=rd_auto_list)
|
||||
def AppSearchUsers(request: Request, plugin_name: Optional[str] = Query(default=None, description="用户名")):
|
||||
|
||||
try:
|
||||
myLogger.info_logger("Receive request: /AppSearchUsers")
|
||||
get_headers(request)
|
||||
ret = {}
|
||||
ret['ResponseData'] = {}
|
||||
ret['ResponseData']['user'] = db.AppSearchUsers(plugin_name)
|
||||
response = JSONResponse(content=ret)
|
||||
except CommandException as ce:
|
||||
ret = {}
|
||||
ret['ResponseData'] = {}
|
||||
ret['Error'] = manage.get_error_info(ce.code, ce.message, ce.detail)
|
||||
response = JSONResponse(content=ret)
|
||||
except Exception as e:
|
||||
ret = {}
|
||||
ret['ResponseData'] = {}
|
||||
ret['Error'] = manage.get_error_info(const.ERROR_SERVER_SYSTEM, "system original error", str(e))
|
||||
response = JSONResponse(content=ret)
|
||||
|
||||
return response
|
||||
|
||||
@router.api_route("/AppUpdateUser", methods=["GET", "POST"], summary="更新appstore用户信息", response_model=Response, response_description=rd_auto_list)
|
||||
def AppUpdateUser(request: Request,user_name: Optional[str] = Query(default=None, description="用户名"), password: Optional[str] = Query(default=None, description="密码")):
|
||||
|
||||
try:
|
||||
myLogger.info_logger("Receive request: /AppUpdateUser")
|
||||
get_headers(request)
|
||||
ret = {}
|
||||
ret['ResponseData'] = {}
|
||||
db.AppUpdateUser(user_name, password)
|
||||
except CommandException as ce:
|
||||
ret = {}
|
||||
ret['ResponseData'] = {}
|
||||
ret['Error'] = manage.get_error_info(ce.code, ce.message, ce.detail)
|
||||
response = JSONResponse(content=ret)
|
||||
except Exception as e:
|
||||
ret = {}
|
||||
ret['ResponseData'] = {}
|
||||
ret['Error'] = manage.get_error_info(const.ERROR_SERVER_SYSTEM, "system original error", str(e))
|
||||
response = JSONResponse(content=ret)
|
||||
|
||||
return response
|
||||
|
||||
def get_headers(request):
|
||||
headers = request.headers
|
||||
try:
|
||||
|
|
BIN
appmanage/database.sqlite
Normal file
BIN
appmanage/database.sqlite
Normal file
Binary file not shown.
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"SERVICES": {
|
||||
"PORTAINER": "2.18.3",
|
||||
"NGINX": "2.10.3",
|
||||
"APPMANAGE": "0.7.2",
|
||||
"REDIS": "7.0.11"
|
||||
},
|
||||
"VERSION": "0.7.2"
|
||||
}
|
23
version.json
Normal file
23
version.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"SERVICES": {
|
||||
"PORTAINER": "2.18.3",
|
||||
"NGINX": "2.10.3",
|
||||
"APPMANAGE": "0.7.2",
|
||||
"REDIS": "7.0.11"
|
||||
},
|
||||
"PLUGINS": {
|
||||
"PORTAINER": "1.0.0",
|
||||
"NGINX": "1.0.0",
|
||||
"MYAPPS": "1.0.1",
|
||||
"APPSTORE": "1.0.0"
|
||||
},
|
||||
"LIBRARY": {
|
||||
"VERSION": "1.0.0"
|
||||
},
|
||||
"OS_SUPPORT": {
|
||||
"CentOS": ["7.9"],
|
||||
"Ubuntu": ["18.04","20.04","22.04"],
|
||||
"RedHat": ["7.9","8.6","9.2"]
|
||||
},
|
||||
"VERSION": "0.8.0"
|
||||
}
|
Loading…
Reference in a new issue