public IActionResult getParticularSlotById(long slotId) { DBHelper dbHelper = new DBHelper(); try { var res = new ParticularSlot(); res.areas = AreaController.getAreasById(slotId); if (res.areas == null) { return(NotFound("暂无场次")); } string query = "SELECT MAP,SELLER_ID,SHOW_ID FROM SLOT WHERE ID = :slotId"; OracleParameter[] parameterForQuery = { new OracleParameter(":slotId", OracleDbType.Long, 10) }; parameterForQuery[0].Value = slotId; DataTable dt = dbHelper.ExecuteTable(query, parameterForQuery); res.map = dt.Rows[0]["MAP"].ToString() == string.Empty ? null : Convert.ToBase64String((byte[])(dt.Rows[0]["MAP"])); res.sellerId = long.Parse(dt.Rows[0]["SELLER_ID"].ToString()); long showId = long.Parse(dt.Rows[0]["SHOW_ID"].ToString()); string queryName = "SELECT NAME FROM SHOW WHERE ID=:showId"; OracleParameter[] parameterForQueryName = { new OracleParameter(":showId", OracleDbType.Long, 10) }; parameterForQueryName[0].Value = showId; DataTable dtForName = dbHelper.ExecuteTable(queryName, parameterForQueryName); string name = dtForName.Rows[0]["NAME"].ToString(); res.showName = name; return(Ok(new JsonResult(res))); } catch (OracleException oe) { return(BadRequest("数据库请求错误 " + "错误代码 " + oe.Number.ToString())); } }
public IActionResult GetSlot(long?sellerId) { if (sellerId is null) { return(BadRequest("商家id为空")); } DBHelper dbHelper = new DBHelper(); try { var res = new List <SellerSlot>(); string querySlotStr = "SELECT ID ,SHOW_ID ,PLACE ,DAY ,TIME_START ,TIME_END FROM SLOT WHERE IS_VALID = 1 AND SELLER_ID = :sellerId"; OracleParameter[] parameterForQuerySlot = { new OracleParameter(":sellerId", OracleDbType.Long) }; parameterForQuerySlot[0].Value = sellerId; DataTable dtSlot = dbHelper.ExecuteTable(querySlotStr, parameterForQuerySlot); foreach (DataRow row in dtSlot.Rows) { long Id = long.Parse(row["ID"].ToString()); long showId = long.Parse(row["SHOW_ID"].ToString()); string queryShowName = "SELECT NAME FROM SHOW WHERE ID =:showId"; OracleParameter[] parameterForQueryName = { new OracleParameter(":showId", OracleDbType.Long, 10) }; parameterForQueryName[0].Value = showId; DataTable dtForName = dbHelper.ExecuteTable(queryShowName, parameterForQueryName); string name = dtForName.Rows[0]["NAME"].ToString(); res.Add(new SellerSlot() { id = Id, showName = name, place = row["PLACE"].ToString(), day = row["DAY"].ToString(), timeStart = row["TIME_START"].ToString(), timeEnd = row["TIME_END"].ToString(), areas = AreaController.getAreasById(Id), }); } if (res.Count == 0) { return(NotFound("无匹配结果")); } else { return(Ok(new JsonResult(res))); } } catch (OracleException oe) { return(BadRequest("数据库请求错误" + "错误代码" + oe.Number)); } }