package com.oqpo.api.web.dto.response.rtnmng.rtnReq;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
import com.oqpo.api.entity.oper.UserMngEntity;
import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;


@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class RtnReqInitInfoResponse {

    @ApiModelProperty(value = "로그인 소속 브랜드아이디") private String brandId;
    @ApiModelProperty(value = "로그인 소속 브랜드명") private String brandNm;
    @ApiModelProperty(value = "로그인 소속 매장아이디") private String storeId;
    @ApiModelProperty(value = "로그인 소속 매장명") private String storeNm;
    @ApiModelProperty(value = "소속") private String reqDept;
    @ApiModelProperty(value = "사용자명") private String userNm;
    @ApiModelProperty(value = "권한타입코드") private String authTpCd;
    @ApiModelProperty(value = "창고구분") private String whsDvsn;
    @ApiModelProperty(value = "창고아이디") private String rtnWhsId;
    @ApiModelProperty(value = "창고명") private String rtnWhsNm;
    @ApiModelProperty(value = "location") private String rtnLocation;
    @ApiModelProperty(value = "location명") private String rtnLocationNm;


    public static RtnReqInitInfoResponse toDTO(UserMngEntity uEntity,  WhsMgntBaseInfoEntity whsEntity) {
        if (uEntity == null) return null;
        return RtnReqInitInfoResponse.builder()
                .brandId(uEntity.getBrandId() == null ? "" :uEntity.getBrandId())
                .brandNm(uEntity.getBrandNm() == null ? "" :uEntity.getBrandNm())
                .storeId(uEntity.getStoreId() == null ? "" :uEntity.getStoreId())
                .storeNm(uEntity.getStoreNm() == null ? "" :uEntity.getStoreNm())
                .reqDept(uEntity.getStoreId() == null ? "브랜드" : "매장")
                .userNm(uEntity.getUserNm() == null ? "" : uEntity.getUserNm())
                .authTpCd(uEntity.getAuthTpCd() == null ? "" : uEntity.getAuthTpCd())
                .whsDvsn(uEntity.getStoreId() == null ? "W01" : "W02")
                .rtnWhsId(whsEntity == null ? "" : whsEntity.getWhsId() == null ? "" : whsEntity.getWhsId())
                .rtnWhsNm(whsEntity == null ? "" : whsEntity.getWhsNm() == null ? "" : whsEntity.getWhsNm())
                .rtnLocation(whsEntity == null ? "" : whsEntity.getLocationInfo() == null ? "" : whsEntity.getLocationInfo().getLocation() == null ? "" : whsEntity.getLocationInfo().getLocation())
                .rtnLocationNm(whsEntity == null ? "" : whsEntity.getLocationInfo() == null ? "" : whsEntity.getLocationInfo().getLocationNm() == null ? "" : whsEntity.getLocationInfo().getLocationNm())
                .build();
    }

}
