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

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

import com.yami.shop.common.config.Constant;
import com.yami.shop.distribution.comment.dto.DistributionRecruitSetDto;
import com.yami.shop.distribution.comment.model.DistributionRecruitSet;
import com.yami.shop.distribution.comment.service.DistributionRecruitSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import ma.glasnost.orika.MapperFacade;
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.RestController;

import java.util.Objects;

/**
 * 分销推广接口
 */
@RestController
@RequestMapping("/p/distribution/recruit")
@Api(tags = "分销推广接口")
@AllArgsConstructor
public class DistributionRecruitSetController {

    private final DistributionRecruitSetService distributionRecruitSetService;

    private final MapperFacade mapperFacade;


    @GetMapping("/info")
    @ApiOperation(value = "获取店铺推广数据" ,notes = "根据店铺id获取")
    public ResponseEntity<DistributionRecruitSetDto> info(){
        DistributionRecruitSet distributionRecruitSet = distributionRecruitSetService.getByShopId();
        if (Objects.equals(0,distributionRecruitSet.getState())) {
            distributionRecruitSet.setContent("");
        }
        return ResponseEntity.ok(mapperFacade.map(distributionRecruitSet, DistributionRecruitSetDto.class));
    }

}
