def add_permission_lib(self, name, strcode):
    """04添加权限"""
    permission = Permission.by_name(name)
    if permission is not None:
        return
    permission = Permission()
    permission.name = name
    permission.strcode = strcode
    self.db.add(permission)
    self.db.commit()
def add_permission_lib(self, name, strcode):
    """04添加权限"""
    permission= Permission.by_name(name)
    if permission is not None:
        flash(self, "权限已存在,添加失败", "error")
        return
    permission = Permission()
    permission.name = name
    permission.strcode = strcode
    self.db.add(permission)
    self.db.commit()
    flash(self, "权限添加成功", "success")
def add_permission_lib(self, name, strcode):
    '''04添加权限'''
    if not name or not strcode:
        flash(self, '请输入权限名和权限码!', 'error')
        return
    permission = Permission.by_name(name)
    # 如果权限有,就不用添加
    if permission is not None:
        flash(self, '权限已存在!', 'error')
        return
    permission = Permission()
    permission.name = name
    permission.strcode = strcode
    self.db.add(permission)
    self.db.commit()
    flash(self, '权限添加成功!', 'success')