package shop.alien.store.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.ExpertImg;
import shop.alien.entity.store.vo.LifeUserExpertVo;
import shop.alien.store.service.StoreUserExpertService;

import java.util.List;
import java.util.Map;

@Api(tags = {"商户-严选达人"})
@Slf4j
@RestController
@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/storeUserExpert")
public class StoreUserExpertController {

    private final StoreUserExpertService storeUserExpertService;

    @ApiOperation("是否是达人")
    @ApiOperationSupport(order = 1)
    @GetMapping("/ifExpert")
    public R<List<LifeUserExpertVo>> ifExpert(@RequestParam("id") String id) {
        log.info("StoreUserExpertController.ifExpert?id={}", id);
        List<LifeUserExpertVo> lifeUserExpertVos = storeUserExpertService.ifExpert(id);
        if (null == lifeUserExpertVos) {
            return R.fail("查询失败");
        }
        return R.data(lifeUserExpertVos);
    }

    @ApiOperation("排行榜查询")
    @ApiOperationSupport(order = 2)
    @GetMapping("/getRankList")
    public R<List<LifeUserExpertVo>> getRankList() {
        log.info("StoreUserExpertController.getRankList");
        return R.data(storeUserExpertService.getRankList());
    }

    @ApiOperation("达人详情")
    @ApiOperationSupport(order = 3)
    @GetMapping("/getExpertDetails")
    public R<List<Map<String, LifeUserExpertVo>>> getExpertDetails(Integer expertId) {
        log.info("StoreUserExpertController.getExpertDetails?expertId={}", expertId);
        return R.data(storeUserExpertService.getExpertDetails(expertId));
    }

@ApiOperation("申请达人，上传图片以及补充说明")
@ApiOperationSupport(order = 4)
@PostMapping("/applyExpert")
public R<Map<String, String>> applyExpert(@RequestBody ExpertImg expertImgs) {
    log.info("StoreUserExpertController.applyExpert?expertImgs={}", expertImgs);
    if (null == expertImgs) {
        return R.fail("参数错误");
    }
    return R.data(storeUserExpertService.getapplyExpert(expertImgs));
}



}
