
package com.tmerclub.cloud.distribution.controller.app;

import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.distribution.model.DistributionMsg;
import com.tmerclub.cloud.distribution.service.DistributionMsgService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * 分销公告信息
 *
 * @author cl
 * @date 2021-08-09 14:14:05
 */
@RestController("appDistributionMsgController")
@RequestMapping("/distributionMsg")
@Tag(name = "app-分销公告信息")
public class DistributionMsgController {

    @Autowired
    private DistributionMsgService distributionMsgService;

    @GetMapping("/page")
    @Operation(summary = "获取分销公告信息列表", description = "分页获取分销公告信息列表")
    public ServerResponseEntity<PageVO<DistributionMsg>> page(@Valid PageDTO pageDTO, @RequestParam(value = "isTop", required = false) Integer isTop) {
        PageVO<DistributionMsg> distributionMsgPage = distributionMsgService.pageApp(pageDTO, isTop);
        return ServerResponseEntity.success(distributionMsgPage);
    }

    @GetMapping
    @Operation(summary = "获取分销公告信息", description = "根据msgId获取分销公告信息")
    public ServerResponseEntity<DistributionMsg> getByMsgId(@RequestParam Long msgId) {
        return ServerResponseEntity.success(distributionMsgService.getByMsgId(msgId));
    }
}
