首页>代码>spring boot使用mongodb数据库实现简单的数据插入和查询实例>/springboot-mongdb/src/main/java/com/singahnd/controller/StudentController.java
package com.singahnd.controller;

import org.springframework.beans.factory.annotation.Autowired;
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.RestController;

import com.singahnd.entity.Student;
import com.singahnd.service.StudentService;

/**
 ************************************************* 
 * @ClassName: StudentController
 * @Description: TODO(学生控制类)
 * @author mjy
 * @date 2018年5月24日 下午2:42:22
 ************************************************
 */
@RestController
@RequestMapping(value = "student", method = RequestMethod.POST)
public class StudentController {

	@Autowired
	private StudentService studentService;

	@RequestMapping(value = "inserStudent")
	public String inserStudent(@RequestBody Student student) {
		boolean inserStudentOne = studentService.inserStudentOne(student);
		if (inserStudentOne) {
			return "成功";
		} else {
			return "失败";
		}
	}

	@RequestMapping(value = "queryStudent")
	public Student queryStudent(@RequestBody Student student) {

		return studentService.queryStudentById(student.getStudentId());

	}
}
最近下载更多
876318269  LV6 2023年11月3日
asd6260647  LV4 2022年6月2日
天险无涯  LV15 2021年11月5日
sunlzh888888  LV28 2021年6月24日
wcy071213  LV27 2021年5月16日
Missqq  LV4 2020年4月27日
NoNameLwj  LV2 2020年2月23日
壹级天灾  LV14 2019年12月12日
寒江雪2017  LV9 2019年11月26日
yfp110  LV2 2019年11月22日
最近浏览更多
smart001 1月6日
暂无贡献等级
漫步的海星  LV4 2023年9月21日
1529860026  LV24 2023年7月19日
crosa_Don  LV18 2023年2月8日
yohohero  LV1 2023年1月15日
rain112  LV30 2022年12月13日
Super强  LV13 2022年10月21日
微信网友_6040315240812544  LV8 2022年10月21日
是你爸爸啊100  LV5 2022年8月8日
2534857231  LV2 2022年6月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友