예제 #1
0
@LastEditTime: 2020-03-27 17:01:34
@LastEditors: Xuannan
'''

from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import WebConfig
from app.utils import object_to_json
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.admin import conf_doc as doc
from flask import g, request
import json
from sqlalchemy import or_, and_

api = Apidoc('系统-配置项')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)
parse_id.add_argument('site', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('site', type=str, required=True, help='请选择所属模块')
parse_base.add_argument('name', type=str, required=True, help='请输入名称')
parse_base.add_argument('ename', type=str, required=True, help='请输入调用名称')
parse_base.add_argument('fieldType', type=str, required=True, help='请选择字段类型')
parse_base.add_argument('placeholder')
parse_base.add_argument('values')
parse_base.add_argument('value')
parse_base.add_argument('lang')
예제 #2
0
@LastEditors: Xuannan
'''

from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models.base import Crud
from app.utils import object_to_json, mysql_to_json
from app.config import PAGINATE_NUM
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.cms import content_doc
from flask import g, current_app, request

from app.models import BlogContent, BlogContentTag, MaitulContent, MaitulContentTag, InfoContent, InfoContentTag, MetalpartsContent, MetalpartsContentTag
from app.models import BlogCategory, MaitulCategory, MetalpartsCategory, InfoCategory
api = Apidoc('内容管理-内容')

parse_id = reqparse.RequestParser()
parse_id.add_argument('id')

parse_base = parse_id.copy()
parse_base.add_argument('title', type=str, required=True, help='请输入标题')
parse_base.add_argument('sort', type=int, help='排序号只能是数字')
parse_base.add_argument('keywords')
parse_base.add_argument('description')
parse_base.add_argument('content')
parse_base.add_argument('cover')
parse_base.add_argument('tags')
parse_base.add_argument('category_id', type=str, required=True, help='请选择所属分类')
parse_base.add_argument('author')
parse_base.add_argument('source')
예제 #3
0
@Description: 
@Author: Xuannan
@Date: 2020-01-17 10:05:42
@LastEditTime : 2020-01-27 20:06:26
@LastEditors  : Xuannan
'''

from flask_restful import Resource, reqparse, abort
from werkzeug.datastructures import FileStorage
from app.utils.file import FileUpload
from app.apis.api_constant import *
from app.apis.admin.common import login_required
from app.utils.api_doc import Apidoc
from app.api_docs.resource import upload_doc as doc

api = Apidoc('通用-上传')
parser = reqparse.RequestParser()
parser.add_argument('file',
                    type=FileStorage,
                    location='files',
                    required=True,
                    help='请上传文件')
parser.add_argument('width', type=int, help='宽度信息有误')
parser.add_argument('height', type=int, help='高度信息有误')
parser.add_argument('watermark', type=str)


class UploadResource(Resource):
    @api.doc(api_doc=doc.upload)
    @login_required
    def post(self):
예제 #4
0
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import Message
from app.utils import object_to_json, mysql_to_json
from app.utils.mail import SendMail
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.resource import message_doc as doc
from flask import g, request
from app.config import PAGINATE_NUM

api = Apidoc('通用-留言')

# 单数据操作
parse_base = reqparse.RequestParser()
parse_base.add_argument('id', type=str)
parse_base.add_argument('site', type=str, required=True, help='请勿非法操作...')

parse_form = parse_base.copy()
parse_form.add_argument('name', type=str)
parse_form.add_argument('email', type=str)
parse_form.add_argument('contact', type=str)
parse_form.add_argument('info', type=str)

parse_reply = parse_base.copy()
parse_reply.add_argument('reply', type=str)
parse_reply.add_argument('show', type=int)
parse_reply.add_argument('sendmail', type=bool)

parse_page = parse_base.copy()
parse_page.add_argument('page', type=int, help='页码只能是数字')
예제 #5
0
@Date: 2019-12-20 18:05:19
@LastEditTime : 2020-02-05 13:40:37
@LastEditors  : Xuannan
'''

