package com.huashe.park.application.web.controller.park;

import com.huashe.park.core.service.IParkAttendUsrDetailService;
import com.huashe.park.domain.entity.ParkAttendUsrDetail;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 用户打卡信息Controller
 *
 * @author ruoyi
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/park/attendUsrDetail")
public class ParkAttendUsrDetailController extends BaseController {
    @Autowired
    private IParkAttendUsrDetailService parkAttendUsrDetailService;

    /**
     * 查询用户打卡信息列表
     */
    @PreAuthorize("@ss.hasPermi('park:attendUsrDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkAttendUsrDetail parkAttendUsrDetail) {
        startPage();
        List<ParkAttendUsrDetail> list = parkAttendUsrDetailService.selectParkAttendUsrDetailList(parkAttendUsrDetail);
        return getDataTable(list);
    }

    /**
     * 导出用户打卡信息列表
     */
    @PreAuthorize("@ss.hasPermi('park:attendUsrDetail:export')")
    @Log(title = "用户打卡信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkAttendUsrDetail parkAttendUsrDetail) {
        List<ParkAttendUsrDetail> list = parkAttendUsrDetailService.selectParkAttendUsrDetailList(parkAttendUsrDetail);
        ExcelUtil<ParkAttendUsrDetail> util = new ExcelUtil<ParkAttendUsrDetail>(ParkAttendUsrDetail.class);
        util.exportExcel(response, list, "用户打卡信息数据");
    }

    /**
     * 获取用户打卡信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('park:attendUsrDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(parkAttendUsrDetailService.selectParkAttendUsrDetailById(id));
    }

    /**
     * 新增用户打卡信息
     */
    @PreAuthorize("@ss.hasPermi('park:attendUsrDetail:add')")
    @Log(title = "用户打卡信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkAttendUsrDetail parkAttendUsrDetail) {
        return toAjax(parkAttendUsrDetailService.insertParkAttendUsrDetail(parkAttendUsrDetail));
    }

    /**
     * 修改用户打卡信息
     */
    @PreAuthorize("@ss.hasPermi('park:attendUsrDetail:edit')")
    @Log(title = "用户打卡信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkAttendUsrDetail parkAttendUsrDetail) {
        return toAjax(parkAttendUsrDetailService.updateParkAttendUsrDetail(parkAttendUsrDetail));
    }

    /**
     * 删除用户打卡信息
     */
    @PreAuthorize("@ss.hasPermi('park:attendUsrDetail:remove')")
    @Log(title = "用户打卡信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(parkAttendUsrDetailService.deleteParkAttendUsrDetailByIds(ids));
    }
}
