74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | 麦沃德科技赋能开发者,助力中小企业发展
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2017~2024 www.wdadmin.cn All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Wdadmin系统产品软件并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||
// +----------------------------------------------------------------------
|
||
// | Author: MY WORLD Team <bd@maiwd.cn> www.wdadmin.cn
|
||
// +----------------------------------------------------------------------
|
||
namespace app\api\controller\wdsxh\points;
|
||
|
||
use app\common\controller\Api;
|
||
|
||
class Goods extends Api
|
||
{
|
||
protected $noNeedLogin = ['*'];
|
||
protected $noNeedRight = ['*'];
|
||
|
||
protected $model = null;
|
||
|
||
public function _initialize()
|
||
{
|
||
parent::_initialize();
|
||
$this->model = new \app\api\model\wdsxh\points\Goods();
|
||
}
|
||
|
||
public function index()
|
||
{
|
||
if(!$this->request->isGet()) {
|
||
$this->error('请求类型错误');
|
||
}
|
||
$param = $this->request->get();
|
||
$page = isset($param['page']) ? $param['page'] : '';
|
||
$limit = isset($param['limit']) ? $param['limit'] : 10;
|
||
$where = [];
|
||
$where['status'] = array('eq','normal');
|
||
$total = $this->model->where($where)->count();
|
||
$data = $this->model
|
||
->where($where)
|
||
->field('id,name,image,points')
|
||
->page($page,$limit)
|
||
->order('weigh desc,createtime desc,id desc')
|
||
->select();
|
||
$this->success('请求成功',['total' => $total,'data' => $data]);
|
||
}
|
||
|
||
/**
|
||
* Desc 详情
|
||
* Create on 2025/11/13 上午8:55
|
||
* Create by wangyafang
|
||
*/
|
||
public function detail(){
|
||
if(!$this->request->isGet()) {
|
||
$this->error('请求类型错误');
|
||
}
|
||
$param = $this->request->get();
|
||
$id = isset($param['id']) ? $param['id'] : '';
|
||
if(!$id){
|
||
$this->error('参数错误');
|
||
}
|
||
$where = [];
|
||
$where['status'] = array('eq','normal');
|
||
$where['id'] = array('eq',$id);
|
||
$data = $this->model
|
||
->where($where)
|
||
->field('id,name,image,slider_images,points,content')
|
||
->find();
|
||
if(!$data){
|
||
$this->error('商品不存在或已下架');
|
||
}
|
||
$this->success('请求成功',$data);
|
||
}
|
||
} |