package com.muyu.fence.domain.database;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.fence.domain.req.ElectronicFenceGroupAddReq;
import com.muyu.fence.domain.req.ElectronicFenceGroupUpdReq;
import com.muyu.fence.domain.resp.ElectronicFenceGroupResp;
import com.muyu.fence.domain.resp.GroupFenceListresp;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.function.Supplier;

/**
 * @Author：yuping
 * @Package：com.muyu.fence.domain
 * @Project：cloud-server
 * @name：ElectronicFenceGroup
 * @Date：2024/9/18 11:14
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@TableName(value = "electronic_fence_group",autoResultMap = true)
public class ElectronicFenceGroup extends BaseEntity {

    /**
     * 主键
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    /**
     * 围栏组优先级
     */
    private Integer priority;
    /**
     * 围栏组名称
     */
    private String groupName;
    /**
     * 围栏组类型
     */
    private String   groupType;

    /**
     * 启用状态
     */
    private String status;


    public static GroupFenceListresp buildGroupFence(ElectronicFenceGroup electronicFenceGroup){

      return   GroupFenceListresp.builder()
                .id(electronicFenceGroup.getId())
                .groupName(electronicFenceGroup.groupName)
                .priority(electronicFenceGroup.getPriority())
                .status(electronicFenceGroup.getStatus())
                .groupType(electronicFenceGroup.groupType)
                .build();

    }




    public static ElectronicFenceGroupResp buildElectronicFenceGroupResp (ElectronicFenceGroup electronicFenceGroup){

        return   ElectronicFenceGroupResp.builder()
                .id(electronicFenceGroup.getId())
                .groupName(electronicFenceGroup.groupName)
                .priority(electronicFenceGroup.getPriority())
                .status(electronicFenceGroup.getStatus())
                .groupType(electronicFenceGroup.groupType)
                .build();

    }

    public static ElectronicFenceGroup buildByAdd(ElectronicFenceGroupAddReq addReq){


      return ElectronicFenceGroup.builder()
                .groupName(addReq.getGroupName())
                .groupType(addReq.getGroupType())
                .status(addReq.getStatus())
                .priority(addReq.getPriority())
                .build();

    }

    public static ElectronicFenceGroup buildByUpd(ElectronicFenceGroupUpdReq updReq, Supplier<Long> ids){


        return ElectronicFenceGroup.builder()
                .id(ids.get())
                .groupName(updReq.getGroupName())
                .groupType(updReq.getGroupType())
                .status(updReq.getStatus())
                .priority(updReq.getPriority())
                .build();

    }







}
