转git仓库
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@@ -0,0 +1,3 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.1.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.inmind</groupId>
|
||||
<artifactId>springboot-web-req-resp</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>springboot-web-req-resp</name>
|
||||
<description>springboot-web-req-resp</description>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<!--依赖管理-->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--XML解析依赖-->
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.inmind;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringbootWebReqRespApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringbootWebReqRespApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.inmind.controller;
|
||||
|
||||
import com.inmind.pojo.Emp;
|
||||
import com.inmind.pojo.Result;
|
||||
import com.inmind.service.EmpService;
|
||||
import com.inmind.service.impl.EmpServiceImplA;
|
||||
import com.inmind.utils.XmlParserUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController//底层带有@Controller,本身是交给IOC容器管理
|
||||
public class EmpController {
|
||||
//设置一个员工业务对象
|
||||
@Autowired//运行时,IOC容器会提供该类型的bean对象,并赋值给该变量----依赖注入
|
||||
@Qualifier("empServiceImplA") //优先级更高,比@Primary,优先级高
|
||||
//@Resource(name = "empServiceImplB")//jdk提供的注解,不用
|
||||
private EmpService empService ;
|
||||
|
||||
@RequestMapping("/listEmp")
|
||||
public Result listEmp(){
|
||||
//1.获取请求数据,交给业务层处理
|
||||
List<Emp> emps = empService.listEmp();
|
||||
//2.响应处理好的数据
|
||||
return Result.success(emps);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.inmind.controller;
|
||||
|
||||
import com.inmind.pojo.User;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class RequestController {
|
||||
|
||||
//原始方式接收请求数据
|
||||
/*@RequestMapping( "/simpleParam")
|
||||
public String simpleParam(HttpServletRequest request){
|
||||
//获取请求参数
|
||||
String name = request.getParameter("name");
|
||||
String ageStr = request.getParameter("age");
|
||||
//手动的数据类型转换
|
||||
int age = Integer.parseInt(ageStr);
|
||||
System.out.println("name:"+name+",age:"+age);
|
||||
return "OK";
|
||||
}*/
|
||||
|
||||
|
||||
//springboot方式获取请求参数(简单参数)
|
||||
|
||||
@RequestMapping( "/simpleParam")
|
||||
//@RequestParam(name = "name" ) 的作用是从请求对象中获取name属性值,将值赋给username变量
|
||||
public String simpleParam(@RequestParam(name = "name",required = false ) String username, Integer age){
|
||||
System.out.println("name:"+username+",age:"+age);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//实体参数
|
||||
@RequestMapping( "/simplePojo")
|
||||
public String simplePojo(User user){
|
||||
System.out.println(user);
|
||||
System.out.println("name:"+user.getName()+",age:"+user.getAge());
|
||||
System.out.println("address:"+user.getAddress());
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//数组参数
|
||||
@RequestMapping( "/arrayParam")
|
||||
public String arrayParam(String[] hobby){
|
||||
System.out.println(Arrays.toString(hobby));
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//集合参数
|
||||
@RequestMapping( "/listParam")
|
||||
public String listParam(@RequestParam List<String> hobby){//由于默认采用数组参数直接获取,使用list接收,会报错,需要使用@RequestParam注解
|
||||
System.out.println(hobby);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//日期参数
|
||||
@RequestMapping( "/dateParam")
|
||||
public String dateParam(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime updateTime){//由于前端的时间格式的多样性,一般前后端约定固定格式,如yyyy-MM-dd HH:mm:ss,所以这里要用一个注解
|
||||
System.out.println(updateTime);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//json参数
|
||||
@RequestMapping( "/jsonParam")
|
||||
//@RequestBody: 将请求体中的json数据,映射为java对象
|
||||
public String jsonParam(@RequestBody User user){
|
||||
System.out.println(user);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
//路径参数
|
||||
@RequestMapping( "/path/{id}/{name}")
|
||||
//@PathVariable: 将路径参数映射为方法参数
|
||||
public String pathParam(@PathVariable Integer id,@PathVariable String name){
|
||||
System.out.println("id:"+id);
|
||||
System.out.println("name:"+name);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.inmind.controller;
|
||||
|
||||
import com.inmind.pojo.Address;
|
||||
import com.inmind.pojo.Result;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class ResponseController {
|
||||
|
||||
@RequestMapping("/hello")
|
||||
public Result hello(){
|
||||
System.out.println("hello world");
|
||||
return Result.success("hello world");
|
||||
}
|
||||
|
||||
@RequestMapping("/getAddr")
|
||||
public Result getAddr(){
|
||||
Address address = new Address();
|
||||
address.setCity("常州");
|
||||
address.setProvince("江苏");
|
||||
return Result.success(address);
|
||||
}
|
||||
|
||||
@RequestMapping("/listAddr")
|
||||
public Result listAddr(){
|
||||
ArrayList<Address> list = new ArrayList<>();
|
||||
list.add(new Address("江苏", "常州"));
|
||||
list.add(new Address("浙江", "杭州"));
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.inmind.dao;
|
||||
|
||||
import com.inmind.pojo.Emp;
|
||||
|
||||
import java.util.List;
|
||||
//定义一个获取员工数据的规范
|
||||
public interface EmpDao {
|
||||
List<Emp> listEmp();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.inmind.dao.impl;
|
||||
|
||||
import com.inmind.dao.EmpDao;
|
||||
import com.inmind.pojo.Emp;
|
||||
import com.inmind.utils.XmlParserUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository//将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转
|
||||
public class EmpDaoImplA implements EmpDao {
|
||||
@Override
|
||||
public List<Emp> listEmp() {
|
||||
//1.加载并解析emp.xml数据
|
||||
String file = this.getClass().getClassLoader().getResource("emp.xml").getFile();
|
||||
List<Emp> emps = XmlParserUtils.parse(file, Emp.class);
|
||||
return emps;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.inmind.pojo;
|
||||
|
||||
public class Address {
|
||||
private String province;
|
||||
private String city;
|
||||
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
public Address(String province, String city) {
|
||||
this.province = province;
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Address{" +
|
||||
"province='" + province + '\'' +
|
||||
", city='" + city + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.inmind.pojo;
|
||||
|
||||
public class Emp {
|
||||
private String name;
|
||||
private Integer age;
|
||||
private String image;
|
||||
private String gender;
|
||||
private String job;
|
||||
|
||||
public Emp() {
|
||||
}
|
||||
|
||||
public Emp(String name, Integer age, String image, String gender, String job) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.image = image;
|
||||
this.gender = gender;
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
public void setJob(String job) {
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Emp{" +
|
||||
"name='" + name + '\'' +
|
||||
", age=" + age +
|
||||
", image='" + image + '\'' +
|
||||
", gender='" + gender + '\'' +
|
||||
", job='" + job + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.inmind.pojo;
|
||||
|
||||
/**
|
||||
* 统一响应结果封装类
|
||||
*/
|
||||
public class Result {
|
||||
private Integer code ;//1 成功 , 0 失败
|
||||
private String msg; //提示信息
|
||||
private Object data; //数据 date
|
||||
|
||||
public Result() {
|
||||
}
|
||||
public Result(Integer code, String msg, Object data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static Result success(Object data){
|
||||
return new Result(1, "success", data);
|
||||
}
|
||||
public static Result success(){
|
||||
return new Result(1, "success", null);
|
||||
}
|
||||
public static Result error(String msg){
|
||||
return new Result(0, msg, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Result{" +
|
||||
"code=" + code +
|
||||
", msg='" + msg + '\'' +
|
||||
", data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.inmind.pojo;
|
||||
|
||||
public class User {
|
||||
private String name;
|
||||
private Integer age;
|
||||
|
||||
private Address address;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String name, Integer age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"name='" + name + '\'' +
|
||||
", age=" + age +
|
||||
", address=" + address +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(Address address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.inmind.service;
|
||||
|
||||
import com.inmind.pojo.Emp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//业务层操作,对数据进行逻辑处理,返回处理后的数据
|
||||
public interface EmpService {
|
||||
List<Emp> listEmp();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.inmind.service.impl;
|
||||
|
||||
import com.inmind.dao.EmpDao;
|
||||
import com.inmind.pojo.Emp;
|
||||
import com.inmind.service.EmpService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@Primary //当DI依赖注入EmpService的变量时,优先使用当前实现类
|
||||
@Service //将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转
|
||||
public class EmpServiceImplA implements EmpService {
|
||||
//设置一个dao的成员变量
|
||||
@Autowired//运行时,IOC容器会提供该类型的bean对象,并赋值给该变量----依赖注入
|
||||
private EmpDao empDao ;
|
||||
|
||||
@Override
|
||||
public List<Emp> listEmp() {
|
||||
//调用dao层的功能,获取员工信息即可
|
||||
List<Emp> emps = empDao.listEmp();
|
||||
|
||||
//逻辑处理
|
||||
//2.对数据进行处理优化(处理性别,处理职位)
|
||||
emps.stream().forEach(emp -> {
|
||||
String gender = emp.getGender();
|
||||
//处理 gender 1:男 2:女
|
||||
if (gender.equals("1")) {
|
||||
emp.setGender("男");
|
||||
} else {
|
||||
emp.setGender("女");
|
||||
}
|
||||
|
||||
//处理job- 1:讲师 2:班主任 3:就业指导
|
||||
String job = emp.getJob();
|
||||
if ("1".equals(job)) {
|
||||
emp.setJob("讲师");
|
||||
} else if ("2".equals(job)) {
|
||||
emp.setJob("班主任");
|
||||
}else if ("3".equals(job)) {
|
||||
emp.setJob("就业指导");
|
||||
}
|
||||
});
|
||||
return emps;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.inmind.service.impl;
|
||||
|
||||
import com.inmind.dao.EmpDao;
|
||||
import com.inmind.pojo.Emp;
|
||||
import com.inmind.service.EmpService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service //将当前类交给IOC容器管理,让它称为IOC容器中的bean对象---IOC控制反转
|
||||
public class EmpServiceImplB implements EmpService {
|
||||
//设置一个dao的成员变量
|
||||
@Autowired//运行时,IOC容器会提供该类型的bean对象,并赋值给该变量----依赖注入
|
||||
private EmpDao empDao ;
|
||||
|
||||
@Override
|
||||
public List<Emp> listEmp() {
|
||||
//调用dao层的功能,获取员工信息即可
|
||||
List<Emp> emps = empDao.listEmp();
|
||||
|
||||
//逻辑处理
|
||||
//2.对数据进行处理优化(处理性别,处理职位)
|
||||
emps.stream().forEach(emp -> {
|
||||
String gender = emp.getGender();
|
||||
//处理 gender 1:男 2:女
|
||||
if (gender.equals("1")) {
|
||||
emp.setGender("男士");
|
||||
} else {
|
||||
emp.setGender("女士");
|
||||
}
|
||||
|
||||
//处理job- 1:讲师 2:班主任 3:就业指导
|
||||
String job = emp.getJob();
|
||||
if ("1".equals(job)) {
|
||||
emp.setJob("讲师");
|
||||
} else if ("2".equals(job)) {
|
||||
emp.setJob("班主任");
|
||||
}else if ("3".equals(job)) {
|
||||
emp.setJob("就业指导");
|
||||
}
|
||||
});
|
||||
return emps;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.inmind.utils;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class XmlParserUtils {
|
||||
|
||||
public static <T> List<T> parse(String file , Class<T> targetClass) {
|
||||
ArrayList<T> list = new ArrayList<T>(); //封装解析出来的数据
|
||||
try {
|
||||
//1.获取一个解析器对象
|
||||
SAXReader saxReader = new SAXReader();
|
||||
//2.利用解析器把xml文件加载到内存中,并返回一个文档对象
|
||||
Document document = saxReader.read(new File(file));
|
||||
//3.获取到根标签
|
||||
Element rootElement = document.getRootElement();
|
||||
//4.通过根标签来获取 user 标签
|
||||
List<Element> elements = rootElement.elements("emp");
|
||||
|
||||
//5.遍历集合,得到每一个 user 标签
|
||||
for (Element element : elements) {
|
||||
//获取 name 属性
|
||||
String name = element.element("name").getText();
|
||||
//获取 age 属性
|
||||
String age = element.element("age").getText();
|
||||
//获取 image 属性
|
||||
String image = element.element("image").getText();
|
||||
//获取 gender 属性
|
||||
String gender = element.element("gender").getText();
|
||||
//获取 job 属性
|
||||
String job = element.element("job").getText();
|
||||
|
||||
//组装数据
|
||||
Constructor<T> constructor = targetClass.getDeclaredConstructor(String.class, Integer.class, String.class, String.class, String.class);
|
||||
constructor.setAccessible(true);
|
||||
T object = constructor.newInstance(name, Integer.parseInt(age), image, gender, job);
|
||||
|
||||
list.add(object);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
spring.application.name=springboot-web-req-resp
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<emps>
|
||||
<emp>
|
||||
<name>金毛狮王111</name>
|
||||
<age>55</age>
|
||||
<image>https://inmind-test.oss-cn-shanghai.aliyuncs.com/01878908-cdaf-4df9-b2b0-e09299da5cc3.jpg</image>
|
||||
<!-- 1: 男, 2: 女 -->
|
||||
<gender>1</gender>
|
||||
<!-- 1: 讲师, 2: 班主任 , 3: 就业指导 -->
|
||||
<job>1</job>
|
||||
</emp>
|
||||
|
||||
<emp>
|
||||
<name>白眉鹰王</name>
|
||||
<age>65</age>
|
||||
<image>https://inmind-test.oss-cn-shanghai.aliyuncs.com/01878908-cdaf-4df9-b2b0-e09299da5cc3.jpg</image>
|
||||
<gender>1</gender>
|
||||
<job>1</job>
|
||||
</emp>
|
||||
|
||||
<emp>
|
||||
<name>青翼蝠王</name>
|
||||
<age>45</age>
|
||||
<image>https://inmind-test.oss-cn-shanghai.aliyuncs.com/01878908-cdaf-4df9-b2b0-e09299da5cc3.jpg</image>
|
||||
<gender>1</gender>
|
||||
<job>2</job>
|
||||
</emp>
|
||||
|
||||
<emp>
|
||||
<name>紫衫龙王</name>
|
||||
<age>38</age>
|
||||
<image>https://inmind-test.oss-cn-shanghai.aliyuncs.com/01878908-cdaf-4df9-b2b0-e09299da5cc3.jpg</image>
|
||||
<gender>2</gender>
|
||||
<job>3</job>
|
||||
</emp>
|
||||
</emps>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>员工信息</title>
|
||||
</head>
|
||||
|
||||
<link rel="stylesheet" href="element-ui/index.css">
|
||||
<script src="./js/vue.js"></script>
|
||||
<script src="./element-ui/index.js"></script>
|
||||
<script src="./js/axios-0.18.0.js"></script>
|
||||
|
||||
<body>
|
||||
<h1 align="center">员工信息列表展示</h1>
|
||||
<div id="app">
|
||||
<el-table :data="tableData" style="width: 100%" stripe border >
|
||||
<el-table-column prop="name" label="姓名" align="center" min-width="20%"></el-table-column>
|
||||
<el-table-column prop="age" label="年龄" align="center" min-width="20%"></el-table-column>
|
||||
<el-table-column label="图像" align="center" min-width="20%">
|
||||
<template slot-scope="scope">
|
||||
<el-image :src="scope.row.image" style="width: 80px; height: 50px;"></el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="gender" label="性别" align="center" min-width="20%"></el-table-column>
|
||||
<el-table-column prop="job" label="职位" align="center" min-width="20%"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
.el-table .warning-row {
|
||||
background: oldlace;
|
||||
}
|
||||
.el-table .success-row {
|
||||
background: #f0f9eb;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: "#app",
|
||||
data() {
|
||||
return {
|
||||
tableData: []
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
axios.get('/listEmp').then(res=>{
|
||||
if(res.data.code){
|
||||
this.tableData = res.data.data;
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
+13
@@ -0,0 +1,13 @@
|
||||
package com.inmind;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringbootWebReqRespApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user