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.ElectroicFenceAddReq;
import com.muyu.fence.domain.req.ElectroicFenceUpdReq;
import com.muyu.fence.domain.resp.ElectronicFenceResp;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.function.Supplier;

/**
 * @Author：yuping
 * @Package：com.muyu.fence.domain
 * @Project：cloud-server
 * @name：ElectronicFence
 * @Date：2024/9/17 16:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@TableName(value = "electronic_fence",autoResultMap = true)
public class ElectronicFence extends BaseEntity {

    /**
     * 主键id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    /**
     * 围栏名称
     */

    private String name;

    /**
     * 围栏类型
     */

    private String fenceType;

    /**
     *经纬度信息
     */

   private String longitudeLatitude;

    /**
     * 电子围栏状态（正常，停用）
     */

   private String  status;

//    /**
//     * 电子围栏的开始时间
//     */
//
//    private Date startTime;
//    /**
//     * 电子围栏的结束时间
//     */
//    private Date endTime;

    /**
     * 描述信息
     */

    private String  fenceDesc;

public static ElectronicFenceResp bullerResp(ElectronicFence electronicFence){

   return ElectronicFenceResp.builder()
            .id(electronicFence.getId())
            .name(electronicFence.getName())
            .status(electronicFence.getStatus())
           .fenceType(electronicFence.getFenceType())
            .longitudeLatitude(electronicFence.getLongitudeLatitude())
            .desc(electronicFence.getFenceDesc())
            .build();
}


public static ElectronicFence buildElectroicAdd(ElectroicFenceAddReq electroicFenceAddReq){

   return ElectronicFence.builder()
           .name(electroicFenceAddReq.getName())
           .fenceDesc(electroicFenceAddReq.getFenceDesc())
           .status(electroicFenceAddReq.getStatus())
           .longitudeLatitude(electroicFenceAddReq.getLongitudeLatitude())
           .fenceType(electroicFenceAddReq.getFenceType())
           .build();


}

public static ElectronicFence buildByElectronicUpd(ElectroicFenceUpdReq electroicFenceUpdReq, Supplier<Long> longSupplier){

  return   ElectronicFence.builder()
            .id(longSupplier.get())
            .name(electroicFenceUpdReq.getName())
            .status(electroicFenceUpdReq.getStatus())
            .fenceDesc(electroicFenceUpdReq.getFenceDesc())
            .longitudeLatitude(electroicFenceUpdReq.getLongitudeLatitude())
            .build();

}







}
