public AdminMatchResp CMatch([FromBody] AdminCMatchReq req) { AdminMatchResp resp = new AdminMatchResp(); try { if (Fun.ExistMID(req.mid)) { Fun.GetSqlConn().Execute($"update `match` set title = '{req.title}', start_time = '{req.start_time}', end_time = '{req.end_time}', description = '{req.description}', detail = '{req.detail}', need_upload = {req.need_upload} where id = {req.mid}"); resp.msg = "ok"; resp.status = 0; } else { resp.status = -1; resp.msg = "参数错误"; } } catch (Exception ex) { resp.msg = "未知错误" + ex.ToString(); resp.status = -2; Console.WriteLine(resp.msg); } return(resp); }
public AdminMatchResp Match([FromBody] AdminMatchReq req) { AdminMatchResp resp = new AdminMatchResp(); try { if (Fun.ExistAID(req.aid)) { Fun.GetSqlConn().Execute($"insert into `match` (title, start_time, end_time, description, detail, create_time, need_upload, is_active) values ('{req.title}', '{req.start_time}', '{req.end_time}', '{req.description}', '{req.detail}', '{Fun.GetNowTimestampString()}', {req.need_upload}, '{1}')"); resp.msg = "ok"; resp.status = 0; } else { resp.status = -1; resp.msg = "参数错误"; } } catch (Exception ex) { resp.msg = "未知错误" + ex.ToString(); resp.status = -2; Console.WriteLine(resp.msg); } return(resp); }
public AdminMatchResp Match(int mid) { AdminMatchResp resp = new AdminMatchResp(); try { if (Fun.ExistMID(mid)) { Fun.GetSqlConn().Execute($"update `match` set is_active = false where id={mid}"); resp.msg = "ok"; resp.status = 0; } else { resp.msg = "参数错误"; resp.status = -1; } } catch (Exception ex) { resp.msg = "未知错误" + ex.ToString(); resp.status = -2; Console.WriteLine(resp.msg); } return(resp); }
public AdminMatchResp Match(int page_index = 1, int page_size = 3) { AdminMatchResp resp = new AdminMatchResp(); try { // var results = Fun.GetSqlConn().Query($"select * from `match` limit {(page_index - 1) * page_size}, {page_size}"); var results = Fun.GetSqlConn().Query($"select * from `match`"); MatchProfile[] mp_arr = new MatchProfile[results.Count()]; int i = 0; foreach (var match in results) { MatchProfile mp = new MatchProfile(); // Console.WriteLine($"select s.id, s.name, s.nick_name, s.gender, s.email, sm.is_upload, sm.create_time, sm.upload_file_time, sm.upload_file_path, sm.is_awards, sm.awards from student_match sm inner join `student` s on sm.id = {match.id} and sm.sid = s.id"); var stus = Fun.GetSqlConn().Query($"select s.id, s.name, s.nick_name, s.gender, s.email, sm.is_upload, sm.create_time, sm.upload_file_time, sm.upload_file_path, sm.is_awards, sm.awards from student_match sm inner join `student` s on sm.mid = {match.id} and sm.sid = s.id"); mp.match = match; mp.stus = stus; mp_arr[i++] = mp; } resp.data = mp_arr; resp.status = 0; resp.msg = "ok"; } catch (Exception ex) { resp.msg = "未知错误" + ex.ToString(); resp.status = -2; Console.WriteLine(resp.msg); } return(resp); }