123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace app\api\controller\v1;
- use app\api\business\SampleBus;
- use app\api\model\Ry;
- use app\api\model\Ryjr as RyjrModel;
- use app\api\model\Subject;
- use app\api\model\Ry as RyModel;
- use OpenApi\Annotations as OA;
- use app\BaseController;
- use thans\jwt\facade\JWTAuth;
- use think\exception\ValidateException;
- use think\facade\Db;
- use think\facade\Filesystem;
- use think\facade\Request as re;
- use think\Request;
- use think\facade\Cache;
- use thans\jwt\JWT;
- use rsa\Rsa;
- class Sample extends BaseController{
- use ResponseJson;
- protected $request;
- protected $middleware = [
- 'jwt' => ['except' => ['uploadfile']],
- ];
- public function __construct(Request $request)
- {
- $this->request = $request;
- }
-
- public function uploadfile(){
- $file = request() -> file('file');
- if ($file == null) {
- return $this ->jsonResponse(-1,'未上传文件');
- }
-
- $temp = explode(".", $_FILES["file"]["name"]);
- $extension = end($temp);
-
- if(!in_array($extension, array("pdf","PDF","DOC","doc","docx","DOCX","PNG","png"))){
- return $this ->jsonResponse(-2,'上传文件不合法');
- }
- try {
- validate(['file' => ['fileSize:10*1024*1024']])->check(['file' => $file]);
- } catch (ValidateException $e) {
- $return['msg'] = $e->getMessage();
- }
-
- $saveName = Filesystem::disk('public') -> putFile('file', $file, 'md5');
-
- $res = str_replace('\\', '/', 'http://syjc.aielab.net/uploads/'.$saveName);
- if($res){
- return $this->jsonSuccessData($res);
- }
- else{
- return $this->jsonData(-1,"上传文件失败");
- }
- }
-
- public function getSampleList(){
- $data = $this->request->post();
- $id=$data['id'];
- $pageNum=$data['pageNum'];
- $pageSize=$data['pageSize'];
- $res['rows'] = Db::name("cyd")->where('rwid','=',$id)->field('ypmc,ypbh,cyjs,cycs,status,brand')->page($pageNum,$pageSize)->select();
- $res['total'] = Db::name("cyd")->count();
- return $this->jsonSuccessData($res);
- }
- public function getSampleDetail(){
- $data = $this->request->post();
- $id=$data['id'];
- $res['rows'] = Db::name("cyd")->where('id','=',$id)
- ->field('ypmc,ypbh,cyjs,cycs,status,brand')
- ->leftJoin('t_','student_user.auth=student_teacher.auth and student_user.login_name=student_teacher.number and student_user.name=student_teacher.name')
- ->find();
- $res['total'] = Db::name("cyd")->count();
- return $this->jsonSuccessData($res);
- }
-
- public function addSample(){
- $data = $this->request->post();
- $resid=Db::name("cyd")->strict(false)->insertGetId($data);
- return $this->jsonSuccessData($resid);
- }
- }
|