<?php namespace Source\Lib;
use Dever;
class Log
{
    # 新增日志
    public function add($info_data_id, $info)
    {
        $data['info_data_id'] = $info_data_id;
        $data['info'] = $info;
        $auth = Dever::load('common', 'manage')->auth();
        if ($auth) {
            $data['uid'] = $auth['uid'];
        }
        return Dever::db('info_data_log', 'source')->insert($data);
    }

    # 获取日志列表
    public function getList($info_data_id)
    {
        $data = Dever::db('info_data_log', 'source')->select(array('info_data_id' => $info_data_id));
        if ($data) {
            $auth = Dever::load('common', 'manage')->auth();
            $system = Dever::db('system', 'manage')->find($auth['extend']['system_id']);
            foreach ($data as &$v) {
                $user = Dever::db($system['user_table'])->find($v['uid']);
                $v['username'] = $user['name'];
                $v['cdate'] = date('Y-m-d H:i:s', $v['cdate']);
            }
        }
        return $data;
    }
}