123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use think\App;
- use think\facade\Validate;
- class GoodChange extends Base
- {
- protected $model=null;
- public function __construct(App $app) {
- parent::__construct($app);
- $this->model=new \app\admin\model\GoodChange();
- }
- //列表详情
- public function list(){
- $params = $this->request->param(['spuCode'=>'','page' => 1,'size' => 15],'post','trim');
- $where = [];
- if($params['spuCode'] !== '') {
- $where[] = ['spuCode','like',"%{$params['spuCode']}%"];
- }
- $list = $this->model
- ->where($where)->json(['before','after'])
- ->order('id desc')
- ->paginate(["page"=>$params['page'],"list_rows"=>$params["size"]]);
- $this->success('获取成功',['list' => $list->items(),'count' => $list->total()]);
- }
- //详情
- public function info(){
- $params=$this->request->param(['id'=>''],'post','trim');
- $valid=Validate::rule(['id|修改记录ID'=>'require']);
- if($valid->check($params)==false){
- $this->error($valid->getError());
- }
- $changeInfo = $this->model
- ->json(['before','after'])
- ->where(["id"=>$params['id']])
- ->findOrEmpty();
- if($changeInfo->isEmpty()){
- $this->error("修改记录不存在");
- }
- $this->success("获取成功",$changeInfo);
- }
- }
|