233631d1dd60bfbaa44315d6e4559f6f38cc5877.svn-base 5.24 KB
/**
 * Copyright © 2015-2018 ODM All rights reserved.
 */
package com.thinkgem.jeesite.modules.reg.web.base;

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.base.RegBaseZdbhqk;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZdbhqkService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

/**
 * 宗地基本信息变化表单维护Controller
 * @author xuyg
 * @version 2015-10-20
 */
@Controller
@RequestMapping(value = "${adminPath}/reg/base/regBaseZdbhqk")
public class RegBaseZdbhqkController extends BaseController {

	@Autowired
	private RegBaseZdbhqkService regBaseZdbhqkService;
	
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	
	@ModelAttribute
	public RegBaseZdbhqk get(@RequestParam(required=false) String id) {
		RegBaseZdbhqk entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = regBaseZdbhqkService.get(id);
		}
		if (entity == null){
			entity = new RegBaseZdbhqk();
		}
		return entity;
	}
	
	@RequiresPermissions("reg:base:regBaseZdbhqk:view")
	@RequestMapping(value = {"list", ""})
	public String list(RegBaseZdbhqk regBaseZdbhqk, HttpServletRequest request, HttpServletResponse response, Model model) {
		if(StringUtils.isNotBlank(request.getParameter("YWH"))){
			regBaseZdbhqk.setYwh(request.getParameter("YWH"));
			model.addAttribute("YWH", request.getParameter("YWH"));
		} 
		//传递宗地代码
		if(StringUtils.isNotBlank(request.getParameter("zddm"))){
			model.addAttribute("ZDDM", request.getParameter("zddm"));
		}
		//WinOpen标示
		if(StringUtils.isNotBlank(request.getParameter("WO"))){
			model.addAttribute("WO", "1");
		}
		//页面操作类型【新增还是更新】
		if(StringUtils.isNotBlank(request.getParameter("optype"))){
			model.addAttribute("optype", "update");
		}
		if(StringUtils.isNotBlank(request.getParameter("LISTVIEWS"))){
			model.addAttribute("LISTVIEWS", "1");
		}
		Page<RegBaseZdbhqk> page = regBaseZdbhqkService.findPage(new Page<RegBaseZdbhqk>(request, response), regBaseZdbhqk); 
		model.addAttribute("page", page);
		return "modules/reg/base/regBaseZdbhqkList";
	}

	@RequiresPermissions("reg:base:regBaseZdbhqk:view")
	@RequestMapping(value = "form")
	public String form(RegBaseZdbhqk regBaseZdbhqk, Model model, HttpServletRequest request) {
		User user = UserUtils.getUser();
		
		//点击了选择已登记信息后,在宗地情况变化信息添加里,应该过滤出与 已登记信息 有关的宗地基本信息 
		//by ztk 2016 -01-16 start
		String bdcqzsdjxxID = request.getParameter("BdcqzsdjxxID");
		if(StringUtils.isNotBlank(bdcqzsdjxxID)){
			RegBusBdcqzsdjxx regBusBdcqzsdjxx  = 	regBusBdcqzsdjxxService.get(bdcqzsdjxxID);
			if(regBusBdcqzsdjxx != null){
				regBaseZdbhqk.setZddm(regBusBdcqzsdjxx.getZddm());
			}
		}
		//by ztk end
		
		model.addAttribute("regBaseZdbhqk", regBaseZdbhqk);
		//传递宗地代码
		if(StringUtils.isNotBlank(request.getParameter("zddm"))){
			model.addAttribute("ZDDM", request.getParameter("zddm"));
		}
		//查看标示
		if(StringUtils.isNotBlank(request.getParameter("VIEWS"))){
			model.addAttribute("VIEWS", request.getParameter("VIEWS"));
		}
		if(StringUtils.isNotBlank(request.getParameter("ywh"))){
			model.addAttribute("YWH", request.getParameter("ywh"));
		} 
		model.addAttribute("SLR", user.getName());
		return "modules/reg/base/regBaseZdbhqkForm";
	}

	@RequiresPermissions("reg:base:regBaseZdbhqk:edit")
	@RequestMapping(value = "save")
	public String save(RegBaseZdbhqk regBaseZdbhqk, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		if (!beanValidator(model, regBaseZdbhqk)){
			return form(regBaseZdbhqk, model, request);
		}
		regBaseZdbhqkService.save(regBaseZdbhqk);
		addMessage(redirectAttributes, "保存宗地基本信息变化成功");
		return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseZdbhqk/?repage&WO=1&YWH="+ request.getParameter("YWH") +"&optype="+request.getParameter("optype");
	}
	
	@RequiresPermissions("reg:base:regBaseZdbhqk:edit")
	@RequestMapping(value = "delete")
	public String delete(RegBaseZdbhqk regBaseZdbhqk, RedirectAttributes redirectAttributes, HttpServletRequest request) {
		regBaseZdbhqkService.delete(regBaseZdbhqk);
		addMessage(redirectAttributes, "删除宗地基本信息变化成功");
		return "redirect:"+Global.getAdminPath()+"/reg/base/regBaseZdbhqk/?repage&YWH="+ request.getParameter("YWH");
	}

}