123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using LeaRun.Application.Entity.BaseManage;
- using LeaRun.Application.IService.BaseManage;
- using LeaRun.Data.Repository;
- using LeaRun.Util.Extension;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using LeaRun.Application.IService.AuthorizeManage;
- using LeaRun.Application.Service.AuthorizeManage;
- namespace LeaRun.Application.Service.BaseManage
- {
- /// <summary>
- /// 版 本 6.1
- /// Copyright (c) 2013-2016 上海力软信息技术有限公司
- /// 创建人:佘赐雄
- /// 日 期:2015.11.02 14:27
- /// 描 述:机构管理
- /// </summary>
- public class OrganizeService : RepositoryFactory<OrganizeEntity>, IOrganizeService
- {
- private IAuthorizeService<OrganizeEntity> iauthorizeservice = new AuthorizeService<OrganizeEntity>();
- #region 获取数据
- /// <summary>
- /// 机构列表
- /// </summary>
- /// <returns></returns>
- public IEnumerable<OrganizeEntity> GetList()
- {
- return this.BaseRepository().IQueryable().OrderByDescending(t => t.SortCode).ToList();
- }
- /// <summary>
- /// 机构实体
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <returns></returns>
- public OrganizeEntity GetEntity(string keyValue)
- {
- return this.BaseRepository().FindEntity(keyValue);
- }
- #endregion
- #region 验证数据
- /// <summary>
- /// 公司名称不能重复
- /// </summary>
- /// <param name="organizeName">公司名称</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public bool ExistFullName(string fullName, string keyValue)
- {
- var expression = LinqExtensions.True<OrganizeEntity>();
- expression = expression.And(t => t.FullName == fullName);
- if (!string.IsNullOrEmpty(keyValue))
- {
- expression = expression.And(t => t.OrganizeId != keyValue);
- }
- return this.BaseRepository().IQueryable(expression).Count() == 0 ? true : false;
- }
- /// <summary>
- /// 外文名称不能重复
- /// </summary>
- /// <param name="enCode">外文名称</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public bool ExistEnCode(string enCode, string keyValue)
- {
- var expression = LinqExtensions.True<OrganizeEntity>();
- expression = expression.And(t => t.EnCode == enCode);
- if (!string.IsNullOrEmpty(keyValue))
- {
- expression = expression.And(t => t.OrganizeId != keyValue);
- }
- return this.BaseRepository().IQueryable(expression).Count() == 0 ? true : false;
- }
- /// <summary>
- /// 中文名称不能重复
- /// </summary>
- /// <param name="shortName">中文名称</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public bool ExistShortName(string shortName, string keyValue)
- {
- var expression = LinqExtensions.True<OrganizeEntity>();
- expression = expression.And(t => t.ShortName == shortName);
- if (!string.IsNullOrEmpty(keyValue))
- {
- expression = expression.And(t => t.OrganizeId != keyValue);
- }
- return this.BaseRepository().IQueryable(expression).Count() == 0 ? true : false;
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 删除机构
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void RemoveForm(string keyValue)
- {
- int count = this.BaseRepository().IQueryable(t => t.ParentId == keyValue).Count();
- if (count > 0)
- {
- throw new Exception("当前所选数据有子节点数据!");
- }
- this.BaseRepository().Delete(keyValue);
- }
- /// <summary>
- /// 保存机构表单(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <param name="organizeEntity">机构实体</param>
- /// <returns></returns>
- public void SaveForm(string keyValue, OrganizeEntity organizeEntity)
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- organizeEntity.Modify(keyValue);
- this.BaseRepository().Update(organizeEntity);
- }
- else
- {
- organizeEntity.Create();
- this.BaseRepository().Insert(organizeEntity);
- }
- }
- #endregion
- }
- }
|