整理项目结构

Change-Id: I14b059f2c462100581d2acfef6efbee130bed861
diff --git a/TRM/back/app/routes.py b/TRM/back/app/routes.py
new file mode 100644
index 0000000..90c9c5c
--- /dev/null
+++ b/TRM/back/app/routes.py
@@ -0,0 +1,63 @@
+from flask import Blueprint, render_template
+from .functions.Fpost import Fpost;
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+from config import Config
+from flask import jsonify,request
+
+main = Blueprint('main', __name__)
+
+
+@main.route('/apostlist',methods=['POST','GET'])
+def postlist():
+    data=request.get_json()
+    engine=create_engine(Config.SQLURL)
+    SessionLocal = sessionmaker(bind=engine)
+    session = SessionLocal()
+    f=Fpost(session)
+    checres=f.checkid(data['userid'])
+    if(not checres):
+        return jsonify({'status': 'error', 'message': 'Unauthorized'})
+    res=f.getlist()
+    respons=[]
+    for datai in res:
+        respons.append({
+            'id': datai[0],
+            'title': datai[1],
+            'status': datai[2]
+        })
+    return jsonify(respons)
+
+@main.route('/agetpost',methods=['POST','GET'])
+def post():
+    data=request.get_json()
+    engine=create_engine(Config.SQLURL)
+    SessionLocal = sessionmaker(bind=engine)
+    session = SessionLocal()
+    f=Fpost(session)
+    checres=f.checkid(data['userid'])
+    if(not checres):
+        return jsonify({'status': 'error', 'message': 'Unauthorized'})
+    res=f.getpost(data['postid'])
+
+    return jsonify(res.to_dict() if res else {})
+
+@main.route('/areview',methods=['POST','GET'])
+def review():
+    data=request.get_json()
+    engine=create_engine(Config.SQLURL)
+    SessionLocal = sessionmaker(bind=engine)
+    session = SessionLocal()
+    f=Fpost(session)
+    checres=f.checkid(data['userid'])
+    if(not checres):
+        return jsonify({'status': 'error', 'message': 'Unauthorized'})
+    
+    res=f.review(data['postid'],data['status'])
+    if not res:
+        return jsonify({'status': 'error', 'message': 'Post not found'})
+    
+    return jsonify({'status': 'success', 'message': 'Post reviewed successfully'})
+
+
+