JPHD-2021-backend/Models/SMS.cs

80 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace _2021_backend.Models
{
public enum SMSType
{
Accept,
Reject,
TimeSelect,
TimeSet,
Signed,
Reply
}
public class SMS
{
public SMS()
{
Guid = Guid.NewGuid();
Tel = "";
Data = new List<string> { };
Type = SMSType.Accept;
Sender = "";
SendTime = DateTime.Now;
}
public SMS(SMSPartialDto dto, Guid host)
{
Guid = Guid.NewGuid();
Tel = dto.SubscriberNumber;
Host = host;
Sender = dto.SubscriberNumber.ToString();
Data = (new string[] { dto.ReplyContent }).ToList<string>();
Type = SMSType.Reply;
var tm = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(dto.ReplyTime).ToLocalTime();
SendTime = tm;
}
[Key]
public Guid Guid { get; set; }
[Display(Name ="Host")]
public Guid Host { get; set; }
[Display(Name ="电话号码")]
public string Tel { get; set; }
[Display(Name ="短信内容")]
public List<string> Data { get; set; }
[Display(Name ="短信类型")]
public SMSType Type { get; set; }
[Display(Name ="发送者")]
public string Sender { get; set; }
[Display(Name = "发送时间")]
[DisplayFormat(DataFormatString = "{0:g}", ApplyFormatInEditMode = true)]
public DateTime SendTime { get; set; }
}
public class SMSResponseDto
{
public class error
{
public string Code;
public string Message;
}
public List<SMSPartialDto> PullSmsReplyStatusSet { get; set; }
public string RequestId { get; set; }
error Error { get; set; }
}
public class SMSPartialDto
{
public string CountryCode { get; set; }
public string ReplyContent { get; set; }
public string SubscriberNumber { get; set; }
public string ExtendCode { get; set; }
public ulong ReplyTime { get; set; }
public string PhoneNumber { get; set; }
public string SignName { get; set; }
}
}