package com.sckw.operation.controller;

import com.sckw.core.exception.SystemException;
import com.sckw.core.web.constant.HttpStatus;
import com.sckw.core.web.response.HttpResult;
import com.sckw.operation.model.vo.req.*;
import com.sckw.operation.service.BannerService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * @author sky
 * @desc 菜单管理
 * @date 2023/8/28
 */
@RestController
@RequestMapping("/kwoBanner")
public class KwoBannerController {

    @Autowired
    private BannerService bannerService;

    /**
     * @param reqVo 分页入参
     * @return HttpResult
     * @desc: 分页查询
     * @author: sky
     * @date: 2023/8/28
     */
    @PostMapping("/queryByPage")
    public HttpResult queryByPage(@RequestBody BannerQueryReqVo reqVo) {
        return HttpResult.ok(bannerService.queryByPage(reqVo));
    }

    /**
     * @param reqVo 新增入参
     * @return HttpResult
     * @desc: 新增入参
     * @author: sky
     * @date: 2023/8/28
     */
    @PostMapping("/add")
    public HttpResult add(@Valid @RequestBody BannerAddReqVo reqVo) {
        bannerService.addService(reqVo);
        return HttpResult.ok(HttpStatus.MSG_003);
    }

    /**
     * @param reqVo 更新
     * @return HttpResult
     * @desc: 更新入参
     * @author: sky
     * @date: 2023/8/28
     */
    @PostMapping("/update")
    public HttpResult update(@Valid @RequestBody BannerAddReqVo reqVo) {
        bannerService.udpateService(reqVo);
        return HttpResult.ok(HttpStatus.MSG_005);
    }

    /**
     * @param reqVo ids
     * @return HttpResult
     * @desc: 删除
     * @author: sky
     * @date: 2023/8/28
     */
    @PostMapping("/delete")
    public HttpResult delete(@Valid @RequestBody IdsReqVo reqVo) {
        bannerService.deleteServer(reqVo.getIds());
        return HttpResult.ok(HttpStatus.MSG_008);
    }

    /**
     * @param reqVo 主键
     * @return HttpResult
     * @desc: 查详情
     * @author: sky
     * @date: 2023/8/28
     */
    @PostMapping("detail")
    public HttpResult detail(@RequestBody IdsReqVo reqVo) {
        return HttpResult.ok(bannerService.detailServer(reqVo.getId()));
    }
    /**
     * @return HttpResult
     * @desc: 获取分类
     * @author: sky
     * @date: 2023/9/12
     */
    @PostMapping("/getCategory")
    public HttpResult getCategory() {
        return HttpResult.ok(bannerService.getCategory());
    }

    /**
     * @param reqVo 上架下架
     * @return HttpResult
     * @desc: 上架下架
     * @author: sky
     * @date: 2023/8/28
     */
    @PostMapping("/updateStatus")
    public HttpResult updateStatus(@Valid @RequestBody BannerUpdateStatusReqVo reqVo) {
        bannerService.updateStatusServer(reqVo);
        return HttpResult.ok(HttpStatus.MSG_005);
    }





}
