package com.yonge.cooleshow.tenant.controller.open;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.microsvc.toolkit.common.response.paging.PageInfo;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.microsvc.toolkit.common.response.template.R;
import com.yonge.cooleshow.biz.dal.service.TenantGroupService;
import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Validated
@RestController
@RequestMapping("${app-config.url.tenant:}/open/tenantGroup")
@Api(tags = "机构小组表")
public class OpenTenantGroupController {

    @Autowired
    private TenantGroupService tenantGroupService;

    @ApiOperation(value = "查询分页", notes = "机构小组表- 传入 TenantGroupWrapper.TenantGroupQuery")
    @PostMapping("/page")
    public R<PageInfo<TenantGroupWrapper.TenantGroup>> page(@RequestBody TenantGroupWrapper.TenantGroupQuery query) {
        IPage<TenantGroupWrapper.TenantGroup> pages = tenantGroupService.selectPage(QueryInfo.getPage(query), query);
        return R.from(QueryInfo.pageInfo(pages));
    }
}