from flask_restful import Resource,reqparse,fields,marshal,abort
from app.apis.api_constant import *
from app.models import Menu
from app.utils import object_to_json
from app.utils.tree import build_tree,getParent
from app.apis.admin.common import login_required,permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.admin import menu_doc as doc
from flask import g

api = Apidoc('系统-后台菜单配置')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id',type=str)

parse_base = parse_id.copy()
parse_base.add_argument('pid',type=str,required=True,help='请选择上级菜单')
parse_base.add_argument('name',type=str,required=True,help='请输入名称')
parse_base.add_argument('url')
parse_base.add_argument('icon')
parse_base.add_argument('sort',type=int,help='排序号只能是数字')

_fields = {
    'pid':fields.String,
    'name':fields.String,
예제 #6
0
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import AdSpace
from app.utils import object_to_json
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.resource import adspace_doc as doc
from flask import g
from app.config import PAGINATE_NUM

api = Apidoc('通用-广告位管理')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('name', type=str, required=True, help='请输入名称')
parse_base.add_argument('ename', type=str, required=True, help='请输入调用名称')
parse_base.add_argument('sort', type=int, help='排序号只能是数字')

_fields = {
    'name': fields.String,
    'ename': fields.String,
    'sort': fields.Integer,
    'id': fields.String
}
sing_fields = {
    'status': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested(_fields)
예제 #7
0

from flask_restful import Resource,reqparse,fields,marshal,abort,inputs
from app.models import Admin,AdminLog,AdminRole, Crud
from app.apis.api_constant import *
from .common import get_admin,login_required,logout,permission_required
import uuid,datetime,json
from app.ext import cache
from flask import g,request
from app.utils import object_to_json,mysql_to_json
from app.apis.common.auth import Auth
from app.config import PAGINATE_NUM
from app.utils.api_doc import Apidoc
from app.api_docs.admin import admin_doc

api = Apidoc('系统-系统管理员')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id',type=str)

# 新增
parse_register = reqparse.RequestParser()
parse_register.add_argument('username',type=str,required=True,help='请输入用户名')
parse_register.add_argument('password',type=str,required=True,help='请输入密码')
parse_register.add_argument('email',type=str,required=True,help='请输入邮箱地址')
parse_register.add_argument('name',type=str,required=True,help='请输入姓名')
parse_register.add_argument('phone',type=inputs.regex(r'1[35789]\d{9}'),required=True,help='手机号码错误')

# 授权
parse_role = parse_id.copy()
예제 #8
0
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import Lang
from app.utils import object_to_json, mysql_to_json
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.admin import lang_doc as doc
from flask import g
from app.config import PAGINATE_NUM

api = Apidoc('系统-语言类型管理')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('name', type=str, required=True, help='请输入名称')
parse_base.add_argument('ename', type=str, required=True, help='请输入调用名称')
parse_base.add_argument('sort', type=int, help='排序号只能是数字')

_fields = {'name': fields.String, 'ename': fields.String, 'id': fields.String}
sing_fields = {
    'status': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested(_fields)
}


def getSingData(id):
    data = Lang.query.filter_by(id=id, is_del='0').first()
예제 #9
0
# coding=utf-8
'''
@Description: 
@Author: Xuannan
@Date: 2019-11-26 09:05:26
@LastEditTime : 2019-12-28 21:35:31
@LastEditors  : Xuannan
'''
from flask_restful import Resource, reqparse, abort
from app.utils.captcha import Captcha
from flask import make_response, current_app
from app.ext import cache
from app.apis.api_constant import *
from app.utils.api_doc import Apidoc
from app.api_docs.common import captcha_doc
api = Apidoc('通用-验证码接口')

parse = reqparse.RequestParser()
parse.add_argument('image_code', type=str, required=True, help='请传入image_code')


class CaptchaResource(Resource):
    @api.doc(api_doc=captcha_doc)
    def get(self):
        """
        图片验证码
        """
        args = parse.parse_args()
        image_code = args.get('image_code')
        text, image_data = Captcha.gene_graph_captcha()
        try:
예제 #10
0
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import Role, RoleRule, Crud
from app.utils import object_to_json, mysql_to_json
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.admin import role_doc as doc
from flask import g
from app.config import PAGINATE_NUM
import json

api = Apidoc('系统-角色管理')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('name', type=str, required=True, help='请输入名称')
parse_base.add_argument('info', type=str)

parse_rules = parse_id.copy()
parse_rules.add_argument('rules', type=str, required=True, help='请配置权限')

_fields = {
    'name': fields.String,
    'info': fields.String,
    'id': fields.String,
}
sing_fields = {
    'status': fields.Integer,
예제 #11
0
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import Ad, Crud
from app.utils import object_to_json, mysql_to_json
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.resource import ad_doc as doc
from flask import g
from app.config import PAGINATE_NUM

api = Apidoc('通用-广告管理')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)
parse_id.add_argument('space_id', type=str)
parse_id.add_argument('ename', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('name', type=str, required=True, help='请输入名称')
parse_base.add_argument('url', type=str)
parse_base.add_argument('info', type=str)
parse_base.add_argument('img', type=str, required=True, help='请上传图片')
parse_base.add_argument('sort', type=int, help='排序号只能是数字')

_fields = {
    'space_id': fields.String,
    'name': fields.String,
    'info': fields.String,
    'img': fields.String,
    'url': fields.String,
예제 #12
0
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.models import Rule
from app.utils import object_to_json, mysql_to_json
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.admin import rule_doc as doc
from flask import g
from app.config import PAGINATE_NUM

api = Apidoc('系统-权限规则管理')

# 单数据操作
parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('name', type=str, required=True, help='请输入名称')
parse_base.add_argument('url', type=str, required=True, help='请输入URL')
parse_base.add_argument('menu_id', type=str, required=True, help='所属菜单不能为空')
parse_base.add_argument('method', type=str, required=True, help='请求方法不能为空')

_fields = {
    'name': fields.String,
    'url': fields.String,
    'menu_id': fields.String,
    'id': fields.String,
    'method': fields.String
}
sing_fields = {
    'status': fields.Integer,
예제 #13
0
@Date: 2019-12-08 19:28:32
@LastEditTime: 2020-03-24 15:15:45
@LastEditors: Xuannan
'''
from flask_restful import Resource, reqparse, fields, marshal, abort
from app.apis.api_constant import *
from app.utils import object_to_json
from app.config import PAGINATE_NUM
from app.apis.admin.common import login_required, permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.cms import tag_doc
from flask import g

from app.models import BlogTag, MaitulTag, MetalpartsTag, InfoTag

api = Apidoc('内容管理-标签')

parse_id = reqparse.RequestParser()
parse_id.add_argument('id', type=str)

parse_base = parse_id.copy()
parse_base.add_argument('name', type=str, required=True, help='请输入标签名称')
parse_base.add_argument('lang')
parse_base.add_argument('sort', type=int, help='排序号只能是数字')

tag_fields = {
    'name': fields.String,
    'lang': fields.String,
    'sort': fields.Integer,
    'id': fields.String
}
예제 #14
0
@LastEditTime: 2020-03-29 18:25:11
@LastEditors: Xuannan
'''
from flask_restful import Resource,reqparse,fields,marshal,abort
from app.apis.api_constant import *
from app.utils import object_to_json
from app.utils.tree import build_tree
from app.apis.admin.common import login_required,permission_required
from app.utils.api_doc import Apidoc
from app.api_docs.cms import category_doc
from flask import g
from sqlalchemy import or_,and_
from app.models import BlogCategory,MaitulCategory,MetalpartsCategory,InfoCategory


api = Apidoc('内容管理-分类')


parse_id = reqparse.RequestParser()
parse_id.add_argument('id')

parse_base = parse_id.copy()
parse_base.add_argument('pid',type=str,required=True,help='请选择上级分类')
parse_base.add_argument('name',type=str,required=True,help='请输入分类名称')
parse_base.add_argument('keywords')
parse_base.add_argument('description')
parse_base.add_argument('icon')
parse_base.add_argument('cover')
parse_base.add_argument('module')
parse_base.add_argument('lang')
parse_base.add_argument('sort',type=int,help='排序号只能是数字')