admin/addon/servicer/shop/controller/Fast.php

87 lines
2.4 KiB
PHP

<?php
/**
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.cdcloudshop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\servicer\shop\controller;
use app\shop\controller\BaseShop;
use addon\servicer\model\Fast as FastModel;
/**
* 关键词回复
*/
class Fast extends BaseShop
{
/**
* 列表
*/
public function index()
{
if (request()->isAjax()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$condition = [['site_id', '=', $this->site_id]];
if (!empty($search_text)) {
$condition[] = ['content', 'like', '%' . $search_text . '%'];
}
$fast_model = new FastModel();
$res = $fast_model->getPageList($condition, $page, $page_size);
return $res;
} else {
return $this->fetch('fast/list');
}
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$fast_model = new FastModel();
return $fast_model->add([
'site_id' => $this->site_id,
'content' => input('content', ''),
]);
}
}
/**
* 编辑
*/
public function edit()
{
$fast_model = new FastModel();
if (request()->isAjax()) {
return $fast_model->edit([
'content' => input('content', ''),
], [['site_id', '=', $this->site_id], ['id', '=', input('id', 0)]]);
}
}
/**
* 删除
*/
public function delete()
{
if (request()->isAjax()) {
$fast_model = new FastModel();
return $fast_model->delete([
['site_id', '=', $this->site_id],
['id', 'in', (string)input('ids', '')]
]);
}
}
}