729a0990076e3a046c75771d78fc297527b18a44.svn-base 3.09 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.SRegBusCfdj;
import com.thinkgem.jeesite.modules.sumdata.service.datatable.SRegBusCfdjService;

/**
 * s_reg_bus_cfdjController
 * @author xuyg
 * @version 2017-03-07
 */
@Controller
@RequestMapping(value = "${adminPath}/sumdata/datatable/sRegBusCfdj")
public class SRegBusCfdjController extends BaseController {

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

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

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

}