package com.sooka.system.real_estate.on_sale_record_change.controller;

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 com.sooka.system.real_estate.on_sale_record_change.domain.TGuijiRealEstateOnSaleRecordChange;
import com.sooka.system.real_estate.on_sale_record_change.service.ITGuijiRealEstateOnSaleRecordChangeService;
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.*;

import java.util.List;

/**
 * 市房地产-现售备案变更信息Controller
 *
 * @author lei
 * @date 2022-08-22
 */
@Controller
@RequestMapping("/system/real_estate/real_estate_on_sale_record_change")
public class TGuijiRealEstateOnSaleRecordChangeController extends BaseController
{
    private String prefix = "system/real_estate/on_sale_record_change";

    @Autowired
    private ITGuijiRealEstateOnSaleRecordChangeService service;

    @RequiresPermissions("system:on_sale_record_change:view")
    @GetMapping()
    public String on_sale_record_change()
    {
        return prefix + "/on_sale_record_change";
    }

    /**
     * 查询市房地产-现售备案变更信息列表
     */
    @RequiresPermissions("system:on_sale_record_change:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiRealEstateOnSaleRecordChange param)
    {
        startPage();
        List<TGuijiRealEstateOnSaleRecordChange> list = service.selectList(param);
        return getDataTable(list);
    }

    /**
     * 导出市房地产-现售备案变更信息列表
     */
    @RequiresPermissions("system:on_sale_record_change:export")
    @Log(title = "市房地产-现售备案变更信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiRealEstateOnSaleRecordChange param)
    {
        List<TGuijiRealEstateOnSaleRecordChange> list = service.selectList(param);
        ExcelUtil<TGuijiRealEstateOnSaleRecordChange> util = new ExcelUtil<TGuijiRealEstateOnSaleRecordChange>(TGuijiRealEstateOnSaleRecordChange.class);
        return util.exportExcel(list, "市房地产-现售备案变更信息");
    }

    /**
     * 新增市房地产-现售备案变更信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存市房地产-现售备案变更信息
     */
    @RequiresPermissions("system:on_sale_record_change:add")
    @Log(title = "市房地产-现售备案变更信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiRealEstateOnSaleRecordChange param)
    {
        return toAjax(service.insert(param));
    }

    /**
     * 修改市房地产-现售备案变更信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiRealEstateOnSaleRecordChange param = service.selectById(id);
        mmap.put("param", param);
        return prefix + "/edit";
    }

    /**
     * 修改保存市房地产-现售备案变更信息
     */
    @RequiresPermissions("system:on_sale_record_change:edit")
    @Log(title = "市房地产-现售备案变更信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiRealEstateOnSaleRecordChange param)
    {
        return toAjax(service.update(param));
    }

    /**
     * 删除市房地产-现售备案变更信息
     */
    @RequiresPermissions("system:on_sale_record_change:remove")
    @Log(title = "市房地产-现售备案变更信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(service.deleteByIds(ids));
    }

    /**
     * 市房地产-现售备案变更信息详情
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiRealEstateOnSaleRecordChange param = service.selectById(id);
        mmap.put("detail", param);
        return prefix + "/detail";
    }
}
