Ver código fonte

feat: add user chain category

王亚超 1 ano atrás
pai
commit
d1057cbd5e

+ 24 - 0
server/api/modules/v1/controllers/UserController.php

@@ -14,6 +14,7 @@ use abei2017\wx\mini\qrcode\Qrcode;
 use api\common\behaviors\QueryParamAuth;
 use api\common\controllers\Controller;
 use api\common\models\User;
+use api\modules\v1\models\Category;
 use api\modules\v1\models\UserEditForm;
 use common\enums\CodeEnum;
 use common\models\Store;
@@ -48,4 +49,27 @@ class UserController extends Controller
 
         return ['data' => User::findOne(Yii::$app->user->id)];
     }
+
+    /**
+     * 设置产业链
+     * @return string[]
+     * @throws ServerErrorHttpException
+     * @author nodelog
+     */
+    public function actionSetChain()
+    {
+        $model = Yii::$app->user->identity;
+        if (!empty($model->chain)) {
+            return ['errcode' => CodeEnum::CODE_ERROR, 'errmsg' => '您已设置产业分类,无需重复设置'];
+        }
+        $chain = request('chain');
+        $model->chain = $chain;
+        $model->save();
+        if ($model->hasErrors()) {
+            throw new ServerErrorHttpException(current($model->getErrors())[0]);
+        }
+
+        return ['errmsg' => '设置成功'];
+
+    }
 }

+ 2 - 0
server/common/modules/user/models/User.php

@@ -67,6 +67,7 @@ use yii\web\ServerErrorHttpException;
  * @property ShareLevel $shareLevel
  * @property Attachment $qrcode
  * @property array $dataCount
+ * @property int $chain
  */
 class User extends ActiveRecord implements IdentityInterface
 {
@@ -154,6 +155,7 @@ class User extends ActiveRecord implements IdentityInterface
             'is_vip' => '是否vip',        //是否vip
             'vip_time' => 'vip有效期',        //是否vip
             'dataCount' => '数据统计',
+            'chain' => '产业链',
         ];
     }
 

+ 1 - 0
server/database/202311301412.sql

@@ -0,0 +1 @@
+ALTER TABLE `dd_user` ADD `chain` TINYINT(2) NULL DEFAULT  COMMENT '产业链';