<?php

namespace app\workerapi\controller;

use app\workerapi\lists\MasterWorkerMessageLists;
use app\workerapi\logic\MasterWorkerMessageLogic;

class MasterWorkerMessageController extends BaseApiController
{
    /**
     * 统计师傅未读消息数量
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 林海涛
     * @date 2024/7/11 下午6:28
     */
    public function msgStatistics()
    {
       $data = MasterWorkerMessageLogic::msgStatistics($this->userId);
       return $this->success('操作成功', $data, 1, 1);

    }

    public function lists()
    {

        return $this->dataLists(new MasterWorkerMessageLists());
    }

    public function showMsg()
    {
        $validate = \think\facade\Validate::rule([
                'ids'  => 'require|array',
            ]);
        if (!$validate->check(request()->all())) {
            return $this->fail($validate->getError());
        }
        MasterWorkerMessageLogic::showMsg(request()->all(),$this->userId);
        return $this->success('操作成功', [], 1, 1);
    }
}