<?php

namespace app\api\controller;

class UserLog extends BaseShopController
{
    
    /**
     * 添加日志
     */
    public function add()
    {
        $params = $this->request->post();

        if(!$this->userId){
            return show(0,'请登录');
        }

        $data = [
            'user_id'=>$this->userId,
            'ip'=>$this->request->ip(),
            'code'=>$params['code'],
            'remark'=>$params['remark'],
        ];

        $text = $_SERVER;
        if(isset($params['text'])){
            foreach($params['text'] as $k=>$v){
                $text[$k]=$v;
            }
        }
        $data['text']=json_encode($text,true);

        \app\common\model\UserLog::create($data);

        return show(1,'写入成功');

    }
    
}