package com.vctgo.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vctgo.common.core.utils.poi.ExcelUtil;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vctgo.common.log.annotation.Log;
import com.vctgo.common.log.enums.BusinessType;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.system.domain.SysReTenantKindergarten;
import com.vctgo.system.service.ISysReTenantKindergartenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 租户幼儿园关联Controller
 *
 * @author wanglonghua
 * @date 2023-08-09
 */
@RestController
@RequestMapping("/tenant_kindergarten")
public class SysReTenantKindergartenController extends BaseController
{
    @Autowired
    private ISysReTenantKindergartenService sysReTenantKindergartenService;

    /**
     * 查询租户幼儿园关联分页列表
     */
    @RequiresPermissions("system:tenant_kindergarten:page")
    @GetMapping("/page")
    public AjaxResult page(SysReTenantKindergarten sysReTenantKindergarten)
    {
        IPage<SysReTenantKindergarten> pageList = sysReTenantKindergartenService.selectSysReTenantKindergartenPage(sysReTenantKindergarten);
        return AjaxResult.success(pageList);
    }

    /**
     * 导出租户幼儿园关联列表
     */
    @RequiresPermissions("system:tenant_kindergarten:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReTenantKindergarten sysReTenantKindergarten)
    {
        List<SysReTenantKindergarten> list = sysReTenantKindergartenService.selectSysReTenantKindergartenList(sysReTenantKindergarten);
        ExcelUtil<SysReTenantKindergarten> util = new ExcelUtil<SysReTenantKindergarten>(SysReTenantKindergarten.class);
        util.exportExcel(response, list, "租户幼儿园关联数据");
    }

    /**
     * 获取租户幼儿园关联详细信息
     */
    @RequiresPermissions("system:tenant_kindergarten:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success((sysReTenantKindergartenService.selectSysReTenantKindergartenById(id)));
    }

    /**
     * 新增租户幼儿园关联
     */
    @RequiresPermissions("system:tenant_kindergarten:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysReTenantKindergarten sysReTenantKindergarten)
    {
        return toAjax(sysReTenantKindergartenService.insertSysReTenantKindergarten(sysReTenantKindergarten));
    }

    /**
     * 修改租户幼儿园关联
     */
    @RequiresPermissions("system:tenant_kindergarten:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysReTenantKindergarten sysReTenantKindergarten)
    {
        return toAjax(sysReTenantKindergartenService.updateSysReTenantKindergarten(sysReTenantKindergarten));
    }

    /**
     * 删除租户幼儿园关联
     */
    @RequiresPermissions("system:tenant_kindergarten:abandon")
	@PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids)
    {
        return toAjax(sysReTenantKindergartenService.logicalDeleteSysReTenantKindergartenByIds(ids));
    }

    /**
     * 删除租户幼儿园关联
     */
    @RequiresPermissions("system:tenant_kindergarten:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysReTenantKindergartenService.deleteSysReTenantKindergartenByIds(ids));
    }
}
