• RESTful风格接口与axios请求总结


    RESTful风格接口与axios请求总结

    1.GET

    axios.get('/api/patient/ds', {
                params: {
                    pageNo: a,
                    pageCount: b,
                    name: app.hzQuery.name,
                    age: app.hzQuery.age
                }
            }).then(function (response) {
                console.log(response);
                app.yyArr = response.data.data.records;
                app.stuTotal = response.data.data.total;
            })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
        @GetMapping("ds")
        @ApiOperation("展示患者信息")
        public Result listPatients(Integer pageNo, Integer pageCount, String name, String age) {
            log.info("展示患者信息");
            PatientQuery patientQuery = new PatientQuery();
            patientQuery.setPageCount(pageCount);
            patientQuery.setPageNo(pageNo);
            patientQuery.setName(name);
            patientQuery.setAge(age);
            return patientService.listPatients(patientQuery);
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    axios.get("/api/dot/getYs/" + id)
                        .then(function (response) {
                            app.staffInfo = response.data.data;
                            app.showUpdate = true;
                            app.$refs["yuyueInfo"].resetFields();
                        })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
        @GetMapping("getYs/{id}")
        @ApiOperation("根据ID查询医生信息")
        public Result getDoctorById(@PathVariable("id") Integer id) {
            log.info("获取id,{}", id);
            return doctorService.getDoctorById(id);
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    2.POST

    axios.post('/api/patient/add', app.stuInfo).then(function (response) {
                                console.log(response);
                                app.showAdd = false;
                                app.$notify.info({title: '提示', message: response.data.msg});
                                getStuInfo(1, 10);
                            })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
        @PostMapping("add")
        @ApiOperation("添加患者")
        @OpetionLog("添加患者")
        public Result addPatient(@RequestBody PatientDTO patientDTO) throws UnknownHostException {
            return patientService.addPatient(patientDTO);
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    3.PUT

    axios.put('/api/patient/UpdateHzupdate', app.StuInfo)
                        .then(function (response) {
                            getStuInfo(1, 10);
                            app.showUpdate = false;
                            app.$notify.info({type: '温馨提示', message: response.data.msg});
                        })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
        @PutMapping("UpdateHzupdate")
        @ApiOperation("更新患者信息")
        @OpetionLog("更新患者信息")
        public Result updatePatient(@RequestBody PatientDTO patientDTO) throws UnknownHostException {
            return patientService.updatePatient(patientDTO);
        }  
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    4.DELETE

    axios.delete('/api/patient/delete/' + id)
                            .then(function (response) {
                                app.$notify.info({type: '温馨提示', message: response.data.msg});
                                getStuInfo(1, 10);
                            })
                            .catch(function (error) {
                                console.log(error);
                            });
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
        @DeleteMapping("delete/{id}")
        @ApiOperation("删除患者")
        @OpetionLog("删除患者")
        public Result deletePatient(@PathVariable Integer id) throws UnknownHostException {
            return patientService.deletePatient(id);
        }  
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 相关阅读:
    XPS表面及表面分析技术-科学指南针
    14天阅读挑战赛——贪心算法(二)
    UE4和C++ 开发-C++与UMG的交互2(C++获取UMG的属性)
    基于JSP+Servlet的宠物养护网站
    基于VMware从零搭建Linux系统
    遍历List集合
    应用层 HTTP消息在服务端的路由 请求头 Host
    搭建HBase分布式集群
    cmd打开idea
    一个颜值功能双在线的Zookeeper可视化工具
  • 原文地址:https://blog.csdn.net/g877835148/article/details/134339833