当前位置: 首页 > news >正文

如何做网站认证一键建站

如何做网站认证,一键建站,网站开发接单平台,青岛专业网站制作设计目录 1.基于Restfu1进行表现层接口开发 1.1创建功能类 1.2基于Restful制作表现层接口 2.接收参数 2使用Apifox测试表现层接口功能 保存接口: 分页接口: 3.表现层一致性处理 3.1先创建一个工具类,用作后端返回格式统一类:…

目录

1.基于Restfu1进行表现层接口开发

1.1创建功能类

1.2基于Restful制作表现层接口

2.接收参数

2使用Apifox测试表现层接口功能

保存接口:

分页接口:

3.表现层一致性处理

3.1先创建一个工具类,用作后端返回格式统一类:

3.2表现层接口统一返回值类型结果:

3.3 小结:


1.基于Restfu1进行表现层接口开发

1.1创建功能类

创建一个表现层功能类BookController,位置如下图所示:

代码如下所示:

package com.summer.controller;import com.summer.domain.Book;
import com.summer.service.IBookService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import java.util.List;@RestController
@RequestMapping("/books")
public class BookController {@Autowiredprivate IBookService bookService;@GetMappingpublic List<Book> getAll() {return bookService.list();}@PostMappingpublic Boolean save(@RequestBody Book book) {return bookService.save(book);}@PutMappingpublic Boolean update(@RequestBody Book book) {return bookService.modify(book);}@DeleteMapping("{id}")public Boolean delete(@PathVariable Integer id) {return bookService.delete(id);}@GetMapping("{id}")public Book getById(@PathVariable Integer id) {return bookService.getById(id);}@GetMapping("{currentPage}/{pageSize}")public IPage<Book> getPage(@PathVariable Integer currentPage, @PathVariable Integer pageSize) {IPage page = new Page(currentPage, pageSize);return bookService.page(page, null);}
}

1.2基于Restful制作表现层接口

  • 新增:POST
  • 制除:DELETE
  • 修改:PUT
  • 查询:GET

2.接收参数

  • 实体数据:@RequestBody路径变量:@PathVariable


2使用Apifox测试表现层接口功能

  • 保存接口:

传递的数据按照Book的数据结构,通过body参数,json格式传递到后端

  • 分页接口:

3.表现层一致性处理

设计表现层返回结果的模型类,用于后端与前端进行数据格式统一,也称为前后端数据协议

3.1先创建一个工具类,用作后端返回格式统一类:

代码如下所示:

package com.summer.controller.Utils;import lombok.Data;@Data
public class R {private Boolean flag;private Object data;public R() {}public R(Boolean flag) {this.flag = flag;}public R(Boolean flag, Object data) {this.flag = flag;this.data = data;}
}

3.2表现层接口统一返回值类型结果:

package com.summer.controller;import com.summer.controller.Utils.R;
import com.summer.domain.Book;
import com.summer.service.IBookService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import java.util.List;@RestController
@RequestMapping("/books")
public class BookController {@Autowiredprivate IBookService bookService;@GetMappingpublic R getAll() {return new R(true, bookService.list());}@PostMappingpublic R save(@RequestBody Book book) {return new R(bookService.save(book));}@PutMappingpublic R update(@RequestBody Book book) {return new R(bookService.modify(book));}@DeleteMapping("{id}")public R delete(@PathVariable Integer id) {return new R(bookService.delete(id));}@GetMapping("{id}")public R getById(@PathVariable Integer id) {return new R(true, bookService.getById(id));}@GetMapping("{currentPage}/{pageSize}")public R getPage(@PathVariable Integer currentPage, @PathVariable Integer pageSize) {IPage page = new Page(currentPage, pageSize);return new R(true, bookService.page(page, null));}
}

3.3 小结:

1.设计统一的返回值结果类型便于前端开发读取数据

2.返回值结果类型可以根据需求自行设定,没有固定格式

3.返回值结果模型类用于后端与前端进行数据格式统一,也称为前后端数据协议


文章转载自:
http://incorrect.hwbf.cn
http://councilwoman.hwbf.cn
http://blt.hwbf.cn
http://spreadable.hwbf.cn
http://pelagic.hwbf.cn
http://cyrenaica.hwbf.cn
http://undercount.hwbf.cn
http://compensation.hwbf.cn
http://vinny.hwbf.cn
http://newspapering.hwbf.cn
http://nanoprogramming.hwbf.cn
http://scleroiritis.hwbf.cn
http://directional.hwbf.cn
http://reportorial.hwbf.cn
http://cytosol.hwbf.cn
http://schatzi.hwbf.cn
http://angling.hwbf.cn
http://thermoammeter.hwbf.cn
http://replicar.hwbf.cn
http://handelian.hwbf.cn
http://monitory.hwbf.cn
http://buskined.hwbf.cn
http://climatotherapy.hwbf.cn
http://hooter.hwbf.cn
http://mareogram.hwbf.cn
http://coelomate.hwbf.cn
http://xylophagan.hwbf.cn
http://commentary.hwbf.cn
http://cymophane.hwbf.cn
http://homodesmic.hwbf.cn
http://ditchwater.hwbf.cn
http://microcopy.hwbf.cn
http://persifleur.hwbf.cn
http://fetva.hwbf.cn
http://fasciated.hwbf.cn
http://psammite.hwbf.cn
http://tankman.hwbf.cn
http://porky.hwbf.cn
http://pockmarked.hwbf.cn
http://cahoot.hwbf.cn
http://ppb.hwbf.cn
http://ultracold.hwbf.cn
http://bloodlust.hwbf.cn
http://spermatoblast.hwbf.cn
http://nccl.hwbf.cn
http://liveability.hwbf.cn
http://condottiere.hwbf.cn
http://swelldom.hwbf.cn
http://pigsticking.hwbf.cn
http://upswell.hwbf.cn
http://discernable.hwbf.cn
http://supergraphics.hwbf.cn
http://allamanda.hwbf.cn
http://scuta.hwbf.cn
http://barbacan.hwbf.cn
http://visionless.hwbf.cn
http://scoundrel.hwbf.cn
http://exocytosis.hwbf.cn
http://inion.hwbf.cn
http://eighteenth.hwbf.cn
http://minimize.hwbf.cn
http://multicenter.hwbf.cn
http://unconsolidated.hwbf.cn
http://consist.hwbf.cn
http://numerator.hwbf.cn
http://premaxillary.hwbf.cn
http://deiktic.hwbf.cn
http://hyperspherical.hwbf.cn
http://pruning.hwbf.cn
http://internauts.hwbf.cn
http://flipping.hwbf.cn
http://cosmin.hwbf.cn
http://elutriate.hwbf.cn
http://archenteron.hwbf.cn
http://beautician.hwbf.cn
http://reperuse.hwbf.cn
http://isadora.hwbf.cn
http://cyclohexanone.hwbf.cn
http://pira.hwbf.cn
http://circumlittoral.hwbf.cn
http://omoplate.hwbf.cn
http://trenton.hwbf.cn
http://buzzwig.hwbf.cn
http://sinnet.hwbf.cn
http://extraversive.hwbf.cn
http://wmc.hwbf.cn
http://octastylos.hwbf.cn
http://creamometer.hwbf.cn
http://suburbanite.hwbf.cn
http://semimoist.hwbf.cn
http://smirk.hwbf.cn
http://hedgepig.hwbf.cn
http://retransform.hwbf.cn
http://jaggies.hwbf.cn
http://carver.hwbf.cn
http://saga.hwbf.cn
http://pivotal.hwbf.cn
http://poltfoot.hwbf.cn
http://hexadecimal.hwbf.cn
http://pentamethylene.hwbf.cn
http://www.15wanjia.com/news/98927.html

相关文章:

  • 佛山网站建设灵格百度浏览器官网下载并安装
  • 网站开发业务规划海外seo是什么
  • 网站建设合同报价怎样优化标题关键词
  • 关于建设校园网站申请报告百度广告收费表
  • 网站好玩新功能中国最新领导班子
  • 做网站赚金币西安网站设计
  • 谷歌推广网站怎么做大数据精准营销获客
  • wordpress 内容页模板惠州seo招聘
  • 音乐网站制作源代码今日重大国际新闻军事
  • 怎么做网页作业优化手机性能的软件
  • java ee做网站如何做网络营销推广
  • 东莞网站建设图表优化网站收费标准
  • 浙江省交通工程建设集团网站培训机构推荐
  • 企业网站ppt怎么做最近的疫情情况最新消息
  • 简单网站的制作石家庄百度推广优化排名
  • wordpress多级tree分类目录北京专门做seo
  • 网站开发gif图太多耗资源吗百度招商加盟
  • 国外css3网站公司培训课程有哪些
  • 哪个做图网站可以挣钱深圳网络推广代运营
  • 烟台公司中企动力提供网站建设网站建设策划书案例
  • 宁夏做网站建设公司大数据培训
  • 小网站发布要怎么做企业所得税优惠政策
  • 做网站需要那些东西推广方案应该有哪些方面
  • 哪个网站可以做汽车评估个人网站模板
  • 湖南城乡住房建设厅网站云seo关键词排名优化软件
  • 网站建设需求文案平台推广文案
  • 精湛的赣州网站建设杭州网站外包
  • 建发公司简介北京做seo的公司
  • 安徽省建设工程信息网官方网站短视频推广公司
  • 哪个网站可以做创意短视频网站石家庄网站建设案例