1、打开任务配置表,如图1
2、打开任务步骤配置表,如图2
3、现在有新的需求:基于不同的租户,可以自定义其任务配置与任务步骤配置,因此,决定新建 租户的任务配置表、租户的任务步骤配置表,且这 2 张表的数据分别为 任务配置表、任务步骤配置表 的子集
4、新建数据库迁移文件,执行迁移后,表结构如图3
5、当租户未自定义时,即 租户的任务配置表、租户的任务步骤配置表 中无当前租户的记录时,默认全部勾选 任务配置表、任务步骤配置表 中的所有记录,如图4
6、新建编辑租户的任务类型与步骤设置的方法文件(/api/rests/config_group_task_step/EditAction.php)
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace api/rests/config_group_task_step; use Yii; use api/models/ConfigTask; use api/models/ConfigTaskStep; use api/models/redis/cmc_console/User as RedisCmcConsoleUser; use api/services/ConfigGroupTaskService; use api/services/ConfigGroupTaskStepService; use yii/helpers/ArrayHelper; use yii/web/UnprocessableEntityHttpException; /** * 编辑租户的任务类型与步骤设置:/config-group-task-steps/edit/my-group-id(config-group-task-step/edit) * * For more details and usage information on ViewAction, see the [guide article on rest controllers](guide:rest-controllers). * * @author Qiang Wang <shuijingwanwq@163.com> * @since 1.0 */ class EditAction extends Action { const IS_CHECKED_NO = 0; //是否被勾选:否 const IS_CHECKED_YES = 1; //是否被勾选:是 /** * Displays a model. * @param string $id the primary key of the model. * @return array * @throws UnprocessableEntityHttpException */ public function run($id) { // 当前用户的身份实例,未认证用户则为 Null /* @var $identity RedisCmcConsoleUser */ $identity = Yii::$app->user->identity; // 比对:group_id,检查其值是否等于:my-group-id if ($id != 'my-group-id') { throw new UnprocessableEntityHttpException(Yii::t('error', '226053'), 226053); } // 查找资源(任务配置)列表 $configTaskItems = ConfigTask::find()->isDeletedNo()->all(); // 查找资源(任务步骤配置)列表 $configTaskStepItems = ConfigTaskStep::find()->isDeletedNo()->isDefaultYes()->all(); // 基于租户ID返回数据模型(任务配置)列表 $configGroupTaskItems = ConfigGroupTaskService::findConfigTaskModelsByGroupId($identity->group_id); // 基于租户ID返回数据模型(任务步骤配置)列表 $configGroupTaskStepItems = ConfigGroupTaskStepService::findConfigTaskStepModelsByGroupId($identity->group_id); // 基于租户的任务步骤配置覆盖任务步骤配置,且基于任务配置ID分组 $configTaskStepGroupItems = []; foreach ($configTaskStepItems as $configTaskStepItem) { $configTaskStepGroupItem = [ 'id' => $configTaskStepItem->id, 'config_task_id' => $configTaskStepItem->config_task_id, 'code' => $configTaskStepItem->step_code, 'name' => $configTaskStepItem->step_name, 'sort_order' => $configTaskStepItem->sort_order, 'is_default' => $configTaskStepItem->is_default, 'is_checked' => static::IS_CHECKED_NO, ]; if (isset($configGroupTaskStepItems[$configTaskStepItem->id])) { $configTaskStepGroupItem['sort_order'] = $configGroupTaskStepItems[$configTaskStepItem->id]->sort_order; $configTaskStepGroupItem['is_default'] = $configGroupTaskStepItems[$configTaskStepItem->id]->is_default; $configTaskStepGroupItem['is_checked'] = static::IS_CHECKED_YES; } $configTaskStepGroupItems[$configTaskStepItem->config_task_id][] = $configTaskStepGroupItem; } $data = []; foreach ($configTaskItems as $configTaskItem) { // 基于步骤顺序,顺序排列;基于ID,倒序排列 if (isset($configTaskStepGroupItems[$configTaskItem->id])) { ArrayHelper::multisort($configTaskStepGroupItems[$configTaskItem->id], ['sort_order', 'id'], [SORT_ASC, SORT_DESC]); } else { $configTaskStepGroupItems[$configTaskItem->id] = []; } $data[] = [ 'id' => $configTaskItem->id, 'code' => $configTaskItem->code, 'name' => $configTaskItem->name, 'is_checked' => isset($configGroupTaskItems[$configTaskItem->id]) ? static::IS_CHECKED_YES: static::IS_CHECKED_NO, 'steps' => $configTaskStepGroupItems[$configTaskItem->id], ]; } return ['code' => 10000, 'message' => Yii::t('success', '126038'), 'data' => $data]; } }
7、新建编辑租户的任务类型与步骤设置的服务文件(/common/services/ConfigGroupTaskService.php)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:19 */ namespace common/services; use Yii; use common/logics/ConfigTask; use common/logics/ConfigGroupTask; use yii/helpers/ArrayHelper; class ConfigGroupTaskService extends Service { /** * 基于租户ID返回数据模型列表 * @param string $groupId 租户ID * @return array 一个 ActiveRecord 实例数组 */ public static function findConfigTaskModelsByGroupId($groupId) { // 基于租户ID查找资源(租户的任务配置)列表 $configGroupTaskItems = ConfigGroupTask::find()->where(['group_id' => $groupId])->all(); if (empty($configGroupTaskItems)) { // 查找资源(任务配置)列表 $configTaskItems = ConfigTask::find()->isDeletedNo()->indexBy(['id'])->all(); } else { // 基于租户ID查找资源(租户的任务配置、是否被删除:否)列表 $configGroupTaskIsDeletedNoItems = ConfigGroupTask::findAllByGroupId($groupId); // 获取 任务配置ID 值列表 $configTaskIds = ArrayHelper::getColumn($configGroupTaskIsDeletedNoItems, 'config_task_id'); // 基于多个ID查找资源(任务配置)列表 $configTaskItems = ConfigTask::findAllByIds($configTaskIds); } return $configTaskItems; } }
8、新建编辑租户的任务类型与步骤设置的服务文件(/common/services/ConfigGroupTaskStepService.php)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:19 */ namespace common/services; use Yii; use common/logics/ConfigTaskStep; use common/logics/ConfigGroupTaskStep; use yii/helpers/ArrayHelper; class ConfigGroupTaskStepService extends Service { /** * 基于租户ID返回数据模型(任务步骤配置)列表 * @param string $groupId 租户ID * @return array 一个 ActiveRecord 实例数组 */ public static function findConfigTaskStepModelsByGroupId($groupId) { // 基于租户ID查找资源(租户的任务步骤配置)列表 $configGroupTaskStepItems = ConfigGroupTaskStep::find()->where(['group_id' => $groupId])->all(); if (empty($configGroupTaskStepItems)) { // 查找资源(任务步骤配置)列表 $configTaskStepItems = ConfigTaskStep::find()->isDeletedNo()->isDefaultYes()->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_DESC])->indexBy(['id'])->all(); } else { // 基于租户ID查找资源(租户的任务步骤配置、是否被删除:否)列表 $configGroupTaskStepIsDeletedNoItems = ConfigGroupTaskStep::findAllIsDefaultYesByGroupId($groupId); // 获取 任务步骤配置ID 值列表 $configTaskStepIds = ArrayHelper::getColumn($configGroupTaskStepIsDeletedNoItems, 'config_task_step_id'); // 基于多个ID查找资源(任务步骤配置)列表 $configTaskStepIsDefaultYesItems = ConfigTaskStep::findAllIsDefaultYesByIds($configTaskStepIds); // 基于租户的任务步骤配置覆盖任务步骤配置 foreach ($configTaskStepIsDefaultYesItems as $configTaskStepItem) { $configTaskStepItem->sort_order = $configGroupTaskStepIsDeletedNoItems[$configTaskStepItem->id]->sort_order; $configTaskStepItem->is_default = $configGroupTaskStepIsDeletedNoItems[$configTaskStepItem->id]->is_default; } // 基于步骤顺序,顺序排列;基于ID,倒序排列 ArrayHelper::multisort($configTaskStepIsDefaultYesItems, ['sort_order', 'id'], [SORT_ASC, SORT_DESC]); // 重建数组索引 $configTaskStepItems = ArrayHelper::index($configTaskStepIsDefaultYesItems, 'id'); } return $configTaskStepItems; } }
9、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户未自定义时,即 租户的任务配置表、租户的任务步骤配置表 中无当前租户的记录时,默认全部勾选 任务配置表、任务步骤配置表 中的所有记录,响应数据与执行的 SQL 如下
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 1, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 8, "is_default": 1, "is_checked": 1 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 1, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 7, "is_default": 1, "is_checked": 1 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 10, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 11, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 1, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) ORDER BY `sort_order`, `id` DESC
10、新建更新租户的任务类型与步骤设置的方法文件(/api/rests/config_group_task_step/UpdateAction.php)
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace api/rests/config_group_task_step; use Yii; use api/models/ConfigGroupTask; use api/models/ConfigGroupTaskStep; use api/models/redis/cmc_console/User as RedisCmcConsoleUser; use api/services/ConfigGroupTaskStepService; use yii/base/Model; use yii/base/InvalidConfigException; use yii/helpers/ArrayHelper; use yii/web/UnprocessableEntityHttpException; use yii/web/ServerErrorHttpException; /** * 更新租户的任务类型与步骤设置:/config-group-task-steps/{group_id}(config-group-task-step/update) * * For more details and usage information on CreateAction, see the [guide article on rest controllers](guide:rest-controllers). * * @author Qiang Wang <shuijingwanwq@163.com> * @since 1.0 */ class UpdateAction extends Action { const IS_CHECKED_NO = 0; //是否被勾选:否 const IS_CHECKED_YES = 1; //是否被勾选:是 /** * @var string the scenario to be assigned to the model before it is validated and updated. * $id {config_column_id} */ public $scenario = Model::SCENARIO_DEFAULT; /** * Updates an existing model. * @param string $id the primary key of the model. * @return array the model being updated * @throws InvalidConfigException if a registered parser does not implement the [[RequestParserInterface]]. * @throws ServerErrorHttpException if there is any error when updating the model * @throws /Throwable */ public function run($id) { // 当前用户的身份实例,未认证用户则为 Null /* @var $identity RedisCmcConsoleUser */ $identity = Yii::$app->user->identity; // 比对:group_id,检查其值是否等于:my-group-id if ($id != 'my-group-id') { throw new UnprocessableEntityHttpException(Yii::t('error', '226053'), 226053); } /* @var $modelClass ConfigGroupTaskStep */ $modelClass = $this->modelClass; $requestParams = Yii::$app->getRequest()->getBodyParams(); /* @var $configGroupTaskItem ConfigGroupTask */ // 基于租户ID查找资源(租户的任务配置、是否被删除:否)列表 $configGroupTaskItems = ConfigGroupTask::find()->equalGroupId()->isDeletedNo()->indexBy('config_task_id')->all(); /* @var $configGroupTaskStepItem ConfigGroupTaskStep */ // 基于租户ID查找资源(租户的任务步骤配置、是否被删除:否)列表 $configGroupTaskStepItems = $modelClass::find()->equalGroupId()->isDeletedNo()->indexBy(['config_task_step_id'])->all(); if (!is_array($requestParams)) { return ['code' => 226010, 'message' => Yii::t('error', '226010')]; } $configGroupTasks = []; $configGroupTaskSteps = []; foreach ($requestParams as $configGroupTaskKey => $configGroupTask) { // 检查 任务配置的ID、任务配置的是否勾选 是否存在 if (!ArrayHelper::keyExists('id', $configGroupTask) || !ArrayHelper::keyExists('is_checked', $configGroupTask) || !in_array($configGroupTask['is_checked'], [static::IS_CHECKED_NO, static::IS_CHECKED_YES])) { throw new UnprocessableEntityHttpException(Yii::t('error', '226080'), 226080); } if ($configGroupTask['is_checked'] == static::IS_CHECKED_YES) { $configGroupTasks[$configGroupTask['id']] = [ 'config_task_id' => $configGroupTask['id'], ]; } // 检查 任务步骤配置列表 是否存在 if (ArrayHelper::keyExists('steps', $configGroupTask)) { foreach ($configGroupTask['steps'] as $configGroupTaskStep) { // 检查 步骤ID、步骤顺序、步骤是否勾选 是否存在 if (!ArrayHelper::keyExists('id', $configGroupTaskStep) || !ArrayHelper::keyExists('sort_order', $configGroupTaskStep) || !ArrayHelper::keyExists('is_checked', $configGroupTaskStep) || !in_array($configGroupTaskStep['is_checked'], [static::IS_CHECKED_NO, static::IS_CHECKED_YES])) { throw new UnprocessableEntityHttpException(Yii::t('error', '226080'), 226080); } $configGroupTaskSteps[$configGroupTaskStep['id']] = [ 'config_task_id' => $configGroupTask['id'], 'config_task_step_id' => $configGroupTaskStep['id'], 'sort_order' => $configGroupTaskStep['sort_order'], 'is_default' => $configGroupTaskStep['is_checked'] == static::IS_CHECKED_YES ? $modelClass::IS_DEFAULT_YES : $modelClass::IS_DEFAULT_NO, ]; } } } /* 租户的任务配置 */ // 使用键名比较计算数组的差集,如果不为空,则删除 (软删除) 出现在 租户的任务配置模型(MySQL) 中但是未出现在 租户的任务配置 中的记录 $configGroupTaskDiffItems = array_diff_key($configGroupTaskItems, $configGroupTasks); $configGroupTasks = array_values($configGroupTasks); $configGroupTaskModels = []; foreach ($configGroupTasks as $configGroupTask) { if (isset($configGroupTaskItems[$configGroupTask['config_task_id']])) { $configGroupTaskItems[$configGroupTask['config_task_id']]->scenario = ConfigGroupTask::SCENARIO_UPDATE; $configGroupTaskModels[] = $configGroupTaskItems[$configGroupTask['config_task_id']]; } else { $configGroupTaskModels[] = new ConfigGroupTask([ 'scenario' => ConfigGroupTask::SCENARIO_UPDATE, ]); } } // 批量填充模型属性 if (!empty($configGroupTaskModels) && !Model::loadMultiple($configGroupTaskModels, $configGroupTasks, '')) { return ['code' => 226010, 'message' => Yii::t('error', '226010')]; } // 批量验证模型 if (!empty($configGroupTaskModels) && !Model::validateMultiple($configGroupTaskModels)) { $configGroupTaskModelsResult = self::handleValidateMultipleError($configGroupTaskModels); if ($configGroupTaskModelsResult['status'] === false) { return ['code' => $configGroupTaskModelsResult['code'], 'message' => $configGroupTaskModelsResult['message']]; } } /* 租户的任务步骤配置 */ // 使用键名比较计算数组的差集,如果不为空,则删除 (软删除) 出现在 租户的任务步骤配置模型(MySQL) 中但是未出现在 租户的任务步骤配置 中的记录 $configGroupTaskStepDiffItems = array_diff_key($configGroupTaskStepItems, $configGroupTaskSteps); $configGroupTaskSteps = array_values($configGroupTaskSteps); $configGroupTaskStepModels = []; foreach ($configGroupTaskSteps as $configGroupTaskStep) { if (isset($configGroupTaskStepItems[$configGroupTaskStep['config_task_step_id']])) { $configGroupTaskStepItems[$configGroupTaskStep['config_task_step_id']]->scenario = ConfigGroupTask::SCENARIO_UPDATE; $configGroupTaskStepModels[] = $configGroupTaskStepItems[$configGroupTaskStep['config_task_step_id']]; } else { $configGroupTaskStepModels[] = new $modelClass([ 'scenario' => $modelClass::SCENARIO_UPDATE, ]); } } // 批量填充模型属性 if (!empty($configGroupTaskStepModels) && !Model::loadMultiple($configGroupTaskStepModels, $configGroupTaskSteps, '')) { return ['code' => 226010, 'message' => Yii::t('error', '226010')]; } // 批量验证模型 if (!empty($configGroupTaskStepModels) && !Model::validateMultiple($configGroupTaskStepModels)) { $configGroupTaskStepModelsResult = self::handleValidateMultipleError($configGroupTaskStepModels); if ($configGroupTaskStepModelsResult['status'] === false) { return ['code' => $configGroupTaskStepModelsResult['code'], 'message' => $configGroupTaskStepModelsResult['message']]; } } /* 操作数据(事务) */ $configGroupTaskStepService = new ConfigGroupTaskStepService(); $result = $configGroupTaskStepService->update($configGroupTaskDiffItems, $configGroupTaskModels, $configGroupTaskStepDiffItems, $configGroupTaskStepModels, $identity); if ($result['status'] === false) { throw new ServerErrorHttpException($result['message'], $result['code']); } return ['code' => 10000, 'message' => Yii::t('success', '126039')]; } }
11、新建更新租户的任务类型与步骤设置的服务文件(/api/services/ConfigGroupTaskService.php)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:17 */ namespace api/services; use Yii; use yii/web/ServerErrorHttpException; class ConfigGroupTaskService extends /common/services/ConfigGroupTaskService { /** * 创建租户的任务配置 * @param object $model 对象 * * @param bool $runValidation 保存记录之前是否执行验证 (调用 [[validate()]]),默认为 true * * @return array * 格式如下: * * [ * 'status' => true, // 成功 * 'data' => [ // object * ] * ] * * [ * 'status' => false, // 失败 * 'code' => 226081, // 返回码 * 'message' => '', // 说明 * ] * * @throws ServerErrorHttpException */ public function create($model, $runValidation = true) { if ($model->save($runValidation)) { return ['status' => true, 'data' => $model]; } elseif ($model->hasErrors()) { $firstError = ''; foreach ($model->getFirstErrors() as $message) { $firstError = $message; break; } return ['status' => false, 'code' => 226081, 'message' => Yii::t('error', Yii::t('error', Yii::t('error', '226081'), ['first_error' => $firstError]))]; } elseif (!$model->hasErrors()) { throw new ServerErrorHttpException('Failed to create the object (tenant/'s task configuration) for unknown reason.'); } } /** * 更新租户的任务配置 * @param object $model 对象 * * @param bool $runValidation 保存记录之前是否执行验证 (调用 [[validate()]]),默认为 true * * @return array * 格式如下: * * [ * 'status' => true, // 成功 * 'data' => [ // object * ] * ] * * [ * 'status' => false, // 失败 * 'code' => 226082, // 返回码 * 'message' => '', // 说明 * ] * * @throws ServerErrorHttpException */ public function update($model, $runValidation = true) { if ($model->save($runValidation)) { return ['status' => true, 'data' => $model]; } elseif ($model->hasErrors()) { $firstError = ''; foreach ($model->getFirstErrors() as $message) { $firstError = $message; break; } return ['status' => false, 'code' => 226082, 'message' => Yii::t('error', Yii::t('error', Yii::t('error', '226082'), ['first_error' => $firstError]))]; } elseif (!$model->hasErrors()) { throw new ServerErrorHttpException('Failed to update the object (tenant/'s task configuration) for unknown reason.'); } } /** * 批量删除(删除租户的任务配置) * * @param $models * * @return bool the saved model or false if saving fails * @throws /Throwable */ public function deleteMultiple($models) { $transaction = Yii::$app->db->beginTransaction(); try { foreach ($models as $model) { if($model->softDelete() === false) { throw new ServerErrorHttpException(Yii::t('error', '226083'), 226083); } } $transaction->commit(); return true; } catch (/Throwable $e) { $transaction->rollBack(); throw $e; } } }
12、新建更新租户的任务类型与步骤设置的服务文件(/api/services/ConfigGroupTaskStepService.php)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:18 */ namespace api/services; use Yii; use api/models/ConfigGroupTask; use api/models/ConfigGroupTaskStep; use yii/web/ServerErrorHttpException; class ConfigGroupTaskStepService extends /common/services/ConfigGroupTaskStepService { /** * 创建租户的任务步骤配置 * @param object $model 对象 * * @param bool $runValidation 保存记录之前是否执行验证 (调用 [[validate()]]),默认为 true * * @return array * 格式如下: * * [ * 'status' => true, // 成功 * 'data' => [ // object * ] * ] * * [ * 'status' => false, // 失败 * 'code' => 226084, // 返回码 * 'message' => '', // 说明 * ] * * @throws ServerErrorHttpException */ public function create($model, $runValidation = true) { if ($model->save($runValidation)) { return ['status' => true, 'data' => $model]; } elseif ($model->hasErrors()) { $firstError = ''; foreach ($model->getFirstErrors() as $message) { $firstError = $message; break; } return ['status' => false, 'code' => 226084, 'message' => Yii::t('error', Yii::t('error', Yii::t('error', '226084'), ['first_error' => $firstError]))]; } elseif (!$model->hasErrors()) { throw new ServerErrorHttpException('Failed to create the object (tenant/'s task step configuration) for unknown reason.'); } } /** * 添加|还原|更新|删除租户的任务配置、添加|还原|更新|删除租户的任务步骤配置 * * @param array $deletedConfigGroupTasks 需要删除的租户的任务配置 * 格式如下: * [ * [ // object * 'id' => 1, // ID * 'group_id' => '015ce30b116ce86058fa6ab4fea4ac63', // 租户ID * 'config_task_id' => 1, // 任务配置ID * 'status' => 1, // 状态,0:禁用;1:启用 * 'is_not_isolated' => 0, // 是否跨租户(不隔离),0:否;1:是 * 'is_deleted' => 0, // 是否被删除,0:否;1:是 * 'created_at' => 1572935084, // 创建时间 * 'updated_at' => 1572935084, // 更新时间 * 'deleted_at' => 0, // 删除时间 * ], * ... * ] * * @param array $configGroupTasks 租户的任务配置 * 格式如下: * [ * [ // object * 'config_task_id' => 1, // 任务配置ID * ], * [ // object * 'id' => 2, // ID * 'group_id' => '015ce30b116ce86058fa6ab4fea4ac63', // 租户ID * 'config_task_id' => 1, // 任务配置ID * 'status' => 1, // 状态,0:禁用;1:启用 * 'is_not_isolated' => 0, // 是否跨租户(不隔离),0:否;1:是 * 'is_deleted' => 0, // 是否被删除,0:否;1:是 * 'created_at' => 1572935084, // 创建时间 * 'updated_at' => 1572935084, // 更新时间 * 'deleted_at' => 0, // 删除时间 * ], * ... * ] * * @param array $deletedConfigGroupTaskSteps 需要删除的租户的任务步骤配置 * 格式如下: * [ * [ // object * 'id' => 1, // ID * 'group_id' => '015ce30b116ce86058fa6ab4fea4ac63', // 租户ID * 'config_task_id' => 1, // 任务配置ID * 'config_task_step_id' => 16, // 任务步骤配置ID * 'config_group_task_id' => 1, // 租户的任务配置ID * 'sort_order' => 1, // 步骤顺序,顺序排列 * 'is_default' => 1, // 是否默认步骤,1:是;0:否 * 'status' => 1, // 状态,0:禁用;1:启用 * 'is_not_isolated' => 0, // 是否跨租户(不隔离),0:否;1:是 * 'is_deleted' => 0, // 是否被删除,0:否;1:是 * 'created_at' => 1572935084, // 创建时间 * 'updated_at' => 1572935084, // 更新时间 * 'deleted_at' => 0, // 删除时间 * ], * ... * ] * * * @param array $configGroupTaskSteps 租户的任务步骤配置 * 格式如下: * [ * [ // object * 'config_task_id' => 1, // 任务配置ID * 'config_task_step_id' => 16, // 任务步骤配置ID * 'sort_order' => 1, // 步骤顺序 * 'is_default' => 1, // 是否默认步骤,1:是;0:否 * ], * [ // object * 'id' => 2, // ID * 'group_id' => '015ce30b116ce86058fa6ab4fea4ac63', // 租户ID * 'config_task_id' => 1, // 任务配置ID * 'config_task_step_id' => 1, // 任务步骤配置ID * 'config_group_task_id' => 1, // 租户的任务配置ID * 'sort_order' => 2, // 步骤顺序,顺序排列 * 'is_default' => 1, // 是否默认步骤,1:是;0:否 * 'status' => 1, // 状态,0:禁用;1:启用 * 'is_not_isolated' => 0, // 是否跨租户(不隔离),0:否;1:是 * 'is_deleted' => 0, // 是否被删除,0:否;1:是 * 'created_at' => 1572935084, // 创建时间 * 'updated_at' => 1572935084, // 更新时间 * 'deleted_at' => 0, // 删除时间 * ], * ... * ] * * @param object $identity 当前用户的身份实例 * * @return array * 格式如下: * * [ * 'status' => true, // 成功 * ] * * @throws /Throwable */ public function update($deletedConfigGroupTasks, $configGroupTasks, $deletedConfigGroupTaskSteps, $configGroupTaskSteps, $identity) { /* 操作数据(事务) */ $transaction = Yii::$app->db->beginTransaction(); try { $configGroupTaskService = new ConfigGroupTaskService(); // 使用键名比较计算数组的差集,如果不为空,则删除 (软删除) 出现在 租户的任务配置模型(MySQL) 中但是未出现在 租户的任务配置列表 中的记录 $configGroupTaskService->deleteMultiple($deletedConfigGroupTasks); // 遍历模型数组,判断在 租户的任务配置 中是否存在,如果不存在则插入,如果存在则更新(已删除则先还原) foreach ($configGroupTasks as $configGroupTask) { $configGroupTaskItem = ConfigGroupTask::find()->where(['group_id' => $identity->group_id, 'config_task_id' => $configGroupTask->config_task_id])->one(); /* @var $model ConfigGroupTask */ if (!isset($configGroupTaskItem)) { $configGroupTask->group_id = $identity->group_id; $configGroupTask->status = $configGroupTask::STATUS_ENABLED; $configGroupTask->is_not_isolated = $configGroupTask::IS_NOT_ISOLATED_NO; $configGroupTask->is_deleted = $configGroupTask::IS_DELETED_NO; $configGroupTask->deleted_at = $configGroupTask::DELETED_AT_DEFAULT; $configGroupTaskServiceCreateResult = $configGroupTaskService->create($configGroupTask, false); if ($configGroupTaskServiceCreateResult['status'] === false) { throw new ServerErrorHttpException($configGroupTaskServiceCreateResult['message'], $configGroupTaskServiceCreateResult['code']); } } else if (isset($configGroupTaskItem)) { if ($configGroupTaskItem->is_deleted == ConfigGroupTask::IS_DELETED_YES && $configGroupTaskItem->restore() === false) { throw new ServerErrorHttpException('Failed to restore the object (tenant/'s task configuration) for unknown reason.'); } } } // 使用键名比较计算数组的差集,如果不为空,则删除 (软删除) 出现在 租户的任务步骤配置模型(MySQL) 中但是未出现在 租户的任务步骤配置列表 中的记录 $this->deleteMultiple($deletedConfigGroupTaskSteps); $configGroupTaskItems = ConfigGroupTask::find()->where(['group_id' => $identity->group_id])->indexBy(['config_task_id'])->all(); // 遍历模型数组,判断在 租户的任务步骤配置 中是否存在,如果不存在则插入,如果存在则更新(已删除则先还原) foreach ($configGroupTaskSteps as $configGroupTaskStep) { $configGroupTaskStepItem = ConfigGroupTaskStep::find()->where(['group_id' => $identity->group_id, 'config_task_step_id' => $configGroupTaskStep->config_task_step_id])->one(); /* @var $model ConfigGroupTaskStep */ if (!isset($configGroupTaskStepItem)) { $configGroupTaskStep->group_id = $identity->group_id; $configGroupTaskStep->config_group_task_id = isset($configGroupTaskItems[$configGroupTaskStep->config_task_id]) ? $configGroupTaskItems[$configGroupTaskStep->config_task_id]['id'] : 0; $configGroupTaskStep->status = $configGroupTaskStep::STATUS_ENABLED; $configGroupTaskStep->is_not_isolated = $configGroupTaskStep::IS_NOT_ISOLATED_NO; $configGroupTaskStep->is_deleted = $configGroupTaskStep::IS_DELETED_NO; $configGroupTaskStep->deleted_at = $configGroupTaskStep::DELETED_AT_DEFAULT; $thisUpdateResult = $this->create($configGroupTaskStep, false); if ($thisUpdateResult['status'] === false) { throw new ServerErrorHttpException($thisUpdateResult['message'], $thisUpdateResult['code']); } } else if (isset($configGroupTaskStepItem)) { if ($configGroupTaskStepItem->is_deleted == ConfigGroupTaskStep::IS_DELETED_YES && $configGroupTaskStepItem->restore() === false) { throw new ServerErrorHttpException('Failed to restore the object (tenant/'s task step configuration) for unknown reason.'); } $configGroupTaskStepItem->config_group_task_id = isset($configGroupTaskItems[$configGroupTaskStep->config_task_id]) ? $configGroupTaskItems[$configGroupTaskStep->config_task_id]['id'] : 0; $configGroupTaskStepItem->sort_order = $configGroupTaskStep->sort_order; $configGroupTaskStepItem->is_default = $configGroupTaskStep->is_default; if ($configGroupTaskStepItem->save(false)) { // return ['status' => true, 'data' => $configGroupTaskStepItem]; } elseif ($configGroupTaskStepItem->hasErrors()) { $firstError = ''; foreach ($configGroupTaskStepItem->getFirstErrors() as $message) { $firstError = $message; break; } throw new ServerErrorHttpException(Yii::t('error', Yii::t('error', Yii::t('error', '226085'), ['first_error' => $firstError])), 226085); } elseif (!$configGroupTaskStepItem->hasErrors()) { throw new ServerErrorHttpException('Failed to update the object (tenant/'s task step configuration) for unknown reason.'); } } } $transaction->commit(); } catch(/Throwable $e) { $transaction->rollBack(); throw $e; } return ['status' => true]; } /** * 批量删除(删除租户的任务步骤配置) * * @param $models * * @return bool the saved model or false if saving fails * @throws /Throwable */ public function deleteMultiple($models) { $transaction = Yii::$app->db->beginTransaction(); try { foreach ($models as $model) { if($model->softDelete() === false) { throw new ServerErrorHttpException(Yii::t('error', '226086'), 226086); } } $transaction->commit(); return true; } catch (/Throwable $e) { $transaction->rollBack(); throw $e; } } }
13、编辑更新租户的任务设置的模型文件(/api/models/ConfigGroupTask.php)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:07 */ namespace api/models; use yii/helpers/ArrayHelper; class ConfigGroupTask extends /common/logics/ConfigGroupTask { const SCENARIO_UPDATE = 'update'; public function scenarios() { $scenarios = parent::scenarios(); $scenarios[self::SCENARIO_UPDATE] = ['config_task_id']; return $scenarios; } /** * @inheritdoc */ public function rules() { $rules = [ /* 添加/还原/更新、删除租户的任务配置 */ [['config_task_id'], 'required', 'on' => self::SCENARIO_UPDATE], ['config_task_id', 'exist', 'targetClass' => '/api/models/ConfigTask', 'targetAttribute' => 'id', 'filter' => ['is_deleted' => ConfigTask::IS_DELETED_NO], 'on' => self::SCENARIO_UPDATE], ]; $parentRules = parent::rules(); return ArrayHelper::merge($rules, $parentRules); } /** * {@inheritdoc} * @return ConfigGroupTaskQuery the active query used by this AR class. */ public static function find() { return new ConfigGroupTaskQuery(get_called_class()); } }
14、编辑更新租户的任务步骤设置的模型文件(/api/models/ConfigGroupTaskStep.php)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:09 */ namespace api/models; use yii/helpers/ArrayHelper; class ConfigGroupTaskStep extends /common/logics/ConfigGroupTaskStep { const SCENARIO_UPDATE = 'update'; public function scenarios() { $scenarios = parent::scenarios(); $scenarios[self::SCENARIO_UPDATE] = ['config_task_id', 'config_task_step_id', 'sort_order', 'is_default']; return $scenarios; } /** * @inheritdoc */ public function rules() { $rules = [ /* 添加/还原/更新、删除租户的任务步骤配置 */ [['config_task_id', 'config_task_step_id', 'sort_order', 'is_default'], 'required', 'on' => self::SCENARIO_UPDATE], [['config_task_step_id'], 'exist', 'targetClass' => '/api/models/ConfigTaskStep', 'targetAttribute' => ['config_task_step_id' => 'id', 'config_task_id' => 'config_task_id'], 'filter' => ['is_deleted' => ConfigTask::IS_DELETED_NO, 'is_default' => ConfigTaskStep::IS_DEFAULT_YES], 'on' => self::SCENARIO_UPDATE], ]; $parentRules = parent::rules(); return ArrayHelper::merge($rules, $parentRules); } /** * {@inheritdoc} * @return ConfigGroupTaskStepQuery the active query used by this AR class. */ public static function find() { return new ConfigGroupTaskStepQuery(get_called_class()); } }
15、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(null)与执行的 SQL (未插入数据) 如下,如图5
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63'
16、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据([])与执行的 SQL (未插入数据) 如下,如图6
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63'
17、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(全部勾选)与执行的 SQL (分别插入 4 、23 条记录) 如下,打开表,如图7
[ { "id": 1, "is_checked": 1, "steps": [ { "id": 16, "sort_order": 1, "is_checked": 1 }, { "id": 1, "sort_order": 2, "is_checked": 1 }, { "id": 3, "sort_order": 3, "is_checked": 1 }, { "id": 4, "sort_order": 4, "is_checked": 1 }, { "id": 17, "sort_order": 5, "is_checked": 1 }, { "id": 5, "sort_order": 6, "is_checked": 1 }, { "id": 6, "sort_order": 7, "is_checked": 1 } ] }, { "id": 2, "is_checked": 1, "steps": [ { "id": 7, "sort_order": 1, "is_checked": 1 }, { "id": 18, "sort_order": 2, "is_checked": 1 }, { "id": 19, "sort_order": 3, "is_checked": 1 }, { "id": 20, "sort_order": 4, "is_checked": 1 }, { "id": 21, "sort_order": 5, "is_checked": 1 }, { "id": 9, "sort_order": 6, "is_checked": 1 } ] }, { "id": 3, "is_checked": 1, "steps": [ { "id": 22, "sort_order": 1, "is_checked": 1 }, { "id": 10, "sort_order": 2, "is_checked": 1 }, { "id": 12, "sort_order": 3, "is_checked": 1 }, { "id": 23, "sort_order": 4, "is_checked": 1 }, { "id": 24, "sort_order": 5, "is_checked": 1 }, { "id": 25, "sort_order": 6, "is_checked": 1 }, { "id": 13, "sort_order": 7, "is_checked": 1 }, { "id": 14, "sort_order": 8, "is_checked": 1 }, { "id": 15, "sort_order": 9, "is_checked": 1 }, { "id": 26, "sort_order": 10, "is_checked": 1 } ] }, { "id": 4, "is_checked": 1, "steps": [] } ]
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=1) AND (`is_deleted`=0)) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=2) AND (`is_deleted`=0)) // 总计 4 次执行 SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=16) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=1) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) // 总计 23 次执行 Begin transaction SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=1) INSERT INTO `pa_config_group_task` (`config_task_id`, `group_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (1, '015ce30b116ce86058fa6ab4fea4ac63', 1, 0, 0, 0, 1572935084, 1572935084) SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=2) // 总计 4 次执行 INSERT INTO `pa_config_group_task` (`config_task_id`, `group_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (2, '015ce30b116ce86058fa6ab4fea4ac63', 1, 0, 0, 0, 1572935084, 1572935084) // 总计 4 次执行 SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=16) INSERT INTO `pa_config_group_task_step` (`config_task_id`, `config_task_step_id`, `sort_order`, `is_default`, `group_id`, `config_group_task_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (1, 16, 1, 1, '015ce30b116ce86058fa6ab4fea4ac63', 1, 1, 0, 0, 0, 1572935084, 1572935084) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=1) // 总计 23 次执行 INSERT INTO `pa_config_group_task_step` (`config_task_id`, `config_task_step_id`, `sort_order`, `is_default`, `group_id`, `config_group_task_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (1, 1, 2, 1, '015ce30b116ce86058fa6ab4fea4ac63', 1, 1, 0, 0, 0, 1572935084, 1572935084) // 总计 23 次执行 Commit transaction
18、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 1, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 7, "is_default": 1, "is_checked": 1 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 1, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 6, "is_default": 1, "is_checked": 1 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 1, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (1, 2, 3, 4)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (16, 1, 3, 4, 17, 5, 6, 7, 18, 19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26)) AND (`is_deleted`=0) AND (`is_default`=1)
19、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(部份勾选,租户的任务配置取消勾选 2 项,租户的任务步骤配置取消勾选 3 项)与执行的 SQL ( 5 条更新语句) 如下,打开表,如图8
[ { "id": 1, "is_checked": 0, "steps": [ { "id": 16, "sort_order": 1, "is_checked": 0 }, { "id": 1, "sort_order": 2, "is_checked": 1 }, { "id": 3, "sort_order": 3, "is_checked": 1 }, { "id": 4, "sort_order": 4, "is_checked": 1 }, { "id": 17, "sort_order": 5, "is_checked": 1 }, { "id": 5, "sort_order": 6, "is_checked": 1 }, { "id": 6, "sort_order": 7, "is_checked": 1 } ] }, { "id": 2, "is_checked": 1, "steps": [ { "id": 7, "sort_order": 1, "is_checked": 0 }, { "id": 18, "sort_order": 2, "is_checked": 0 }, { "id": 19, "sort_order": 3, "is_checked": 1 }, { "id": 20, "sort_order": 4, "is_checked": 1 }, { "id": 21, "sort_order": 5, "is_checked": 1 }, { "id": 9, "sort_order": 6, "is_checked": 1 } ] }, { "id": 3, "is_checked": 1, "steps": [ { "id": 22, "sort_order": 1, "is_checked": 1 }, { "id": 10, "sort_order": 2, "is_checked": 1 }, { "id": 12, "sort_order": 3, "is_checked": 1 }, { "id": 23, "sort_order": 4, "is_checked": 1 }, { "id": 24, "sort_order": 5, "is_checked": 1 }, { "id": 25, "sort_order": 6, "is_checked": 1 }, { "id": 13, "sort_order": 7, "is_checked": 1 }, { "id": 14, "sort_order": 8, "is_checked": 1 }, { "id": 15, "sort_order": 9, "is_checked": 1 }, { "id": 26, "sort_order": 10, "is_checked": 1 } ] }, { "id": 4, "is_checked": 0, "steps": [] } ]
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=2) AND (`is_deleted`=0)) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=3) AND (`is_deleted`=0)) // 总计 2 次执行 SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=16) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=1) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) // 总计 23 次执行 Begin transaction UPDATE `pa_config_group_task` SET `is_deleted`=1, `deleted_at`=1572939461 WHERE `id`=1 UPDATE `pa_config_group_task` SET `is_deleted`=1, `deleted_at`=1572939461 WHERE `id`=4 // 总计 23 次执行 SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=2) SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=3) // 总计 2 次执行 SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=16) UPDATE `pa_config_group_task_step` SET `is_default`=0, `updated_at`=1572939461 WHERE `id`=1 SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=7) // 总计 2 次执行 UPDATE `pa_config_group_task_step` SET `is_default`=0, `updated_at`=1572939461 WHERE `id`=8 // 总计 3 次执行 Commit transaction
20、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下,如图9
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 0, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 7, "is_default": 1, "is_checked": 1 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 1, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 6, "is_default": 1, "is_checked": 1 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 0, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (2, 3)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (1, 3, 4, 17, 5, 6, 19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26)) AND (`is_deleted`=0) AND (`is_default`=1)
21、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(删除第 1 个对象,即删除第 1 个租户的任务配置(数量为 1) 及其下的所有任务步骤配置(数量为 7))与执行的 SQL ( 7 条软删除语句,因为租户的任务配置早已被软删除) 如下,打开表,如图10
[ { "id": 2, "is_checked": 1, "steps": [ { "id": 7, "sort_order": 1, "is_checked": 0 }, { "id": 18, "sort_order": 2, "is_checked": 0 }, { "id": 19, "sort_order": 3, "is_checked": 1 }, { "id": 20, "sort_order": 4, "is_checked": 1 }, { "id": 21, "sort_order": 5, "is_checked": 1 }, { "id": 9, "sort_order": 6, "is_checked": 1 } ] }, { "id": 3, "is_checked": 1, "steps": [ { "id": 22, "sort_order": 1, "is_checked": 1 }, { "id": 10, "sort_order": 2, "is_checked": 1 }, { "id": 12, "sort_order": 3, "is_checked": 1 }, { "id": 23, "sort_order": 4, "is_checked": 1 }, { "id": 24, "sort_order": 5, "is_checked": 1 }, { "id": 25, "sort_order": 6, "is_checked": 1 }, { "id": 13, "sort_order": 7, "is_checked": 1 }, { "id": 14, "sort_order": 8, "is_checked": 1 }, { "id": 15, "sort_order": 9, "is_checked": 1 }, { "id": 26, "sort_order": 10, "is_checked": 1 } ] }, { "id": 4, "is_checked": 0, "steps": [] } ]
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=2) AND (`is_deleted`=0)) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=3) AND (`is_deleted`=0)) // 总计 2 次执行 SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=7) AND (`pa_config_task_step`.`config_task_id`=2) AND ((`is_deleted`=0) AND (`is_default`=1))) SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=18) AND (`pa_config_task_step`.`config_task_id`=2) AND ((`is_deleted`=0) AND (`is_default`=1))) // 总计 16 次执行 Begin transaction SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=2) SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=3) // 总计 2 次执行 UPDATE `pa_config_group_task_step` SET `is_deleted`=1, `deleted_at`=1572940590 WHERE `id`=1 UPDATE `pa_config_group_task_step` SET `is_deleted`=1, `deleted_at`=1572940590 WHERE `id`=2 // 总计 7 次执行 SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=7) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=18) // 总计 16 次执行 Commit transaction
22、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下,如图11
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 0, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 4, "is_default": 1, "is_checked": 0 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 5, "is_default": 1, "is_checked": 0 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 6, "is_default": 1, "is_checked": 0 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 7, "is_default": 1, "is_checked": 0 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 8, "is_default": 1, "is_checked": 0 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 1, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 6, "is_default": 1, "is_checked": 1 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 0, "steps": [] } ] }
SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (2, 3)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26)) AND (`is_deleted`=0) AND (`is_default`=1)
23、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(全部勾选)与执行的 SQL (分别软还原 2 、9 条记录) 如下,打开表,如图12
[ { "id": 1, "is_checked": 1, "steps": [ { "id": 16, "sort_order": 1, "is_checked": 1 }, { "id": 1, "sort_order": 2, "is_checked": 1 }, { "id": 3, "sort_order": 3, "is_checked": 1 }, { "id": 4, "sort_order": 4, "is_checked": 1 }, { "id": 17, "sort_order": 5, "is_checked": 1 }, { "id": 5, "sort_order": 6, "is_checked": 1 }, { "id": 6, "sort_order": 7, "is_checked": 1 } ] }, { "id": 2, "is_checked": 1, "steps": [ { "id": 7, "sort_order": 1, "is_checked": 1 }, { "id": 18, "sort_order": 2, "is_checked": 1 }, { "id": 19, "sort_order": 3, "is_checked": 1 }, { "id": 20, "sort_order": 4, "is_checked": 1 }, { "id": 21, "sort_order": 5, "is_checked": 1 }, { "id": 9, "sort_order": 6, "is_checked": 1 } ] }, { "id": 3, "is_checked": 1, "steps": [ { "id": 22, "sort_order": 1, "is_checked": 1 }, { "id": 10, "sort_order": 2, "is_checked": 1 }, { "id": 12, "sort_order": 3, "is_checked": 1 }, { "id": 23, "sort_order": 4, "is_checked": 1 }, { "id": 24, "sort_order": 5, "is_checked": 1 }, { "id": 25, "sort_order": 6, "is_checked": 1 }, { "id": 13, "sort_order": 7, "is_checked": 1 }, { "id": 14, "sort_order": 8, "is_checked": 1 }, { "id": 15, "sort_order": 9, "is_checked": 1 }, { "id": 26, "sort_order": 10, "is_checked": 1 } ] }, { "id": 4, "is_checked": 1, "steps": [] } ]
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=1) AND (`is_deleted`=0)) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=2) AND (`is_deleted`=0)) // 总计 4 次执行 SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=16) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=1) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) // 总计 23 次执行 Begin transaction SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=1) UPDATE `pa_config_group_task` SET `is_deleted`=0, `deleted_at`=0 WHERE `id`=1 SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=2) // 总计 4 次执行 UPDATE `pa_config_group_task` SET `is_deleted`=0, `deleted_at`=0 WHERE `id`=4 // 总计 2 次执行 SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=16) UPDATE `pa_config_group_task_step` SET `is_deleted`=0, `deleted_at`=0 WHERE `id`=1 UPDATE `pa_config_group_task_step` SET `is_default`=1, `updated_at`=1572942440 WHERE `id`=1 SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=1) // 总计 23 次执行 UPDATE `pa_config_group_task_step` SET `is_deleted`=0, `deleted_at`=0 WHERE `id`=2 // 总计 7 次执行 UPDATE `pa_config_group_task_step` SET `is_default`=1, `updated_at`=1572942440 WHERE `id`=8 // 总计 3 次执行 Commit transaction
24、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 1, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 7, "is_default": 1, "is_checked": 1 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 1, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 6, "is_default": 1, "is_checked": 1 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 1, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (1, 2, 3, 4)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (16, 1, 3, 4, 17, 5, 6, 7, 18, 19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26)) AND (`is_deleted`=0) AND (`is_default`=1)
25、截断 租户的任务配置表、租户的任务步骤配置表,在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(删除第 1 个对象,仅保留后 3 个对象,且其中一个对象的所有步骤全部不勾选,其中一个对象勾选部份步骤)与执行的 SQL (分别插入 2 、16 条记录) 如下,打开表,如图13、图14
[ { "id": 2, "is_checked": 0, "steps": [ { "id": 7, "sort_order": 1, "is_checked": 0 }, { "id": 18, "sort_order": 2, "is_checked": 0 }, { "id": 19, "sort_order": 3, "is_checked": 0 }, { "id": 20, "sort_order": 4, "is_checked": 0 }, { "id": 21, "sort_order": 5, "is_checked": 0 }, { "id": 9, "sort_order": 6, "is_checked": 0 } ] }, { "id": 3, "is_checked": 1, "steps": [ { "id": 22, "sort_order": 1, "is_checked": 1 }, { "id": 10, "sort_order": 2, "is_checked": 0 }, { "id": 12, "sort_order": 3, "is_checked": 1 }, { "id": 23, "sort_order": 4, "is_checked": 0 }, { "id": 24, "sort_order": 5, "is_checked": 1 }, { "id": 25, "sort_order": 6, "is_checked": 1 }, { "id": 13, "sort_order": 7, "is_checked": 1 }, { "id": 14, "sort_order": 8, "is_checked": 1 }, { "id": 15, "sort_order": 9, "is_checked": 1 }, { "id": 26, "sort_order": 10, "is_checked": 1 } ] }, { "id": 4, "is_checked": 1, "steps": [] } ]
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=3) AND (`is_deleted`=0)) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=4) AND (`is_deleted`=0)) // 总计 2 次执行 SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=7) AND (`pa_config_task_step`.`config_task_id`=2) AND ((`is_deleted`=0) AND (`is_default`=1))) SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=18) AND (`pa_config_task_step`.`config_task_id`=2) AND ((`is_deleted`=0) AND (`is_default`=1))) // 总计 16 次执行 Begin transaction SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=3) INSERT INTO `pa_config_group_task` (`config_task_id`, `group_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (3, '015ce30b116ce86058fa6ab4fea4ac63', 1, 0, 0, 0, 1572955001, 1572955001) SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=4) // 总计 2 次执行 INSERT INTO `pa_config_group_task` (`config_task_id`, `group_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (4, '015ce30b116ce86058fa6ab4fea4ac63', 1, 0, 0, 0, 1572955001, 1572955001) // 总计 2 次执行 SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=7) INSERT INTO `pa_config_group_task_step` (`config_task_id`, `config_task_step_id`, `sort_order`, `is_default`, `group_id`, `config_group_task_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (2, 7, 1, 0, '015ce30b116ce86058fa6ab4fea4ac63', 0, 1, 0, 0, 0, 1572955001, 1572955001) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=18) // 总计 16 次执行 INSERT INTO `pa_config_group_task_step` (`config_task_id`, `config_task_step_id`, `sort_order`, `is_default`, `group_id`, `config_group_task_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (2, 18, 2, 0, '015ce30b116ce86058fa6ab4fea4ac63', 0, 1, 0, 0, 0, 1572955001, 1572955001) // 总计 16 次执行 Commit transaction
26、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下,发现 Bug,如果任务步骤配置没有勾选,那么其字段:步骤顺序、是否默认步骤未覆盖任务步骤配置表中的数据,外在表现便是:用户所设置的步骤顺序不起作用
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 0, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 4, "is_default": 1, "is_checked": 0 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 5, "is_default": 1, "is_checked": 0 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 6, "is_default": 1, "is_checked": 0 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 7, "is_default": 1, "is_checked": 0 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 8, "is_default": 1, "is_checked": 0 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 0, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 4, "is_default": 1, "is_checked": 0 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 5, "is_default": 1, "is_checked": 0 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 6, "is_default": 1, "is_checked": 0 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 7, "is_default": 1, "is_checked": 0 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 5, "is_default": 1, "is_checked": 0 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 1, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (3, 4)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (22, 12, 24, 25, 13, 14, 15, 26)) AND (`is_deleted`=0) AND (`is_default`=1)
27、编辑服务文件(/common/services/ConfigGroupTaskStepService.php),以修复 Bug,新增加一个方法的参数($groupId, $isDefaultYes = true)
<?php /** * Created by PhpStorm. * User: Qiang Wang * Date: 2019/11/01 * Time: 10:19 */ namespace common/services; use Yii; use common/logics/ConfigTaskStep; use common/logics/ConfigGroupTaskStep; use yii/helpers/ArrayHelper; class ConfigGroupTaskStepService extends Service { /** * 基于租户ID返回数据模型(任务步骤配置)列表 * @param string $groupId 租户ID * @param bool $isDefaultYes 是否添加条件,默认步骤,1:是 * @return array 一个 ActiveRecord 实例数组 */ public static function findConfigTaskStepModelsByGroupId($groupId, $isDefaultYes = true) { // 基于租户ID查找资源(租户的任务步骤配置)列表 $configGroupTaskStepItems = ConfigGroupTaskStep::find()->where(['group_id' => $groupId])->all(); if (empty($configGroupTaskStepItems)) { // 查找资源(任务步骤配置)列表 if ($isDefaultYes) { $configTaskStepItems = ConfigTaskStep::find()->isDeletedNo()->isDefaultYes()->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_DESC])->indexBy(['id'])->all(); } else { $configTaskStepItems = ConfigTaskStep::find()->isDeletedNo()->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_DESC])->indexBy(['id'])->all(); } } else { // 基于租户ID查找资源(租户的任务步骤配置、是否被删除:否)列表 if ($isDefaultYes) { $configGroupTaskStepIsDeletedNoItems = ConfigGroupTaskStep::findAllIsDefaultYesByGroupId($groupId); } else { $configGroupTaskStepIsDeletedNoItems = ConfigGroupTaskStep::findAllByGroupId($groupId); } // 获取 任务步骤配置ID 值列表 $configTaskStepIds = ArrayHelper::getColumn($configGroupTaskStepIsDeletedNoItems, 'config_task_step_id'); // 基于多个ID查找资源(任务步骤配置)列表 if ($isDefaultYes) { $configTaskStepIsDeletedNoItems = ConfigTaskStep::findAllIsDefaultYesByIds($configTaskStepIds); } else { $configTaskStepIsDeletedNoItems = ConfigTaskStep::findAllByIds($configTaskStepIds); } // 基于租户的任务步骤配置覆盖任务步骤配置 foreach ($configTaskStepIsDeletedNoItems as $configTaskStepIsDeletedNoItem) { $configTaskStepIsDeletedNoItem->sort_order = $configGroupTaskStepIsDeletedNoItems[$configTaskStepIsDeletedNoItem->id]->sort_order; $configTaskStepIsDeletedNoItem->is_default = $configGroupTaskStepIsDeletedNoItems[$configTaskStepIsDeletedNoItem->id]->is_default; } // 基于步骤顺序,顺序排列;基于ID,倒序排列 ArrayHelper::multisort($configTaskStepIsDeletedNoItems, ['sort_order', 'id'], [SORT_ASC, SORT_DESC]); // 重建数组索引 $configTaskStepItems = ArrayHelper::index($configTaskStepIsDeletedNoItems, 'id'); } return $configTaskStepItems; } }
28、编辑方法文件(/api/rests/config_group_task_step/EditAction.php)
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace api/rests/config_group_task_step; use Yii; use api/models/ConfigTask; use api/models/ConfigTaskStep; use api/models/ConfigGroupTaskStep; use api/models/redis/cmc_console/User as RedisCmcConsoleUser; use api/services/ConfigGroupTaskService; use api/services/ConfigGroupTaskStepService; use yii/helpers/ArrayHelper; use yii/web/UnprocessableEntityHttpException; /** * 编辑租户的任务类型与步骤设置:/config-group-task-steps/edit/my-group-id(config-group-task-step/edit) * * For more details and usage information on ViewAction, see the [guide article on rest controllers](guide:rest-controllers). * * @author Qiang Wang <shuijingwanwq@163.com> * @since 1.0 */ class EditAction extends Action { const IS_CHECKED_NO = 0; //是否被勾选:否 const IS_CHECKED_YES = 1; //是否被勾选:是 /** * Displays a model. * @param string $id the primary key of the model. * @return array * @throws UnprocessableEntityHttpException */ public function run($id) { // 当前用户的身份实例,未认证用户则为 Null /* @var $identity RedisCmcConsoleUser */ $identity = Yii::$app->user->identity; // 比对:group_id,检查其值是否等于:my-group-id if ($id != 'my-group-id') { throw new UnprocessableEntityHttpException(Yii::t('error', '226053'), 226053); } // 查找资源(任务配置)列表 $configTaskItems = ConfigTask::find()->isDeletedNo()->all(); // 查找资源(任务步骤配置)列表 $configTaskStepItems = ConfigTaskStep::find()->isDeletedNo()->isDefaultYes()->all(); // 基于租户ID返回数据模型(任务配置)列表 $configGroupTaskItems = ConfigGroupTaskService::findConfigTaskModelsByGroupId($identity->group_id); // 基于租户ID返回数据模型(任务步骤配置)列表 $configGroupTaskStepItems = ConfigGroupTaskStepService::findConfigTaskStepModelsByGroupId($identity->group_id, false); // 基于租户的任务步骤配置覆盖任务步骤配置,且基于任务配置ID分组 $configTaskStepGroupItems = []; foreach ($configTaskStepItems as $configTaskStepItem) { $configTaskStepGroupItem = [ 'id' => $configTaskStepItem->id, 'config_task_id' => $configTaskStepItem->config_task_id, 'code' => $configTaskStepItem->step_code, 'name' => $configTaskStepItem->step_name, 'sort_order' => $configTaskStepItem->sort_order, 'is_default' => $configTaskStepItem->is_default, 'is_checked' => static::IS_CHECKED_NO, ]; if (isset($configGroupTaskStepItems[$configTaskStepItem->id])) { $configTaskStepGroupItem['sort_order'] = $configGroupTaskStepItems[$configTaskStepItem->id]->sort_order; $configTaskStepGroupItem['is_default'] = $configGroupTaskStepItems[$configTaskStepItem->id]->is_default; if ($configGroupTaskStepItems[$configTaskStepItem->id]->is_default == ConfigGroupTaskStep::IS_DEFAULT_YES) { $configTaskStepGroupItem['is_checked'] = static::IS_CHECKED_YES; } } $configTaskStepGroupItems[$configTaskStepItem->config_task_id][] = $configTaskStepGroupItem; } $data = []; foreach ($configTaskItems as $configTaskItem) { // 基于步骤顺序,顺序排列;基于ID,倒序排列 if (isset($configTaskStepGroupItems[$configTaskItem->id])) { ArrayHelper::multisort($configTaskStepGroupItems[$configTaskItem->id], ['sort_order', 'id'], [SORT_ASC, SORT_DESC]); } else { $configTaskStepGroupItems[$configTaskItem->id] = []; } $data[] = [ 'id' => $configTaskItem->id, 'code' => $configTaskItem->code, 'name' => $configTaskItem->name, 'is_checked' => isset($configGroupTaskItems[$configTaskItem->id]) ? static::IS_CHECKED_YES: static::IS_CHECKED_NO, 'steps' => $configTaskStepGroupItems[$configTaskItem->id], ]; } return ['code' => 10000, 'message' => Yii::t('success', '126038'), 'data' => $data]; } }
29、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下,已修复 Bug,如果任务步骤配置没有勾选,那么其字段:步骤顺序、是否默认步骤已覆盖任务步骤配置表中的数据,外在表现便是:用户所设置的步骤顺序已起作用
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 0, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 0 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 0 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 4, "is_default": 1, "is_checked": 0 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 5, "is_default": 1, "is_checked": 0 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 6, "is_default": 1, "is_checked": 0 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 7, "is_default": 1, "is_checked": 0 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 8, "is_default": 1, "is_checked": 0 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 0, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 0, "is_checked": 0 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 0, "is_checked": 0 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 3, "is_default": 0, "is_checked": 0 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 4, "is_default": 0, "is_checked": 0 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 5, "is_default": 0, "is_checked": 0 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 6, "is_default": 0, "is_checked": 0 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 0, "is_checked": 0 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 4, "is_default": 0, "is_checked": 0 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 1, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (3, 4)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (7, 18, 19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26)) AND (`is_deleted`=0)
30、在 Postman 中 PUT:http://api.pcs-api.localhost/v1/config-group-task-steps/my-group-id ,请求数据(全部勾选)与执行的 SQL (分别插入 2 、7 条记录,分别更新 0、8 条记录) 如下,打开表,如图15
[ { "id": 1, "is_checked": 1, "steps": [ { "id": 16, "sort_order": 1, "is_checked": 1 }, { "id": 1, "sort_order": 2, "is_checked": 1 }, { "id": 3, "sort_order": 3, "is_checked": 1 }, { "id": 4, "sort_order": 4, "is_checked": 1 }, { "id": 17, "sort_order": 5, "is_checked": 1 }, { "id": 5, "sort_order": 6, "is_checked": 1 }, { "id": 6, "sort_order": 7, "is_checked": 1 } ] }, { "id": 2, "is_checked": 1, "steps": [ { "id": 7, "sort_order": 1, "is_checked": 1 }, { "id": 18, "sort_order": 2, "is_checked": 1 }, { "id": 19, "sort_order": 3, "is_checked": 1 }, { "id": 20, "sort_order": 4, "is_checked": 1 }, { "id": 21, "sort_order": 5, "is_checked": 1 }, { "id": 9, "sort_order": 6, "is_checked": 1 } ] }, { "id": 3, "is_checked": 1, "steps": [ { "id": 22, "sort_order": 1, "is_checked": 1 }, { "id": 10, "sort_order": 2, "is_checked": 1 }, { "id": 12, "sort_order": 3, "is_checked": 1 }, { "id": 23, "sort_order": 4, "is_checked": 1 }, { "id": 24, "sort_order": 5, "is_checked": 1 }, { "id": 25, "sort_order": 6, "is_checked": 1 }, { "id": 13, "sort_order": 7, "is_checked": 1 }, { "id": 14, "sort_order": 8, "is_checked": 1 }, { "id": 15, "sort_order": 9, "is_checked": 1 }, { "id": 26, "sort_order": 10, "is_checked": 1 } ] }, { "id": 4, "is_checked": 1, "steps": [] } ]
SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=1) AND (`is_deleted`=0)) SELECT EXISTS(SELECT * FROM `pa_config_task` WHERE (`pa_config_task`.`id`=2) AND (`is_deleted`=0)) // 总计 4 次执行 SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=16) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) SELECT EXISTS(SELECT * FROM `pa_config_task_step` WHERE (`pa_config_task_step`.`id`=1) AND (`pa_config_task_step`.`config_task_id`=1) AND ((`is_deleted`=0) AND (`is_default`=1))) // 总计 23 次执行 Begin transaction SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=1) INSERT INTO `pa_config_group_task` (`config_task_id`, `group_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (1, '015ce30b116ce86058fa6ab4fea4ac63', 1, 0, 0, 0, 1573004620, 1573004620) SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_id`=2) // 总计 4 次执行 INSERT INTO `pa_config_group_task` (`config_task_id`, `group_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (2, '015ce30b116ce86058fa6ab4fea4ac63', 1, 0, 0, 0, 1573004620, 1573004620) // 总计 2 次执行 SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=16) INSERT INTO `pa_config_group_task_step` (`config_task_id`, `config_task_step_id`, `sort_order`, `is_default`, `group_id`, `config_group_task_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (1, 16, 1, 1, '015ce30b116ce86058fa6ab4fea4ac63', 3, 1, 0, 0, 0, 1573004620, 1573004620) SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`config_task_step_id`=1) // 总计 23 次执行 INSERT INTO `pa_config_group_task_step` (`config_task_id`, `config_task_step_id`, `sort_order`, `is_default`, `group_id`, `config_group_task_id`, `status`, `is_not_isolated`, `is_deleted`, `deleted_at`, `created_at`, `updated_at`) VALUES (1, 1, 2, 1, '015ce30b116ce86058fa6ab4fea4ac63', 3, 1, 0, 0, 0, 1573004620, 1573004620) // 总计 7 次执行 UPDATE `pa_config_group_task_step` SET `config_group_task_id`=4, `is_default`=1, `updated_at`=1573004620 WHERE `id`=1 UPDATE `pa_config_group_task_step` SET `config_group_task_id`=4, `is_default`=1, `updated_at`=1573004620 WHERE `id`=2 // 总计 6 次执行 UPDATE `pa_config_group_task_step` SET `is_default`=1, `updated_at`=1573004620 WHERE `id`=8 UPDATE `pa_config_group_task_step` SET `is_default`=1, `updated_at`=1573004620 WHERE `id`=10 // 总计 2 次执行 Commit transaction
31、在 Postman 中 GET:http://api.pcs-api.localhost/v1/config-group-task-steps/edit/my-group-id ,当租户已自定义时,即 租户的任务配置表、租户的任务步骤配置表 中有当前租户的记录时,基于租户的相关记录判断是否勾选 任务配置表、任务步骤配置表 中的记录,响应数据与执行的 SQL 如下
{ "code": 10000, "message": "编辑租户的任务类型与步骤设置成功", "data": [ { "id": 1, "code": "tv_broadcast", "name": "电视播出", "is_checked": 1, "steps": [ { "id": 16, "config_task_id": 1, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 1, "config_task_id": 1, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 3, "config_task_id": 1, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 4, "config_task_id": 1, "code": "video_editing", "name": "视频编辑", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 17, "config_task_id": 1, "code": "tandem_list", "name": "串联单", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 5, "config_task_id": 1, "code": "program_render", "name": "节目上传", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 6, "config_task_id": 1, "code": "program_authen", "name": "节目审查", "sort_order": 7, "is_default": 1, "is_checked": 1 } ] }, { "id": 2, "code": "inter_view", "name": "采访任务", "is_checked": 1, "steps": [ { "id": 7, "config_task_id": 2, "code": "begin_shot", "name": "上传素材", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 18, "config_task_id": 2, "code": "material_review", "name": "素材审核", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 19, "config_task_id": 2, "code": "writing", "name": "撰写稿件", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 20, "config_task_id": 2, "code": "writing_draft", "name": "撰写通稿", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 21, "config_task_id": 2, "code": "final_review", "name": "定稿审核", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 9, "config_task_id": 2, "code": "finish_interview", "name": "结束采访", "sort_order": 6, "is_default": 1, "is_checked": 1 } ] }, { "id": 3, "code": "rich_doc", "name": "互联网发布", "is_checked": 1, "steps": [ { "id": 22, "config_task_id": 3, "code": "retrieval", "name": "取稿", "sort_order": 1, "is_default": 1, "is_checked": 1 }, { "id": 10, "config_task_id": 3, "code": "writing", "name": "撰写稿件", "sort_order": 2, "is_default": 1, "is_checked": 1 }, { "id": 12, "config_task_id": 3, "code": "manuscript_review", "name": "稿件审核", "sort_order": 3, "is_default": 1, "is_checked": 1 }, { "id": 23, "config_task_id": 3, "code": "newspaper_issued", "name": "报纸签发", "sort_order": 4, "is_default": 1, "is_checked": 1 }, { "id": 24, "config_task_id": 3, "code": "wechat_group_reference", "name": "微信组稿引用", "sort_order": 5, "is_default": 1, "is_checked": 1 }, { "id": 25, "config_task_id": 3, "code": "website_release", "name": "网站发布", "sort_order": 6, "is_default": 1, "is_checked": 1 }, { "id": 13, "config_task_id": 3, "code": "app_release", "name": "APP发布", "sort_order": 7, "is_default": 1, "is_checked": 1 }, { "id": 14, "config_task_id": 3, "code": "wechat_release", "name": "微信发布", "sort_order": 8, "is_default": 1, "is_checked": 1 }, { "id": 15, "config_task_id": 3, "code": "blog_release", "name": "微博发布", "sort_order": 9, "is_default": 1, "is_checked": 1 }, { "id": 26, "config_task_id": 3, "code": "qq_release", "name": "企鹅号发布", "sort_order": 10, "is_default": 1, "is_checked": 1 } ] }, { "id": 4, "code": "other", "name": "手动任务", "is_checked": 1, "steps": [] } ] }
SELECT * FROM `pa_config_task` WHERE `is_deleted`=0 SELECT * FROM `pa_config_task_step` WHERE (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (3, 4, 1, 2)) AND (`is_deleted`=0) SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (7, 18, 19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26, 16, 1, 3, 4, 17, 5, 6)) AND (`is_deleted`=0)
32、基于租户的任务配置,可用于创建任务时,对于 任务配置ID 的验证,编辑任务的模型文件(/api/models/PlanTask.php),新增加验证规则(validateConfigTaskId)
<?php namespace api/models; use Yii; use api/models/redis/cmc_console/User as RedisCmcConsoleUser; use api/services/ConfigGroupTaskService; use yii/db/Expression; use yii/helpers/ArrayHelper; class PlanTask extends /common/logics/PlanTask { const SCENARIO_CREATE = 'create'; /** * {@inheritdoc} */ public function scenarios() { $scenarios = parent::scenarios(); $scenarios[self::SCENARIO_CREATE] = ['plan_id', 'config_column_id', 'title', 'config_task_id', 'occur_at', 'ended_at', 'exec_user_id', 'place', 'address', 'task_info']; return $scenarios; } /** * @inheritdoc */ public function rules() { $rules = [ /* 指派(创建任务) */ [['config_column_id'], 'validateConfigColumnId', 'when' => function($model) { return empty($model->plan_id); }, 'on' => self::SCENARIO_CREATE], ['config_task_id', 'exist', 'targetClass' => '/api/models/ConfigTask', 'targetAttribute' => 'id', 'filter' => ['is_deleted' => ConfigTask::IS_DELETED_NO, 'status' => ConfigTask::STATUS_ENABLED], 'on' => self::SCENARIO_CREATE], //create ['config_task_id', 'validateConfigTaskId', 'on' => self::SCENARIO_CREATE], //create [['exec_user_id'], 'validateExecUserId', 'on' => self::SCENARIO_CREATE], ]; $parentRules = parent::rules(); return ArrayHelper::merge($rules, $parentRules); } /** * 验证范围(基于租户ID返回数据模型(任务配置)列表):任务配置ID(场景:创建任务时,检查任务配置ID是否为当前租户所属的任务配置) * * @param string $attribute the attribute currently being validated * @param array $params the additional name-value pairs given in the rule */ public function validateConfigTaskId($attribute, $params) { if (!$this->hasErrors()) { // 当前用户的身份实例,未认证用户则为 Null /* @var $identity RedisCmcConsoleUser */ $identity = Yii::$app->user->identity; // 基于租户ID返回数据模型(任务配置)列表 $configGroupTaskItems = ConfigGroupTaskService::findConfigTaskModelsByGroupId($identity->group_id); if (!ArrayHelper::keyExists($this->$attribute, $configGroupTaskItems)) { $this->addError($attribute, Yii::t('error', Yii::t('error', Yii::t('error', '226087'), ['id' => $this->$attribute]))); } } }
响应:422 { "code": 226004, "message": "数据验证失败:任务配置ID:1,不属于当前租户所属的任务配置" }
33、基于租户的任务步骤配置,可用于创建任务时,插入任务步骤表时,可插入哪些步骤,编辑 /api/services/PlanTaskService.php
// 基于租户ID返回数据模型(任务步骤配置)列表 $configGroupTaskStepItems = ConfigGroupTaskStepService::findConfigTaskStepModelsByGroupId($identity->group_id, true); // 一个多维数组,它由第一级的 config_task_id 分组,并且不在第二级索引 $configGroupTaskStepItems = ArrayHelper::index($configGroupTaskStepItems, null, 'config_task_id'); /* @var PlanTask $model */ foreach ($models as $key => $model) { $model->group_id = $identity->group_id; $model->plan_id = $planId; $model->create_user_id = $identity->id; $model->create_name = $identity->login_name; $model->exec_name = $model->userByExecUserId['login_name']; $model->task_data = serialize([]); $model->is_united = $isUnited; $model->is_not_isolated = $isNotIsolated; if (!$model->save(false)) { throw new ServerErrorHttpException(Yii::t('error', '202015'), 202015); } /* 将模型记录转换为索引数组 */ /* 选题任务步骤 */ $configTaskSteps = isset($configGroupTaskStepItems[$model->config_task_id]) ? $configGroupTaskStepItems[$model->config_task_id] : []; /* @var ConfigTaskStep $configTaskStep */ foreach ($configTaskSteps as $configTaskStep) { if ($configTaskStep->status == ConfigTaskStep::STATUS_ENABLED) { $planTaskStepRows[] = [ $model->group_id, $model->id, $model->title, $configTaskStep->step_code, $configTaskStep->step_name, $configTaskStep->sort_order, $model->create_name, PlanTaskStep::STATUS_NOT_STARTED, PlanTaskStep::IS_DELETED_NO, $time, $time, PlanTaskStep::DELETED_AT_DEFAULT, ]; } } }
34、基于租户的任务步骤配置,总计 23 个步骤,取消勾选 5 个步骤,创建任务时,插入任务步骤表时,仅插入 18 条记录,执行 SQL 如下,如图16
SELECT * FROM `pa_config_group_task` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) SELECT * FROM `pa_config_task` WHERE (`id` IN (3, 4, 1, 2)) AND (`is_deleted`=0) Begin transaction SELECT * FROM `pa_config_group_task_step` WHERE `group_id`='015ce30b116ce86058fa6ab4fea4ac63' SELECT * FROM `pa_config_group_task_step` WHERE (`group_id`='015ce30b116ce86058fa6ab4fea4ac63') AND (`is_deleted`=0) AND (`is_default`=1) SELECT * FROM `pa_config_task_step` WHERE (`id` IN (7, 18, 19, 20, 21, 9, 22, 10, 12, 23, 24, 25, 13, 14, 15, 26, 5, 6)) AND (`is_deleted`=0) AND (`is_default`=1) INSERT INTO `pa_plan_task_step` (`group_id`, `task_id`, `task_title`, `step_code`, `step_name`, `sort_order`, `updated_name`, `status`, `is_deleted`, `created_at`, `updated_at`, `deleted_at`) VALUES ('015ce30b116ce86058fa6ab4fea4ac63', 5, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 1', 'program_render', '节目上传', 6, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 5, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 1', 'program_authen', '节目审查', 7, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 6, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 2', 'begin_shot', '上传素材', 1, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 6, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 2', 'material_review', '素材审核', 2, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 6, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 2', 'writing', '撰写稿件', 3, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 6, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 2', 'writing_draft', '撰写通稿', 4, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 6, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 2', 'final_review', '定稿审核', 5, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 6, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 2', 'finish_interview', '结束采访', 6, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'retrieval', '取稿', 1, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'writing', '撰写稿件', 2, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'manuscript_review', '稿件审核', 3, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'newspaper_issued', '报纸签发', 4, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'wechat_group_reference', '微信组稿引用', 5, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'website_release', '网站发布', 6, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'app_release', 'APP发布', 7, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'wechat_release', '微信发布', 8, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'blog_release', '微博发布', 9, '13281105967', 1, 0, 1573008480, 1573008480, 0), ('015ce30b116ce86058fa6ab4fea4ac63', 7, '深圳市1 - 选题 - 13281105967 - 20191106 - 1 - 3', 'qq_release', '企鹅号发布', 10, '13281105967', 1, 0, 1573008480, 1573008480, 0)
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/181413.html