<?php

namespace app\service\controller;

use app\admin\model\Servicenotice as ServicenoticeModel;

/**
 * 接口
 */
class Dinterface extends Common
{

    public function getNotice()
    {
        $this->doTokenCheck();

        $uid = input('post.uid');
        $uid = intval(trim($uid, 'KF'));
        $rets = (new ServicenoticeModel())->where(['uid' => $uid, 'readtime' => 0])->order('id asc')->limit(20)->select();
        if ($rets) {
            foreach ($rets as $val) {
                $val->readtime = time();
                $val->save();
            }
        } else {
            return json(['code' => 1, 'data' => [], 'msg' => 'success']);
        }

        return json(['code' => 1, 'data' => $rets, 'msg' => 'success']);
    }


}
