package finalmyapp;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@RestController
public class HelloController {
@Autowired
private HelloService helloService;
@Autowired
JdbcTemplate jdbcTemplate;
@RequestMapping(method=RequestMethod.GET,value="/")
public String welcome() {
jdbcTemplate.execute("insert into user(email,password)values('java@javatpoint.com','java@javatpoint.com')");
return helloService.welcomeMessage();
}
@RequestMapping(method=RequestMethod.GET,value="/hello")
public String helloMessage() {
return helloService.helloMessage();
}
@RequestMapping(method=RequestMethod.GET,value="/name")
public String getName() {
return helloService.getUserName();
}
@RequestMapping(method=RequestMethod.GET,value="/address")
public List<Topic> getAddress() {
return helloService.getAddress();
}
@RequestMapping(method=RequestMethod.GET,params= {"name","lname"},value="/updatename")
public String updateName(@RequestParam String name,@RequestParam String lname) {
System.out.println("--hareonly--"+lname+name);
return helloService.getFullName(lname+name);
}
@RequestMapping(method=RequestMethod.GET,value="/getPath/{pname}/{plname}")
public String getPath(@PathVariable String pname,@PathVariable String plname) {
return pname+plname;
}
@RequestMapping(method=RequestMethod.POST,value="/updatename")
public List <Topic> updateNamePost(@RequestBody Topic topic) {
System.out.println("--hareonly--"+topic);
return helloService.updateName(topic);
}
}
No comments:
Post a Comment