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.core.domain.entity.SysDept;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.columns.YjInherit;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.columns.IYjInheritService;
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/inherit")
public class YjInheritController extends BaseController
{
    @Autowired
    private IYjInheritService yjInheritService;


    @Autowired
    private ISysDeptService iSysDeptService;



    @PostMapping("/getBase")
    public AjaxResult getBae()
    {
        SysDept sysDept =new SysDept();
        sysDept.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
        List<SysDept> sysDepts = iSysDeptService.selectDeptList(sysDept);
        return AjaxResult.success(sysDepts);
    }

    /**
     * 查询瑜伽传承列表
     */
    @PreAuthorize("@ss.hasPermi('system:inherit:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjInherit yjInherit)
    {
        startPage();
        yjInherit.setTenantId(SecurityUtils.getLoginUser().getNowTenantId());
        List<YjInherit> list = yjInheritService.selectYjInheritList(yjInherit);

        return getDataTable(list);
    }

    /**
     * 导出瑜伽传承列表
     */
    @PreAuthorize("@ss.hasPermi('system:inherit:export')")
    @Log(title = "瑜伽传承", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjInherit yjInherit) throws IOException {
        List<YjInherit> list = yjInheritService.selectYjInheritList(yjInherit);
        ExcelUtil<YjInherit> util = new ExcelUtil<YjInherit>(YjInherit.class);
        util.exportExcel(response, list, "瑜伽传承数据");
    }

    /**
     * 获取瑜伽传承详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inherit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(yjInheritService.selectYjInheritById(id));
    }

    /**
     * 新增瑜伽传承
     */
    @PreAuthorize("@ss.hasPermi('system:inherit:add')")
    @Log(title = "瑜伽传承", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjInherit yjInherit)
    {

        yjInherit.setId(IdWorker.get32UUID());
        return toAjax(yjInheritService.insertYjInherit(yjInherit));
    }

    /**
     * 修改瑜伽传承
     */
    @PreAuthorize("@ss.hasPermi('system:inherit:edit')")
    @Log(title = "瑜伽传承", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjInherit yjInherit)
    {
        return toAjax(yjInheritService.updateYjInherit(yjInherit));
    }

    /**
     * 删除瑜伽传承
     */
    @PreAuthorize("@ss.hasPermi('system:inherit:remove')")
    @Log(title = "瑜伽传承", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(yjInheritService.deleteYjInheritByIds(ids));
    }
}
