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.SysReGardenBranch;
import com.vctgo.system.service.ISysReGardenBranchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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-10-28
 */
@Api(tags = "集团租户与幼儿园租户关联")
@RestController
@RequestMapping("/association/garden/branch")
public class SysReGardenBranchController extends BaseController {
    @Autowired
    private ISysReGardenBranchService sysReGardenBranchService;

    /**
     * 查询集团幼儿园租户关联分页列表
     */
    @ApiOperation(value = "查询集团幼儿园租户关联分页列表")
    @RequiresPermissions("system:re_garden_branch:page")
    @GetMapping("/page")
    public AjaxResult page(SysReGardenBranch sysReGardenBranch) {
        IPage<SysReGardenBranch> pageList = sysReGardenBranchService.selectSysReGardenBranchPage(sysReGardenBranch);
        return AjaxResult.success(pageList);
    }

    /**
     * 查询集团幼儿园租户关联列表
     */
    @ApiOperation(value = "查询集团幼儿园租户关联列表")
//    @RequiresPermissions("system:re_garden_branch:list")
    @GetMapping("/list")
    public AjaxResult associationList(SysReGardenBranch sysReGardenBranch) {
        List<SysReGardenBranch> tenantList = sysReGardenBranchService.selectSysReGardenBranchList(sysReGardenBranch);
        return AjaxResult.success(tenantList);
    }

    /**
     * 导出集团幼儿园租户关联列表
     */
    @ApiOperation(value = "导出集团幼儿园租户关联列表")
    @RequiresPermissions("system:re_garden_branch:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReGardenBranch sysReGardenBranch) {
        List<SysReGardenBranch> list = sysReGardenBranchService.selectSysReGardenBranchList(sysReGardenBranch);
        ExcelUtil<SysReGardenBranch> util = new ExcelUtil<SysReGardenBranch>(SysReGardenBranch.class);
        util.exportExcel(response, list, "集团幼儿园租户关联数据");
    }

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

    /**
     * 新增集团幼儿园租户关联
     */
    @ApiOperation(value = "新增集团幼儿园租户关联")
    @RequiresPermissions("system:re_garden_branch:add")
    @PostMapping
    public AjaxResult add(@RequestBody SysReGardenBranch sysReGardenBranch) {
        return toAjax(sysReGardenBranchService.insertSysReGardenBranch(sysReGardenBranch));
    }

    /**
     * 修改集团幼儿园租户关联
     */
    @ApiOperation(value = "修改集团幼儿园租户关联")
    @RequiresPermissions("system:re_garden_branch:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody SysReGardenBranch sysReGardenBranch) {
        return toAjax(sysReGardenBranchService.updateSysReGardenBranch(sysReGardenBranch));
    }

    /**
     * 逻辑删除集团幼儿园租户关联
     */
    @ApiOperation(value = "逻辑删除集团幼儿园租户关联")
    @RequiresPermissions("system:re_garden_branch:abandon")
    @PutMapping("/abandon/{ids}")
    public AjaxResult abandon(@PathVariable Long[] ids) {
        return toAjax(sysReGardenBranchService.logicalDeleteSysReGardenBranchByIds(ids));
    }

    /**
     * 删除集团幼儿园租户关联
     */
    @ApiOperation(value = "删除集团幼儿园租户关联")
    @RequiresPermissions("system:re_garden_branch:remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysReGardenBranchService.deleteSysReGardenBranchByIds(ids));
    }
}
