/**

* @OA\Get(path="/api/article",

* tags={"文章管理"},

* summary="文章列表",

* @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string", default="123456")),

* @OA\Parameter(name="page", in="query", description="页码", @OA\Schema(type="int", default="1")),

* @OA\Parameter(name="limit", in="query", description="行数", @OA\Schema(type="int", default="10")),

* @OA\Response(response="200", description="The User")

* )

*/

public function index()

{

$limit = $this->request->param('limit/d', 10);

$data = ArticleModel::paginate($limit);

return $this->jsonReturn(200, 'success', $data);

}

/**

* @OA\Post(path="/api/article",

* tags={"文章管理"},

* summary="新增文章",

* @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),

* @OA\RequestBody(

* @OA\MediaType(

* mediaType="multipart/form-data",

* @OA\Schema(

* @OA\Property(description="文章名称", property="title", type="string", default="dd"),

* @OA\Property(description="文章内容", property="content", type="string"),

* required={"title", "content"})

* )

* ),

* @OA\Response(response="200", description="successful operation")

* )

*/

public function save()

{

$param = $this->request->post();

$rule = [

'title' => 'require',

'content' => 'require'

];

$param = array_intersect_key($param, $rule);

try {

$this->validate($param, $rule);

} catch (ValidateException $e) {

return $this->jsonReturn(412, $e->getError());

}

ArticleModel::create([

'title' => $param['title'],

'content' => $param['content'],

'created_at' => date('Y-m-d H:i:s')

]);

return $this->jsonReturn();

}

/**

* @OA\Get(path="/api/article/{id}",

* tags={"文章管理"},

* summary="文章详情",

* @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),

* @OA\Parameter(name="id", in="path", description="文章id", @OA\Schema(type="int")),

* @OA\Response(response="200", description="The User")

* )

*/

public function read($id)

{

$data = ArticleModel::whereId($id)->find();

return $this->jsonReturn(200, 'success', $data);

}

/**

* @OA\Put(path="/api/article/{id}",

* tags={"文章管理"},

* summary="编辑文章",

* @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),

* @OA\Parameter(name="id", in="path", description="文章id", @OA\Schema(type="int")),

* @OA\RequestBody(

* @OA\MediaType(

* mediaType="content-type/json",

* @OA\Schema(

* @OA\Property(description="文章名称", property="title", type="string"),

* @OA\Property(description="文章内容", property="content", type="string"),

* required={"title", "content"})

* )

* ),

* @OA\Response(response="200", description="successful operation")

* )

*/

public function update($id)

{

$param = $this->request->put();

$rule = [

'title' => 'require',

'content' => 'require'

];

$param = array_intersect_key($param, $rule);

try {

$this->validate($param, $rule);

} catch (ValidateException $e) {

return $this->jsonReturn(412, $e->getError());

}

ArticleModel::whereId($id)->update([

'title' => $param['title'],

'content' => $param['content'],

'updated_at' => date('Y-m-d H:i:s')

]);

return $this->jsonReturn();

}

/**

* @OA\Delete(path="/api/article/{id}",

* tags={"文章管理"},

* summary="删除文章",

* @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),

* @OA\Parameter(name="id", in="path", description="文章id", @OA\Schema(type="int")),

* @OA\Response(response="200", description="The User")

* )

*/

public function delete($id)

{

ArticleModel::destroy($id);

return $this->jsonReturn();

}

