public Result findCreate() { var user = HttpContext.Session.Get("User"); User creator = null; if (user == null || user.Length == 0) { return(Result.failResult("登录过期", null)); } else { try { User res = (User)ByteConvert.BytesToObject(user); creator = res; } catch (Exception e) { return(Result.failResult("Error", null)); } } var resm = _service.findCreateParty(creator.uid); return(Result.successResult("OK", resm)); }
public Result showUser() { var user = HttpContext.Session.Get("User"); if (user == null || user.Length == 0) { return(Result.failResult("登录过期", null)); } else { try { User res = (User)ByteConvert.BytesToObject(user); return(Result.successResult("OK", res.username)); }catch (Exception e) { return(Result.failResult("Error", null)); } } }
public Result closeParty(int id) { var user = HttpContext.Session.Get("User"); User creator = null; if (user == null || user.Length == 0) { return(Result.failResult("登录过期", null)); } else { try { User res = (User)ByteConvert.BytesToObject(user); creator = res; } catch (Exception e) { return(Result.failResult("Error", null)); } } var auth = _service.checkMem(creator.uid, id); if (auth != 2) { return(Result.failResult("没有权限", null)); } var resm = _service.setPartyStatus(id, 1); if (resm) { return(Result.successResult("OK", null)); } else { return(Result.failResult("队伍处于关闭状态", null)); } }
public Result publish([FromBody] PublishReq req) { var user = HttpContext.Session.Get("User"); if (!req.validate()) { return(Result.failResult("格式有误", null)); } User creator = null; if (user == null || user.Length == 0) { return(Result.failResult("登录过期", null)); } else { try { User res = (User)ByteConvert.BytesToObject(user); creator = res; } catch (Exception e) { return(Result.failResult("Error", null)); } } int id = _service.createParty(creator.uid, req); if (id == -1) { return(Result.failResult("Error", null)); } else { return(Result.successResult("队伍发布成功", id)); } }
public Result removeMem([FromBody] RemoveReq req) { var user = HttpContext.Session.Get("User"); User creator = null; if (user == null || user.Length == 0) { return(Result.failResult("登录过期", null)); } else { try { User res = (User)ByteConvert.BytesToObject(user); creator = res; } catch (Exception e) { return(Result.failResult("Error", null)); } } var auth = _service.checkMem(creator.uid, req.pid); if (auth != 2) { return(Result.failResult("没有权限", null)); } if (_service.removeMem(req.username, req.pid)) { return(Result.successResult("OK", null)); } else { return(Result.failResult("目标不在队伍中", null)); } }