* Modify product api.

This commit is contained in:
songchenxuan
2023-07-05 10:38:00 +08:00
parent d1f392868a
commit e5920bc0fc
2 changed files with 11 additions and 3 deletions
+2
View File
@@ -107,10 +107,12 @@ class productEntry extends entry
*/
public function put($productID)
{
$useCode = $this->checkCodeUsed();
$oldProduct = $this->loadModel('product')->getByID($productID);
/* Set $_POST variables. */
$fields = 'program,line,name,PO,QD,RD,type,desc,whitelist,status,acl';
if($useCode) $fields .= ',code';
$this->batchSetPost($fields, $oldProduct);
$control = $this->loadController('product', 'edit');
+9 -3
View File
@@ -112,14 +112,20 @@ class productsEntry extends entry
*/
public function post()
{
$fields = 'program,code,line,name,PO,QD,RD,type,desc,whitelist';
$useCode = $this->checkCodeUsed();
$fields = 'program,line,name,PO,QD,RD,type,desc,whitelist';
if($useCode) $fields .= ',code';
$this->batchSetPost($fields);
$this->setPost('acl', $this->request('acl', 'private'));
$this->setPost('whitelist', $this->request('whitelist', array()));
$control = $this->loadController('product', 'create');
$this->requireFields('name,code');
$requireFields = 'name';
if($useCode) $requireFields .= ',code';
$this->requireFields($requireFields);
$control->create($this->request('program', 0));
@@ -130,7 +136,7 @@ class productsEntry extends entry
$product = $this->loadModel('product')->getByID($data->id);
$product = $this->format($product, 'createdDate:time,whitelist:userList,createdBy:user,PO:user,RD:user,QD:user');
return $this->send(200, $product);
return $this->send(201, $product);
}
/**