package com.cool.store.entity;

import cn.hutool.crypto.digest.MD5;
import com.cool.store.constants.CommonConstants;
import com.cool.store.enums.DataSourceEnum;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 
 * @author   zhangchenbiao
 * @date   2023-06-08 10:54
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysRoleDO implements Serializable {
    @ApiModelProperty("自增id")
    private Long id;

    @ApiModelProperty("角色id")
    private String roleId;

    @ApiModelProperty("角色名称")
    private String roleName;

    @ApiModelProperty("角色类型 0-同步 1-自建")
    private Integer roleType;

    @ApiModelProperty("第三方唯一id")
    private String thirdUniqueId;

    @ApiModelProperty("删除标识")
    private Boolean deleted;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("更新时间")
    private Date updateTime;

    @ApiModelProperty("创建人")
    private String createUser;

    @ApiModelProperty("更新人")
    private String updateUser;

    public static SysRoleDO convertSyncDO(String roleName){
        SysRoleDO role = new SysRoleDO();
        role.setRoleId(MD5.create().digestHex(roleName));
        role.setRoleName(roleName);
        role.setRoleType(DataSourceEnum.SYNC.getCode());
        role.setDeleted(Boolean.FALSE);
        role.setCreateTime(new Date());
        role.setUpdateTime(new Date());
        return role;
    }
}