1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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'],true)
- ->order('id desc')
- ->select();
- $result = [];
- foreach ($list as $item){
-
- $keys = array_keys($item["before"]);
- foreach ($keys as $key){
- $temp=[];
- $temp['field'] = \app\admin\model\GoodChange::$mapField[$key] ?? "";
- $temp['before'] = $item['before'][$key] ?? "";
- $temp['after'] = $item['after'][$key] ?? "";
- $temp['apply_name'] = $item['apply_name'];
- $temp['addtime'] = $item['addtime'];
- $result[] = $temp;
- }
-
-
- }
- $this->success('获取成功', $result);
- }
- //详情
- 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);
- }
- }
|