package com.czg.controller.user;

import com.czg.market.service.TbMemberConfigService;
import com.czg.market.vo.MemberDetailVO;
import com.czg.market.vo.MemberListVO;
import com.czg.market.vo.UMemberConfigVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
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;

import java.util.List;

/**
 * 会员
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/user")
public class UMemberController {
    @Resource
    private TbMemberConfigService memberConfigService;

    /**
     * 获取当前店铺会员开通配置信息
     *
     * @param shopId 店铺id
     */
    @GetMapping("/member/config")
    public CzgResult<UMemberConfigVO> getConfig(@RequestParam Long shopId) {
        return CzgResult.success(memberConfigService.detail(shopId, StpKit.USER.getLoginIdAsLong()));
    }

    /**
     * 获取所有已开通的会员
     *
     * @return 列表
     */
    @GetMapping("/member/list")
    public CzgResult<List<MemberListVO>> getMemberList() {
        return CzgResult.success(memberConfigService.getMemberList(StpKit.USER.getLoginIdAsLong()));
    }

    /**
     * 获取会员信息详情
     *
     * @param shopId 店铺id
     */
    @GetMapping("/member/detail")
    public CzgResult<MemberDetailVO> getDetail(@RequestParam Long shopId) {
        return CzgResult.success(memberConfigService.getUserDetail(StpKit.USER.getLoginIdAsLong(), shopId));
    }
}
