first commit
This commit is contained in:
124
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Info.php
Normal file
124
芳林公司项目/www.zhiyuanhelp.com/application/api/controller/Info.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/13
|
||||
* Time: 19:34
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\Province;
|
||||
use app\api\model\Batchs;
|
||||
use app\api\model\ProScoreRank;
|
||||
use app\api\validate\BatchsValidate;
|
||||
use app\api\validate\IDMustValidate;
|
||||
use think\Db;
|
||||
|
||||
class Info extends BaseController
|
||||
{
|
||||
/*
|
||||
* 区域查询
|
||||
* */
|
||||
public function getAreaInfo(){
|
||||
$type = input('type',1);
|
||||
$result = Province::getAreaInfo($type);
|
||||
return api_return("获取成功",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 院校类型和院校特色
|
||||
* */
|
||||
public function getSchoolTypeInfo(){
|
||||
//院校类型
|
||||
$result = Db::table('school_cates')->cache(3600)->select();
|
||||
$res['schoolType'] = $result;
|
||||
//院校特色
|
||||
$res['schoolFeature'] = config('setsub.schoolFeature');
|
||||
//院校性质
|
||||
$res['schoolPub'] = config('setsub.is_pub');
|
||||
return api_return("获取成功",$res);
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据省份和年份,文理、分数查询最新批次
|
||||
* @param province int 省份code
|
||||
* */
|
||||
public function getBatchsByProvince(){
|
||||
//参数验证
|
||||
(new BatchsValidate())->goCheck();
|
||||
$provinceID = input('province');
|
||||
$score = input('score');
|
||||
$subType = input('subType',0);
|
||||
$result = Batchs::getBatchsByProvince($provinceID,$score,$subType);
|
||||
if(empty($result)){
|
||||
return api_error('暂无批次');
|
||||
}else{
|
||||
return api_return('获取成功',$result);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* 根据省份获取科目相关数据
|
||||
* @Param int provinceID
|
||||
* */
|
||||
public function getProSubject(){
|
||||
//参数验证
|
||||
(new IDMustValidate())->goCheck();
|
||||
$provinceID = input('id');
|
||||
//找出该省份高考类型并返回科目
|
||||
$proSubArr = config('setsub.diffProTest');
|
||||
$result = array();
|
||||
|
||||
//type 1普通高考 2新高考 3特殊高考
|
||||
if(in_array($provinceID,$proSubArr[1])){
|
||||
$result['subType'] = config('setsub.subType');
|
||||
$result['type'] = 3;
|
||||
$result['specialTestSub'] = config('setsub.specialTestSub');
|
||||
}elseif(in_array($provinceID,$proSubArr[2])){
|
||||
$result['type'] = 2;
|
||||
$result['newTestSub'] = config('setsub.newTestSub');
|
||||
}else{
|
||||
$result['type'] = 1;
|
||||
$result['subType'] = config('setsub.subType');
|
||||
}
|
||||
|
||||
|
||||
return api_return("获取成功!",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据省份和分数,文理科查询位次
|
||||
* */
|
||||
public function getUserProRank(){
|
||||
(new BatchsValidate())->goCheck();
|
||||
$array = input('');
|
||||
$result = ProScoreRank::getProRankByScore($array);
|
||||
return api_return("ok",$result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 图片上传
|
||||
* */
|
||||
public function uploadImage()
|
||||
{
|
||||
$this->verifyToken();
|
||||
// 获取上传文件
|
||||
$file = request()->file('imageName');
|
||||
$path = './uploads';
|
||||
// 移动到框架应用根目录/public/uploads/ 目录下
|
||||
$info = $file->validate(['size'=>41943040,'ext'=>'jpg,png,gif'])->move($path);
|
||||
|
||||
// 获取表单上传文件
|
||||
if ($info) {
|
||||
$infopath = str_replace("\\","/",$info->getSaveName());
|
||||
// 成功上传后 获取上传信息
|
||||
return api_return('ok',$infopath);
|
||||
} else {
|
||||
return api_error('upload fail');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user