├── README.md ├── Spring-boot-hello-world ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── liangwei │ │ │ └── demo │ │ │ ├── DemoApplication.java │ │ │ ├── config │ │ │ ├── MybatisConfig.java │ │ │ ├── SwaggerConfig.java │ │ │ └── WebConfiguration.java │ │ │ ├── controller │ │ │ ├── BookController.java │ │ │ └── UserController.java │ │ │ ├── mapper │ │ │ ├── BookMapper.java │ │ │ └── UserMapper.java │ │ │ ├── model │ │ │ ├── Book.java │ │ │ └── User.java │ │ │ └── service │ │ │ ├── BookService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ ├── BookServiceImpl.java │ │ │ └── UserServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── liangwei │ └── demo │ └── DemoApplicationTests.java └── vue-hello-world ├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── README.md ├── babel.config.js ├── package.json ├── src ├── App.vue ├── api │ └── user.js ├── assets │ └── logo.png ├── axios │ ├── api.request.js │ └── index.js ├── components │ └── HelloWorld.vue ├── main.js ├── router.js ├── store.js └── views │ ├── About.vue │ └── Home.vue ├── vue.config.js └── yarn.lock /README.md: -------------------------------------------------------------------------------- 1 | # Spring-Boot-And-Vue 2 | 3 | # Spring-boot-hello-world项目运行 4 | 5 | ## Project 导入 6 | ``` 7 | 使用IDE导入Mvane项目 8 | ``` 9 | 10 | 11 | ### 项目设置 12 | ``` 13 | 设置项目运行JDK运行环境 14 | ``` 15 | 16 | 17 | # vue-hello-world项目运行 18 | 19 | ## Project setup 20 | ``` 21 | yarn install 22 | ``` 23 | 24 | ### Compiles and hot-reloads for development 25 | ``` 26 | yarn run serve 27 | ``` 28 | 29 | ### Compiles and minifies for production 30 | ``` 31 | yarn run build 32 | ``` 33 | 34 | ### Lints and fixes files 35 | ``` 36 | yarn run lint 37 | ``` 38 | 39 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.2.RELEASE 9 | 10 | 11 | com.liangwei 12 | demo 13 | 1.0 14 | 15 | war 16 | 17 | demo 18 | Demo project for Spring Boot 19 | 20 | 21 | 1.8 22 | 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-web 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | test 34 | 35 | 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | 41 | 42 | 43 | 44 | org.mybatis.spring.boot 45 | mybatis-spring-boot-starter 46 | 1.3.1 47 | 48 | 49 | 50 | io.springfox 51 | springfox-swagger2 52 | 2.9.2 53 | 54 | 55 | 56 | io.springfox 57 | springfox-swagger-ui 58 | 2.9.2 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 8 | 9 | @SpringBootApplication 10 | public class DemoApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(DemoApplication.class, args); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/config/MybatisConfig.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.config; 2 | 3 | import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * mybatis 注解版 9 | * 10 | */ 11 | 12 | @Configuration 13 | public class MybatisConfig { 14 | @Bean 15 | public ConfigurationCustomizer configurationCustomizer() { 16 | return new ConfigurationCustomizer() { 17 | 18 | @Override 19 | public void customize(org.apache.ibatis.session.Configuration configuration) { 20 | // 设置驼峰命名规则 21 | configuration.setMapUnderscoreToCamelCase(true); 22 | } 23 | }; 24 | } 25 | } -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.http.converter.HttpMessageConverter; 6 | import org.springframework.web.servlet.config.annotation.*; 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.PathSelectors; 9 | import springfox.documentation.builders.RequestHandlerSelectors; 10 | import springfox.documentation.service.ApiInfo; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | import java.util.List; 16 | 17 | @Configuration 18 | @EnableSwagger2 19 | public class SwaggerConfig { 20 | @Bean 21 | public Docket api() { 22 | return new Docket(DocumentationType.SWAGGER_2) 23 | .apiInfo(apiInfo()) 24 | .select() 25 | .apis(RequestHandlerSelectors.any()) 26 | .paths(PathSelectors.any()) 27 | .build(); 28 | } 29 | 30 | private ApiInfo apiInfo() { 31 | return new ApiInfoBuilder() 32 | .title("Spring Boot中使用Swagger2构建RESTful APIs") 33 | .description("图书子系统") 34 | .termsOfServiceUrl("更多请关注http://www.baidu.com") 35 | .contact("liangwei") 36 | .version("1.0") 37 | .build(); 38 | } 39 | } -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/config/WebConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.config; 2 | 3 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; 4 | import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.*; 7 | 8 | 9 | @Configuration 10 | @AutoConfigureAfter(DispatcherServletAutoConfiguration.class) 11 | public class WebConfiguration extends WebMvcConfigurationSupport { 12 | 13 | @Override 14 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 15 | registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); 16 | registry.addResourceHandler("swagger-ui.html") 17 | .addResourceLocations("classpath:/META-INF/resources/"); 18 | registry.addResourceHandler("/webjars/**") 19 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 20 | super.addResourceHandlers(registry); 21 | } 22 | 23 | /** 24 | * CROS跨域的处理 25 | */ 26 | @Override 27 | public void addCorsMappings(CorsRegistry registry) { 28 | registry.addMapping("/**") 29 | .allowedOrigins("*") 30 | .allowedMethods("GET", "POST", "PUT", "OPTIONS", "DELETE", "PATCH") 31 | .allowCredentials(true).maxAge(3600); 32 | } 33 | } -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/controller/BookController.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.controller; 2 | 3 | import com.liangwei.demo.model.Book; 4 | import com.liangwei.demo.service.BookService; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiImplicitParam; 7 | import io.swagger.annotations.ApiImplicitParams; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import java.util.List; 16 | 17 | @RestController 18 | @RequestMapping("/api") 19 | @Api("图书api") 20 | public class BookController { 21 | 22 | @Autowired 23 | private BookService bookService; 24 | 25 | @ApiOperation("查询书本的信息") 26 | @RequestMapping(value ="/book", method = RequestMethod.GET) 27 | public List BookQry() { 28 | return bookService.getBook(); 29 | } 30 | 31 | @ApiOperation("增加书本信息") 32 | @RequestMapping(value ="/book", method = RequestMethod.POST) 33 | public void BookAdd(Book book){ 34 | bookService.addBook(book); 35 | } 36 | 37 | @ApiOperation("修改书本信息") 38 | @RequestMapping(value ="/book", method = RequestMethod.PUT) 39 | public void BookUpdate(Book book){ 40 | bookService.updateBookById(book); 41 | } 42 | 43 | @ApiOperation("删除书本信息") 44 | @ApiImplicitParam(name = "id", value = "书本编号", required = true, dataType = "Integer") 45 | @RequestMapping(value ="/book", method = RequestMethod.DELETE) 46 | public void BookDel(@RequestParam(value="id") int id){ 47 | bookService.delBookById(id); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.controller; 2 | 3 | import com.liangwei.demo.model.User; 4 | import com.liangwei.demo.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.text.ParseException; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | @RestController 13 | @RequestMapping("/api") 14 | public class UserController { 15 | 16 | @Autowired 17 | private UserService userService; 18 | 19 | @RequestMapping(value ="/user", method = RequestMethod.GET) 20 | public List UserQry() { 21 | return userService.getUser(); 22 | } 23 | 24 | @RequestMapping(value ="/user", method = RequestMethod.POST) 25 | public void UserAdd(User user){ 26 | userService.AddUser(user); 27 | } 28 | 29 | @RequestMapping(value ="/user", method = RequestMethod.PUT) 30 | public void UserUpdate(User user){ 31 | userService.updateUserByNo(user); 32 | } 33 | 34 | @RequestMapping(value ="/user", method = RequestMethod.DELETE) 35 | public void UserDel(@RequestParam(value="no") int no){ 36 | userService.delUserById(no); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/mapper/BookMapper.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.mapper; 2 | 3 | import com.liangwei.demo.model.Book; 4 | import org.apache.ibatis.annotations.*; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface BookMapper { 10 | 11 | @Insert({"insert into book(id, name, price) values(#{id}, #{name}, #{price})"}) 12 | void addBook(Book book); 13 | 14 | @Delete("delete from book where id=#{id}") 15 | void delBookById(@Param("id") int id); 16 | 17 | @Update("update book set name = #{name}, price = #{price} where id = #{id}") 18 | void updateBookById(@Param("name") String name, @Param("price") float price, @Param("id") int id); 19 | 20 | @Select("select * from book") 21 | List getBook(); 22 | } 23 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.mapper; 2 | 3 | import java.util.List; 4 | import com.liangwei.demo.model.User; 5 | import org.apache.ibatis.annotations.*; 6 | import org.apache.ibatis.annotations.Delete; 7 | import org.apache.ibatis.annotations.Insert; 8 | import org.apache.ibatis.annotations.Param; 9 | import org.apache.ibatis.annotations.Select; 10 | 11 | @Mapper 12 | public interface UserMapper { 13 | 14 | @Insert({"insert into user(no, name, email) values(#{no}, #{name}, #{email})"}) 15 | void AddUser(User userInfo); 16 | 17 | @Delete("delete from user where no=#{no}") 18 | void delUserById(@Param("no") int no); 19 | 20 | @Update("update user set name = #{name}, email = #{email} where no = #{no}") 21 | void updateUserByNo(@Param("name") String name, @Param("email") String email, @Param("no") int no); 22 | 23 | @Select("select * from user") 24 | List getUser(); 25 | } 26 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/model/Book.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.model; 2 | 3 | public class Book { 4 | 5 | private int id; 6 | 7 | private String name; 8 | 9 | private float price; 10 | 11 | public int getId() { 12 | return id; 13 | } 14 | 15 | public void setId(int id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public float getPrice() { 28 | return price; 29 | } 30 | 31 | public void setPrice(float price) { 32 | this.price = price; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.model; 2 | 3 | /** 4 | * 用户实体的类 5 | */ 6 | public class User { 7 | 8 | private int no; 9 | 10 | private String name; 11 | 12 | private String email; 13 | 14 | public int getNo() { 15 | return no; 16 | } 17 | 18 | public void setNo(int no) { 19 | this.no = no; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getEmail() { 31 | return email; 32 | } 33 | 34 | public void setEmail(String email) { 35 | this.email = email; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/service/BookService.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.service; 2 | 3 | import com.liangwei.demo.model.Book; 4 | import org.apache.ibatis.annotations.*; 5 | 6 | import java.util.List; 7 | 8 | public interface BookService { 9 | 10 | void addBook(Book book); 11 | 12 | void delBookById(int id); 13 | 14 | void updateBookById(Book book); 15 | 16 | List getBook(); 17 | } 18 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.service; 2 | 3 | import com.liangwei.demo.model.User; 4 | import org.apache.ibatis.annotations.*; 5 | import java.util.List; 6 | 7 | public interface UserService { 8 | 9 | void AddUser(User user); 10 | 11 | void delUserById(@Param("no") int no); 12 | 13 | void updateUserByNo(User user); 14 | 15 | List getUser(); 16 | } 17 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/service/impl/BookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.service.impl; 2 | 3 | import com.liangwei.demo.mapper.BookMapper; 4 | import com.liangwei.demo.model.Book; 5 | import com.liangwei.demo.service.BookService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class BookServiceImpl implements BookService { 13 | 14 | @Autowired 15 | private BookMapper bookMapper; 16 | 17 | @Override 18 | public void addBook(Book book) { 19 | bookMapper.addBook(book); 20 | } 21 | 22 | @Override 23 | public void delBookById(int id) { 24 | bookMapper.delBookById(id); 25 | } 26 | 27 | @Override 28 | public void updateBookById(Book book) { 29 | bookMapper.updateBookById(book.getName(),book.getPrice(),book.getId()); 30 | } 31 | 32 | @Override 33 | public List getBook() { 34 | return bookMapper.getBook(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/java/com/liangwei/demo/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo.service.impl; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import com.liangwei.demo.mapper.UserMapper; 8 | import com.liangwei.demo.model.User; 9 | import com.liangwei.demo.service.UserService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void AddUser(User user) { 21 | userMapper.AddUser(user); 22 | } 23 | 24 | @Override 25 | public void delUserById(int no) { 26 | userMapper.delUserById(no); 27 | } 28 | 29 | @Override 30 | public void updateUserByNo(User user) { 31 | userMapper.updateUserByNo(user.getName(),user.getEmail(),user.getNo()); 32 | } 33 | 34 | @Override 35 | public List getUser() { 36 | 37 | List userList = userMapper.getUser(); 38 | 39 | // lamdba表达式的使用 40 | 41 | // List userListOrderBy= userList.stream().filter((User u) -> u.getName() == "1212").collect(Collectors.toList()); 42 | 43 | Collections.sort(userList,(user1, user2) -> user1.getNo() - user2.getNo()); 44 | 45 | return userList; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 2 | spring.datasource.url=jdbc:mysql://localhost:3306/liang?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 3 | spring.datasource.username=root 4 | spring.datasource.password=root 5 | -------------------------------------------------------------------------------- /Spring-boot-hello-world/src/test/java/com/liangwei/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.liangwei.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /vue-hello-world/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /vue-hello-world/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | 'extends': [ 7 | 'plugin:vue/essential', 8 | 'eslint:recommended' 9 | ], 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 13 | }, 14 | parserOptions: { 15 | parser: 'babel-eslint' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vue-hello-world/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /vue-hello-world/.postcssrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /vue-hello-world/README.md: -------------------------------------------------------------------------------- 1 | # vue-hello-world 2 | 3 | ## Project setup 4 | ``` 5 | yarn install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | yarn run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | yarn run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | yarn run lint 21 | ``` 22 | -------------------------------------------------------------------------------- /vue-hello-world/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /vue-hello-world/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-hello-world", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.18.0", 12 | "install": "^0.12.2", 13 | "iview": "^3.2.2", 14 | "vue": "^2.5.21", 15 | "vue-router": "^3.0.1", 16 | "vuex": "^3.0.1" 17 | }, 18 | "devDependencies": { 19 | "@vue/cli-plugin-babel": "^3.0.0", 20 | "@vue/cli-plugin-eslint": "^3.0.0", 21 | "@vue/cli-service": "^3.0.0", 22 | "babel-eslint": "^10.0.1", 23 | "eslint": "^5.8.0", 24 | "eslint-plugin-vue": "^5.0.0", 25 | "vue-template-compiler": "^2.5.21" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vue-hello-world/src/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 32 | -------------------------------------------------------------------------------- /vue-hello-world/src/api/user.js: -------------------------------------------------------------------------------- 1 | import HttpRequest from '@/axios/api.request' 2 | 3 | export const UserQryAction = () => { 4 | return HttpRequest.request({ 5 | url: 'user/', 6 | method: 'get' 7 | }) 8 | } 9 | 10 | export const UserAddAction = (parameter) => { 11 | return HttpRequest.request({ 12 | url: 'user/', 13 | method: 'post', 14 | params: parameter 15 | }) 16 | } 17 | 18 | export const UserUpdateAction = (parameter) => { 19 | return HttpRequest.request({ 20 | url: 'user/', 21 | method: 'put', 22 | params: parameter 23 | }) 24 | } 25 | 26 | export const UserDelAction = (parameter) => { 27 | return HttpRequest.request({ 28 | url: 'user/', 29 | method: 'delete', 30 | params: { 31 | no: parameter 32 | } 33 | }) 34 | } 35 | 36 | -------------------------------------------------------------------------------- /vue-hello-world/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangwei0101/Spring-Boot-And-Vue/e30d516084d97a10ef66f07acb3395aa7f3e10af/vue-hello-world/src/assets/logo.png -------------------------------------------------------------------------------- /vue-hello-world/src/axios/api.request.js: -------------------------------------------------------------------------------- 1 | import axios from "axios" 2 | import config from './index' 3 | const baseUrl = process.env.NODE_ENV === 'development' ? config.baseUrl.dev : config.baseUrl.pro 4 | 5 | const HttpRequest = axios.create({ 6 | baseURL: baseUrl, // api的base_url 7 | timeout: 5000 // 请求超时时间 8 | }); 9 | export default HttpRequest 10 | -------------------------------------------------------------------------------- /vue-hello-world/src/axios/index.js: -------------------------------------------------------------------------------- 1 | export default { 2 | /** 3 | * @description api请求基础路径 4 | */ 5 | baseUrl: { 6 | dev: 'http://localhost:8080/api/', 7 | pro: 'http://101.132.124.171:8080/demo-1.0/api/' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /vue-hello-world/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 47 | 48 | 49 | 65 | -------------------------------------------------------------------------------- /vue-hello-world/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import store from './store' 5 | import iView from 'iview' 6 | import 'iview/dist/styles/iview.css' 7 | 8 | Vue.use(iView) 9 | Vue.config.productionTip = false 10 | 11 | new Vue({ 12 | router, 13 | store, 14 | render: h => h(App) 15 | }).$mount('#app') 16 | -------------------------------------------------------------------------------- /vue-hello-world/src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Home from './views/Home.vue' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | mode: 'history', 9 | base: process.env.BASE_URL, 10 | routes: [ 11 | { 12 | path: '/', 13 | name: 'home', 14 | component: Home 15 | }, 16 | { 17 | path: '/about', 18 | name: 'about', 19 | // route level code-splitting 20 | // this generates a separate chunk (about.[hash].js) for this route 21 | // which is lazy-loaded when the route is visited. 22 | component: () => import(/* webpackChunkName: "about" */ './views/About.vue') 23 | } 24 | ] 25 | }) 26 | -------------------------------------------------------------------------------- /vue-hello-world/src/store.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | export default new Vuex.Store({ 7 | state: { 8 | 9 | }, 10 | mutations: { 11 | 12 | }, 13 | actions: { 14 | 15 | } 16 | }) 17 | -------------------------------------------------------------------------------- /vue-hello-world/src/views/About.vue: -------------------------------------------------------------------------------- 1 | 65 | 66 | 205 | 206 | -------------------------------------------------------------------------------- /vue-hello-world/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /vue-hello-world/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | lintOnSave: false, 3 | devServer: { 4 | port: 8000, 5 | }, 6 | } 7 | --------------------------------------------------------------------------------