package com.da.dangan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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.da.common.annotation.Log;
import com.da.common.core.controller.BaseController;
import com.da.common.core.domain.AjaxResult;
import com.da.common.enums.BusinessType;
import com.da.dangan.domain.DaCzrkdj;
import com.da.dangan.service.IDaCzrkdjService;
import com.da.common.utils.poi.ExcelUtil;
import com.da.common.core.page.TableDataInfo;

/**
 * 常住人口登记Controller
 * 
 * @author hs
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/dangan/czrkdj")
public class DaCzrkdjController extends BaseController
{
    @Autowired
    private IDaCzrkdjService daCzrkdjService;

    /**
     * 查询常住人口登记列表
     */
    @PreAuthorize("@ss.hasPermi('dangan:czrkdj:list')")
    @GetMapping("/list")
    public TableDataInfo list(DaCzrkdj daCzrkdj)
    {
        startPage();
        List<DaCzrkdj> list = daCzrkdjService.selectDaCzrkdjList(daCzrkdj);
        return getDataTable(list);
    }

    /**
     * 导出常住人口登记列表
     */
    @PreAuthorize("@ss.hasPermi('dangan:czrkdj:export')")
    @Log(title = "常住人口登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DaCzrkdj daCzrkdj)
    {
        List<DaCzrkdj> list = daCzrkdjService.selectDaCzrkdjList(daCzrkdj);
        ExcelUtil<DaCzrkdj> util = new ExcelUtil<DaCzrkdj>(DaCzrkdj.class);
        util.exportExcel(response, list, "常住人口登记数据");
    }

    /**
     * 获取常住人口登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangan:czrkdj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(daCzrkdjService.selectDaCzrkdjById(id));
    }

    /**
     * 新增常住人口登记
     */
    @PreAuthorize("@ss.hasPermi('dangan:czrkdj:add')")
    @Log(title = "常住人口登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DaCzrkdj daCzrkdj)
    {
        return toAjax(daCzrkdjService.insertDaCzrkdj(daCzrkdj));
    }

    /**
     * 修改常住人口登记
     */
    @PreAuthorize("@ss.hasPermi('dangan:czrkdj:edit')")
    @Log(title = "常住人口登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DaCzrkdj daCzrkdj)
    {
        return toAjax(daCzrkdjService.updateDaCzrkdj(daCzrkdj));
    }

    /**
     * 删除常住人口登记
     */
    @PreAuthorize("@ss.hasPermi('dangan:czrkdj:remove')")
    @Log(title = "常住人口登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(daCzrkdjService.deleteDaCzrkdjByIds(ids));
    }
}
