package com.bonus.canteen.core.allocation.canteen.model;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bonus.canteen.core.allocation.canteen.dto.DzCanteenAuthDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 定制-食堂访问权限表
 *
 * @author shihao.li
 * @date 2024/8/22 15:57
 */
@Data
@NoArgsConstructor
@TableName("dz_alloc_canteen_auth")
@ApiModel(value = "定制-食堂访问权限表")
public class DzAllocCanteenAuth {
    /**
     * 主键id
     */
    @TableId
    @ApiModelProperty(value = "主键id")
    private Long id;
    @ApiModelProperty(value = "食堂id")
    private Long canteenId;
    /**
     * 将 List<Long> 转成String，取的时候 对应转换
     */
    @ApiModelProperty(value = "所属组织")
    private String orgIds;
    @ApiModelProperty(value = "食堂业务类型 1-食堂 2-超市")
    private Integer canteenType;
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime crtime;

    public DzAllocCanteenAuth(DzCanteenAuthDTO canteenAuthDTO, Integer canteenType) {
        this.canteenId = canteenAuthDTO.getCanteenId();
        this.orgIds = JSONUtil.toJsonStr(canteenAuthDTO.getOrgIdList());
        this.canteenType = canteenType;
    }
}
