From 9520c98eb66e43d06f37a86e44854e579956acb0 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Thu, 29 Jun 2023 17:52:15 +0800 Subject: [PATCH] update user --- appmanage/Dockerfile | 2 +- appmanage/api/model/user.py | 10 +++++++ appmanage/api/service/db.py | 19 +++++++++++++ appmanage/api/v1/routers/apps.py | 47 ++++++++++++++++++++++++++++++- appmanage/database.sqlite | Bin 0 -> 163840 bytes install/version.json | 9 ------ version.json | 23 +++++++++++++++ 7 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 appmanage/api/model/user.py create mode 100644 appmanage/api/service/db.py create mode 100644 appmanage/database.sqlite delete mode 100644 install/version.json create mode 100644 version.json diff --git a/appmanage/Dockerfile b/appmanage/Dockerfile index d6cf741e..8b1d2295 100644 --- a/appmanage/Dockerfile +++ b/appmanage/Dockerfile @@ -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 diff --git a/appmanage/api/model/user.py b/appmanage/api/model/user.py new file mode 100644 index 00000000..723b748f --- /dev/null +++ b/appmanage/api/model/user.py @@ -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 \ No newline at end of file diff --git a/appmanage/api/service/db.py b/appmanage/api/service/db.py new file mode 100644 index 00000000..676714d7 --- /dev/null +++ b/appmanage/api/service/db.py @@ -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 \ No newline at end of file diff --git a/appmanage/api/v1/routers/apps.py b/appmanage/api/v1/routers/apps.py index 67e6e790..fbc074f9 100644 --- a/appmanage/api/v1/routers/apps.py +++ b/appmanage/api/v1/routers/apps.py @@ -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: diff --git a/appmanage/database.sqlite b/appmanage/database.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..fba00d5b691bfd185140e3cb73df53c7bc6bf465 GIT binary patch literal 163840 zcmeI*OHW*79Khi-Lko&bPrcw+Z#^OvnqH)gV%ml2Xkj&>UTBOfGKEt+5oYMj)T)Uw z#?RqbXhOomoeRH+TURE=og4qB1PPQ96Cknr%;Xo|b9>J_53?a5IUj%6X!Y~#R;Rn# z>}R#)WKt?6SFs%#8S?AT$0009C72y6>fHU|3JTSf#39JN4Yqx8#B-{WxS zPwNAJ9PW%}J9>fdz8)T`j*gbT|D@l%xsu=Q<=vw4`yb8L7iP1C`g@JpY^>NdmQ7ZM zv(52h|EslpEc>F_UAo=uX7kqS*mF)T*ASF~0f*mX{2_-tA))sLR|KYWJ|%7fK& z=SrVG`0n)Xti<2Gi@p5L-Mqb&@7f&L@r~MbaI*MqpN}ig2G&oHF<2$-C*^cJNypP4 zALEZ<=>!N6AV7cs0RjXF5FkL{zykB7q3WBbsZR%0TW`8a`3g{hef)0eZUsVlX2u1sIrV^=Kb+CdjJR~|ZDE!MQw>Gqqg zcHV6k3)o!CgW(=G-eXs#SjfpFNqK7o z{6qXd|M=<8$t(MvJ-6S%hmTbs-enH~0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyaCidaG1aN)MD%p@Y*aih;DzYL=%wi8sCXPf z7QGg|8l8@cYtKY)L=(|u^j!3OG#VX`hN3izCk-agM8#tVpNvML!DuXcJ$fp7B03g% z5g