package com.ruoyi.web.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.HdZd;
import com.ruoyi.web.service.IHdZdService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动信息-账单Controller
 * 
 * @author shenzx
 * @date 2025-09-17
 */
@RestController
@RequestMapping("/hd/zd")
public class HdZdController extends BaseController
{
    private IHdZdService hdZdService;
    @Autowired
    public void setHdZdService(IHdZdService hdZdService) {
        this.hdZdService = hdZdService;
    }

    /**
     * 查询活动信息-账单列表
     */
    @PreAuthorize("@ss.hasPermi('hd:zd:list')")
    @GetMapping("/list")
    public TableDataInfo list(HdZd hdZd)
    {
        startPage();
        QueryWrapper<HdZd> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(hdZd);
        List<HdZd> hdZdList = hdZdService.list(queryWrapper);
        return getDataTable(hdZdList);
    }

    /**
     * 导出活动信息-账单列表
     */
    @PreAuthorize("@ss.hasPermi('hd:zd:export')")
    @Log(title = "活动信息-账单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HdZd hdZd)
    {
        QueryWrapper<HdZd> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(hdZd);
        List<HdZd> list = hdZdService.list(queryWrapper);
        ExcelUtil<HdZd> util = new ExcelUtil<>(HdZd.class);
        util.exportExcel(response, list, "活动信息-账单数据");
    }

    /**
     * 获取活动信息-账单详细信息
     */
    @PreAuthorize("@ss.hasPermi('hd:zd:query')")
    @GetMapping(value = "/{hdId}")
    public AjaxResult getInfo(@PathVariable("hdId") Long hdId)
    {
        return success(hdZdService.getById(hdId));
    }

    /**
     * 新增活动信息-账单
     */
    @PreAuthorize("@ss.hasPermi('hd:zd:add')")
    @Log(title = "活动信息-账单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HdZd hdZd)
    {
        hdZdService.save(hdZd);
        return success(hdZd);
    }

    /**
     * 修改活动信息-账单
     */
    @PreAuthorize("@ss.hasPermi('hd:zd:edit')")
    @Log(title = "活动信息-账单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HdZd hdZd)
    {
        hdZdService.updateById(hdZd);
        return success(hdZd);
    }

    /**
     * 删除活动信息-账单
     */
    @PreAuthorize("@ss.hasPermi('hd:zd:remove')")
    @Log(title = "活动信息-账单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hdIds}")
    public AjaxResult remove(@PathVariable Long[] hdIds)
    {
        return toAjax(hdZdService.removeByIds(Arrays.asList(hdIds)));
    }
}
