123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace app\controller;
- use think\annotation\Route;
- use think\annotation\route\Middleware;
- use hg\apidoc\annotation as Apidoc;
- use app\BaseController;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use thans\filesystem\Filesystem;
- use think\response\Json;
- /**
- * @Apidoc\Title("文件上传")
- * @Apidoc\Group("文件")
- * @Apidoc\Sort (8)
- */
- class UploadFile extends BaseController
- {
- protected $middleware = [
- 'jwt',
- ];
- use ResponseJson;
- /**
- * @Apidoc\Title("企业营业执照上传")
- * @Apidoc\Tag("文件")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("enterpriseCardUpload",method="POST")
- * @Middleware({})
- */
- public function enterpriseCardUpload(): Json
- {
- $file = request()->file('image');
- $savename = (new Filesystem(app()))->disk("aliyun")->putFile( 'enterprise', $file, 'uniqid');
- return $this->JsonSucess(["filename"=>$savename,"url"=>"https://ahwgh.oss-cn-hangzhou.aliyuncs.com/".$savename]);
- }
- /**
- * @Apidoc\Title("法人、个人身份证上传")
- * @Apidoc\Tag("文件")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("personCardUpload",method="POST")
- * @Middleware({})
- */
- public function personCardUpload(): Json
- {
- $file = request()->file('image');
- $savename = (new Filesystem(app()))->disk("aliyun")->putFile( 'person', $file, 'uniqid');
- return $this->JsonSucess(["filename"=>$savename,"url"=>"https://ahwgh.oss-cn-hangzhou.aliyuncs.com/".$savename]);
- }
- /**
- * @Apidoc\Title("产品图片上传")
- * @Apidoc\Tag("文件")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("productUpload",method="POST")
- * @Middleware({})
- */
- public function productUpload(): Json
- {
- $file = request()->file('image');
- $savename = (new Filesystem(app()))->disk("aliyun")->putFile( 'product', $file, 'uniqid');
- return $this->JsonSucess(["filename"=>$savename,"url"=>"https://ahwgh.oss-cn-hangzhou.aliyuncs.com/".$savename]);
- }
- /**
- * @Apidoc\Title("产品认证上传")
- * @Apidoc\Tag("文件")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("productCreUpload",method="POST")
- * @Middleware({})
- */
- public function productCreUpload(): Json
- {
- $file = request()->file('image');
- $savename = (new Filesystem(app()))->disk("aliyun")->putFile( 'productCre', $file, 'uniqid');
- return $this->JsonSucess(["filename"=>$savename,"url"=>"https://ahwgh.oss-cn-hangzhou.aliyuncs.com/".$savename]);
- }
- /**
- * @Apidoc\Title("巡检照片上传")
- * @Apidoc\Tag("文件")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("patrolInspectionUpload",method="POST")
- * @Middleware({})
- */
- public function patrolInspectionUpload(): Json
- {
- $file = request()->file('image');
- $savename = (new Filesystem(app()))->disk("aliyun")->putFile( 'patrolInspection', $file, 'uniqid');
- return $this->JsonSucess(["filename"=>$savename,"url"=>"https://ahwgh.oss-cn-hangzhou.aliyuncs.com/".$savename]);
- }
- /**
- * @Apidoc\Title("投入品照片上传")
- * @Apidoc\Tag("文件")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("inputUpload",method="POST")
- * @Middleware({})
- */
- public function inputUpload(): Json
- {
- $file = request()->file('image');
- $savename = (new Filesystem(app()))->disk("aliyun")->putFile( 'input', $file, 'uniqid');
- return $this->JsonSucess(["filename"=>$savename,"url"=>"https://ahwgh.oss-cn-hangzhou.aliyuncs.com/".$savename]);
- }
- }
|