Commit 1e3f69cb by 李承祥

基础配置接口

parent 5e8f6891
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.Infrastructure;
using Performance.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api.Controllers
{
[Route("api/[controller]")]
public class ConfigController : Controller
{
private ConfigService _configService;
public ConfigController(ConfigService configService)
{
_configService = configService;
}
#region director
/// <summary>
/// 获取director列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("directorlist")]
[HttpPost]
public ApiResponse<List<DirectorResponse>> GetDireList([FromBody]ApiRequest request)
{
var list = _configService.GetDireList();
return new ApiResponse<List<DirectorResponse>>(ResponseType.OK, "ok", list);
}
/// <summary>
/// 添加数据 director
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("direinsert")]
[HttpPost]
public ApiResponse<DirectorResponse> DireInsert([FromBody]DirectorRequest request)
{
var director = _configService.DireInsert(request);
return new ApiResponse<DirectorResponse>(ResponseType.OK, director);
}
/// <summary>
/// 更新数据 director
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("direupdate")]
[HttpPost]
public ApiResponse<DirectorResponse> DireUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]DirectorRequest request)
{
var director = _configService.DireUpdate(request);
return new ApiResponse<DirectorResponse>(ResponseType.OK, director);
}
/// <summary>
/// 删除数据 director
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("diredelete")]
[HttpPost]
public ApiResponse DireDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]DirectorRequest request)
{
if (!_configService.DireDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
#region drugprop
[Route("drugproplist")]
[HttpPost]
public ApiResponse<List<DrugpropResponse>> GetDrugList([FromBody]ApiRequest request)
{
var list = _configService.GetDrugList();
return new ApiResponse<List<DrugpropResponse>>(ResponseType.OK, "ok", list);
}
[Route("druginsert")]
[HttpPost]
public ApiResponse<DrugpropResponse> DrugInsert([FromBody]DrugpropRequest request)
{
var drugprop = _configService.DrugInsert(request);
return new ApiResponse<DrugpropResponse>(ResponseType.OK, drugprop);
}
[Route("drugupdate")]
[HttpPost]
public ApiResponse<DrugpropResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody]DrugpropRequest request)
{
var drugprop = _configService.DrugUpdate(request);
return new ApiResponse<DrugpropResponse>(ResponseType.OK, drugprop);
}
[Route("drugdelete")]
[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]DrugpropRequest request)
{
if (!_configService.DrugDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
#region income
[Route("incomelist")]
[HttpPost]
public ApiResponse<List<IncomeResponse>> GetIncomeList([FromBody]ApiRequest request)
{
var list = _configService.GetIncomeList();
return new ApiResponse<List<IncomeResponse>>(ResponseType.OK, "ok", list);
}
[Route("incomeinsert")]
[HttpPost]
public ApiResponse<IncomeResponse> Insert([FromBody]IncomeRequest request)
{
var income = _configService.IncomeInsert(request);
return new ApiResponse<IncomeResponse>(ResponseType.OK, income);
}
[Route("incomeupdate")]
[HttpPost]
public ApiResponse<IncomeResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody]IncomeRequest request)
{
var income = _configService.IncomeUpdate(request);
return new ApiResponse<IncomeResponse>(ResponseType.OK, income);
}
[Route("incomedelete")]
[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]IncomeRequest request)
{
if (!_configService.IncomeDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
#region position
[Route("positionlist")]
[HttpPost]
public ApiResponse<List<PositionResponse>> GetPositionList([FromBody]ApiRequest request)
{
var list = _configService.GetPositionList();
return new ApiResponse<List<PositionResponse>>(ResponseType.OK, "ok", list);
}
[Route("posinsert")]
[HttpPost]
public ApiResponse<PositionResponse> PositionInsert([FromBody]PositionRequest request)
{
var position = _configService.PositionInsert(request);
return new ApiResponse<PositionResponse>(ResponseType.OK, position);
}
[Route("posupdate")]
[HttpPost]
public ApiResponse<PositionResponse> PositionUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]PositionRequest request)
{
var position = _configService.PositionUpdate(request);
return new ApiResponse<PositionResponse>(ResponseType.OK, position);
}
[Route("posdelete")]
[HttpPost]
public ApiResponse PositionDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]PositionRequest request)
{
if (!_configService.PositionDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
#region workyear
[Route("workyearlist")]
[HttpPost]
public ApiResponse<List<WorkyearResponse>> GetWorkList([FromBody]ApiRequest request)
{
var list = _configService.GetWorkList();
return new ApiResponse<List<WorkyearResponse>>(ResponseType.OK, "ok", list);
}
[Route("workinsert")]
[HttpPost]
public ApiResponse<WorkyearResponse> WorkyearInsert([FromBody]WorkyearRequest request)
{
var workyear = _configService.WorkInsert(request);
return new ApiResponse<WorkyearResponse>(ResponseType.OK, workyear);
}
[Route("workupdate")]
[HttpPost]
public ApiResponse<WorkyearResponse> WorkyearUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]WorkyearRequest request)
{
var workyear = _configService.WorkUpdate(request);
return new ApiResponse<WorkyearResponse>(ResponseType.OK, workyear);
}
[Route("workdelete")]
[HttpPost]
public ApiResponse WorkyearDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]WorkyearRequest request)
{
if (!_configService.WorkDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
}
}
\ No newline at end of file
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" /> <PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" /> <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
......
...@@ -55,16 +55,16 @@ public enum EmpolyeeType ...@@ -55,16 +55,16 @@ public enum EmpolyeeType
/// <summary> 行政中层 </summary> /// <summary> 行政中层 </summary>
[Description("行政中层")] [Description("行政中层")]
MiddleManage = 2, MiddleManage = 2,
/// <summary> 行政中层 </summary> /// <summary> 行政工勤 </summary>
[Description("行政工勤")] [Description("行政工勤")]
LogisticsWorkers = 3, LogisticsWorkers = 3,
/// <summary> 行政中层 </summary> /// <summary> 临床科室主任 </summary>
[Description("临床科室主任")] [Description("临床科室主任")]
Director = 4, Director = 4,
/// <summary> 行政中层 </summary> /// <summary> 临床科室副主任 </summary>
[Description("临床科室副主任")] [Description("临床科室副主任")]
DeputyDirector = 5, DeputyDirector = 5,
/// <summary> 行政中层 </summary> /// <summary> 临床科室护士长 </summary>
[Description("临床科室护士长")] [Description("临床科室护士长")]
Nurse = 6, Nurse = 6,
} }
......
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class DirectorRequest : ApiRequest
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public string TypeName { get; set; }
public string JobTitle { get; set; }
public Nullable<decimal> Value { get; set; }
public class DirectorRequestValidator : AbstractValidator<DirectorRequest>
{
public DirectorRequestValidator()
{
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class DrugpropRequest : ApiRequest
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public Nullable<decimal> MaxRange { get; set; }
public Nullable<decimal> MinRange { get; set; }
public Nullable<decimal> Value { get; set; }
public class DrugpropRequestValidator : AbstractValidator<DrugpropRequest>
{
public DrugpropRequestValidator()
{
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class IncomeRequest : ApiRequest
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public string SheetNameKeyword { get; set; }
public string UnitName { get; set; }
public Nullable<decimal> Value { get; set; }
public class IncomeRequestValidator : AbstractValidator<IncomeRequest>
{
public IncomeRequestValidator()
{
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class PositionRequest : ApiRequest
{
public int ID { get; set; }
/// <summary>
/// 绩效ID
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 职位名称
/// </summary>
public string JobTitle { get; set; }
/// <summary>
/// 职位归类 1 院领导 2 行政中层 3 行政工勤 4 临床科室主任 5 临床科室副主任 6 临床科室护士长
/// </summary>
public Nullable<int> JobType { get; set; }
/// <summary>
/// 额外补偿系数
/// </summary>
public Nullable<decimal> ExtraFactor { get; set; }
/// <summary>
/// 职位类别 1 普通类别 2 基础绩效来源
/// </summary>
public Nullable<int> State { get; set; }
public class PositionRequestValidator : AbstractValidator<PositionRequest>
{
public PositionRequestValidator()
{
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class WorkyearRequest : ApiRequest
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public Nullable<decimal> MaxRange { get; set; }
public Nullable<decimal> MinRange { get; set; }
public Nullable<decimal> Value { get; set; }
public class WorkyearRequestValidator : AbstractValidator<WorkyearRequest>
{
public WorkyearRequestValidator()
{
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class DirectorResponse
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public string TypeName { get; set; }
public string JobTitle { get; set; }
public Nullable<decimal> Value { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class DrugpropResponse
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public Nullable<decimal> MaxRange { get; set; }
public Nullable<decimal> MinRange { get; set; }
public Nullable<decimal> Value { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class IncomeResponse
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public string SheetNameKeyword { get; set; }
public string UnitName { get; set; }
public Nullable<decimal> Value { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class PositionResponse
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public string JobTitle { get; set; }
public Nullable<int> JobType { get; set; }
public Nullable<decimal> ExtraFactor { get; set; }
public Nullable<int> State { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class WorkyearResponse
{
public int ID { get; set; }
public Nullable<int> AllotID { get; set; }
public Nullable<decimal> MaxRange { get; set; }
public Nullable<decimal> MinRange { get; set; }
public Nullable<decimal> Value { get; set; }
}
}
...@@ -32,6 +32,7 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -32,6 +32,7 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<cof_director> Cof_Director { get; set; } public virtual DbSet<cof_director> Cof_Director { get; set; }
public virtual DbSet<res_baiscnorm> Res_Baiscnorm { get; set; } public virtual DbSet<res_baiscnorm> Res_Baiscnorm { get; set; }
public virtual DbSet<res_compute> Res_Compute { get; set; } public virtual DbSet<res_compute> Res_Compute { get; set; }
public virtual DbSet<cof_position> Dic_Position { get; set; } public virtual DbSet<cof_position> Cof_Position { get; set; }
public virtual DbSet<cof_workyear> Cof_Workyear { get; set; }
} }
} }
...@@ -23,6 +23,11 @@ public class cof_director ...@@ -23,6 +23,11 @@ public class cof_director
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
///
/// </summary>
public string TypeName { get; set; } public string TypeName { get; set; }
/// <summary> /// <summary>
......
...@@ -21,6 +21,11 @@ public class cof_income ...@@ -21,6 +21,11 @@ public class cof_income
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 关键字匹配 /// 关键字匹配
/// </summary> /// </summary>
public string SheetNameKeyword { get; set; } public string SheetNameKeyword { get; set; }
......
...@@ -21,6 +21,11 @@ public class cof_position ...@@ -21,6 +21,11 @@ public class cof_position
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
/// 绩效id
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 职位名称 /// 职位名称
/// </summary> /// </summary>
public string JobTitle { get; set; } public string JobTitle { get; set; }
...@@ -31,6 +36,11 @@ public class cof_position ...@@ -31,6 +36,11 @@ public class cof_position
public Nullable<int> JobType { get; set; } public Nullable<int> JobType { get; set; }
/// <summary> /// <summary>
/// 额外补偿系数
/// </summary>
public Nullable<decimal> ExtraFactor { get; set; }
/// <summary>
/// 职位类别 1 普通类别 2 基础绩效来源 /// 职位类别 1 普通类别 2 基础绩效来源
/// </summary> /// </summary>
public Nullable<int> State { get; set; } public Nullable<int> State { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" cof_income.cs">
// * FileName: cof_workyear.cs
// * history : 2019-03-25 13:10:58
// </copyright>
//
using System;
using System.ComponentModel.DataAnnotations;
namespace Performance.EntityModels
{
/// <summary>
/// cof_workyear Entity Model
/// </summary>
public class cof_workyear
{
/// <summary>
/// ID
/// </summary>
[Key]
public int ID { get; set; }
/// <summary>
/// 绩效id
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> MaxRange { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> MinRange { get; set; }
/// <summary>
///
/// </summary>
public Nullable<decimal> Value { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" dic_position.cs">
// * FileName: cof_workyear.cs
// * history : Created by T4 2019-03-25 13:14:55
// </copyright>
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
public class PerforCofworkyearRepository : PerforRepository<cof_workyear>
{
public PerforCofworkyearRepository(PerformanceDbContext context) : base(context)
{
}
}
}
using AutoMapper;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Services
{
public class ConfigService : IAutoInjection
{
private PerforCofdirectorRepository _directorRepository;
private PerforCofdrugpropRepository _drugpropRepository;
private PerforCofincomeRepository _incomeRepository;
private PerforCofpositionRepository _positionRepository;
private PerforCofworkyearRepository _workyearRepository;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofincomeRepository cofincomeRepository,
PerforCofpositionRepository cofpositionRepository,
PerforCofworkyearRepository cofworkyearRepository)
{
this._directorRepository = cofdirectorRepository;
this._drugpropRepository = cofdrugpropRepository;
this._incomeRepository = cofincomeRepository;
this._positionRepository = cofpositionRepository;
this._workyearRepository = cofworkyearRepository;
}
#region cof_director
/// <summary>
/// 获取cof_director列表
/// </summary>
/// <returns></returns>
public List<DirectorResponse> GetDireList()
{
var list = _directorRepository.GetEntities();
return Mapper.Map<List<DirectorResponse>>(list);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DirectorResponse DireInsert(DirectorRequest request)
{
var director = Mapper.Map<cof_director>(request);
if (!_directorRepository.Add(director))
throw new PerformanceException("保存失败");
return Mapper.Map<DirectorResponse>(director);
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DirectorResponse DireUpdate(DirectorRequest request)
{
var director = _directorRepository.GetEntity(t => t.ID == request.ID);
if (null == director)
throw new PerformanceException($"ID不存在 :{request.ID}");
director.TypeName = request.TypeName;
director.JobTitle = request.JobTitle;
director.Value = request.Value;
if (!_directorRepository.Update(director))
throw new PerformanceException("保存失败");
return Mapper.Map<DirectorResponse>(director);
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool DireDelete(DirectorRequest request)
{
var director = _directorRepository.GetEntity(t => t.ID == request.ID);
if (null == director)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _directorRepository.Remove(director);
}
#endregion
#region cof_drugprop
/// <summary>
/// 获取cof_drugprop列表
/// </summary>
/// <returns></returns>
public List<DrugpropResponse> GetDrugList()
{
var list = _drugpropRepository.GetEntities();
return Mapper.Map<List<DrugpropResponse>>(list);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DrugpropResponse DrugInsert(DrugpropRequest request)
{
var drugprop = Mapper.Map<cof_drugprop>(request);
if (!_drugpropRepository.Add(drugprop))
throw new PerformanceException("保存失败");
return Mapper.Map<DrugpropResponse>(drugprop);
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DrugpropResponse DrugUpdate(DrugpropRequest request)
{
var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
if (null == drugprop)
throw new PerformanceException($"ID不存在 :{request.ID}");
drugprop.MaxRange = request.MaxRange;
drugprop.MinRange = request.MinRange;
drugprop.Value = request.Value;
if (!_drugpropRepository.Update(drugprop))
throw new PerformanceException("保存失败");
return Mapper.Map<DrugpropResponse>(drugprop);
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool DrugDelete(DrugpropRequest request)
{
var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
if (null == drugprop)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _drugpropRepository.Remove(drugprop);
}
#endregion
#region cof_income
/// <summary>
/// 获取cof_income列表
/// </summary>
/// <returns></returns>
public List<IncomeResponse> GetIncomeList()
{
var list = _incomeRepository.GetEntities();
return Mapper.Map<List<IncomeResponse>>(list);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public IncomeResponse IncomeInsert(IncomeRequest request)
{
var income = Mapper.Map<cof_income>(request);
if (!_incomeRepository.Add(income))
throw new PerformanceException("保存失败");
return Mapper.Map<IncomeResponse>(income);
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public IncomeResponse IncomeUpdate(IncomeRequest request)
{
var income = _incomeRepository.GetEntity(t => t.ID == request.ID);
if (null == income)
throw new PerformanceException($"ID不存在 :{request.ID}");
income.SheetNameKeyword = request.SheetNameKeyword;
income.UnitName = request.UnitName;
income.Value = request.Value;
if (!_incomeRepository.Update(income))
throw new PerformanceException("保存失败");
return Mapper.Map<IncomeResponse>(income);
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool IncomeDelete(IncomeRequest request)
{
var income = _incomeRepository.GetEntity(t => t.ID == request.ID);
if (null == income)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _incomeRepository.Remove(income);
}
#endregion
#region cof_position
/// <summary>
/// 获取cof_position列表
/// </summary>
/// <returns></returns>
public List<PositionResponse> GetPositionList()
{
var list = _positionRepository.GetEntities();
return Mapper.Map<List<PositionResponse>>(list);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public PositionResponse PositionInsert(PositionRequest request)
{
var position = Mapper.Map<cof_position>(request);
if (!_positionRepository.Add(position))
throw new PerformanceException("保存失败");
return Mapper.Map<PositionResponse>(position);
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public PositionResponse PositionUpdate(PositionRequest request)
{
var position = _positionRepository.GetEntity(t => t.ID == request.ID);
if (null == position)
throw new PerformanceException($"ID不存在 :{request.ID}");
position.JobTitle = request.JobTitle;
position.JobType = request.JobType;
position.ExtraFactor = request.ExtraFactor;
position.State = request.State;
if (!_positionRepository.Update(position))
throw new PerformanceException("保存失败");
return Mapper.Map<PositionResponse>(position);
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool PositionDelete(PositionRequest request)
{
var position = _positionRepository.GetEntity(t => t.ID == request.ID);
if (null == position)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _positionRepository.Remove(position);
}
#endregion
#region cof_workyear
/// <summary>
/// 获取cof_drugprop列表
/// </summary>
/// <returns></returns>
public List<WorkyearResponse> GetWorkList()
{
var list = _workyearRepository.GetEntities();
return Mapper.Map<List<WorkyearResponse>>(list);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public WorkyearResponse WorkInsert(WorkyearRequest request)
{
var workyear = Mapper.Map<cof_workyear>(request);
if (!_workyearRepository.Add(workyear))
throw new PerformanceException("保存失败");
return Mapper.Map<WorkyearResponse>(workyear);
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public WorkyearResponse WorkUpdate(WorkyearRequest request)
{
var workyear = _workyearRepository.GetEntity(t => t.ID == request.ID);
if (null == workyear)
throw new PerformanceException($"ID不存在 :{request.ID}");
workyear.MaxRange = request.MaxRange;
workyear.MinRange = request.MinRange;
workyear.Value = request.Value;
if (!_workyearRepository.Update(workyear))
throw new PerformanceException("保存失败");
return Mapper.Map<WorkyearResponse>(workyear);
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool WorkDelete(WorkyearRequest request)
{
var workyear = _workyearRepository.GetEntity(t => t.ID == request.ID);
if (null == workyear)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _workyearRepository.Remove(workyear);
}
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment