AuthorityDelController.class.php 1.17 KB
<?php

/**
 * 权限范围删除
 * AbstractController.class.php
 * $author$
 */

namespace Apicp\Controller\Integral;

use Common\Service\AuthorityMainService;
use Common\Service\AuthorityService;

class AuthorityDelController extends AbstractController
{
    public function index()
    {
        $amId = I('post.am_id');
        if (empty($amId)) {
            L('_ERR_PARAMS_CAN_NOT_EMPTY', ['name' => '要删除的ID']);
        }

        // 删除
        try {
            $authorityMainServ = new AuthorityMainService();
            $haveAuthorityService = new AuthorityService();

            $authorityMainServ->start_trans();
            $haveAuthorityService->start_trans();

            $authorityMainServ->delete_by_conds(['am_id' => $amId]);
            $haveAuthorityService->delete_by_conds(['am_id' => $amId]);

            $authorityMainServ->commit();
            $haveAuthorityService->commit();
        } catch (\Exception $e) {
            $authorityMainServ->rollback();
            $haveAuthorityService->rollback();

            // 不影响主流程
            \Think\Log::record('删除出错:' . var_export($e->getMessage()));
        }

        return true;
    }
}