def edit(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(TreeDO, **arg_dict) BizUtil.check_assert(obj.id, "id") res = TreeService.edit(obj) if res: return bean_util.sqlalchemy_obj_to_dict(res)
if res: return bean_util.sqlalchemy_obj_to_dict(res) def save(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(${className}DO, **arg_dict) res = ${className}Service.save(obj) if res: return bean_util.sqlalchemy_obj_to_dict(res) def edit(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(${className}DO, **arg_dict) BizUtil.check_assert(obj.id, "id") res = ${className}Service.edit(obj) if res: return bean_util.sqlalchemy_obj_to_dict(res) def remove(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(${className}DO, **arg_dict) res = ${className}Service.delete_by_id(obj) ${className}Service.commit() if res: return bean_util.sqlalchemy_obj_to_dict(res) class ${className}Service(BaseService):
def tree_save(): try: args = request.get_json() return Result.success(tree_biz.save(**args)) except Exception as e: return BizUtil.handle_error("save error", e)
def tree_list(): try: args = request.get_json() return Result.success(tree_biz.query(**args)) except Exception as e: return BizUtil.handle_error("list error", e)
from flask import request from flask import current_app as app from routes import open_api as api from base.biz import BizUtil from base.biz import Result from biz import ${classNameLower}_biz @api.route("${ctlUrlPrefix}/save", methods=["POST"]) def ${classNameLower}_save(): try: args = request.get_json() return Result.success(${classNameLower}_biz.save(**args)) except Exception as e: return BizUtil.handle_error("save error", e) @api.route("${ctlUrlPrefix}/edit", methods=["POST"]) def ${classNameLower}_edit(): try: args = request.get_json() return Result.success(${classNameLower}_biz.edit(**args)) except Exception as e: return BizUtil.handle_error("edit error", e) @api.route("${ctlUrlPrefix}/get", methods=["POST"]) def ${classNameLower}_get(): try: args = request.get_json()