Browse Source

feat:类目修改记录列表、详情

snow 1 year ago
parent
commit
bf7bd47128
3 changed files with 44 additions and 4 deletions
  1. 2 2
      app/admin/controller/Base.php
  2. 40 2
      app/admin/controller/GoodChange.php
  3. 2 0
      app/admin/route/app.php

+ 2 - 2
app/admin/controller/Base.php

@@ -97,7 +97,7 @@ class Base extends BaseController
      public function validateToken($request){
             $token = $request['token']?? '';
             $companyNo = $request['relaComNo'] ?? '';
-            if($token=='') $this->error('参数token不能为空','101');
+            if($token=='') $this->error('参数token不能为空',101);
             $effetc = VerifyTokens($token);
             if(!empty($effetc) && $effetc['code']!=0)$this->error($effetc['message'],$effetc['code']);
             $this->uid=$effetc['data']['id']??'';
@@ -109,7 +109,7 @@ class Base extends BaseController
             $userrole = \app\admin\model\UserRole::where(['uid'=>$this->uid,'is_del'=>0])->where($where)
             ->findOrEmpty();
             if($userrole->isEmpty()){
-            	 $this->error("账户已禁用",'101');
+            	 $this->error("账户已禁用",101);
             }
             $this->roleid=$userrole->roleid;
             $role =\app\admin\model\Role::where(['id'=>$userrole->roleid])->findOrEmpty();

+ 40 - 2
app/admin/controller/GoodChange.php

@@ -4,6 +4,7 @@ declare (strict_types = 1);
 namespace app\admin\controller;
 
 use think\App;
+use think\facade\Validate;
 
 class GoodChange extends Base
 {
@@ -13,11 +14,48 @@ class GoodChange extends Base
     	$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);
     }
 }

+ 2 - 0
app/admin/route/app.php

@@ -269,5 +269,7 @@ route::rule("departtipsadd","admin/DepartTips/departcreate");//网络部录单
 route::rule("wechat_getinfo","admin/WeChat/getinfo");//微信授权获取用户信息
 route::rule("wechat_getconfig","admin/WeChat/getConfig");//微信获取页面jssdk配置
 
+route::rule("goodChangeList","admin/GoodChange/list");
+route::rule("goodChangeInfo","admin/GoodChange/info");