GoodChange.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller;
  4. use think\App;
  5. use think\facade\Validate;
  6. class GoodChange extends Base
  7. {
  8. protected $model=null;
  9. public function __construct(App $app) {
  10. parent::__construct($app);
  11. $this->model=new \app\admin\model\GoodChange();
  12. }
  13. //列表详情
  14. public function list(){
  15. $params = $this->request->param(['spuCode'=>'','page' => 1,'size' => 15],'post','trim');
  16. $where = [];
  17. if($params['spuCode'] !== '') {
  18. $where[] = ['spuCode','like',"%{$params['spuCode']}%"];
  19. }
  20. $list = $this->model
  21. ->where($where)->json(['before','after'])
  22. ->order('id desc')
  23. ->paginate(["page"=>$params['page'],"list_rows"=>$params["size"]]);
  24. $this->success('获取成功',['list' => $list->items(),'count' => $list->total()]);
  25. }
  26. //详情
  27. public function info(){
  28. $params=$this->request->param(['id'=>''],'post','trim');
  29. $valid=Validate::rule(['id|修改记录ID'=>'require']);
  30. if($valid->check($params)==false){
  31. $this->error($valid->getError());
  32. }
  33. $changeInfo = $this->model
  34. ->json(['before','after'])
  35. ->where(["id"=>$params['id']])
  36. ->findOrEmpty();
  37. if($changeInfo->isEmpty()){
  38. $this->error("修改记录不存在");
  39. }
  40. $this->success("获取成功",$changeInfo);
  41. }
  42. }