package com.ylx.merchant.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylx.common.core.domain.R;
import com.ylx.massage.service.IMaTechnicianService;
import com.ylx.moment.service.ITechnicianMomentService;
import com.ylx.massage.service.MerchantApplyFileService;
import com.ylx.merchant.domain.dto.*;
import com.ylx.merchant.domain.vo.*;
import com.ylx.order.service.TCommentUserService;
import com.ylx.project.domain.bookMerchant.vo.ProjectInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/customer/merchant")
@Api(tags = {"用户端商户"})
@Slf4j
@PreAuthorize("@customerAuth.isCustomer()")
public class CustomerMerchantController {

    @Resource
    private IMaTechnicianService maTechnicianService;
    @Resource
    private ITechnicianMomentService momentService;
    @Resource
    private TCommentUserService commentUserService;
    @Resource
    private MerchantApplyFileService merchantApplyFileService;

    @PostMapping("/page")
    @ApiOperation("同城搭子分页查询接口")
    public R<Page<MerchantListVO>> getMerchantPage(@Validated @RequestBody MerchantListDTO dto) {
        Page<MerchantListVO> pageData = this.maTechnicianService.getMerchantPage(dto);
        return R.ok(pageData);
    }

    @PostMapping("/project/page")
    @ApiOperation("同城搭子商户技能分页查询接口")
    public R<Page<ProjectInfoVO>> getMerchantProject(@Validated @RequestBody MerchantProjectDTO dto) {
        Page<ProjectInfoVO> pageData = this.maTechnicianService.getByMerchantProject(dto);
        return R.ok(pageData);
    }

    @PostMapping("/moment/page")
    @ApiOperation("商户动态分页查询接口")
    public R<Page<MomentVO>> getMerchantMoment(@Validated @RequestBody MerchantMomentDTO dto) {
        Page<MomentVO> pageData = this.momentService.getByMerchantMoment(dto);
        return R.ok(pageData);
    }

    @PostMapping("/comment/page")
    @ApiOperation("商户订单顾客评价分页查询接口")
    public R<Page<MerchantCommentVO>> getMerchantComment(@Validated @RequestBody MerchantCommentDTO dto) {
        Page<MerchantCommentVO> pageData = this.commentUserService.getMerchantComment(dto);
        return R.ok(pageData);
    }

    @PostMapping("/picture/list")
    @ApiOperation("商户主页相册查询接口")
    public R<List<String>> getMerchantPicture(@Validated @RequestBody MerchantPictureDTO dto) {
        List<String> list = this.merchantApplyFileService.getMerchantPicture(dto);
        return R.ok(list);
    }

    @PostMapping("/detail")
    @ApiOperation("商户主页商户详情接口")
    public R<MerchantDetailVO> getDetailById(@Validated @RequestBody MerchantDetailDTO dto) {
        MerchantDetailVO vo = this.maTechnicianService.getDetail(dto);
        return R.ok(vo);
    }


}
