package com.dgtly.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dgtly.common.annotation.Log;
import com.dgtly.common.enums.BusinessType;
import com.dgtly.system.domain.AlertUpvoteLog;
import com.dgtly.system.service.IAlertUpvoteLogService;
import com.dgtly.common.core.controller.BaseController;
import com.dgtly.common.core.domain.AjaxResult;
import com.dgtly.common.utils.poi.ExcelUtil;
import com.dgtly.common.core.page.TableDataInfo;

/**
 * 弹框点赞日志Controller
 * 
 * @author dgtlc
 * @date 2024-12-24
 */
@Controller
@RequestMapping("/system/upvoteLog")
public class AlertUpvoteLogController extends BaseController
{
    private String prefix = "system/upvoteLog";

    @Autowired
    private IAlertUpvoteLogService alertUpvoteLogService;

    @RequiresPermissions("system:upvoteLog:view")
    @GetMapping()
    public String log()
    {
        return prefix + "/upvoteLog";
    }

    /**
     * 查询弹框点赞日志列表
     */
    @RequiresPermissions("system:upvoteLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AlertUpvoteLog alertUpvoteLog)
    {
        startPage();
        List<AlertUpvoteLog> list = alertUpvoteLogService.selectAlertUpvoteLogList(alertUpvoteLog);
        return getDataTable(list);
    }

    /**
     * 导出弹框点赞日志列表
     */
    @RequiresPermissions("system:upvoteLog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AlertUpvoteLog alertUpvoteLog)
    {
        List<AlertUpvoteLog> list = alertUpvoteLogService.selectAlertUpvoteLogList(alertUpvoteLog);
        ExcelUtil<AlertUpvoteLog> util = new ExcelUtil<AlertUpvoteLog>(AlertUpvoteLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 新增弹框点赞日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存弹框点赞日志
     */
    @RequiresPermissions("system:upvoteLog:add")
    @Log(title = "弹框点赞日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AlertUpvoteLog alertUpvoteLog)
    {
        return toAjax(alertUpvoteLogService.insertAlertUpvoteLog(alertUpvoteLog));
    }

    /**
     * 修改弹框点赞日志
     */
    @GetMapping("/edit/{alertUpvoteId}")
    public String edit(@PathVariable("alertUpvoteId") Long alertUpvoteId, ModelMap mmap)
    {
        AlertUpvoteLog alertUpvoteLog = alertUpvoteLogService.selectAlertUpvoteLogById(alertUpvoteId);
        mmap.put("alertUpvoteLog", alertUpvoteLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存弹框点赞日志
     */
    @RequiresPermissions("system:upvoteLog:edit")
    @Log(title = "弹框点赞日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AlertUpvoteLog alertUpvoteLog)
    {
        return toAjax(alertUpvoteLogService.updateAlertUpvoteLog(alertUpvoteLog));
    }

    /**
     * 删除弹框点赞日志
     */
    @RequiresPermissions("system:upvoteLog:remove")
    @Log(title = "弹框点赞日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(alertUpvoteLogService.deleteAlertUpvoteLogByIds(ids));
    }
}
