package com.da.dangan.controller;

import com.da.common.annotation.Log;
import com.da.common.core.controller.BaseController;
import com.da.common.core.domain.AjaxResult;
import com.da.common.core.page.TableDataInfo;
import com.da.common.enums.BusinessType;
import com.da.common.utils.poi.ExcelUtil;
import com.da.dangan.domain.DaPicturesRecard;
import com.da.dangan.service.IDaPicturesRecardService;
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 hs
 * @date 2024-05-13
 */
@RestController
@RequestMapping("/dangan/pictureRecard")
public class DaPicturesRecardController extends BaseController
{
    @Autowired
    private IDaPicturesRecardService daPicturesRecardService;

    /**
     * 查询档案图片信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('dangan:pictureRecard:list')")
    @GetMapping("/list")
    public TableDataInfo list(DaPicturesRecard daPicturesRecard)
    {
        startPage();
        List<DaPicturesRecard> list = daPicturesRecardService.selectDaPicturesRecardList(daPicturesRecard);
        return getDataTable(list);
    }

    /**
     * 导出档案图片信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('dangan:pictureRecard:export')")
    @Log(title = "档案图片信息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DaPicturesRecard daPicturesRecard)
    {
        List<DaPicturesRecard> list = daPicturesRecardService.selectDaPicturesRecardList(daPicturesRecard);
        ExcelUtil<DaPicturesRecard> util = new ExcelUtil<DaPicturesRecard>(DaPicturesRecard.class);
        util.exportExcel(response, list, "档案图片信息记录数据");
    }

    /**
     * 获取档案图片信息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangan:pictureRecard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(daPicturesRecardService.selectDaPicturesRecardById(id));
    }

    /**
     * 新增档案图片信息记录
     */
    @PreAuthorize("@ss.hasPermi('dangan:pictureRecard:add')")
    @Log(title = "档案图片信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DaPicturesRecard daPicturesRecard)
    {
        return toAjax(daPicturesRecardService.insertDaPicturesRecard(daPicturesRecard));
    }

    /**
     * 修改档案图片信息记录
     */
    @PreAuthorize("@ss.hasPermi('dangan:pictureRecard:edit')")
    @Log(title = "档案图片信息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DaPicturesRecard daPicturesRecard)
    {
        return toAjax(daPicturesRecardService.updateDaPicturesRecard(daPicturesRecard));
    }

    /**
     * 删除档案图片信息记录
     */
    @PreAuthorize("@ss.hasPermi('dangan:pictureRecard:remove')")
    @Log(title = "档案图片信息记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(daPicturesRecardService.deleteDaPicturesRecardByIds(ids));
    }
}
