wangmingchuan321@qq.com 10 months ago
commit a8ec1016fb
  1. 30
      app/admin/controller/Store.php
  2. 14
      app/api/controller/Article.php

@ -184,18 +184,38 @@ class Store extends Controller
*/ */
public function auth(int $storeId): Json public function auth(int $storeId): Json
{ {
SyncTask::where('store_id', $storeId)->delete();
$platformList = $this->request->param('platformList'); $platformList = $this->request->param('platformList');
$currItems = SyncTask::where('store_id', $storeId)->select()->toArray();
if ($currItems) {
$delIds = [];
foreach ($currItems as $item) {
if (!in_array($item['channel'], $platformList)) {
$delIds[] = $item['id'];
}
}
unset($item);
//删除
if ($delIds) {
SyncTask::whereIn('id', $delIds)->delete();
}
}
$curr_channels = array_column($currItems, "channel");
$inData = []; $inData = [];
foreach ($platformList as $value) { foreach ($platformList as $platform) {
if (in_array($platform, $curr_channels)) {
continue;
}
$inData[] = [ $inData[] = [
'store_id' => $storeId, 'store_id' => $storeId,
'channel' => $value, 'channel' => $platform,
'create_time' => time(), 'create_time' => time(),
]; ];
} }
$model = new SyncTask; if ($inData) {
$model->addAll($inData); $model = new SyncTask;
$model->addAll($inData);
}
return $this->renderSuccess('操作成功'); return $this->renderSuccess('操作成功');
} }

@ -61,7 +61,7 @@ class Article extends Controller
*/ */
public function add(): Json public function add(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$title = $this->request->post('title'); $title = $this->request->post('title');
@ -97,7 +97,7 @@ class Article extends Controller
*/ */
public function edit(): Json public function edit(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$articleId = intval($this->request->post('article_id')); $articleId = intval($this->request->post('article_id'));
@ -140,7 +140,7 @@ class Article extends Controller
*/ */
public function delete(): Json public function delete(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$articleId = intval($this->request->post('article_id')); $articleId = intval($this->request->post('article_id'));
@ -163,7 +163,7 @@ class Article extends Controller
*/ */
public function addCategory(): Json public function addCategory(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$name = $this->request->post('name'); $name = $this->request->post('name');
@ -191,7 +191,7 @@ class Article extends Controller
*/ */
public function editCategory(): Json public function editCategory(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$categoryId = intval($this->request->post('category_id')); $categoryId = intval($this->request->post('category_id'));
@ -226,7 +226,7 @@ class Article extends Controller
*/ */
public function delCategory(): Json public function delCategory(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$categoryId = intval($this->request->post('category_id')); $categoryId = intval($this->request->post('category_id'));
@ -250,7 +250,7 @@ class Article extends Controller
*/ */
public function categoryList(): Json public function categoryList(): Json
{ {
if (UserService::isStore()) { if (!UserService::isStore()) {
throwError("无权限", 403); throwError("无权限", 403);
} }
$model = new \app\api\model\article\Category; $model = new \app\api\model\article\Category;

Loading…
Cancel
Save