swagge php token,swagger在thinkphp6的使用方式相关推荐

  1. ThinkPHP6项目基操目录

    前言 ThinkPHP是一个免费开源的,快速.简单的面向对象的轻量级PHP开发框架,是为了敏捷WEB应用开发和简化企业应用开发而诞生的.ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色 ...

  2. NETCore2.2/3.0+使用带有权限验证的Swagger

    文章目录 Swagger 什么是Swagger NuGet安装 Startup注册Swagger 设置默认首页打开Swagger 为接口添加注释 JWT 什么是JWT 注册授权认证服务 API接口添加 ...

  3. Spring Boot(9)之 Swagger 接口文档生成器

    1.添加依赖 spring4all工具源码 <dependency><groupId>com.spring4all</groupId><artifactId& ...

  4. swagger ui 怎么输入对象_Swagger UI 传入对象类型参数

    Swagger要传送对象作为参数,只需添加@ModelAttribute或@RequestBody @RestController @RequestMapping("/api/json/re ...

  5. thinkPHP6.0入门笔记(四)——删除和修改用户信息

    thinkPHP6.0实现删除和修改用户信息 1.删除用户信息 2.优化bootstrap资源引入方式 3.浏览器的cookie与session机制 4.token令牌原理 5.利用token防止表单 ...

  6. SpringBoot+OAuth2+Spring Security+Redis+mybatis-plus+mysql+swagger搭建实现

    一.项目结构介绍 源码下载 直接看图就行: 关键点都在config包里面,那我们看看config: 很明了, Excepition 是自定义异常封装类 redis redis缓存配置 security ...

  7. Ubuntu安装Swagger UI

    环境 操作系统:Ubuntu 22.04 node 16.15.1 npm 8.11.0 安装Swagger UI 方法0:官网在线的 Swagge UI https://swagger.io/too ...

  8. oauth2 增加token 返回参数_RingCentral Tech | OAuth2.0面面观

    ▲点击"RingCentral铃盛软件"并设为[星标],及时获取RingCentral的资讯 只要是接触过开放各种开放平台的开发者,对于OAuth概念肯定不陌生.但是由于OAuth ...

  9. JSON WEB TOKEN(JWT)的分析

    JSON WEB TOKEN(JWT)的分析 一般情况下,客户的会话数据会存在文件中,或者引入redis来存储,实现session的管理,但是这样操作会存在一些问题,使用文件来存储的时候,在多台机器上 ...

最新文章

  1. 当 “HTTP” 先生遇上“S”小姐
  2. 基于排队理论的云计算模型的MATLAB仿真
  3. C++使用链表实现queue之一(附完整源码)
  4. 监控员工离职倾向系统已被下架,网友:劝你善良
  5. php按钮css样式,CSS 按钮
  6. 炒房客共识:深圳楼市要撑不住了
  7. 辽宁工业大学有没有计算机专业,辽宁工业大学(专业学位)计算机技术考研难吗...
  8. 选股方法-陶博士-月线反方法的思路来源
  9. qdialog 只有点击才能获得焦点_张怡筠:怎么做,孩子才能真正爱上学习?
  10. 阿里云轻量级服务器上JDK及tomcat部署配置
  11. 简单类型参数是值传递,对象参数是引用传递
  12. 橡胶柱压缩_橡胶=汽车半条命:浅谈ABAQUS橡胶大变形仿真5大注意事项
  13. Android计算器代码分析
  14. IDEA 打包docker镜像详解
  15. 真随机数 c语言编程,C语言真正获取随机数
  16. java 不能回滚_在Java 8中回滚()语句执行失败的最佳方法是什么?
  17. Embeded linux之网卡驱动
  18. html5 监控系统界面,基于WEB服务器实现监控系统的视频图像显示
  19. Linux指令lunch,linux命令 launch是什么命令?
  20. 内存模块与计算机兼容,内存条不兼容怎么办?常见解决方法在此!

热门文章

  1. MATLAB判断矩阵相等
  2. android 记录路线轨迹_基于百度地图SDK记录运动轨迹
  3. redis版本_全球首发|阿里云正式推出云数据库Redis6.0版本
  4. matlab怎么整合成一个模块,Matlab如何将m文件制定成模块
  5. js 取得数组下标_数组的介绍及使用
  6. Bash脚本教程之字符串操作
  7. Bash脚本教程之基本语法
  8. https://blog.csdn.net/weixin_40412037/article/details/112235003
  9. java实验文法报告_西安邮电大学编译原理LL文法分析器实验(java).doc
  10. python读取word图片_Python中如何读取Word中的图片