
package com.icomsys.main_vm.biz.common.system.vo;

import com.icomsys.main_vm.biz.common.login.res.UserVo;
import com.icomsys.main_vm.db.jpa.entity.system.TbIcsOprMngInfo;
import com.icomsys.main_vm.db.jpa.entity.system.TbServiceGrouop;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
public class SystemCustSaveSubReq {

    private String addServiceGroupName;
    private String addServiceGroup;
    private String addOprMngCode;
    private String addServiceGroupDesc;
    private String addUseYn;
    private List<String> authList;

    @Builder
    public SystemCustSaveSubReq(String addServiceGroupName, String addServiceGroup, String addOprMngCode, String addServiceGroupDesc, String addUseYn, List<String> authList) {
        this.addServiceGroupName = addServiceGroupName;
        this.addServiceGroup = addServiceGroup;
        this.addOprMngCode = addOprMngCode;
        this.addServiceGroupDesc = addServiceGroupDesc;
        this.addUseYn = addUseYn;
        this.authList = authList;
    }

    public TbServiceGrouop toService(String custCode, UserVo uv, String yn) {
        System.out.println("use - " + this.addUseYn);
        return TbServiceGrouop.builder()
                .serviceGroup(this.addServiceGroup.toUpperCase())
                .serviceGroupUpper(this.addServiceGroup)
                .custCode(custCode)
                .serviceType("M")
                .serviceGroupName(this.addServiceGroupName)
                .serviceGroupDesc(this.addServiceGroupDesc)
                .useYn(yn)
                .registId(uv.getUserId())
                .registDate(LocalDateTime.now())
                .updateId(uv.getUserId())
                .updateDate(LocalDateTime.now())
                .build();
    }
    public TbServiceGrouop toService(String custCode, UserVo uv) {
        System.out.println("use - " + this.addUseYn);
        return TbServiceGrouop.builder()
                .serviceGroup(this.addServiceGroup.toUpperCase())
                .serviceGroupUpper(this.addServiceGroup)
                .custCode(custCode)
                .serviceType("M")
                .serviceGroupName(this.addServiceGroupName)
                .serviceGroupDesc(this.addServiceGroupDesc)
                .useYn("Y")
                .registId(uv.getUserId())
                .registDate(LocalDateTime.now())
                .updateId(uv.getUserId())
                .updateDate(LocalDateTime.now())
                .build();
    }

    public TbIcsOprMngInfo toOprmngCode(String custCode, UserVo uv) {
        return TbIcsOprMngInfo.builder()
                .custCode(custCode)
                .serviceGroup(this.addServiceGroup)
                .oprMngCode(custCode+"_RCP_"+this.addServiceGroup.toUpperCase())
                .solVal("RCP")
                .useYn("Y")
                .registId(uv.getUserId())
                .registDate(LocalDateTime.now())
                .updateId(uv.getUserId())
                .updateDate(LocalDateTime.now())
                .build();
    }

}
