<?php


namespace app\wechat\controller;


use app\wechat\IndexController;
use app\wechat\service\FollowService;
use app\wechat\validate\FollowValidate;
use support\Request;

class FollowController extends IndexController
{
    public function __construct()
    {
        $this->validateClass = new FollowValidate();
    }

    /**
     * Notes: 添加跟进记录
     * User: yb
     * Date: 2024/8/13
     * Time: 11:25
     * @param Request $request
     */
    public function addFollow(Request $request)
    {
        $params = $request->post();
        if (!$this->validateClass->check($params)) {
            return json_fail($this->validateClass->getError());
        }
        return FollowService::add($params);
    }

    /**
     * Notes: 跟进记录列表
     * User: yb
     * Date: 2024/8/13
     * Time: 15:55
     * @param Request $request
     */
    public function followList(Request $request)
    {
        $params = $request->post();
        return FollowService::index($params);
    }

    /**
     * Notes: 跟进记录详情
     * User: yb
     * Date: 2024/8/13
     * Time: 17:00
     * @param Request $request
     * @return \support\Response
     */
    public function followInfo(Request $request)
    {
        $params = $request->post();
        if (empty($params['id'])) {
            return json_fail('跟进记录id不能为空');
        }
        return FollowService::info($params['id']);
    }
}