def cancel_article_like(): """ 取消文章点赞 :arg {"articleId":1,"token": "xx13v9wp-t4gl-gsxn-mnd6-ftnhx6gnp3r0"} :return: """ article_info = request.get_json() article_id = article_info.get("articleId") # 参数校验 if not _parameters_filter([article_id]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 检查是否已经赞过了 user_id = session.get("user").get("id") query_article_like_detail = "select * from tbl_article_like as a " \ "where a.userId=%d and a.articleId=%d and a.status=1" % (user_id, article_id) if not query(query_article_like_detail): return json(get_json(code=-100, msg="您还没有赞过此文章!")) # 修改状态 update_article_like_sql = "update tbl_article_like as a set " \ "a.status=0 where a.userId=%d and a.articleId=%d" % (user_id, article_id) if excute(update_article_like_sql): return json(get_json(msg="成功取消此文章的点赞!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def article_collect(): """ 收藏文章 :arg {"articleId":1,"token": "xx13v9wp-t4gl-gsxn-mnd6-ftnhx6gnp3r0"} :return: json """ article_info = request.get_json() article_id = article_info.get("articleId") # 参数校验 if not _parameters_filter([article_id]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 检查是否已经收藏过文章 user_id = session.get("user").get("id") query_article_collect_detail = "select * from tbl_article_collect as a " \ "where a.userId=%d and a.articleId=%d and a.status=1" % (user_id, article_id) if query(query_article_collect_detail): return json(get_json(code=-100, msg="您已经收藏过此文章了!")) # 检查是否存在文章 query_article_sql = "select * from tbl_article where id=%d and status=1" % article_id if not query(query_article_sql): return json(get_json(code=-100, msg="文章不在了...!")) # 增加文章收藏记录 insert_article_collect_sql = "insert into tbl_article_collect " \ "values(NULL, %d, %d, 1, '%s', NULL )" % (user_id, article_id, get_current_time()) if excute(insert_article_collect_sql): return json(get_json(msg="收藏文章成功!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def user_regist(): """ 用户注册 :arg {"username":"******", "password":"******", "nickname":"nickname"} :return json """ user_info = request.get_json() nickname = user_info.get("nickname") username = user_info.get("username") password = user_info.get("password") create_date = get_current_time() # 参数校验 if not _parameters_filter([username, password, nickname]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 判断用户名是否已被占用 query_user_sql = "select * from tbl_user where username='******'" % username if query(query_user_sql): return json(get_json(code=-300, msg="用户名已存在!")) # 没被占用,进行注册 user_reg_sql = "insert into tbl_user values(NULL, '%s', '%s', '%s'," \ "NULL, 1,'','','',NULL,'','','','',NULL,'','%s',NULL)" % (username, password, nickname, create_date) if excute(user_reg_sql): return json(get_json(msg="注册成功!")) return json(get_json(code=-100, msg="注册失败,用户名可能已经存在了!"))
def add_article(): """ 新增文章 :arg { "title":"title", "imgId":1,"type":2, "content":"test", "source":"123","token": "6gax71xs-z38o-8178-3a2t-6c3jjcm2cn18" } :return: json """ article_info = request.get_json() type = article_info.get("type") title = article_info.get("title") img_id = article_info.get("imgId") source = article_info.get("source") content = article_info.get("content") user_id = _get_admin_session()["adminInfo"]["id"] # 参数校验 if not _admin_parameters_filter([title, img_id, type, content, source]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 插入文章记录 insert_article_sql = "INSERT INTO tbl_article VALUES" \ "(NULL, '%s', %d, %d, '%s', '%s', 0, 0, 1, %d, '%s', NULL)" % \ (title, img_id, type, content, source, user_id, get_current_time()) if excute(insert_article_sql): return json(get_json()) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def reply_comment(): """ 回复评论 :arg {"articleId":1, "commentId":5, "commentContent":"test","token": "xx13v9wp-t4gl-gsxn-mnd6-ftnhx6gnp3r0"} :return: json """ comments_info = request.get_json() article_id = comments_info.get("articleId") comment_id = comments_info.get("commentId") comment_content = comments_info.get("commentContent") # 参数校验 if not _parameters_filter([article_id, comment_id, comment_content]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 文章下是否有此评论,这里有bug todo # 增加文章评论 user_id = session.get("user").get("id") insert_reply_comment_sql = "insert into tbl_article_comment values" \ "(NULL, %d, %d, '%s', 1, '%s', NULL, %d)" % \ (user_id, article_id, comment_content, get_current_time(), comment_id) if excute(insert_reply_comment_sql): return json(get_json()) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def update_article(): """ 更新文章 :arg { "id":1, "type":1, "title":"title_test", "source":"1", "status":1, "content":"test_test", "imgId":1,"token": "75wglrvu-uiol-ifza-73c9-d9vu4e5sql0m" } :return: """ article_info = request.get_json() id = article_info.get("id") type = article_info.get("type") title = article_info.get("title") img_id = article_info.get("imgId") source = article_info.get("source") status = article_info.get("status") content = article_info.get("content") # 参数校验 if not _admin_parameters_filter( [id, status, title, type, content, source, img_id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新文章 update_article_sql = "update tbl_article set " \ "title='%s', type=%d, source='%s', status=%d, content='%s', updateDate='%s', imgId='%d'" \ "where id=%d" % (title, type, source, status, content, get_current_time(), img_id, id) if excute(update_article_sql): return json(get_json(msg="更新成功!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def upload(): """ 公共上传资源接口 :arg file:上传文件格式;source:图片资源,详细请求数据参见uploadDemo.html :return: """ # 检验来源 file_source = request.form.get("source") if not _parameters_filter([file_source]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 保存图片文件到服务器 file = request.files['file'] file_name = create_token() + "." + file.filename.split(".")[1] if _upload_files(file, file_name): # 执行插入数据库操作 insert_img_source_sql = "INSERT INTO tbl_image_sources " \ "values(NULL, '%s', 1, '%s', NULL)" % (file_name, get_current_time()) # 执行成功返回该img信息 if excute(insert_img_source_sql): query_img_sql = "select * from tbl_image_sources where path='%s'" % file_name datas = {"imgInfo": query(query_img_sql)} return json(get_json(data=datas)) return json(get_json(code=-100, msg="操作失败!"))
def add_user(): """ 新增用户 :arg {"username":"******", "password":"******", "nickname":"nickname", "token": "4cmhr7a8-t0zw-sskr-3e5i-o9sdxv48878p"} :return: json """ user_info = request.get_json() nickname = user_info.get("nickname") username = user_info.get("username") password = user_info.get("password") create_date = get_current_time() # 参数校验 if not _admin_parameters_filter([username, password, nickname]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 判断用户名是否已被占用 query_user_sql = "select * from tbl_user where username='******'" % username if query(query_user_sql): return json(get_json(code=-300, msg="用户名已存在!")) # 没被占用,进行注册 user_reg_sql = "insert into tbl_user values" \ "(NULL, '%s', '%s', '%s',NULL,1,'','','',NULL,'','','','',NULL,'','%s',NULL)" \ % (username, password, nickname, create_date) print(user_reg_sql) if excute(user_reg_sql): return json(get_json(msg="新增用户成功!")) return json(get_json(code=-100, msg="新增用户失败!"))
def add_carouse(): """ 增加轮播图 :arg {"type":0, "imgId":1,"status":1,"content":"", "url":"http://www.google.com/", "token": "zwoqgqod-c392-ingy-6cyl-stvk7nadyrpe"} :arg {"type":1, "imgId":1,"status":1,"content":"123", "url":"","token": "zwoqgqod-c392-ingy-6cyl-stvk7nadyrpe"} :return: json """ carouse_info = request.get_json() url = carouse_info.get("url") type = carouse_info.get("type") img_id = carouse_info.get("imgId") status = carouse_info.get("status") content = carouse_info.get("content") create_date = get_current_time() # 参数校验,如果type为0,url不能为空;如果如果为1,content不能为空 if type != None and type == 0: paras = [type, img_id, status, url] else: paras = [type, img_id, status, content] if not _admin_parameters_filter(paras): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 构造sql并执行 insert_anno_sql = "INSERT into tbl_carouse " \ "values(NULL, %d, %d, %d, '%s', '%s', '%s')" % (type, img_id, status, content, url, create_date) if excute(insert_anno_sql): return json(get_json(msg="添加成功!")) return json(get_json(code=-100, msg="添加失败,请检查数据库链接!"))
def update_carouse(): """ 修改轮播图 :arg {"id":1, "type":0, "imgId":1,"status":1,"content":"", "url":"http://www.google.com/","token": "zwoqgqod-c392-ingy-6cyl-stvk7nadyrpe"} :arg {"id":1, "type":1, "imgId":1,"status":1,"content":"123", "url":"","token": "zwoqgqod-c392-ingy-6cyl-stvk7nadyrpe"} :return: """ carouse_info = request.get_json() id = carouse_info.get("id") url = carouse_info.get("url") type = carouse_info.get("type") img_id = carouse_info.get("imgId") status = carouse_info.get("status") content = carouse_info.get("content") # 参数校验,如果type为0,url不能为空;如果如果为1,content不能为空 if type != None and type == 0: paras = [type, img_id, status, url] else: paras = [type, img_id, status, content] if not _admin_parameters_filter(paras): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新轮播图信息 update_carouse_sql = "update tbl_carouse set type=%d, imgId=%d, status=%d, content='%s', url='%s' where id=%d" % \ (type, img_id, status, content, url, id) if excute(update_carouse_sql): return json(get_json()) return json(get_json(code=-100, msg="添加失败,请检查数据库链接!"))
def user_login(): """ 用户登录 :arg {"username":"******", "password":"******", "captcha":"123456"} :return json """ user_info = request.get_json() captcha = user_info.get("captcha") username = user_info.get("username") password = user_info.get("password") # 参数校验 if not _parameters_filter([username, password, captcha]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # todo # 修改验证码 if captcha == "123456": query_login_sql = "select * from tbl_user where username='******' and password='******'" % ( username, password) result = query(query_login_sql) if result: if result[0].get("status") == 1: # 生成并插入token user_token = create_token() insert_token_sql = "update tbl_user set token='%s' where id=%d" % ( user_token, result[0]["id"]) excute(insert_token_sql) # 查询IMG并更新Token query_img_sql = "select * from tbl_image_sources where id=%d" % result[ 0].get("imgId") result[0]["img"] = query(query_img_sql)[0].get("path") result[0]["token"] = user_token # 保存用户信息 _set_user_session(result[0]) return json(get_json(data={"token": user_token}, msg="登录成功!")) else: return json(get_json(msg="登录失败, 您已经禁止登陆网站, 请联系管理员处理!")) return json(get_json( code="-100", msg="登录失败,用户名或密码不正确!", ))
def adminlogin(): ''' 管理员登陆 arg:{"username":"******","password":"******"} return: json ''' admininfo = request.get_json() username = admininfo["username"] password = admininfo["password"] if username != None and password != None: result = query( "SELECT * FROM tbl_admin where username = '******' and password = '******';" % (username, password)) if result: token = create_token() result[0]["token"] = token _set_admin_session(result[0]) excute( "UPDATE `tbl_admin` SET `token`='%s' WHERE (`id`='%d') LIMIT 1" % (token, result[0].get("id"))) response = {} response["code"] = 200 response["data"] = {"token": token} response["msg"] = "登陆成功!" return json(response) else: response = {} response["code"] = 200 response["data"] = 0 response["msg"] = "账号或者密码错误!" return json(response) else: response = {} response["code"] = 200 response["data"] = 0 response["msg"] = "账号或者密码不能为空。" return json(response)
def article_detailes(): """ 查询文章详情和评论 :arg: {"articleId":1} :return: """ article_info = request.get_json() article_id = article_info.get("id") # id为空不允许 if not _parameters_filter([article_id]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # -1:未登录用户 user = session.get("user") if user: user_id = user.get("id") else: user_id = -1 # 首先默认请求此接口为浏览了该文章 try: # 增加浏览数量,如果没有浏览,则增加一条浏览数据,否则修改浏览时间 query_article_sql = "select * from tbl_article_browsing_history " \ "as a where a.userId=%d and a.articleId=%d and a.status=1" % (user_id, article_id) if query(query_article_sql): article_browsing_sql = "update tbl_article_browsing_history set updateDate='%s'" % get_current_time( ) excute(article_browsing_sql) else: article_browsing_sql = "INSERT INTO tbl_article_browsing_history " \ "VALUES (NULL, %d, %d, 1, '%s',NULL)" % (user_id, article_id, get_current_time()) excute(article_browsing_sql) # 查询article阅读总数 query_article_readcount_sql = "select * from tbl_article where id=%d" % article_id read_counts = query(query_article_readcount_sql)[0].get( "readCount") + 1 # 更新readCount总数 update_article_browsing_count = "update tbl_article set readCount=%d, " \ "updateDate='%s' where id=%d" % (read_counts, get_current_time(), article_id) excute(update_article_browsing_count) except Exception as e: print(e) pass # 查询文章和对应的评论 query_article_sql = "select * from tbl_article where id=%s and status=1" % article_id query_comments_sql = "select * from tbl_article_comment where articleId=%s and status=1" % article_id results = { "article": query(query_article_sql), "comments": query(query_comments_sql) } return json(get_json(data=results))
def delete_anno(): """ 删除公告:软删除 :arg {"id":1,"token": "qzh84z4m-vsl7-ltkq-6xzq-wur2tkts2ppw"} :return: """ anno_info = request.get_json() id = anno_info.get("id") # 参数校验 if not _admin_parameters_filter([id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 构造参数并执行sql delete_anno_sql = "update tbl_announcement set status=0 where id=%d" % id if excute(delete_anno_sql): return json(get_json(msg="删除成功,该公告将不会在首页显示!")) return json(get_json(code=-100, msg="删除失败,请检查数据库链接!"))
def recover_comment(): """ 恢复显示文章的评论 :arg {"id": 1, "token":"3dfvjaj0-81hp-gwzl-wub9-2qsllamg2mou"} :return: json """ comment_info = request.get_json() id = comment_info.get("id") # 参数校验 if not _admin_parameters_filter([id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新评论记录 update_comment_sql = "update tbl_article_comment set status = 1 where id=%d" % id if excute(update_comment_sql): return json(get_json(msg="评论已设置为显示!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def recover_user(): """ 恢复用户 :arg {"id":1,"token": "2fvblixe-mxqg-weu5-mvqo-48ick796k009"} :return: """ user_info = request.get_json() id = user_info.get("id") # 参数校验 if not _admin_parameters_filter([id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新文章 update_article_sql = "update tbl_user set status=1 where id=%d" % id if excute(update_article_sql): return json(get_json(msg="恢复成功, 该用户可以登陆网站!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def active_article(): """ 激活已删除的文章 :arg {"id":1, "token":"dd0tl9ek-v65c-un69-v450-vdjxweucf0f7"}} :return: """ article_info = request.get_json() id = article_info.get("id") # 参数校验 if not _admin_parameters_filter([id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新文章 update_article_sql = "update tbl_article set status=1 where id=%d" % id if excute(update_article_sql): return json(get_json(msg="激活文章成功!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def delete_carouse(): """ 删除轮播图 :arg {"id":1, "token": "zwoqgqod-c392-ingy-6cyl-stvk7nadyrpe"} :return: """ carouse_info = request.get_json() id = carouse_info.get("id") # 参数校验 if not _admin_parameters_filter([id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新轮播图 update_carouse_sql = "update tbl_carouse set status=0 where id=%d" % id if excute(update_carouse_sql): return json(get_json()) return json(get_json(code=-100, msg="添加失败,请检查数据库链接!"))
def update_user(): """ 编辑用户信息 :arg { "id":1, "status":1, "sex":"男", "age":22, "email":"*****@*****.**", "wechat":"snake", "remark":"greate full!", "address":"test", "nickname":"snake", "signature":"signature", "cellphone":"15000000000", "education":"education","token": "4cmhr7a8-t0zw-sskr-3e5i-o9sdxv48878p" } :return: json """ user_info = request.get_json() id = user_info.get("id") sex = user_info.get("sex") age = user_info.get("age") email = user_info.get("email") status = user_info.get("status") wechat = user_info.get("wechat") remark = user_info.get("remark") address = user_info.get("address") nickname = user_info.get("nickname") signature = user_info.get("signature") cellphone = user_info.get("cellphone") education = user_info.get("education") updateDate = get_current_time() # 执行用户信息更新 update_user_sql = "update tbl_user set nickname='%s'," \ "sex='%s',age=%d, email='%s', wechat='%s'," \ "remark='%s',address='%s',nickname='%s'," \ "signature='%s',cellphone='%s',education='%s'," \ "updateDate='%s',status=%d where id='%s'" % \ (nickname, sex, age, email, wechat, remark, address, \ nickname, signature, cellphone, education, updateDate, status, id) # 更新成功则重置session并返回最新的用户信息 if excute(update_user_sql): return json(get_json(msg="修改成功!")) return json(get_json(code=-100, msg="修改失败!"))
def defriend_user(): """ 拉黑用户 :arg {"id":1,"token": "2fvblixe-mxqg-weu5-mvqo-48ick796k009"} :return: """ user_info = request.get_json() id = user_info.get("id") # 参数校验 if not _admin_parameters_filter([id]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 更新文章 update_article_sql = "update tbl_user set status=0 where id=%d" % id if excute(update_article_sql): return json( get_json(msg="拉黑成功, 该用户被禁止登陆网站!")) # todo 这里有bug,不能及时踢下线,哈哈哈 return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def update_user_info(): """ 编辑用户信息 :arg { "sex":"男","imgId":1, "age":22, "email":"*****@*****.**", "wechat":"snake", "remark":"greate full!", "address":"test", "nickname":"snake", "signature":"signature", "cellphone":"15000000000", "education":"education","token":"pmqkp62j-n5pw-w882-zk3e-qh8722mivo4u" } :return: json """ user_info = request.get_json() sex = user_info.get("sex") age = user_info.get("age") token = user_info.get("token") email = user_info.get("email") img_id = user_info.get("imgId") wechat = user_info.get("wechat") remark = user_info.get("remark") address = user_info.get("address") nickname = user_info.get("nickname") signature = user_info.get("signature") cellphone = user_info.get("cellphone") education = user_info.get("education") updateDate = get_current_time() # 执行用户信息更新 update_user_sql = "update tbl_user set nickname='%s', imgId=%d, sex='%s'," \ "age=%d, email='%s', wechat='%s',remark='%s',address='%s'," \ "nickname='%s',signature='%s',cellphone='%s',education='%s',updateDate='%s' where token='%s'" % \ (nickname, img_id, sex, age, email, wechat, remark, address, nickname, signature, cellphone, education, updateDate, token) # 更新成功则重置session并返回最新的用户信息 if excute(update_user_sql): user = query("select * from tbl_user where token='%s'" % token)[0] _set_user_session(user) # 返回用户信息 return json(get_json(msg="修改成功", data=_get_user_session())) return json(get_json(code=-100, msg="修改失败!"))
def article_comment(): """ 文章评论 :arg {"articleId":1, "content":"test", "token": "xx13v9wp-t4gl-gsxn-mnd6-ftnhx6gnp3r0"} :return: json """ comments_info = request.get_json() user_id = session.get("user").get("id") article_id = comments_info.get("id") comment_content = comments_info.get("content") # 参数校验 if not _parameters_filter([article_id, comment_content]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 增加文章评论 insert_aritcle_comment_sql = "insert into tbl_article_comment values" \ "(NULL, %d, %d, '%s', 1, '%s', NULL, NULL)" % \ (user_id, article_id, comment_content, get_current_time()) if excute(insert_aritcle_comment_sql): return json(get_json(msg="评论成功!")) return json(get_json(code=-100, msg="操作失败!"))
def update_anno(): """ 修改公告 :arg {"id":1, "title":"测试", "content":"测试", "status":1,"token": "qzh84z4m-vsl7-ltkq-6xzq-wur2tkts2ppw"} :return: """ anno_info = request.get_json() id = anno_info.get("id") title = anno_info.get("title") content = anno_info.get("content") status = anno_info.get("status") # 参数校验 if not _admin_parameters_filter([id, title, content, status]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 构造sql并执行 insert_anno_sql = "update tbl_announcement " \ "set title='%s', content='%s', status=%d where id=%d" % (title, content, status, id) if excute(insert_anno_sql): return json(get_json(msg="修改成功!")) return json(get_json(code=-100, msg="修改失败,请检查数据库链接!"))
def article_like(): """ 文章点赞 :arg {"articleId":1,"token": "xx13v9wp-t4gl-gsxn-mnd6-ftnhx6gnp3r0"} :return: json """ article_info = request.get_json() article_id = article_info.get("articleId") # 参数校验 if not _parameters_filter([article_id]): return json(get_json(code=-200, msg="参数存在空值,请检查参数!")) # 检查是否已经赞过了 user_id = session.get("user").get("id") query_article_like_detail = "select * from tbl_article_like as a " \ "where a.userId=%d and a.articleId=%d and a.status=1" % (user_id, article_id) if query(query_article_like_detail): return json(get_json(code=-100, msg="您已经赞过了此文章!")) # 检查是否存在文章 query_article_sql = "select * from tbl_article as a where a.id=%d and a.status=1" % article_id if not query(query_article_sql): return json(get_json(code=-100, msg="文章不在了...!")) # 如果存在记录则修改时间,如果没有记录则增加记录 query_article_like_detail = "select * from tbl_article_like as a where " \ "a.userId=%d and a.articleId=%d" % (user_id, article_id) if query(query_article_like_detail): update_article_collect_sql = "update tbl_article_like as a " \ "set a.status=1 where a.userId=%d and a.articleId=%d" % (user_id, article_id) else: update_article_collect_sql = "insert into tbl_article_like " \ "values(NULL, %d, %d, 1, '%s', NULL )" % (user_id, article_id, get_current_time()) if excute(update_article_collect_sql): return json(get_json(msg="文章点赞成功!")) return json(get_json(code=-100, msg="操作失败,请检查数据库链接!"))
def add_anno(): """ 增加公告 :arg {"title":"测试", "content":"测试", "status":1,"token": "qzh84z4m-vsl7-ltkq-6xzq-wur2tkts2ppw"} :return: """ anno_info = request.get_json() title = anno_info.get("title") content = anno_info.get("content") status = anno_info.get("status") create_date = get_current_time() admin_id = _get_admin_session()["adminInfo"]["id"] # 参数校验 if not _admin_parameters_filter([title, content, status]): return json(get_json(code=-200, msg="操作失败,参数有误!")) # 构造sql并执行 insert_anno_sql = "INSERT into tbl_announcement " \ "values(NULL, '%s', %d, %d, '%s', '%s')" % (content, status, admin_id, create_date, title) if excute(insert_anno_sql): return json(get_json(msg="添加成功!")) return json(get_json(code=-100, msg="添加失败,请检查数据库链接!"))