123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shensong
- * Date: 2022/9/27
- * Time: 11:34
- */
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request;
- use App\Service\IntelligentMassSendingService;
- use Illuminate\Validation\Rule;
- class IntelligentMassSendingController extends Controller
- {
- # 平台列表
- public function platformIndex()
- {
- $data = IntelligentMassSendingService::platformIndex();
- return self::returnValue($data);
- }
- # 添加账号
- public function addAccount(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'platform_id' => 'required|integer',
- 'account' => 'required|string',
- 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['platform_id'] = $request->input('platform_id');
- $params['account'] = $request->input('account');
- $params['description'] = $request->input('description');
- $params['status'] = $request->input('status');
- $params['sys_group_id'] = $request->input('sys_group_id');
- list($res, $code) = IntelligentMassSendingService::addAccount($params);
- return self::returnValue($res, $code);
- }
- # 账号列表
- public function accountIndex(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'page' => 'required|numeric',
- 'page_size' => 'required|numeric',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- list($list, $count) = IntelligentMassSendingService::accountIndex($page, $pageSize, $sysGroupId);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- # 编辑账号
- public function editAccount(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'account_id' => 'required|integer',
- 'account' => 'required|string',
- 'platform_id' => 'required|integer',
- 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $accountId = $request->input('account_id');
- $params['account'] = $request->input('account');
- $params['platform_id'] = $request->input('platform_id');
- $params['description'] = $request->input('description');
- $params['status'] = $request->input('status');
- list($res, $code) = IntelligentMassSendingService::editAccount($accountId, $params);
- return self::returnValue($res, $code);
- }
- # 账号列表--下拉框
- public function accountList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'platform_id' => 'nullable|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $platformId = $request->input('platform_id');
- $sysGroupId = $request->input('sys_group_id');
- $list = IntelligentMassSendingService::accountList($platformId, $sysGroupId);
- return self::returnValue($list);
- }
- # 添加小程序
- public function addSmallApp(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'app_name' => 'required|string',
- 'app_id' => 'required|string',
- 'platform_id' => 'required|integer',
- 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['app_name'] = $request->input('app_name');
- $params['app_id'] = $request->input('app_id');
- $params['platform_id'] = $request->input('platform_id');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['status'] = $request->input('status');
- list($res, $code) = IntelligentMassSendingService::addSmallApp($params);
- return self::returnValue($res, $code);
- }
- # 编辑小程序
- public function editSmallApp(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'data_id' => 'required|integer',
- 'app_name' => 'required|string',
- 'app_id' => 'required|string',
- 'platform_id' => 'required|integer',
- 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $dataId = $request->input('data_id');
- $params['app_name'] = $request->input('app_name');
- $params['app_id'] = $request->input('app_id');
- $params['platform_id'] = $request->input('platform_id');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['status'] = $request->input('status');
- list($res, $code) = IntelligentMassSendingService::editSmallApp($dataId, $params);
- return self::returnValue($res, $code);
- }
- # 小程序列表
- public function smallAppIndex(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'page' => 'required|numeric',
- 'app_name' => 'nullable|string',
- 'page_size' => 'required|numeric',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $appName = $request->input('app_name');
- $page = $request->input('page');
- $pageSize = $request->input('page_size');
- $sysGroupId = $request->input('sys_group_id');
- list($list, $count) = IntelligentMassSendingService::smallAppIndex($appName, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- # 小程序下拉列表
- public function smallAppList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'platform_id' => 'integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $platformId = $request->input('platform_id');
- $list = IntelligentMassSendingService::smallAppList($sysGroupId, $platformId);
- return self::returnValue($list);
- }
- # 公众号下拉列表
- public function appList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $list = IntelligentMassSendingService::appList($corpid);
- return self::returnValue($list);
- }
- }
|