Skip to content
Snippets Groups Projects
Commit 59c198d4 authored by Zekun Fan's avatar Zekun Fan
Browse files

demo

parent b04a12b0
No related branches found
No related tags found
1 merge request!1Master
# 651project
651 project, business system for groceries
\ No newline at end of file
.
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── freshonline
│ │ │ ├── advice
│ │ │ ├── constants
│ │ │ ├── controller
│ │ │ ├── dao
│ │ │ ├── dto
│ │ │ ├── enums
│ │ │ ├── exception
│ │ │ ├── interceptor
│ │ │ ├── listener
│ │ │ ├── model
│ │ │ ├── schedule
│ │ │ ├── service
│ │ │ └── utils
│ │ └── resources
│ │ ├── mapper
│ │ ├── static
│ │ │ └── images
│ │ └── templates
│ └── test
│ └── java
│ └── com
│ └── example
│ └── freshonline
│ └── controller
└── target
├── classes
│ └── com
│ └── example
│ └── freshonline
├── generated-sources
│ └── annotations
├── generated-test-sources
│ └── test-annotations
└── test-classes
└── com
└── example
└── freshonline
package com.example.freshonline.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class Config implements WebMvcConfigurer {
// handler cors problem
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowCredentials(true)
.allowedMethods("*")
.maxAge(3600);
}
}
package com.example.freshonline.controller;
import com.alibaba.fastjson.JSONObject;
import com.example.freshonline.model.User;
import org.springframework.web.bind.annotation.*;
import javax.xml.transform.Source;
import java.util.Date;
@RestController
public class HelloWorld {
@GetMapping("/hello/{hello_id}")
public String h1(@PathVariable("hello_id") Integer id, @RequestParam("hello_name") String xxx){
System.out.println("h1: hello_id="+ id+ "-----hello_name="+xxx);
return "h1: hello_id="+ id+ "-----hello_name="+xxx;
}
@GetMapping("/hello/{user_id}/orders")
public String h2(@PathVariable("user_id") String id,
@RequestParam("pagesize") Integer pagesize,
@RequestParam("pagenum") Integer pagenum,
@RequestParam("start") Date start_date,
@RequestParam("end") Date end){
return "h2: user_id="+ id+
"-----pagesize="+pagesize+
"----pagenum="+pagenum+
"----start="+start_date.toString()+
"----end="+end.toString();
}
@PostMapping("/hello/user")
public String h3(@RequestBody JSONObject req){
User user = req.toJavaObject(User.class);
return "h3: "+ user.toString();
}
}
package com.example.freshonline.model;
import lombok.Data;
@Data
public class User {
private Integer id;
private String name;
private String pwd;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment