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.HdQd;
import com.ruoyi.web.service.IHdQdService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动信息-签到Controller
 * 
 * @author shenzx
 * @date 2025-09-17
 */
@RestController
@RequestMapping("/hd/qd")
public class HdQdController extends BaseController
{
    private IHdQdService hdQdService;
    @Autowired
    public void setHdQdService(IHdQdService hdQdService) {
        this.hdQdService = hdQdService;
    }

    /**
     * 查询活动信息-签到列表
     */
    @PreAuthorize("@ss.hasPermi('hd:qd:list')")
    @GetMapping("/list")
    public TableDataInfo list(HdQd hdQd)
    {
        startPage();
        QueryWrapper<HdQd> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(hdQd);
        List<HdQd> hdQdList = hdQdService.list(queryWrapper);
        return getDataTable(hdQdList);
    }

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

    /**
     * 获取活动信息-签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('hd:qd:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hdQdService.getById(id));
    }

    /**
     * 新增活动信息-签到
     */
    @PreAuthorize("@ss.hasPermi('hd:qd:add')")
    @Log(title = "活动信息-签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HdQd hdQd)
    {
        hdQdService.save(hdQd);
        return success(hdQd);
    }

    /**
     * 修改活动信息-签到
     */
    @PreAuthorize("@ss.hasPermi('hd:qd:edit')")
    @Log(title = "活动信息-签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HdQd hdQd)
    {
        hdQdService.updateById(hdQd);
        return success(hdQd);
    }

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