package com.example.springBootDemo.controller;
import java.util.List;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
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 com.example.springBootDemo.bean.JsonResult;
import com.example.springBootDemo.bean.Person;
import com.example.springBootDemo.service.PersonService;
@RestController
//@EnableCaching
//@RequestMapping(value = "/springboot")
public class UserController {
@Autowired
private PersonService personService;
@RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
ResponseEntity<JsonResult> getUserById(@PathVariable(value = "id") Integer id) throws Exception{
JsonResult r = new JsonResult();
Person person = personService.getPersonById(id);
r.setResult(person);
r.setStatus("ok");
return ResponseEntity.ok(r);
}
@RequestMapping(value = "users", method = RequestMethod.GET)
public ResponseEntity<JsonResult> getUserList(){
JsonResult r = new JsonResult();
List<Person> personLt = personService.getPersonList();
r.setResult(personLt);
r.setStatus("ok");
return ResponseEntity.ok(r);
}
@RequestMapping(value = "allusers", method = RequestMethod.GET)
public List<Person> getUserAll(){
JsonResult r = new JsonResult();
List<Person> personLt = personService.getPersonList();
r.setResult(personLt);
r.setStatus("ok");
return personLt;
}
@RequestMapping("addUserInfo")
public ResponseEntity<JsonResult> addUserInfo() {
JsonResult r = new JsonResult();
Person user = new Person();
user.setId((int)(Math.random()*100+1));
user.setName("cwh");
user.setSex("0");
user.setAge(10);
user.setTel("13636232212");
personService.add(user);
r.setResult(user);
r.setStatus("ok");
return ResponseEntity.ok(r);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
springcloud+mybaits+redis源码
共51个文件
class:13个
java:11个
properties:6个
需积分: 9 15 下载量 37 浏览量
2018-11-08
02:22:34
上传
评论 3
收藏 90KB ZIP 举报
温馨提示
springcloud+mybaits+redis源码,可运行,需要安装Redis,记得导入demo.sql及修改application-dev.properties内的数据库信息和Redis信息,
资源推荐
资源详情
资源评论
收起资源包目录
springBootDemo.zip (51个子文件)
demo.sql 465B
springBootDemo
.project 566B
mvnw.cmd 5KB
mvnw 6KB
src
test
java
com
example
springBootDemo
cache
CacheJest.java 1KB
SpringBootDemoApplicationTests.java 353B
main
test.js 67B
resources
application-dev.properties 1KB
application.properties 120B
mapper
templates
home.html 2KB
login.html 2KB
static
java
com
example
springBootDemo
service
PersonService.java 516B
impl
PersonServiceImpl.java 2KB
controller
UserController.java 2KB
SampleController.java 304B
mapper
RedisCacheDao.java 876B
PersonMapper.java 964B
SpringBootDemoApplication.java 743B
web
cache
bean
JsonResult.java 479B
Person.java 928B
test.html 355B
target
classes
application-dev.properties 1KB
application.properties 120B
mapper
PermissionDaoMapper.xml 764B
UserDaomapper.xml 913B
com
example
springBootDemo
service
PersonService.class 623B
impl
PersonServiceImpl.class 2KB
SpringBootDemoApplication.class 884B
controller
UserController.class 3KB
SampleController.class 645B
mapper
RedisCacheDao.class 2KB
PersonMapper.class 1KB
web
cache
bean
JsonResult.class 1KB
Person.class 1KB
templates
home.html 2KB
login.html 2KB
test-classes
com
example
springBootDemo
SpringBootDemoApplicationTests.class 672B
cache
CacheJest.class 2KB
com
example
springBootDemo
.settings
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 356B
org.eclipse.core.resources.prefs 155B
.mvn
wrapper
maven-wrapper.jar 46KB
maven-wrapper.properties 110B
pom.xml 4KB
.classpath 1KB
.gitignore 268B
bin
src
test
java
com
example
springBootDemo
SpringBootDemoApplicationTests.class 1KB
main
java
com
example
springBootDemo
SpringBootDemoApplication.class 1KB
target
classes
META-INF
MANIFEST.MF 339B
maven
com.example
springBootDemo
pom.properties 253B
pom.xml 2KB
共 51 条
- 1
资源评论
Michael_Yjliang
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功