package com.ruoyi.mall.controller;

import java.util.List;
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.mall.domain.TbSignUp;
import com.ruoyi.mall.service.ITbSignUpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户签到Controller
 * 
 * @author ruoyi
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/mall/signUp")
public class TbSignUpController extends BaseController
{
    @Autowired
    private ITbSignUpService tbSignUpService;

    /**
     * 查询用户签到列表
     */
    @PreAuthorize("@ss.hasPermi('mall:signUp:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbSignUp tbSignUp)
    {
        startPage();
        List<TbSignUp> list = tbSignUpService.selectTbSignUpList(tbSignUp);
        return getDataTable(list);
    }

    /**
     * 导出用户签到列表
     */
    @PreAuthorize("@ss.hasPermi('mall:signUp:export')")
    @Log(title = "用户签到", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbSignUp tbSignUp)
    {
        List<TbSignUp> list = tbSignUpService.selectTbSignUpList(tbSignUp);
        ExcelUtil<TbSignUp> util = new ExcelUtil<TbSignUp>(TbSignUp.class);
        return util.exportExcel(list, "用户签到数据");
    }

    /**
     * 获取用户签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:signUp:query')")
    @GetMapping(value = "/{signUpId}")
    public AjaxResult getInfo(@PathVariable("signUpId") Long signUpId)
    {
        return AjaxResult.success(tbSignUpService.selectTbSignUpBySignUpId(signUpId));
    }

    /**
     * 新增用户签到
     */
    @PreAuthorize("@ss.hasPermi('mall:signUp:add')")
    @Log(title = "用户签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbSignUp tbSignUp)
    {
        return toAjax(tbSignUpService.insertTbSignUp(tbSignUp));
    }

    /**
     * 修改用户签到
     */
    @PreAuthorize("@ss.hasPermi('mall:signUp:edit')")
    @Log(title = "用户签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbSignUp tbSignUp)
    {
        return toAjax(tbSignUpService.updateTbSignUp(tbSignUp));
    }

    /**
     * 删除用户签到
     */
    @PreAuthorize("@ss.hasPermi('mall:signUp:remove')")
    @Log(title = "用户签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{signUpIds}")
    public AjaxResult remove(@PathVariable Long[] signUpIds)
    {
        return toAjax(tbSignUpService.deleteTbSignUpBySignUpIds(signUpIds));
    }
}
