161 lines
4.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Learun.Util;
using Learun.Util.SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Learun.Application.Organization
{
/// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM
/// 创建人:研发部
/// 日 期2017.04.17
/// 描 述:公司管理
/// </summary>
public class CompanyService
{
#region
Repository<CompanyEntity> _companyRepository => new Repository<CompanyEntity>();
#endregion
#region
private string fieldSql;
public CompanyService()
{
fieldSql = @"
t.F_CompanyId,
t.F_Category,
t.F_ParentId,
t.F_EnCode,
t.F_ShortName,
t.F_FullName,
t.F_Nature,
t.F_OuterPhone,
t.F_InnerPhone,
t.F_Fax,
t.F_Postalcode,
t.F_Email,
t.F_Manager,
t.F_ProvinceId,
t.F_CityId,
t.F_CountyId,
t.F_Address,
t.F_WebAddress,
t.F_FoundedTime,
t.F_BusinessScope,
t.F_SortCode,
t.F_DeleteMark,
t.F_EnabledMark,
t.F_Description,
t.F_CreateDate,
t.F_CreateUserId,
t.F_CreateUserName,
t.F_ModifyDate,
t.F_ModifyUserId,
t.F_ModifyUserName
";
}
#endregion
#region
/// <summary>
/// 获取公司列表信息(全部)
/// </summary>
/// <returns></returns>
public List<CompanyEntity> GetList()
{
try
{
//var strSql = new StringBuilder();
//strSql.Append("SELECT ");
//strSql.Append(fieldSql);
//strSql.Append(" FROM LR_Base_Company t WHERE t.F_EnabledMark = 1 AND t.F_DeleteMark = 0 ORDER BY t.F_ParentId,t.F_EnCode ");
//return this.BaseRepository().FindList<CompanyEntity>(strSql.ToString());
var res = _companyRepository.GetList().Where(x => x.F_EnabledMark == 1 && x.F_DeleteMark == 0).
OrderBy(x => x.F_ParentId).OrderBy(x => x.F_EnCode);
return res.ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region
/// <summary>
/// 虚拟删除公司
/// </summary>
/// <param name="keyValue">主键</param>
public void VirtualDelete(string keyValue)
{
try
{
CompanyEntity entity = new CompanyEntity()
{
F_CompanyId = keyValue,
F_DeleteMark = 1
};
_companyRepository.Update(entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
/// <summary>
/// 保存公司表单(新增、修改)
/// </summary>
/// <param name="keyValue">主键值</param>
/// <param name="companyEntity">公司实体</param>
/// <returns></returns>
public void SaveEntity(string keyValue, CompanyEntity companyEntity)
{
try
{
if (!string.IsNullOrEmpty(keyValue))
{
companyEntity.Modify(keyValue);
_companyRepository.Update(companyEntity);
}
else
{
companyEntity.Create();
_companyRepository.Insert(companyEntity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
}
}