Esempio n. 1
0
        public ActionResult <Result> Publish([FromBody] dynamic ticket)
        {
            JObject data = JObject.Parse(ticket.ToString());

            //解析数据
            TTicket tkt = new TTicket
            {
                Email  = data["Email"].ToString(),
                TypeId = int.Parse(data["TypeId"].ToString())
            };

            TTicketChat tktc = new TTicketChat
            {
                Content = data["Content"].ToString(),
                Annex   = data["Annex"]?.ToString()
            };

            string reg_email = @"^\w+(?<=[^ ])@\w+\.\w+$";

            if (!Regex.IsMatch(tkt.Email, reg_email))
            {
                throw new ResultException("邮箱格式错误");
            }

            if (tkt.TypeId != 0 && tkt.TypeId != 400002 && (tkt.TypeId < 600000 || tkt.TypeId >= 700000))
            {
                throw new ResultException("工单类型错误");
            }

            //发布
            ticketServer.Publish(tkt, tktc);

            // ticketServer.Create(new TTicket()
            // {
            //     TypeId = ticket.TypeId == 0 ? 400002 : ticket.TypeId,
            //     Email = ticket.Email,
            //     Content = ticket.Content,
            //     Annex = ticket.Annex
            // });
            return(new Result(200, "成功"));
        }