123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <?php
- namespace App\Http\Controllers\User;
- use App\Http\Controllers\Controller;
- use App\Http\Controllers\Core\Auth;
- use App\Models\User\InviteConfigModel;
- use App\Services\User\LikeInviteQuestionService;
- use Illuminate\Http\Request;
- class LikeInviteQuestionController extends Controller
- {
- /**
- * 我的录制->问题列表
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\VersionException
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- */
- public function createQuestion(Request $request)
- {
- $low_version = $latest_version = "2.11.10";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $this->validate($request, [
- 'question' => 'required',
- 'voice_src' => 'required',
- 'template_id' => 'required',
- 'question_type' => 'required'
- ]);
- $liqs = new LikeInviteQuestionService();
- $id = $liqs->createQuestion($uid, $request->toArray());
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => [
- 'id' => $id
- ]
- ]);
- }
- /**
- * 回答心动考验->换题列表
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\VersionException
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- */
- public function questionList(Request $request)
- {
- $low_version = $latest_version = "2.11.10";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- Auth::auth();
- $this->validate($request, [
- 'user_id' => 'required|integer',
- 'question_type' => 'required|in:0,1'
- ]);
- $user_id = $request->post('user_id');
- $question_type = $request->post('question_type', 0);
- $liqs = new LikeInviteQuestionService();
- $data = $liqs->questionList($user_id, $question_type);
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- ]);
- }
- /**
- * 我的录制->问题列表
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\VersionException
- */
- public function list(Request $request)
- {
- $low_version = $latest_version = "2.11.10";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $type = $request->get('type', 0);
- $page = $request->get('page', 1);
- $pages = array(
- 'page' => $request->get('page') ?? 1,
- 'limit' => 10
- );
- $liqs = new LikeInviteQuestionService();
- $data = $liqs->list($uid, $type, $pages);
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- ]);
- }
- /**
- * 我的录制->删除问题
- * @param int $question_id
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\AlertException
- * @throws \App\Exceptions\VersionException
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- */
- public function deleteQuestion(int $question_id, Request $request)
- {
- $low_version = $latest_version = "2.11.10";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $liqs = new LikeInviteQuestionService();
- $liqs->deleteQuestion($uid, $question_id);
- return response([
- 'code' => 200,
- 'message' => 'success'
- ]);
- }
- /**
- * 心动考验开关
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\AlertException
- * @throws \App\Exceptions\VersionException
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- * @deprecated 2.17.0 以上版本弃用
- * @version 2.17.0
- */
- public function likeInviteQuestionSwitch(Request $request)
- {
- $low_version = $latest_version = "2.17.0";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $this->validate($request, [
- 'task_type' => "required|in:task_photo,task_question,task_sing",
- 'switch' => "required|in:0,1"
- ]);
- $task_type = $request->post('task_type');
- $switch = $request->post('switch');
- $liqs = new LikeInviteQuestionService();
- $liqs->likeInviteQuestionSwitch($uid, $task_type, $switch);
- return response([
- 'code' => 200,
- 'message' => 'success'
- ]);
- }
- /**
- * 心动考验页的取消喜欢|喜欢 某人
- * @param int $question_id
- * @param Request $request
- * @return array
- * @throws \App\Exceptions\AlertException
- * @throws \App\Exceptions\VersionException
- * @throws \Tymon\JWTAuth\Exceptions\JWTException
- * @version 2.11.10
- */
- public function thumbQuestion(int $question_id, Request $request)
- {
- $low_version = $latest_version = "2.11.10";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $liqs = new LikeInviteQuestionService();
- $data = $liqs->thumb($uid, $question_id);
- return response([
- 'code' => 200,
- 'message' => 'success',
- 'data' => $data
- ]);
- }
- /**
- * 设置邀请问题
- * @param Request $request
- * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
- */
- public function setInviteQuestion(Request $request)
- {
- $low_version = $latest_version = "2.17.0";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $this->validate($request, [
- 'task_photo' => '',
- 'task_question' => '',
- 'task_sing' => '',
- 'task_paint' => '',
- 'task_question_data' => 'array',
- 'task_sing_data' => 'array',
- ]);
- $invite_config = InviteConfigModel::updateOrCreate(
- ['uid' => $uid],
- $request->all()
- );
- return response([
- 'code' => 200,
- 'message' => 'OK',
- 'data' => $invite_config
- ]);
- }
- /**
- * 获取邀请的问题
- * @param Request $request
- * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
- */
- public function getInviteQuestion(Request $request)
- {
- $low_version = $latest_version = "2.17.0";
- version($request->header('version', '0.00.01'), $low_version, $latest_version);
- $uid = Auth::auth();
- $invite_config = InviteConfigModel::firstOrCreate([
- 'uid' => $uid
- ]);
- return response([
- 'code' => 200,
- 'message' => 'OK',
- 'data' => $invite_config
- ]);
- }
- }
|