UserRESTfullWS.java
package com.sunilos.proj0.rest;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
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.ResponseBody;
import com.sunilos.proj0.ctl.BaseCtl;
import com.sunilos.proj0.dto.UserDTO;
import com.sunilos.proj0.dto.StudentDTO;
import com.sunilos.proj0.dto.UserDTO;
import com.sunilos.proj0.form.UserForm;
import com.sunilos.proj0.form.StudentForm;
import com.sunilos.proj0.form.UserForm;
import com.sunilos.proj0.service.UserServiceInt;
import com.sunilos.proj0.service.UserServiceInt;
/**
* User RESTFul Web Service.
*
* @author SunilOS
* @version 1.0
* @Copyright (c) SunilOS
*/
@Controller
@RequestMapping(value = "/rest/User")
public class UserRESTfullWS extends BaseCtl {
private static Logger log = Logger.getLogger(UserRESTfullWS.class);
@Autowired
private UserServiceInt service;
/**
* Gets User information
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public UserDTO get(@PathVariable long id) {
log.debug("UserCtl doDisplay() Start");
UserDTO dto = service.findByPK(id);
return dto;
}
/**
* Gets User list
*
* @param form
* @return
*/
@RequestMapping(value = "/search", method = RequestMethod.GET)
@ResponseBody
public List getList(UserForm form) {
UserDTO dto = (UserDTO) form.getDto();
return service.search(dto, form.getPageNo(), form.getPageSize());
}
/**
* Deletes a User
*
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/delete/{id}")
@ResponseBody
public UserDTO delete(@PathVariable long id) throws Exception {
UserDTO dto = service.findByPK(id);
service.delete(id);
return dto;
}
}