package com.ruoyi.model.controller;

import java.io.IOException;
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.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.model.domain.AppCheckImage;
import com.ruoyi.model.service.IAppCheckImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 打卡图片Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/model/AppCheckImage")
public class AppCheckImageController extends BaseController
{
    @Autowired
    private IAppCheckImageService appCheckImageService;

    /**
     * 查询打卡图片列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppCheckImage:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppCheckImage appCheckImage)
    {
        startPage();
        List<AppCheckImage> list = appCheckImageService.selectAppCheckImageList(appCheckImage);
        return getDataTable(list);
    }

    /**
     * 导出打卡图片列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppCheckImage:export')")
    @Log(title = "打卡图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppCheckImage appCheckImage) throws IOException {
        List<AppCheckImage> list = appCheckImageService.selectAppCheckImageList(appCheckImage);
        ExcelUtil<AppCheckImage> util = new ExcelUtil<AppCheckImage>(AppCheckImage.class);
        util.exportExcel(response, list, "打卡图片数据");
    }

    /**
     * 获取打卡图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppCheckImage:query')")
    @GetMapping(value = "/{checkImageId}")
    public AjaxResult getInfo(@PathVariable("checkImageId") Long checkImageId)
    {
        return success(appCheckImageService.selectAppCheckImageByCheckImageId(checkImageId));
    }

    /**
     * 新增打卡图片
     */
    @PreAuthorize("@ss.hasPermi('model:AppCheckImage:add')")
    @Log(title = "打卡图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppCheckImage appCheckImage)
    {
        return toAjax(appCheckImageService.insertAppCheckImage(appCheckImage));
    }

    /**
     * 修改打卡图片
     */
    @PreAuthorize("@ss.hasPermi('model:AppCheckImage:edit')")
    @Log(title = "打卡图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppCheckImage appCheckImage)
    {
        return toAjax(appCheckImageService.updateAppCheckImage(appCheckImage));
    }

    /**
     * 删除打卡图片
     */
    @PreAuthorize("@ss.hasPermi('model:AppCheckImage:remove')")
    @Log(title = "打卡图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkImageIds}")
    public AjaxResult remove(@PathVariable Long[] checkImageIds)
    {
        return toAjax(appCheckImageService.deleteAppCheckImageByCheckImageIds(checkImageIds));
    }
}
