public ResponseFuncTreeCheckedGet FuncTreeCheckedGet(RequestFuncTreeCheckedGet request) { ResponseFuncTreeCheckedGet response = new ResponseFuncTreeCheckedGet(); using (cnn = GetConnection()) { var ts = cnn.BeginTransaction(); try { string sql = @"WITH CTE(id, name, img, PARENTID,seq) AS (SELECT id,name,img, PARENTID,seq FROM tks_fas_function WHERE id = @Id UNION ALL SELECT B.id,B.name,B.img,B.PARENTID,B.Seq FROM tks_fas_function B INNER JOIN CTE ON B.PARENTID = CTE.id) SELECT * FROM CTE order by seq"; var funcs = cnn.Query <TKS_FAS_Function>(sql, new { Id = "-" }, ts).ToList(); sql = "select * from TKS_FAS_Entity2Function where type=@Type and entityId=@EntityId"; var checkedFuncs = cnn.Query <TKS_FAS_Entity2Function>(sql, new { Type = "R", EntityId = request.EntityId }, ts).ToList(); ts.Commit(); TKS_FAS_TreeItem root = new TKS_FAS_TreeItem(); var first = funcs.Where(p => p.Id == "-").FirstOrDefault(); root = Trans2TreeItem(first); if (checkedFuncs.Any(p => { return(p.FunctionId == root.id && p.CheckState == "checked"); })) { root.@checked = true; } CreateTree(funcs, ref root, checkedFuncs); response.Data = new List <TKS_FAS_TreeItem>(); response.Data.Add(root); response.IsSuccess = true; response.Message = "加载完毕"; return(response); } catch (Exception ex) { return(this.DealException(response, ex) as ResponseFuncTreeCheckedGet); } } }
public ResponseFuncTreeCheckedGet FuncTreeCheckedGet([FromBody] RequestFuncTreeCheckedGet request) { try { FunctionBLL bll = new FunctionBLL(); return(bll.FuncTreeCheckedGet(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }