查询接口现在其实挺简单的,就是将前端发送的数据在数据库中查询一下
这里来说说表结构吧
- 官网名字就是要下载的软件的官网名字
- 内容就是对这个软件的介绍
- 地址就是对应的官网地址或者点击下载后跳转的地址
挺简单的不够后面在进行补充吧
@RestController @RequestMapping("//directory") @Api(value = "查询模块",tags = "C端图书查询接口") public class DirectoryController { @Autowired private IDirectoryService directoryService; @GetMapping("/getList") @ApiOperation(value = "获得官网") public RespBean getList(){ Listlist = directoryService.list(); return RespBean.success("success",list); } @PostMapping("/selectName") @ApiOperation(value = "查询官网") public RespBean selectName(@RequestBody SelectDTO selectDTO){ System.out.println(selectDTO); QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("name",selectDTO.getNa()); List list =directoryService.list(queryWrapper); return RespBean.success("success",list); } }
第一个getList接口其实可以不用,这只是我一开始测试整体时写的
首先的事先@Autowired自动注册iservice层
应为用到了Mybatis所以可以直接写个warpper
在service.list时用wrapper里面的内容进行筛选
然后直接返回数据,然后数据的RespBean是统一返回的类
@Data @NoArgsConstructor @AllArgsConstructor public class RespBean { private long code; private String message; private Object data; public static RespBean success(String message){ return new RespBean(200,message,null); } public static RespBean success(String message,Object obj){ return new RespBean(200,message,obj); } public static RespBean error(String message,Object obj){ return new RespBean(500,message,obj); } public static RespBean error(String message){ return new RespBean(500,message,null); } }
@Data public class SelectDTO { String na; String ne; }然后是申请相关的接口
都差不多
*/ @RestController @RequestMapping("//application") @Api(value = "申请模块",tags = "C端申请端口") public class ApplicationController { @Autowired private IApplicationService applicationService; @PostMapping("/addApplication") @ApiOperation(value = "增加申请") public RespBean addApplication(@RequestBody Application application){ Snowflake snowflake = IdUtil.getSnowflake(1, 1); application.setApplication_id(snowflake.nextId()); System.out.println(application); boolean save = applicationService.save(application); if (save){ return RespBean.success("1"); } return RespBean.error("2"); } @GetMapping("/selectList") @ApiOperation(value = "所有的申请列表") public RespBean selectList(){ List list = applicationService.list(); return RespBean.success("成功",list); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)