all(),[ 'corpid' => 'required|string', 'name' => 'required|string', 'is_for_all' => ['required', Rule::in([0, 1])], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $params = array(); $ruleId = $request->input('rule_id'); $params['sys_group_id'] = $request->input('sys_group_id'); $params['corpid'] = $request->input('corpid'); $params['admin_id'] = $request->input('admin_id', 1); $params['is_for_all'] = $request->input('is_for_all'); // 是否通用于全部员工 0:否 1:是 $params['users'] = $request->input('users'); // 使用成员,当通用于全部员工是,该字段可为空 $params['name'] = $request->input('name'); $params['msg_data'] = $request->input('msg_data'); # 设置新用户欢迎语发送规则 $errNo = WelcomeMsgService::setRule($ruleId, $params); return self::returnValue([], $errNo); } /** * 新用户欢迎语列表 * */ public function ruleLists(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $userId = $request->input('user_id'); $status = $request->input('status'); $page = $request->input('page', 1); $pageSize = $request->input('page_size', 20); # 获取群发规则列表 $errno = 0; list($list, $count) = WelcomeMsgService::ruleList($corpid, $userId, $status, $page, $pageSize, $errno); if($errno) return self::returnValue([], $errno); return self::returnPageValue($list, $count, $pageSize, $page); } /** * 新用户欢迎语详情 * */ public function ruleDetail(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); # 获取新用户欢迎语详情 $errno = 0; $detail = WelcomeMsgService::ruleDetail($corpid, $ruleId, $errno); return self::returnValue($detail, $errno); } /** * 新用户欢迎语规则启用/禁用 * */ public function updateStatus(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', 'status' => ['required', Rule::in([0, 1])], ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $status = $request->input('status'); $ruleId = $request->input('rule_id'); $errno = WelcomeMsgService::updateStatus($corpid, $ruleId, $status); return self::returnValue([], $errno); } /** * 新用户欢迎语规则删除 * */ public function ruleDel(Request $request) { $validator = \Validator::make($request->all(),[ 'corpid' => 'required|string', 'rule_id' => 'required|integer', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $corpid = $request->input('corpid'); $ruleId = $request->input('rule_id'); $errno = WelcomeMsgService::ruleDel($corpid, $ruleId); return self::returnValue([], $errno); } /** * 获取字符串的长度 * */ public function strLength(Request $request) { $validator = \Validator::make($request->all(),[ 'content' => 'required|string', ]); if ($validator->fails()) { return self::returnValue($validator->getMessageBag(), 1102); } $content = $request->input('content'); $length = strlen($content); return self::returnValue(['length' => $length]); } }