package com.sooka.system.controller;

import java.util.List;

import com.sooka.common.annotation.Log;
import com.sooka.common.core.controller.BaseController;
import com.sooka.common.core.domain.AjaxResult;
import com.sooka.common.core.page.TableDataInfo;
import com.sooka.common.enums.BusinessType;
import com.sooka.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sooka.system.domain.TGuijiNaturalresourcesBdcdjxx;
import com.sooka.system.service.ITGuijiNaturalresourcesBdcdjxxService;

/**
 * 不动产登记信息Controller
 *
 * @author lei
 * @date 2021-10-29
 */
@Controller
@RequestMapping("/system/bdcdjxx")
public class TGuijiNaturalresourcesBdcdjxxController extends BaseController {
    private String prefix = "system/bdcdjxx";

    @Autowired
    private ITGuijiNaturalresourcesBdcdjxxService tGuijiNaturalresourcesBdcdjxxService;

    //不动产住宅
    @RequiresPermissions("system:bdczz:view")
    @GetMapping()
    public String bdcdjxx(ModelMap map) {
        map.put("flag","bdczz");
        return prefix + "/bdcdjxx";
    }

    //不动产办公
    @RequiresPermissions("system:bdcbg:view")
    @GetMapping("/bdcbg")
    public String bdcbg(ModelMap map) {
        map.put("flag","bdcbg");
        return prefix + "/bdcdjxx";
    }

    //不动产商业服务
    @RequiresPermissions("system:bdcsyfw:view")
    @GetMapping("/bdcsyfw")
    public String bdcsyfw(ModelMap map) {
        map.put("flag","bdcsyfw");
        return prefix + "/bdcdjxx";
    }

    //不动产其他
    @RequiresPermissions("system:bdcqt:view")
    @GetMapping("/bdcqt")
    public String bdcqt(ModelMap map) {
        map.put("flag","bdcqt");
        return prefix + "/bdcdjxx";
    }

    //不动产住宅
    @RequiresPermissions("system:bdcdjxx:list")
    @PostMapping("/bdczzList")
    @ResponseBody
    public TableDataInfo bdczzList(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        startPage();
        tGuijiNaturalresourcesBdcdjxx.setGhyt("住宅");
        List<TGuijiNaturalresourcesBdcdjxx> list = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxList(tGuijiNaturalresourcesBdcdjxx);
        return getDataTable(list);
    }

    //不动产办公
    @RequiresPermissions("system:bdcdjxx:list")
    @PostMapping("/bdcbgList")
    @ResponseBody
    public TableDataInfo bdcbg(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        startPage();
        tGuijiNaturalresourcesBdcdjxx.setGhyt("办公");
        List<TGuijiNaturalresourcesBdcdjxx> list = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxList(tGuijiNaturalresourcesBdcdjxx);
        return getDataTable(list);
    }

    //不动产商业服务
    @RequiresPermissions("system:bdcdjxx:list")
    @PostMapping("/bdcsyfwList")
    @ResponseBody
    public TableDataInfo bdcsyfw(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        startPage();
        tGuijiNaturalresourcesBdcdjxx.setGhyt("商业服务");
        List<TGuijiNaturalresourcesBdcdjxx> list = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxList(tGuijiNaturalresourcesBdcdjxx);
        return getDataTable(list);
    }

    //不动产其他
    @RequiresPermissions("system:bdcdjxx:list")
    @PostMapping("/bdcqtList")
    @ResponseBody
    public TableDataInfo bdcqt(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        startPage();
//        tGuijiNaturalresourcesBdcdjxx.setGhyt("商业服务");
        List<TGuijiNaturalresourcesBdcdjxx> list = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxQtList(tGuijiNaturalresourcesBdcdjxx);
        return getDataTable(list);
    }

    /**
     * 查询不动产登记信息列表
     */
    @RequiresPermissions("system:bdcdjxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        startPage();
        List<TGuijiNaturalresourcesBdcdjxx> list = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxList(tGuijiNaturalresourcesBdcdjxx);
        return getDataTable(list);
    }

    /**
     * 导出不动产登记信息列表
     */
    @RequiresPermissions("system:bdcdjxx:export")
    @Log(title = "不动产登记信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        List<TGuijiNaturalresourcesBdcdjxx> list = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxList(tGuijiNaturalresourcesBdcdjxx);
        ExcelUtil<TGuijiNaturalresourcesBdcdjxx> util = new ExcelUtil<TGuijiNaturalresourcesBdcdjxx>(TGuijiNaturalresourcesBdcdjxx.class);
        return util.exportExcel(list, "bdcdjxx");
    }

    /**
     * 新增不动产登记信息
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存不动产登记信息
     */
    @RequiresPermissions("system:bdcdjxx:add")
    @Log(title = "不动产登记信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        return toAjax(tGuijiNaturalresourcesBdcdjxxService.insertTGuijiNaturalresourcesBdcdjxx(tGuijiNaturalresourcesBdcdjxx));
    }

    /**
     * 修改不动产登记信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx = tGuijiNaturalresourcesBdcdjxxService.selectTGuijiNaturalresourcesBdcdjxxById(id);
        mmap.put("tGuijiNaturalresourcesBdcdjxx", tGuijiNaturalresourcesBdcdjxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存不动产登记信息
     */
    @RequiresPermissions("system:bdcdjxx:edit")
    @Log(title = "不动产登记信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiNaturalresourcesBdcdjxx tGuijiNaturalresourcesBdcdjxx) {
        return toAjax(tGuijiNaturalresourcesBdcdjxxService.updateTGuijiNaturalresourcesBdcdjxx(tGuijiNaturalresourcesBdcdjxx));
    }

    /**
     * 删除不动产登记信息
     */
    @RequiresPermissions("system:bdcdjxx:remove")
    @Log(title = "不动产登记信息", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(tGuijiNaturalresourcesBdcdjxxService.deleteTGuijiNaturalresourcesBdcdjxxByIds(ids));
    }
}
