2a919110f18a332b0b7d2ed50645a51ed5b5a5e7.svn-base 2.89 KB
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ycsl.web.ywbj;

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.ycsl.entity.ywbj.YcslYwbj;
import com.thinkgem.jeesite.modules.ycsl.service.ywbj.YcslYwbjService;

/**
 * 业务办结状态Controller
 * @author lw
 * @version 2020-12-28
 */
@Controller
@RequestMapping(value = "${adminPath}/ycsl/ywbj/ycslYwbj")
public class YcslYwbjController extends BaseController {

	@Autowired
	private YcslYwbjService ycslYwbjService;
	
	@ModelAttribute
	public YcslYwbj get(@RequestParam(required=false) String id) {
		YcslYwbj entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = ycslYwbjService.get(id);
		}
		if (entity == null){
			entity = new YcslYwbj();
		}
		return entity;
	}
	
	@RequiresPermissions("ycsl:ywbj:ycslYwbj:view")
	@RequestMapping(value = {"list", ""})
	public String list(YcslYwbj ycslYwbj, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<YcslYwbj> page = ycslYwbjService.findPage(new Page<YcslYwbj>(request, response), ycslYwbj); 
		model.addAttribute("page", page);
		return "modules/ycsl/ywbj/ycslYwbjList";
	}

	@RequiresPermissions("ycsl:ywbj:ycslYwbj:view")
	@RequestMapping(value = "form")
	public String form(YcslYwbj ycslYwbj, Model model) {
		model.addAttribute("ycslYwbj", ycslYwbj);
		return "modules/ycsl/ywbj/ycslYwbjForm";
	}

	@RequiresPermissions("ycsl:ywbj:ycslYwbj:edit")
	@RequestMapping(value = "save")
	public String save(YcslYwbj ycslYwbj, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, ycslYwbj)){
			return form(ycslYwbj, model);
		}
		ycslYwbjService.save(ycslYwbj);
		addMessage(redirectAttributes, "保存业务办结状态成功");
		return "redirect:"+Global.getAdminPath()+"/ycsl/ywbj/ycslYwbj/?repage";
	}
	
	@RequiresPermissions("ycsl:ywbj:ycslYwbj:edit")
	@RequestMapping(value = "delete")
	public String delete(YcslYwbj ycslYwbj, RedirectAttributes redirectAttributes) {
		ycslYwbjService.delete(ycslYwbj);
		addMessage(redirectAttributes, "删除业务办结状态成功");
		return "redirect:"+Global.getAdminPath()+"/ycsl/ywbj/ycslYwbj/?repage";
	}

}