package com.ruoyi.interfaces.controller;

import com.ruoyi.interfaces.core.page.Page;
import com.ruoyi.interfaces.core.page.PageParam;
import com.ruoyi.interfaces.core.page.PageUtils;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.interfaces.domain.SysCate;
import com.ruoyi.interfaces.service.SysCateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("用户信息管理")
@RestController
@RequestMapping("/pt/cate")
public class PtCateController extends BaseController {

    private final SysCateService sysCateService;

    public PtCateController(SysCateService sysCateService) {
        this.sysCateService = sysCateService;
    }

    @ApiOperation("数据列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public List<SysCate> list(String tabName) {
        SysCate criteria = new SysCate();
        criteria.setCateTable(tabName);
        return sysCateService.findAllO(criteria);
    }

    @ApiOperation("树数据列表")
    @PostMapping("/pageList")
    public Page pageList(PageParam<SysCate> sysCatePageParam) {
        return PageUtils.convert(sysCateService.pageList(sysCatePageParam));
    }

    @RequestMapping(value = "/listWithCount", method = RequestMethod.GET)
    public AjaxResult listWithCount() {
        return AjaxResult.success(sysCateService.listWithCount());
    }
}
