12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /**
- * 命名空间: CZFW.Framework.Modules.Logic
- *
- * 功 能: N/A
- * 类 名: TypeLogic
- *
- * Ver 变更日期 负责人 变更内容
- * ───────────────────────────────────
- * V0.01 2016/12/1 9:10:08 吴争辉 初稿
- *
- * Copyright (c) 2016 CHUANGZHIKEJI Corporation. All rights reserved.
- *┌──────────────────────────────────┐
- *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
- *│ 版权所有:创执科技(北京)有限公司 │
- *└──────────────────────────────────┘
- */
- using System.Collections.Generic;
- using System.Linq;
- using CZFW.Framework.Interface;
- using CZFW.Framework.Model.Entity;
- using CZFW.Framework.Model.ViewModel;
- namespace CZFW.Framework.Logic
- {
- /// <summary>
- /// 分类
- /// </summary>
- public class TypeLogic : LogicBase<TypeEntity>, IType
- {
- /// <summary>
- /// 根据父Id获取类型列表
- /// </summary>
- /// <param name="parentId">父Id</param>
- /// <returns></returns>
- public TableModel<TypeEntity> GetListByParentId(int parentId, int pageIndex, int pageSize)
- {
- var queryable = Queryable.Where(x => x.ParentId == parentId);
- int rowsCount = queryable.Count();
- var model = new TableModel<TypeEntity>();
- var data = queryable.OrderByDescending(x => x.SortOrder).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
- model.SetData(data);
- model.Pager = new PagerModel(rowsCount, pageIndex, pageSize);
- model.TableHeads = PropertyHelper.Get(typeof(TypeEntity));
- return model;
- }
- public IList<TypeEntity> GetListByParentId(int parentId)
- {
- return Queryable.Where(x => x.ParentId == parentId).OrderByDescending(x => x.SortOrder).ToList();
- }
- public ResultModel RemoveType(int id)
- {
- var typeList = DbContext.Set<TypeEntity>().Where(x => x.ParentId == id).ToList();
- if (typeList.Count > 0)
- {
- RemoveEntities(x => x.ParentId == id);
- }
- return RemoveEntity(id);
- }
- }
- }
|