From 9a167db8175bd45be5a897e073bf5e88fae4ab91 Mon Sep 17 00:00:00 2001 From: zz <193970753@qq.com> Date: Thu, 19 Sep 2024 10:13:05 +0800 Subject: [PATCH] =?UTF-8?q?9.19=20=E4=B8=8A=E5=8D=88=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Vue/Vue001/src/App.vue | 325 ++++++++++++++++-- .../Controllor/JsaonControllor.java | 64 +++- 2 files changed, 349 insertions(+), 40 deletions(-) diff --git a/Vue/Vue001/src/App.vue b/Vue/Vue001/src/App.vue index b590534..37bd8a7 100644 --- a/Vue/Vue001/src/App.vue +++ b/Vue/Vue001/src/App.vue @@ -1,41 +1,302 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/springboot/src/main/java/com/zhangzihao/springboot/springboot/Controllor/JsaonControllor.java b/springboot/src/main/java/com/zhangzihao/springboot/springboot/Controllor/JsaonControllor.java index 8025fda..de2f32b 100644 --- a/springboot/src/main/java/com/zhangzihao/springboot/springboot/Controllor/JsaonControllor.java +++ b/springboot/src/main/java/com/zhangzihao/springboot/springboot/Controllor/JsaonControllor.java @@ -1,20 +1,68 @@ package com.zhangzihao.springboot.springboot.Controllor; +import com.zhangzihao.springboot.springboot.model.Student; import com.zhangzihao.springboot.springboot.model.User; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; + +import javax.xml.transform.Result; +import java.io.File; +import java.io.IOException; +import java.util.UUID; @Controller -public class JsaonControllor { - //返回Json数据,App/小程序 前端分离 +public class JsonController { + // @RequestMapping("getUser") +// //@RequestMapping("getUser") 表明这个方法处理 getUser 的请求 +// @ResponseBody +// public User getUser(){ +// User user = new User(); +// user.setUsername("Lala"); +// user.setClassname("医信1班"); +// return user; +// } + @Autowired + IStudentService studentService; + @RequestMapping("getstudents") + public Result getstudents(){ + return Result.ok(studentService.list()); + } + + @RequestMapping("login1") + public Result login1(String username,String password){ + if(username.equals("admin")&& password.equals("123456")) + return Result.ok("登录成功"); + return Result.error("登录失败"); + } + @RequestMapping("getuser") - @ResponseBody - public User getUser() - { + public User getuser(){ User user = new User(); - user.setUsername("张三"); - user.setClassname("21医信"); + user.setUsername("Lala"); + user.setClassname("医信1班"); return user; } -} + + @RequestMapping("uploadcommit1") + public Result uploadSuccess(MultipartFile file) throws IOException + { + File file1 = new File("D:\\data"); + String fileName = UUID.randomUUID().toString()+file.getOriginalFilename(); + file.transferTo(new File(file1,fileName)); + return Result.ok().put("data","http://127.0.0.1:8080/"+fileName); + } + @RequestMapping("/deletestudentbyid/{id}") + public Result deleteStudentById(@PathVariable Integer id) + { + return Result.ok(studentService.removeById(id)); + } + @RequestMapping("") + public Result saveDate(Student student) + { + return Result.ok(studentService.saveOrUpdate(student)); + } +} \ No newline at end of file