package com.vetti.web.controller.hotake;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.vetti.common.annotation.Log;
import com.vetti.common.core.controller.BaseController;
import com.vetti.common.core.domain.AjaxResult;
import com.vetti.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.vetti.hotake.domain.HotakeSysNotice;
import com.vetti.hotake.service.IHotakeSysNoticeService;
import com.vetti.common.utils.poi.ExcelUtil;
import com.vetti.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 通知Controller
 *
 * @author ID
 * @date 2025-11-01
 */
@Api(tags = "通知")
@RestController
@RequestMapping("/hotake/sysNotice")
public class HotakeSysNoticeController extends BaseController {
    @Autowired
    private IHotakeSysNoticeService hotakeSysNoticeService;

    /**
     * 查询通知列表
     */
    @ApiOperation("查询通知列表")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:list')")
    @GetMapping("/listview")
    public AjaxResult listView(HotakeSysNotice hotakeSysNotice) {
        return AjaxResult.success(hotakeSysNoticeService.selectHotakeSysNoticeViewList(hotakeSysNotice));
    }

    /**
     * 获取通知详细信息
     */
    @ApiOperation("查看通知详细信息")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:query')")
    @GetMapping(value = "/view/{id}")
    public AjaxResult viewInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(hotakeSysNoticeService.selectHotakeSysNoticeViewById(id));
    }

    @ApiOperation("全部已读")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:query')")
    @GetMapping(value = "/allread")
    public AjaxResult allRead() {
        return AjaxResult.success(hotakeSysNoticeService.allRead());
    }


    /**
     * 查询通知列表
     */
    @ApiOperation("查询通知列表")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotakeSysNotice hotakeSysNotice) {
        startPage();
        List<HotakeSysNotice> list = hotakeSysNoticeService.selectHotakeSysNoticeList(hotakeSysNotice);
        return getDataTable(list);
    }

    /**
     * 导出通知列表
     */
    @ApiOperation("导出通知列表")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:export')")
    @Log(title = "通知", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HotakeSysNotice hotakeSysNotice) {
        List<HotakeSysNotice> list = hotakeSysNoticeService.selectHotakeSysNoticeList(hotakeSysNotice);
        ExcelUtil<HotakeSysNotice> util = new ExcelUtil<HotakeSysNotice>(HotakeSysNotice.class);
        return util.exportExcel(list, "通知数据");
    }

    @ApiOperation("获取通知详细信息")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(hotakeSysNoticeService.selectHotakeSysNoticeById(id));
    }

    /**
     * 新增通知
     */
    @ApiOperation("新增通知")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:add')")
    @Log(title = "通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestPart(value = "files", required = false) List<MultipartFile> files, HotakeSysNotice hotakeSysNotice) {
        return toAjax(hotakeSysNoticeService.insertHotakeSysNotice(files, hotakeSysNotice));
    }

    /**
     * 修改通知
     */
    @ApiOperation("修改通知")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:edit')")
    @Log(title = "通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestPart(value = "files", required = false) List<MultipartFile> files, HotakeSysNotice hotakeSysNotice) {
        return toAjax(hotakeSysNoticeService.updateHotakeSysNotice(files, hotakeSysNotice));
    }

    /**
     * 删除通知
     */
    @ApiOperation("删除通知")
    @PreAuthorize("@ss.hasPermi('hotake:sysNotice:remove')")
    @Log(title = "通知", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hotakeSysNoticeService.deleteHotakeSysNoticeByIds(ids));
    }
}
