package com.hzs.member.base.controller.api;

import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.member.achieve.service.ICuMemberAchieveService;
import com.hzs.member.achieve.vo.CuMemberNewAddAchieveVO;
import lombok.extern.slf4j.Slf4j;
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.RestController;

import java.util.*;

/**
 * 会员首页
 *
 * @Description:
 * @Author: ljc
 * @Time: 2023/5/4 21:06
 * @Classname: ApiHomePageController
 * @Package_name: com.hzs.member.base.controller.api
 */
@Slf4j
@RequestMapping("/api/member")
@RestController
public class ApiHomePageController {

    @Autowired
    private ICuMemberAchieveService cuMemberAchieveService;

    /**
     * 新增业绩
     *
     * @param dayType
     * @return AjaxResult
     */
    @GetMapping("/new-add-achieve")
    public AjaxResult newAddAchieve(Integer dayType) {
        CuMemberNewAddAchieveVO newAddAchieveVO = CuMemberNewAddAchieveVO.builder().dayType(dayType)
                .pkMember(SecurityUtils.getUserId()).pkCountry(SecurityUtils.getPkCountry()).build();
        List<CuMemberNewAddAchieveVO> cuMemberNewAddAchieveVOList = cuMemberAchieveService.selectNewAddAchieve(newAddAchieveVO);
        return AjaxResult.success(cuMemberNewAddAchieveVOList);
    }

    /**
     * 荣誉奖衔
     *
     * @return AjaxResult
     */
    @GetMapping("/index-awards")
    public AjaxResult selectAwards() {
        return AjaxResult.success(cuMemberAchieveService.selectAwardsByPkMember(SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

    /**
     * 会员荣誉奖衔
     *
     * @return AjaxResult
     */
    @GetMapping("/index-member-awards")
    public AjaxResult selectMemberAwards(Integer pkAwards) {
        return AjaxResult.success(cuMemberAchieveService.selectMemberAwards(SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

}
