コード例 #1
0
        public StuMatchResp MyMatch(int sid)
        {
            StuMatchResp resp = new StuMatchResp();

            try
            {
                if (Fun.ExistSID(sid))
                {
                    var result = Fun.GetSqlConn().Query($"select * from `student_match` sm inner join `match` m on sm.sid = {sid} and sm.mid = m.id and is_active = true;");
                    resp.data   = result;
                    resp.status = 0;
                    resp.msg    = "ok";
                }
                else
                {
                    resp.msg    = "参数错误";
                    resp.status = -1;
                }
            }
            catch (Exception ex)
            {
                resp.msg    = "未知错误" + ex.ToString();
                resp.status = -2;
                Console.WriteLine(resp.msg);
            }

            return(resp);
        }
コード例 #2
0
        public StuMatchResp Match(int page_index = 1, int page_size = 3)
        {
            StuMatchResp resp = new StuMatchResp();

            try
            {
                // var matchs = Fun.GetSqlConn().Query($"select * from `match` where is_active = {true} limit {(page_index - 1) * page_size}, {page_size}");
                var matchs = Fun.GetSqlConn().Query($"select * from `match`");
                resp.data   = matchs;
                resp.status = 0;
                resp.msg    = "ok";
            }
            catch (Exception ex)
            {
                resp.msg    = "未知错误" + ex.ToString();
                resp.status = -2;
                Console.WriteLine(resp.msg);
            }

            return(resp);
        }
コード例 #3
0
        public StuMatchResp Match([FromBody] StuMatchReq req)
        {
            StuMatchResp resp = new StuMatchResp();

            try
            {
                if (!Fun.ExistSID(req.sid) || !Fun.ExistMID(req.mid))
                {
                    resp.msg    = "用户或比赛不存在";
                    resp.status = -1;
                }
                else
                {
                    if (req.CheckStuMatch())
                    {
                        resp.msg    = "你已经报名这个比赛啦";
                        resp.status = -1;
                    }
                    else
                    {
                        //Console.WriteLine($"insert into `student_match` (sid, mid, create_time, is_upload, upload_file_path, upload_file_time) values ({req.sid}, {req.mid}, '{Fun.GetNowTimestampString()}', {0}, '', '')");
                        Fun.GetSqlConn().Execute($"insert into `student_match` (sid, mid, create_time, is_upload, upload_file_path, upload_file_time) values ({req.sid}, {req.mid}, '{Fun.GetNowTimestampString()}', '{0}', '', '')");
                        resp.msg    = "报名成功";
                        resp.status = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                resp.msg    = "未知错误" + ex.ToString();
                resp.status = -2;
                Console.WriteLine(resp.msg);
            }

            return(resp);
        }