/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.distribution.api.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.distribution.comment.dto.DistributionMsgDto;
import com.yami.shop.distribution.comment.model.DistributionMsg;
import com.yami.shop.distribution.comment.service.DistributionMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分销公告接口
 */
@RestController
@RequestMapping("/p/distribution/msg")
@Api(tags = "分销公告接口")
@AllArgsConstructor
public class DistributionMsgController {

    private final DistributionMsgService distributionMsgService;

    @GetMapping("/info")
    @ApiOperation(value = "获取公告详情", notes = "根据公告id获取")
    public ResponseEntity<DistributionMsgDto> info(Long msgId){
        return ResponseEntity.ok(distributionMsgService.getDistributionMsgDtoByMsgId(msgId));
    }

    /**
     * 公告
     */
    @GetMapping("/page")
    @ApiOperation(value = "公告列表", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isTop", value = "是否置顶", required = false, dataType = "Integer")
    })
    public ResponseEntity<IPage<DistributionMsgDto>> page(PageParam<DistributionMsg> page,@RequestParam(value = "isTop", required = false) Integer isTop) {
        return ResponseEntity.ok(distributionMsgService.getDistributionMsgDtoShopId(page,isTop));
    }

}
