package com.pinganwj.clinic.web.test.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.pinganwj.clinic.web.test.service.TestStuService;
import com.pinganwj.common.model.db.test.TestStudent;
import com.pinganwj.common.utils.ReturnMsg;
import com.pinganwj.common.web.constants.AppConstants;
import com.pinganwj.common.web.constants.AppConstantsMsg;
@Controller
@RequestMapping("/Student")
public class TestStuController {
@Resource
TestStuService testStuService;
Logger logger = LoggerFactory.getLogger(getClass());
private String backMsg;
/**
*
*/
@RequestMapping("/getAllStudent")
public void getAllStudent(HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.getAllStudent(), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController getAllStudent() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
/**
* 删除
*
* @Description: delStudentById
* @param id
* @param request
* @param response
* void
*
*/
@RequestMapping("/delStudentById")
public void delStudentById(String id, HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.delStudentById(id), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController delStudentById() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
/**
* 保存
*
* @Description: save
* @param id
* @param request
* @param response
* void
*
*/
@RequestMapping("/save")
public void save(@RequestBody TestStudent TestStudent, HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.insertStudent(TestStudent), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController save() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
/**
* 更新
*
* @Description: update
* @param id
* @param request
* @param response
* void
*
*/
@RequestMapping("/updateStudentById")
public void update(@RequestBody TestStudent TestStudent, HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.updateStudentById(TestStudent), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController updateStudentById() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
}
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.pinganwj.clinic.web.test.service.TestStuService;
import com.pinganwj.common.model.db.test.TestStudent;
import com.pinganwj.common.utils.ReturnMsg;
import com.pinganwj.common.web.constants.AppConstants;
import com.pinganwj.common.web.constants.AppConstantsMsg;
@Controller
@RequestMapping("/Student")
public class TestStuController {
@Resource
TestStuService testStuService;
Logger logger = LoggerFactory.getLogger(getClass());
private String backMsg;
/**
*
*/
@RequestMapping("/getAllStudent")
public void getAllStudent(HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.getAllStudent(), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController getAllStudent() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
/**
* 删除
*
* @Description: delStudentById
* @param id
* @param request
* @param response
* void
*
*/
@RequestMapping("/delStudentById")
public void delStudentById(String id, HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.delStudentById(id), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController delStudentById() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
/**
* 保存
*
* @Description: save
* @param id
* @param request
* @param response
* void
*
*/
@RequestMapping("/save")
public void save(@RequestBody TestStudent TestStudent, HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.insertStudent(TestStudent), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController save() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
/**
* 更新
*
* @Description: update
* @param id
* @param request
* @param response
* void
*
*/
@RequestMapping("/updateStudentById")
public void update(@RequestBody TestStudent TestStudent, HttpServletRequest request, HttpServletResponse response) {
try {
backMsg = ReturnMsg.plusMsg(testStuService.updateStudentById(TestStudent), AppConstants.ERROR_CODE_E0000000, AppConstantsMsg.ERROR_MSG_E0000000);
} catch (Exception e) {
logger.error("TestStuController updateStudentById() 异常:[{}]", e.getMessage());
backMsg = ReturnMsg.plusMsg("", AppConstants.ERROR_CODE_E1SP0001, "系统异常");
}
ReturnMsg.sendMsg(backMsg, response, request);
}
}