<?php

namespace app\admin\controller;


use app\admin\controller\BaseAdminController;
use app\admin\lists\ChangeLogLists;
use app\admin\logic\ChangeLogLogic;
use app\admin\validate\ChangeLogValidate;


/**
 * ChangeLog控制器
 * Class ChangeLogController
 * @package app\admin\controller
 */
class ChangeLogController extends BaseAdminController
{


    /**
     * @notes 获取列表
     * @return \think\response\Json
     * @author admin
     * @date 2025/01/06 10:03
     */
    public function lists()
    {
        return $this->dataLists(new ChangeLogLists());
    }


    /**
     * @notes 添加
     * @return \think\response\Json
     * @author admin
     * @date 2025/01/06 10:03
     */
    public function add()
    {
        $params = (new ChangeLogValidate())->post()->goCheck('add');
        $result = ChangeLogLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(ChangeLogLogic::getError());
    }


    /**
     * @notes 编辑
     * @return \think\response\Json
     * @author admin
     * @date 2025/01/06 10:03
     */
    public function edit()
    {
        $params = (new ChangeLogValidate())->post()->goCheck('edit');
        $result = ChangeLogLogic::edit($params);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(ChangeLogLogic::getError());
    }


    /**
     * @notes 删除
     * @return \think\response\Json
     * @author admin
     * @date 2025/01/06 10:03
     */
    public function delete()
    {
        $params = (new ChangeLogValidate())->post()->goCheck('delete');
        ChangeLogLogic::delete($params);
        return $this->success('删除成功', [], 1, 1);
    }


    /**
     * @notes 获取详情
     * @return \think\response\Json
     * @author admin
     * @date 2025/01/06 10:03
     */
    public function detail()
    {
        $params = (new ChangeLogValidate())->goCheck('detail');
        $result = ChangeLogLogic::detail($params);
        return $this->data($result);
    }


}