删除curd层
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
from flask import Blueprint, render_template, request, jsonify
|
||||
|
||||
from applications.common import curd
|
||||
from applications.common.helper import ModelFilter
|
||||
from applications.common.utils.http import table_api, success_api, fail_api
|
||||
from applications.common.utils.rights import authorize
|
||||
from applications.common.utils.validate import xss_escape
|
||||
from applications.extensions import db
|
||||
from applications.models import DictType, DictData
|
||||
from applications.common.admin import dict_curd
|
||||
from applications.schemas import DictTypeSchema, DictDataSchema
|
||||
|
||||
admin_dict = Blueprint('adminDict', __name__, url_prefix='/admin/dict')
|
||||
@@ -22,13 +22,17 @@ def main():
|
||||
@admin_dict.get('/dictType/data')
|
||||
@authorize("admin:dict:main", log=True)
|
||||
def dict_type_data():
|
||||
# 获取请求参数
|
||||
type_name = xss_escape(request.args.get('typeName', type=str))
|
||||
dict_all = DictType.query
|
||||
# 查询参数构造
|
||||
mf = ModelFilter()
|
||||
if type_name:
|
||||
dict_all = dict_all.filter(DictType.type_name.like('%' + type_name + '%'))
|
||||
dict_all = dict_all.layui_paginate()
|
||||
mf.vague(field_name="type_name", value=type_name)
|
||||
# orm查询
|
||||
# 使用分页获取data需要.items
|
||||
dict_all = DictType.query.filter(mf.get_filter(DictType)).layui_paginate()
|
||||
count = DictType.query.count()
|
||||
data = curd.model_to_dicts(Schema=DictTypeSchema, model=dict_all.items)
|
||||
data = curd.model_to_dicts(schema=DictTypeSchema, data=dict_all.items)
|
||||
return table_api(data=data, count=count)
|
||||
|
||||
|
||||
@@ -78,7 +82,7 @@ def dict_type_update():
|
||||
def dict_type_enable():
|
||||
_id = request.json.get('id')
|
||||
if id:
|
||||
res = dict_curd.enable_dict_type_status(_id)
|
||||
res = curd.enable_status(DictType,_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api("启动成功")
|
||||
@@ -91,7 +95,7 @@ def dict_type_enable():
|
||||
def dict_type_dis_enable():
|
||||
_id = request.json.get('id')
|
||||
if id:
|
||||
res = dict_curd.disable_dict_type_status(_id)
|
||||
res = curd.disable_status(DictType,_id)
|
||||
if not res:
|
||||
return fail_api(msg="出错啦")
|
||||
return success_api("禁用成功")
|
||||
@@ -102,7 +106,7 @@ def dict_type_dis_enable():
|
||||
@admin_dict.delete('/dictType/remove/<int:_id>')
|
||||
@authorize("admin:dict:remove", log=True)
|
||||
def dict_type_delete(_id):
|
||||
res = dict_curd.delete_type_by_id(_id)
|
||||
res = curd.delete_one_by_id(DictType,_id)
|
||||
if not res:
|
||||
return fail_api(msg="删除失败")
|
||||
return success_api(msg="删除成功")
|
||||
@@ -114,7 +118,7 @@ def dict_code_data():
|
||||
type_code = xss_escape(request.args.get('typeCode', type=str))
|
||||
dict_data = DictData.query.filter_by(type_code=type_code).layui_paginate()
|
||||
count = DictType.query.count()
|
||||
data = curd.model_to_dicts(Schema=DictDataSchema, model=dict_data.items)
|
||||
data = curd.model_to_dicts(schema=DictDataSchema, data=dict_data.items)
|
||||
return table_api(data=data, count=count)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user