51f5e6bad4fe2cf330d6ff17ecb3dc6b1e46893d.svn-base 3.17 KB
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sumdata.web.datatable;

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.sumdata.entity.datatable.SRegBusSjmain;
import com.thinkgem.jeesite.modules.sumdata.service.datatable.SRegBusSjmainService;

/**
 * s_reg_bus_sjmainController
 * @author xuyg
 * @version 2017-03-08
 */
@Controller
@RequestMapping(value = "${adminPath}/sumdata/datatable/sRegBusSjmain")
public class SRegBusSjmainController extends BaseController {

	@Autowired
	private SRegBusSjmainService sRegBusSjmainService;
	
	@ModelAttribute
	public SRegBusSjmain get(@RequestParam(required=false) String id) {
		SRegBusSjmain entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = sRegBusSjmainService.get(id);
		}
		if (entity == null){
			entity = new SRegBusSjmain();
		}
		return entity;
	}
	
	@RequiresPermissions("sumdata:datatable:sRegBusSjmain:view")
	@RequestMapping(value = {"list", ""})
	public String list(SRegBusSjmain sRegBusSjmain, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<SRegBusSjmain> page = sRegBusSjmainService.findPage(new Page<SRegBusSjmain>(request, response), sRegBusSjmain); 
		model.addAttribute("page", page);
		return "modules/sumdata/datatable/sRegBusSjmainList";
	}

	@RequiresPermissions("sumdata:datatable:sRegBusSjmain:view")
	@RequestMapping(value = "form")
	public String form(SRegBusSjmain sRegBusSjmain, Model model) {
		model.addAttribute("sRegBusSjmain", sRegBusSjmain);
		return "modules/sumdata/datatable/sRegBusSjmainForm";
	}

	@RequiresPermissions("sumdata:datatable:sRegBusSjmain:edit")
	@RequestMapping(value = "save")
	public String save(SRegBusSjmain sRegBusSjmain, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, sRegBusSjmain)){
			return form(sRegBusSjmain, model);
		}
		sRegBusSjmainService.save(sRegBusSjmain);
		addMessage(redirectAttributes, "保存s_reg_bus_sjmain成功");
		return "redirect:"+Global.getAdminPath()+"/sumdata/datatable/sRegBusSjmain/?repage";
	}
	
	@RequiresPermissions("sumdata:datatable:sRegBusSjmain:edit")
	@RequestMapping(value = "delete")
	public String delete(SRegBusSjmain sRegBusSjmain, RedirectAttributes redirectAttributes) {
		sRegBusSjmainService.delete(sRegBusSjmain);
		addMessage(redirectAttributes, "删除s_reg_bus_sjmain成功");
		return "redirect:"+Global.getAdminPath()+"/sumdata/datatable/sRegBusSjmain/?repage";
	}

}