
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

using TEAMModelOS.SDK.Context.Attributes.Azure;


namespace TEAMModelOS.SDK.Models
{
    /// <summary>
    /// 投票
    /// </summary>    
    public class Vote : CosmosEntity
    {
        public Vote()
        {
            pk = "Vote";
            options = new List<OptionVote>();

        }
        /// <summary>
        /// 发布层级 类型 school  teacher
        /// </summary>
        public string owner { get; set; }
        /// <summary>
        /// 学校编码或教师tmdid
        /// </summary>
        [Required(ErrorMessage = "school 必须设置")]
        public string school { get; set; }
        /// <summary>
        /// 投票名称
        /// </summary>
        [Required(ErrorMessage = "name 必须设置")]
        public string name { get; set; }
        /// <summary>
        /// 创建者的id 
        /// </summary>
        [Required(ErrorMessage = "creatorId 必须设置")]
        public string creatorId { get; set; }
        /// <summary>
        /// 投票描述 
        /// </summary>
        public string description { get; set; }
        /// <summary>
        /// pending 待发布|going 已发布|finish 已结束
        /// </summary>
        //[Required(ErrorMessage = "progress 必须设置")]
        public string progress { get; set; }
        /// <summary>
        /// 投票选项
        /// </summary>
        public List<OptionVote> options { get; set; }
        /// <summary>
        /// //匿名投票，不公布投票人相关信息
        /// </summary>
        public bool secret { get; set; }
        /// <summary>
        /// 投票周期/once一次，day天，week周,month月，年year等
        /// </summary>
        [Required(ErrorMessage = "times 必须设置")]
        public string times { get; set; }
        //周期内可投票数
        public int voteNum { get; set; }
        //周期内是否允许重复投相同一个选项。
        public bool repeat { get; set; } 
        /// <summary>
        /// school|private
        /// </summary>
        [Required(ErrorMessage = "scope 必须设置")]
        public string scope { get; set; }
        /// <summary>
        /// 参与投票的教师醍摩豆id
        /// </summary>
        public List<string> tmdids { get; set; }
        /// <summary>
        ///  scope 为school时 是学校的班级  为private 时是私人班级
        /// </summary>
        public List<string> classes { get; set; }
        
        /// <summary>
        /// 开始时间
        /// </summary>
        public long startTime { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public long createTime { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public long endTime { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public long updateTime { get; set; }
        /// <summary>
        /// 投票记录
        /// </summary>
        public string recordUrl { get; set; }
        /// <summary>
        /// TTL删除改变状态使用
        /// </summary>
        public int? status { get; set; } = 0;
        public long? size { get; set; } = 0;
    }
    /// <summary>
    /// 投票选项
    /// </summary>
    public class OptionVote
    {
        /// <summary>
        /// 投票编号
        /// </summary>
        public string code { get; set; }
        /// <summary>
        /// 投票对象
        /// </summary>
        public string value { get; set; }
        /// <summary>
        /// 投票对象描述
        /// </summary>
        public string desc { get; set; }
    }
}

