package com.cool.store.controller.webc;

import com.cool.store.request.config.ConfigItemQueryRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.config.ConfigItemService;
import com.cool.store.vo.config.ConfigItemVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "标准店小程序-配置项管理")
@RestController
@RequestMapping("/mini/configItem")
@RequiredArgsConstructor
public class MiniConfigItemController {

    private final ConfigItemService configItemService;

    @ApiOperation("分页查询配置项")
    @PostMapping("/queryPage")
    public ResponseResult<PageInfo<ConfigItemVO>> queryPage(@RequestBody ConfigItemQueryRequest request) {
        return ResponseResult.success(configItemService.queryPage(request));
    }

    @ApiOperation("查询大类下的配置项")
    @GetMapping("/listByCategoryId")
    public ResponseResult<List<ConfigItemVO>> listByCategoryId(@RequestParam("categoryId") Long categoryId) {
        return ResponseResult.success(configItemService.listByCategoryId(categoryId));
    }

}
