package com.red.circle.other.adapter.app.user.user;

import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.dto.cmd.CreateSpecialIdCmd;
import com.red.circle.framework.dto.Response;
import com.red.circle.other.app.service.user.user.SpecialIdService;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.model.user.UserConsumptionLevel;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/special-id")
@RequiredArgsConstructor
public class SpecialIdController {

    private final SpecialIdService specialIdService;
    private final UserProfileGateway userProfileGateway;

    @PostMapping("/create")
    public Boolean createSpecialId( @RequestBody CreateSpecialIdCmd cmd) {
        cmd.setUserId(cmd.requiredReqUserId());
        UserConsumptionLevel consumptionLevel = userProfileGateway.getUserConsumptionLevel(
            SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin()),
            cmd.getUserId()
        );

        cmd.setWealthLevel(consumptionLevel.getWealthLevel());
        return specialIdService.createSpecialId(cmd);
    }
    
}
