BUG

parent 2b09ff8d
...@@ -8,6 +8,7 @@ namespace Performance.DtoModels ...@@ -8,6 +8,7 @@ namespace Performance.DtoModels
{ {
public class SetAssessRequest public class SetAssessRequest
{ {
public int AllotID { get; set; }
public int AssessID { get; set; } public int AssessID { get; set; }
public List<string> Department { get; set; } public List<string> Department { get; set; }
} }
...@@ -16,6 +17,7 @@ public class SetAssessRequestValidator : AbstractValidator<SetAssessRequest> ...@@ -16,6 +17,7 @@ public class SetAssessRequestValidator : AbstractValidator<SetAssessRequest>
{ {
public SetAssessRequestValidator() public SetAssessRequestValidator()
{ {
RuleFor(t => t.AllotID).NotNull().GreaterThan(0);
RuleFor(t => t.AssessID).NotNull().GreaterThan(0); RuleFor(t => t.AssessID).NotNull().GreaterThan(0);
RuleFor(t => t.Department).NotNull().Must(p => RuleFor(t => t.Department).NotNull().Must(p =>
{ {
......
...@@ -22,6 +22,11 @@ public class as_data ...@@ -22,6 +22,11 @@ public class as_data
public int ID { get; set; } public int ID { get; set; }
/// <summary> /// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 考核类别ID /// 考核类别ID
/// </summary> /// </summary>
public Nullable<int> AssessID { get; set; } public Nullable<int> AssessID { get; set; }
......
...@@ -94,11 +94,20 @@ public ApiResponse SetAssessType(SetAssessRequest request) ...@@ -94,11 +94,20 @@ public ApiResponse SetAssessType(SetAssessRequest request)
if (entity == null) if (entity == null)
return new ApiResponse(ResponseType.Fail, "考核类别ID无效"); return new ApiResponse(ResponseType.Fail, "考核类别ID无效");
var entities = perforAsdataRepository.GetEntities(t => t.AssessID == request.AssessID && request.Department.Contains(t.Department)); var entities = perforAsdataRepository.GetEntities(t => t.AllotID == request.AllotID);
if (entities != null && entities.Count > 0) if (entities != null)
return new ApiResponse(ResponseType.Fail, "科室考核类别重复分配", entities.Select(t => t.Department)); {
//保留共有
var addList = request.Department.Select(t => new as_data { AssessID = request.AssessID, Department = t }).ToArray(); var intersectList = entities.Where(t => t.AssessID == request.AssessID).Select(t => t.Department).Intersect(request.Department).ToList();
if (intersectList != null && intersectList.Count() > 0)
intersectList.ForEach(t => request.Department.Remove(t));
//删除更改
var removeList = perforAsdataRepository.GetEntities(t => intersectList.Contains(t.Department));
if (removeList != null && removeList.Count() > 0)
perforAsdataRepository.RemoveRange(removeList.ToArray());
}
//添加新增
var addList = request.Department.Select(t => new as_data { AllotID = request.AllotID, AssessID = request.AssessID, Department = t }).ToArray();
var result = perforAsdataRepository.AddRange(addList); var result = perforAsdataRepository.AddRange(addList);
return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail); return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail);
......
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