学生详情接口
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\controller;
|
namespace app\controller;
|
||||||
|
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@@ -8,40 +9,79 @@ class Student
|
|||||||
public function lists()
|
public function lists()
|
||||||
{
|
{
|
||||||
$post = $GLOBALS['data']['data'];
|
$post = $GLOBALS['data']['data'];
|
||||||
if(empty($post['type'])){
|
if (empty($post['type'])) {
|
||||||
return show("请选择传类型");
|
return show("请选择传类型");
|
||||||
}
|
}
|
||||||
$type = $post['type'];
|
$type = $post['type'];
|
||||||
$typeArray = [1,2,3,4];
|
$typeArray = [1, 2, 3, 4];
|
||||||
if(!in_array($type,$typeArray)){
|
if (! in_array($type, $typeArray)) {
|
||||||
return show("不支持当前类型!");
|
return show("不支持当前类型!");
|
||||||
}
|
}
|
||||||
//1=未来之星;2=适龄儿童;3=残联儿童;4=全部
|
//1=未来之星;2=适龄儿童;3=残联儿童;4=全部
|
||||||
if($type == 1) $where = "type=1";
|
if ($type == 1) {
|
||||||
if($type == 2) $where = "type=2";
|
$where = "type=1";
|
||||||
if($type == 3) $where = "disabled=1";
|
}
|
||||||
if($type == 4) $where = "";
|
if ($type == 2) {
|
||||||
|
$where = "type=2";
|
||||||
|
}
|
||||||
|
if ($type == 3) {
|
||||||
|
$where = "disabled=1";
|
||||||
|
}
|
||||||
|
if ($type == 4) {
|
||||||
|
$where = "";
|
||||||
|
}
|
||||||
|
|
||||||
$lastIndex = lastindex();
|
$lastIndex = lastindex();
|
||||||
if($lastIndex == 0) {
|
if ($lastIndex == 0) {
|
||||||
$lastIndex = 1;
|
$lastIndex = 1;
|
||||||
}
|
}
|
||||||
$result = [];
|
$result = [];
|
||||||
$list = Db::name("student")->where($where)->limit(env("page_count"))->order('hot desc')->paginate([
|
$list = Db::name("student")->where($where)->limit(env("page_count"))->order('hot desc')->paginate([
|
||||||
"list_rows"=>env("PAGE_COUNT"),
|
"list_rows" => env("PAGE_COUNT"),
|
||||||
"page"=>$lastIndex
|
"page" => $lastIndex
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if(empty($list)) return show("获取成功", SUCCESS_CODE,$result);
|
if (empty($list)) {
|
||||||
if($list->currentPage() < $list->lastPage()){
|
return show("获取成功", SUCCESS_CODE, $result);
|
||||||
$result['lastIndex'] = $lastIndex +1;
|
}
|
||||||
}else{
|
if ($list->currentPage() < $list->lastPage()) {
|
||||||
|
$result['lastIndex'] = $lastIndex + 1;
|
||||||
|
} else {
|
||||||
$result['lastIndex'] = 0;
|
$result['lastIndex'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = StudentToArray($list);
|
$result = StudentToArray($list);
|
||||||
return show(SUCCESS_MESSAGE,SUCCESS_CODE,$result);
|
return show(SUCCESS_MESSAGE, SUCCESS_CODE, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes : 获取学生的详情
|
||||||
|
*
|
||||||
|
* @Date : 2022/9/9 16:41
|
||||||
|
* @Author : <Jason.C>
|
||||||
|
*/
|
||||||
|
public function info()
|
||||||
|
{
|
||||||
|
$studentId = $GLOBALS['data']['data']['student_id'];
|
||||||
|
|
||||||
|
$vo = \app\model\Student::find($studentId);
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
"id" => $vo['id'],
|
||||||
|
"hot" => $vo['hot'],
|
||||||
|
"avatar" => $vo['avatar'],
|
||||||
|
"nickname" => $vo['nickname'],
|
||||||
|
"is_disabled" => $vo['disabled'],
|
||||||
|
"type" => $vo["type"],
|
||||||
|
"identifier" => $vo['identifier'],
|
||||||
|
"article_count" => $vo['article_count'],
|
||||||
|
"city" => $vo['city'],
|
||||||
|
"school" => $vo['school'],
|
||||||
|
"age" => $vo['age'],
|
||||||
|
];
|
||||||
|
|
||||||
|
return show(SUCCESS_MESSAGE, SUCCESS_CODE, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user