AppOperateLogExample.php 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<?php
/**
 * 操作日志示例
 *
 * @author zhangdongying
 * @date   2023-03-01
 */
declare(strict_types=1);

namespace Meibuyu\Common\GlobalLog\Example;

use Meibuyu\Common\GlobalLog\AppOperateLogService;
use Psr\Container\ContainerInterface;

class AppOperateLogExample
{
    /**
     * 容器实例
     */
    protected $container;

    /**
     * 初始化
     *
     * @param ContainerInterface $container 容器实例
     * @throws \Throwable
     */
    public function  __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * addUserOperateLog 调用示例
     *
     * @return void
     * @throws \Throwable
     */
    public function addUserOperateLogExample()
    {
        $this->container->get(AppOperateLogService::class)->addUserOperateLog(
            'products',
            '1',
zhangdongying's avatar
zhangdongying committed
44
            '产品管理-产品列表-产品编辑',
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
            ['product_id' => 1, 'name' => 'bbb'],
            ['id' => 1, 'name' => 'aaa'],
            ['id' => 2, 'name' => 'bbb']
        );
    }

    /**
     * addSystemOperateLog 调用示例
     *
     * @return void
     * @throws \Throwable
     */
    public function addSystemOperateLogExample()
    {
        $this->container->get(AppOperateLogService::class)->addSystemOperateLog(
zhangdongying's avatar
zhangdongying committed
60
            'AppOperateLogExample@addSystemOperateLogExample',
61 62
            'products',
            '1',
zhangdongying's avatar
zhangdongying committed
63
            '产品管理-产品列表-产品编辑',
64 65 66 67 68 69
            ['product_id' => 1, 'name' => 'bbb'],
            ['id' => 1, 'name' => 'aaa'],
            ['id' => 2, 'name' => 'bbb']
        );
    }
}