package com.ichangzuo.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ichangzuo.common.result.PageResult;
import com.ichangzuo.common.result.Result;
import com.ichangzuo.system.model.bo.QnAUpdateBO;
import com.ichangzuo.system.model.bo.StyleRecomStatBO;
import com.ichangzuo.system.model.bo.StyleUpdateBO;
import com.ichangzuo.system.model.entity.Message;
import com.ichangzuo.system.model.entity.Style;
import com.ichangzuo.system.model.query.MessagePageQuery;
import com.ichangzuo.system.model.query.StylePageQuery;
import com.ichangzuo.system.model.vo.StyleStatisticVO;
import com.ichangzuo.system.service.impl.StyleServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/style")
@RequiredArgsConstructor
public class StyleController {
    private final StyleServiceImpl styleService;

    @Operation(summary = "分页列表")
    @GetMapping("/page")
    public PageResult<Style> listPagedStyle( StylePageQuery queryParams ) {
        IPage<Style> result = styleService.pageStyle(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "统计")
    @GetMapping("/statistic")
    public Result<?> statistic() {
        StyleStatisticVO vo = styleService.statistic();
//        System.out.println(vo);
        return Result.success(vo);
    }

    @PutMapping(value = "/update")
    public Result<?> updateQnA( @RequestBody StyleUpdateBO bo ) {
        boolean result = styleService.updateStyle(bo);
        return Result.judge(result);
    }
}
