package com.agri.system.domain;

import com.agri.common.annotation.Excel;
import com.agri.common.core.domain.BaseEntity;
import com.agri.common.core.domain.entity.SysUser;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;
import java.util.List;

/**
 * 大棚信息（用户-设备关联）对象 sys_user_agri
 * 
 * @author lld
 * @date 2026-01-25
 */
@Data
@TableName("sys_user_agri")
public class SysUserAgri extends BaseEntity
{
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /** 主键ID（雪花） */
    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /** 大棚ID */
    @Excel(name = "大棚ID")
    private String agriId;

    /** 协同用户ID */
    @Excel(name = "协同用户ID")
    private Long userId;

    /** 角色：3-OWNER/2-ADMIN/1-OPERATOR/0-VIEWER */
    @Excel(name = "角色：3-OWNER/2-ADMIN/1-OPERATOR/0-VIEWER")
    private Integer role;

    /** 权限位（位运算）：1=查看 2=控制 4=配置 8=分享/成员管理 16=导出等 */
    @Excel(name = "权限位", readConverterExp = "位=运算")
    private Integer permMask;

    /** 状态：0=禁用 1=启用 2=待接受邀请 */
    @Excel(name = "状态：0=禁用 1=启用 2=待接受邀请")
    private Integer status;

    /** 邀请人用户ID */
    @Excel(name = "邀请人用户ID")
    private Long inviteBy;

    /** 邀请时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Excel(name = "邀请时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date inviteTime;

    /** 接受时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Excel(name = "接受时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date acceptTime;

    /** 版本号（乐观锁） */
    @Excel(name = "版本号", readConverterExp = "乐=观锁")
    @Version
    private Integer version;

    @TableField(exist = false)
    private SysUser sysUser;

    @TableField(exist = false)
    private String imei;

    @TableField(exist = false)
    private Boolean disabled;

    @TableField(exist = false)
    private List<Long> idList;

    public SysUserAgri(List<Long> idList) {
        this.idList = idList;
    }

    public SysUserAgri() {
    }
}
