package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;

import java.util.Arrays;

import com.ruoyi.common.core.controller.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DFixAddressArea;
import com.ruoyi.system.service.IDFixAddressAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 固定地址区划Controller
 *
 * @author ruoyi
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/system/dFixAddressArea")
public class DFixAddressAreaController extends BaseController {
    private final IDFixAddressAreaService dFixAddressAreaService;

    public DFixAddressAreaController(IDFixAddressAreaService dFixAddressAreaService) {
        this.dFixAddressAreaService = dFixAddressAreaService;
    }

    
  

    /**
     * 查询固定地址区划列表
     *
     * @param dFixAddressArea 固定地址区划
     * @return 固定地址区划集合
     * @date 2023-07-05
     */
    @PreAuthorize("@ss.hasPermi('system:dFixAddressArea:list')")
    @GetMapping("/list")
    public TableDataInfo list(DFixAddressArea dFixAddressArea) {
        startPage();
        List<DFixAddressArea> list = dFixAddressAreaService.queryList(dFixAddressArea);
        return getDataTable(list);
    }


    /**
     * 导出固定地址区划列表
     *
     * @param dFixAddressArea 固定地址区划
     * @date 2023-07-05
     */
    @PreAuthorize("@ss.hasPermi('system:dFixAddressArea:export')")
    @Log(title = "固定地址区划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DFixAddressArea dFixAddressArea) {
        List<DFixAddressArea> list = dFixAddressAreaService.list(new QueryWrapper<>());
        ExcelUtil<DFixAddressArea> util = new ExcelUtil<>(DFixAddressArea. class);
        util.exportExcel(response, list, "固定地址区划数据");
    }

    /**
     * 获取固定地址区划详细信息
     *
     * @param id 主键id
     * @return 结果
     * @date 2023-07-05
     */
    @PreAuthorize("@ss.hasPermi('system:dFixAddressArea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dFixAddressAreaService.getById(id));
    }


    /**
     * 新增固定地址区划信息
     *
     * @param dFixAddressArea 固定地址区划
     * @return 结果
     * @date 2023-07-05
     */
    @PreAuthorize("@ss.hasPermi('system:dFixAddressArea:add')")
    @Log(title = "固定地址区划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DFixAddressArea dFixAddressArea) {
        return toAjax(dFixAddressAreaService.save(dFixAddressArea));
    }


    /**
     * 修改固定地址区划信息
     *
     * @param dFixAddressArea 固定地址区划
     * @return 结果
     * @date 2023-07-05
     */
    @PreAuthorize("@ss.hasPermi('system:dFixAddressArea:edit')")
    @Log(title = "固定地址区划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DFixAddressArea dFixAddressArea) {
        return toAjax(dFixAddressAreaService.updateById(dFixAddressArea));
    }


    /**
     * 删除固定地址区划信息
     *
     * @param ids 主键ids
     * @return 结果
     * @date 2023-07-05
     */
    @PreAuthorize("@ss.hasPermi('system:dFixAddressArea:remove')")
    @Log(title = "固定地址区划", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(dFixAddressAreaService.removeByIds(Arrays.asList(ids)));
    }


}
