package ink.wgink.service.role.pojo.vos;

import ink.wgink.annotation.CheckEmptyAnnotation;
import ink.wgink.annotation.CheckListAnnotation;
import ink.wgink.service.role.service.IRolePermissionService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: PermissionVO
 * @Description: 权限
 * @Author: WenG
 * @Date: 2020-05-27 15:58
 * @Version: 1.0
 **/
@ApiModel
public class RolePermissionVO {

    @ApiModelProperty(name = "type", value = "类型")
    @CheckEmptyAnnotation(name = "类型", types = {IRolePermissionService.PERMISSION_INSERT, IRolePermissionService.PERMISSION_DELETE, IRolePermissionService.PERMISSION_UPDATE, IRolePermissionService.PERMISSION_QUERY})
    private String type;
    @ApiModelProperty(name = "permissionIdArray", value = "权限ID列表")
    @CheckListAnnotation(name = "权限ID列表")
    private List<String> permissionIds;

    public String getType() {
        return type == null ? "" : type.trim();
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<String> getPermissionIds() {
        if (permissionIds == null) {
            return new ArrayList<>();
        }
        return permissionIds;
    }

    public void setPermissionIds(List<String> permissionIds) {
        this.permissionIds = permissionIds;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"type\":\"")
                .append(type).append('\"');
        sb.append(",\"permissionIds\":")
                .append(permissionIds);
        sb.append('}');
        return sb.toString();
    }
}
