コード例 #1
0
 /**
  * 分类与属性绑定
  */
 public function actionCategoryattr()
 {
     $identity = Identity::checkIdentity('categoryattr', '/app-backend/backend/category/categoryattr');
     if (is_array($identity)) {
         return $identity;
     }
     $categoryId = \Yii::$app->request->_get('cid', 0);
     $attributeId = \Yii::$app->request->_get('attid', 0);
     $action = \Yii::$app->request->_get('action', '');
     $res = ['code' => 3, 'msg' => 'data erorr'];
     if (!$categoryId || !$attributeId || !$action) {
         return $res;
     }
     $data['categoryId'] = $categoryId;
     $data['attributeId'] = $attributeId;
     if ($action == 'a') {
         $exres = Attribute::bindCategoryAttr($data);
     } elseif ($action == 'r') {
         $exres = Attribute::removeCategoryAttr($data);
     }
     if ($exres) {
         return ['code' => 0, 'msg' => 'ok'];
     }
     return $res;
 }