package com.caliverse.admin.domain.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

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

@AllArgsConstructor
@NoArgsConstructor
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Groups {
    @JsonProperty("group_id")
    private Long groupId;
    @JsonProperty("row_num")
    private Long rowNum;
    @JsonProperty("group_nm")
    private String groupNm;

    private String description;

    @JsonProperty("create_dt")
    private LocalDateTime createDt;
    @JsonProperty("create_by")
    private Long createBy;
    @JsonProperty("update_dt")
    private LocalDateTime updateDt;
    @JsonProperty("update_by")
    private Long updateBy;
    @JsonProperty("member_cnt")
    private Long memberCnt;

    public List<SimpleGrantedAuthority> getAuthorities() {
        List list = new ArrayList();
        list.add(new SimpleGrantedAuthority(this.getName() ));
        return list;
    }

    public String getName(){
        return this.groupNm.toString();
    }

}
