You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.0 KiB
PHP
133 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\EditHospitalQuestionInput;
|
|
use App\Models\HospitalQuestion;
|
|
use Illuminate\Http\Request;
|
|
use Yo;
|
|
use Login;
|
|
|
|
class HospitalQuestionController extends Controller
|
|
{
|
|
public function delete(Request $request)
|
|
{
|
|
Login::admin([17]);
|
|
$ids = $request->post('ids');
|
|
HospitalQuestion::whereIn('id', $ids)->update([
|
|
'del' => 1
|
|
]);
|
|
return Yo::delete_echo($ids);
|
|
}
|
|
|
|
public function update(EditHospitalQuestionInput $request)
|
|
{
|
|
Login::admin([17]);
|
|
$id = $request->post('id');
|
|
$hospital = $request->post('hospital');
|
|
$question = $request->post('question');
|
|
$type = $request->post('type');
|
|
$content = $request->post('content');
|
|
$mark = $request->post('mark');
|
|
$status = $request->post('status');
|
|
$order = $request->post('order');
|
|
$hospital_question = HospitalQuestion::find($id);
|
|
if (!$hospital_question) Yo::error_echo(100000, ['新闻']);
|
|
$hospital_question->hospital = $hospital;
|
|
$hospital_question->question = $question;
|
|
$hospital_question->type = $type;
|
|
$hospital_question->content = $content;
|
|
$hospital_question->mark = $mark ?? '';
|
|
$hospital_question->status = $status;
|
|
$hospital_question->order = $order;
|
|
$hospital_question->save();
|
|
return Yo::update_echo($hospital_question->id);
|
|
}
|
|
|
|
public function create(EditHospitalQuestionInput $request)
|
|
{
|
|
Login::admin([17]);
|
|
$hospital = $request->post('hospital');
|
|
$question = $request->post('question');
|
|
$type = $request->post('type');
|
|
$content = $request->post('content');
|
|
$mark = $request->post('mark');
|
|
$status = $request->post('status');
|
|
$order = $request->post('order');
|
|
$hospital_question = new HospitalQuestion();
|
|
$hospital_question->hospital = $hospital;
|
|
$hospital_question->question = $question;
|
|
$hospital_question->type = $type;
|
|
$hospital_question->content = $content;
|
|
$hospital_question->mark = $mark ?? '';
|
|
$hospital_question->status = $status;
|
|
$hospital_question->order = $order;
|
|
$hospital_question->save();
|
|
return Yo::create_echo($hospital_question->id);
|
|
}
|
|
|
|
public function admin_list(Request $request)
|
|
{
|
|
$hospital = $request->post('hospital');
|
|
$hospital_question_list = HospitalQuestion::where('hospital', $hospital)
|
|
->where('del', 2)->orderBy('order', 'asc')
|
|
->orderBy('id', 'asc')
|
|
->get();
|
|
return Yo::echo([
|
|
'list' => $hospital_question_list
|
|
]);
|
|
}
|
|
|
|
public function question_list($hospital, $data)
|
|
{
|
|
$peis = new PEISApiController();
|
|
$list = $peis::Post('获取题目列表', $hospital, $data);
|
|
return $list['data'];
|
|
}
|
|
|
|
public function list(Request $request)
|
|
{
|
|
$hospital = $request->post('hospital');
|
|
$type = $request->post('type');
|
|
$hospital_question_list = [];
|
|
if ($type == 1) {
|
|
$hospital_question_list = HospitalQuestion::where('hospital', $hospital)
|
|
->where('status', 1)->where('del', 2)->orderBy('id', 'desc')->get();
|
|
if (count($hospital_question_list) == 0) {
|
|
$hospital_question_list = HospitalQuestion::where('hospital', 0)
|
|
->where('status', 1)->where('del', 2)
|
|
->orderBy('order', 'asc')
|
|
->orderBy('id', 'asc')
|
|
->get();
|
|
}
|
|
}
|
|
if ($type == 2) {
|
|
$hospital_question_list = self::question_list($hospital, [
|
|
"性别" => $request->post('sex')
|
|
]);
|
|
}
|
|
return Yo::echo(['list' => $hospital_question_list]);
|
|
}
|
|
|
|
public function push_choose($hospital, $data)
|
|
{
|
|
$peis = new PEISApiController();
|
|
$list = $peis::Post('获取答题结果', $hospital, $data);
|
|
return $list['data'];
|
|
}
|
|
|
|
public function push(Request $request)
|
|
{
|
|
$hospital = $request->post('hospital');
|
|
$age = $request->post('age');
|
|
$sex = $request->post('sex');
|
|
$choose = $request->post('choose');
|
|
$res = self::push_choose($hospital, [
|
|
"年龄" => intval($age),
|
|
"选中项" => $choose,
|
|
"性别" => $sex == 1 ? '男' : "女"
|
|
]);
|
|
return Yo::echo(['list' => $res]);
|
|
}
|
|
}
|