package com.ruoyi.api.controller.commonproblem;

import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.base.commonproblem.domain.bo.CommonProblemBo;
import com.ruoyi.base.commonproblem.domain.vo.CommonProblemVo;
import com.ruoyi.base.commonproblem.service.ICommonProblemService;
import com.ruoyi.common.enums.FilePathSplicingType;
import com.ruoyi.common.filepathsplicing.FilePathSplicing;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * API常见问题Controller
 *
 * @author xiechao
 * @date 2023-12-21
 */
@Api(value = "API常见问题控制器", tags = {"API常见问题控制器"})
@RequiredArgsConstructor
@RestController
@RequestMapping("api/common/problem")
public class ApiCommonProblemController {

    private final ICommonProblemService iCommonProblemService;

    /**
     * 分页查询常见问题列表
     */
    @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
    @ApiOperation("查询常见问题列表")
    @GetMapping("/page")
    public TableDataInfo<CommonProblemVo> page(@Validated(QueryGroup.class) CommonProblemBo bo, PageQuery pageQuery) {
        return iCommonProblemService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取常见问题详细信息
     */
    @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
    @ApiOperation("获取常见问题详细信息")
    @GetMapping("/info/{id}")
    public R<CommonProblemVo> getInfo(@ApiParam("主键") @NotNull(message = "主键不能为空")
                                      @PathVariable("id") Integer id) {
        return R.ok(iCommonProblemService.getById(id));
    }

}
