package com.ruoyi.web.controller.columns;

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

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.columns.YjAppreciate;
import com.ruoyi.system.service.columns.IYjAppreciateService;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 瑜伽欣赏Controller
 * 
 * @author ruoyi
 * @date 2025-10-29
 */
@RestController
@RequestMapping("/system/appreciate")
public class YjAppreciateController extends BaseController
{
    @Autowired
    private IYjAppreciateService yjAppreciateService;

    /**
     * 查询瑜伽欣赏列表
     */
    @PreAuthorize("@ss.hasPermi('system:appreciate:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjAppreciate yjAppreciate)
    {
        startPage();
        yjAppreciate.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
        List<YjAppreciate> list = yjAppreciateService.selectYjAppreciateList(yjAppreciate);
        return getDataTable(list);
    }

    /**
     * 导出瑜伽欣赏列表
     */
    @PreAuthorize("@ss.hasPermi('system:appreciate:export')")
    @Log(title = "瑜伽欣赏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjAppreciate yjAppreciate) throws IOException {
        List<YjAppreciate> list = yjAppreciateService.selectYjAppreciateList(yjAppreciate);
        ExcelUtil<YjAppreciate> util = new ExcelUtil<YjAppreciate>(YjAppreciate.class);
        util.exportExcel(response, list, "瑜伽欣赏数据");
    }

    /**
     * 获取瑜伽欣赏详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:appreciate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {

        return AjaxResult.success(yjAppreciateService.selectYjAppreciateById(id));
    }

    /**
     * 新增瑜伽欣赏
     */
    @PreAuthorize("@ss.hasPermi('system:appreciate:add')")
    @Log(title = "瑜伽欣赏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjAppreciate yjAppreciate)
    {
        yjAppreciate.setId(IdWorker.get32UUID());
        return toAjax(yjAppreciateService.insertYjAppreciate(yjAppreciate));
    }

    /**
     * 修改瑜伽欣赏
     */
    @PreAuthorize("@ss.hasPermi('system:appreciate:edit')")
    @Log(title = "瑜伽欣赏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjAppreciate yjAppreciate)
    {
        return toAjax(yjAppreciateService.updateYjAppreciate(yjAppreciate));
    }

    /**
     * 删除瑜伽欣赏
     */
    @PreAuthorize("@ss.hasPermi('system:appreciate:remove')")
    @Log(title = "瑜伽欣赏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(yjAppreciateService.deleteYjAppreciateByIds(ids));
    }
}
