12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?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)
- ->order('id desc')
- ->paginate(["page"=>$params['page'],"list_rows"=>$params["size"]]);
- foreach ($list as $item) {
- $item->before = json_decode($item->before);
- $item->after = json_decode($item->after);
- }
- $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->where(["id"=>$params['id']])->findOrEmpty();
- if($changeInfo->isEmpty()){
- $this->error("修改记录不存在");
- }
- $changeInfo->before = json_decode($changeInfo->before);
- $changeInfo->after = json_decode($changeInfo->after);
- $this->success("获取成功",$changeInfo);
- }
- }
|