all(),[ 'name' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $groupId = $request->input('group_id'); $groupName = $request->input('name'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 创建/编辑 素材组 list($groupId, $errno) = MediaService::editGroup($groupId, $groupName, $sysGroupId, $adminId); return self::returnValue(['group_id' => $groupId], $errno); } /** * 删除素材组 * */ public function delGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'group_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $groupId = $request->input('group_id'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 删除 $errno = MediaService::delGroup($groupId, $sysGroupId, $adminId); return self::returnValue([], $errno); } /** * 素材组列表 * */ public function groupList(Request $request) { $keyword = $request->input('keyword'); $sysGroupId = $request->input('sys_group_id'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取素材组列表 list($list, $count) = MediaService::getGroupList($sysGroupId, $keyword, $page, $pageSize); return self::returnPageValue($list, $count, $pageSize, $page); } /** * 批量新增/编辑素材到素材库 * */ public function editMedia(Request $request) { $validator = \Validator::make($request->all(),[ 'media_data' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $mediaData = $request->input('media_data'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 批量保存素材 $failList = []; $errno = MediaService::editMedia($mediaData, $sysGroupId, $adminId, $failList); if(!empty($failList)) return self::returnValue(['fail_list' => $failList], $errno); return self::returnValue([], $errno); } /** * 素材列表 * */ public function mediaList(Request $request) { $platformId = $request->input('platform_id'); $groupId = $request->input('group_id'); $keyword = $request->input('keyword'); $sysGroupId = $request->input('sys_group_id'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取素材组列表 list($list, $count) = MediaService::getMediaList($sysGroupId, $keyword, $platformId, $groupId, $page, $pageSize); return self::returnPageValue($list, $count, $pageSize, $page); } /** * 批量移动分组 * */ public function changeGroup(Request $request) { $validator = \Validator::make($request->all(),[ 'media_ids' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $mediaIds = $request->input('media_ids'); $groupId = $request->input('group_id'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 执行移动 $errno = MediaService::changeGroup($mediaIds, $groupId, $sysGroupId, $adminId); return self::returnValue([], $errno); } /** * 批量删除素材 * */ public function delMedia(Request $request) { $validator = \Validator::make($request->all(),[ 'media_ids' => 'required', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $mediaIds = $request->input('media_ids'); $sysGroupId = $request->input('sys_group_id'); $adminId = $request->input('admin_id'); # 执行删除 $errno = MediaService::delMedia($mediaIds, $sysGroupId, $adminId); return self::returnValue([], $errno); } /** * 素材库选择素材 * */ public function mediaSel(Request $request) { $validator = \Validator::make($request->all(),[ 'media_id' => 'required|integer', 'corpid' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $mediaId = $request->input('media_id'); # 素材入material表 $errno = 0; $data = MediaService::saveMaterial($mediaId, $corpid, $errno); return self::returnValue($data, $errno); } }