3ed167102981e675dea197bd008534f2a8bb6045.svn-base 2.41 KB
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.web.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseYy;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseYyService;

/**
 * 预约排号保存Controller
 * @author hsg
 * @version 2017-11-03
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/base/regBaseYy")
public class RegBaseYyController extends BaseController {

	@Autowired
	private RegBaseYyService regBaseYyService;
	
	@ModelAttribute
	public RegBaseYy get(@RequestParam(required=false) String id) {
		RegBaseYy entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBaseYyService.get(id);
		}
		if (entity == null){
			entity = new RegBaseYy();
		}
		return entity;
	}
	
	@RequestMapping(value = {"list", ""})
	public String list(RegBaseYy regBaseYy, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<RegBaseYy> page = regBaseYyService.findPage(new Page<RegBaseYy>(request, response), regBaseYy); 
		model.addAttribute("page", page);
		return "modules/reg/base/regBaseYyList";
	}

	@RequestMapping(value = "save")
	public String save(RegBaseYy regBaseYy, Model model, RedirectAttributes redirectAttributes) {
		regBaseYyService.save(regBaseYy);
		addMessage(redirectAttributes, "保存预约排号保存成功");
		return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseYy/?repage";
	}
	
	@RequestMapping(value = "delete")
	public String delete(RegBaseYy regBaseYy, RedirectAttributes redirectAttributes) {
		regBaseYyService.delete(regBaseYy);
		addMessage(redirectAttributes, "删除预约排号保存成功");
		return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseYy/?repage";
	}

}