浏览代码

新增产品增加接口

huangsanjia 1 年之前
父节点
当前提交
895f36d26c
共有 1 个文件被更改,包括 28 次插入0 次删除
  1. 28 0
      application/api/controller/Product.php

+ 28 - 0
application/api/controller/Product.php

@@ -1009,4 +1009,32 @@ class Product extends Api
         }
 
     }
+    /**
+     * 新增产品
+     * @ApiMethod POST
+     *
+    */
+   public function addProduct(){
+       if (Request::instance()->isPost() == false){
+           $this->error('非法请求');
+       }
+       $params = Request::instance()->post();
+       if (empty($params)){
+           $this->error('参数不能为空');
+       }
+       $uniqId = \db('产品_基本资料')->order('UniqID desc')->value('UniqID');
+       if (empty($uniqId)){
+           $params['UniqID'] = 1;
+       }else{
+           $params['UniqID'] = $uniqId + 1;
+       }
+       $params['Sys_rq'] = date('Y-m-d H:i:s');
+       $sql = \db('产品_基本资料')->fetchSql(true)->insert($params);
+       $res = Db::query($sql);
+       if ($res !== false){
+           $this->success('新增成功');
+       }else{
+           $this->error('新增失败');
+       }
+   }
 }