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

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

import org.apache.shiro.authz.annotation.RequiresPermissions;
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.updata.RegBusSjhjtable;
import com.thinkgem.jeesite.modules.reg.service.updata.RegBusSjhjtableService;

/**
 * 数据汇交Controller
 * @author xuyg
 * @version 2016-08-10
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/updata/regBusSjhjtable")
public class RegBusSjhjtableController extends BaseController {

	@Autowired
	private RegBusSjhjtableService regBusSjhjtableService;
	
	@ModelAttribute
	public RegBusSjhjtable get(@RequestParam(required=false) String id) {
		RegBusSjhjtable entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBusSjhjtableService.get(id);
		}
		if (entity == null){
			entity = new RegBusSjhjtable();
		}
		return entity;
	}
	
	@RequiresPermissions("reg:updata:regBusSjhjtable:view")
	@RequestMapping(value = {"list", ""})
	public String list(RegBusSjhjtable regBusSjhjtable, HttpServletRequest request, HttpServletResponse response, Model model) {
		String qxdm = Global.getAreaCode();
		regBusSjhjtable.setAreacode(qxdm);
		Page<RegBusSjhjtable> page = regBusSjhjtableService.findPage(new Page<RegBusSjhjtable>(request, response), regBusSjhjtable); 
		model.addAttribute("page", page);
		return "modules/reg/updata/regBusSjhjtableList";
	}

	@RequiresPermissions("reg:updata:regBusSjhjtable:view")
	@RequestMapping(value = "form")
	public String form(RegBusSjhjtable regBusSjhjtable, Model model) {
		model.addAttribute("regBusSjhjtable", regBusSjhjtable);
		return "modules/reg/updata/regBusSjhjtableForm";
	}

	@RequiresPermissions("reg:updata:regBusSjhjtable:edit")
	@RequestMapping(value = "save")
	public String save(RegBusSjhjtable regBusSjhjtable, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, regBusSjhjtable)){
			return form(regBusSjhjtable, model);
		}
		regBusSjhjtableService.save(regBusSjhjtable);
		addMessage(redirectAttributes, "保存数据汇交成功");
		return "redirect:"+Global.getAdminPath()+"/reg/updata/regBusSjhjtable/?repage";
	}
	
	@RequiresPermissions("reg:updata:regBusSjhjtable:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBusSjhjtable regBusSjhjtable, RedirectAttributes redirectAttributes) {
		regBusSjhjtableService.delete(regBusSjhjtable);
		addMessage(redirectAttributes, "删除数据汇交成功");
		return "redirect:"+Global.getAdminPath()+"/reg/updata/regBusSjhjtable/?repage";
	}

}