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.YjSense;
import com.ruoyi.system.service.columns.IYjSenseService;
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/sense")
public class YjSenseController extends BaseController
{
    @Autowired
    private IYjSenseService yjSenseService;

    /**
     * 查询瑜伽常识列表
     */
    @PreAuthorize("@ss.hasPermi('system:sense:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjSense yjSense)
    {
        startPage();
        //Long nowTenantId = SecurityUtils.getLoginUser().getNowTenantId();
        yjSense.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
        List<YjSense> list = yjSenseService.selectYjSenseList(yjSense);
        return getDataTable(list);
    }

    /**
     * 导出瑜伽常识列表
     */
    @PreAuthorize("@ss.hasPermi('system:sense:export')")
    @Log(title = "瑜伽常识", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjSense yjSense) throws IOException {
        List<YjSense> list = yjSenseService.selectYjSenseList(yjSense);
        ExcelUtil<YjSense> util = new ExcelUtil<YjSense>(YjSense.class);
        util.exportExcel(response, list, "瑜伽常识数据");
    }

    /**
     * 获取瑜伽常识详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sense:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(yjSenseService.selectYjSenseById(id));
    }

    /**
     * 新增瑜伽常识
     */
    @PreAuthorize("@ss.hasPermi('system:sense:add')")
    @Log(title = "瑜伽常识", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjSense yjSense)
    {
        yjSense.setId(IdWorker.get32UUID());
        return toAjax(

            yjSenseService.insertYjSense(yjSense));
    }

    /**
     * 修改瑜伽常识
     */
    @PreAuthorize("@ss.hasPermi('system:sense:edit')")
    @Log(title = "瑜伽常识", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjSense yjSense)
    {
        return toAjax(yjSenseService.updateYjSense(yjSense));
    }

    /**
     * 删除瑜伽常识
     */
    @PreAuthorize("@ss.hasPermi('system:sense:remove')")
    @Log(title = "瑜伽常识", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(yjSenseService.deleteYjSenseByIds(ids));
    }
}
