|
@@ -0,0 +1,158 @@
|
|
|
+using AutoMapper;
|
|
|
+using EyeSoft.Extensions;
|
|
|
+using OASystem.Domain.Dtos.Resource;
|
|
|
+using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Domain.Entities.Resource;
|
|
|
+using OASystem.Domain.ViewModels.Resource;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 世运会成本预算 仓储
|
|
|
+ /// </summary>
|
|
|
+ public class GamesBudgetMasterRepository : BaseRepository<Grp_GamesBudgetMaster, Grp_GamesBudgetMaster>
|
|
|
+ {
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly JsonView _jv;
|
|
|
+ public GamesBudgetMasterRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
|
|
|
+ {
|
|
|
+ _mapper = mapper;
|
|
|
+ _jv = new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "操作失败!" };
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// List
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JsonView> ListAsync(GamesBudgetMasterListDto dto)
|
|
|
+ {
|
|
|
+ _jv.Msg = "暂无数据!";
|
|
|
+ var search = dto.Search;
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+ var infos = await _sqlSugar.Queryable<Grp_GamesBudgetMaster>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(search), x => x.T0.Contains(search) || x.ProjectWork.Contains(search) || x.CalculationContent.Contains(search))
|
|
|
+ .OrderByDescending(x => x.CreateTime)
|
|
|
+ .Select<GamesBudgetMasterListView>()
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+
|
|
|
+ _jv.Code = StatusCodes.Status200OK;
|
|
|
+ _jv.Msg = $"操作成功!";
|
|
|
+ _jv.Data = infos;
|
|
|
+ _jv.Count = total;
|
|
|
+
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JsonView> InfoAsync(int id)
|
|
|
+ {
|
|
|
+ _jv.Msg = "暂无数据!";
|
|
|
+ var info = await _sqlSugar.Queryable<Grp_GamesBudgetMaster>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.Id == id)
|
|
|
+ .Select<GamesBudgetMasterInfoView>()
|
|
|
+ .FirstAsync();
|
|
|
+ if (info != null)
|
|
|
+ {
|
|
|
+ _jv.Code = StatusCodes.Status200OK;
|
|
|
+ _jv.Msg = $"操作成功!";
|
|
|
+ _jv.Data = info;
|
|
|
+ }
|
|
|
+
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 添加
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JsonView> AddAsync(GamesBudgetMasterAddDto dto)
|
|
|
+ {
|
|
|
+ var info = _mapper.Map<Grp_GamesBudgetMaster>(dto);
|
|
|
+
|
|
|
+ var isNl = await _sqlSugar.Queryable<Grp_GamesBudgetMaster>()
|
|
|
+ .FirstAsync(x => x.IsDel == 0 &&
|
|
|
+ (x.T0.Equals(info.T0) ||
|
|
|
+ x.ProjectWork.Equals (info.ProjectWork) ||
|
|
|
+ x.CalculationContent.Equals(info.CalculationContent)));
|
|
|
+ if (isNl != null)
|
|
|
+ {
|
|
|
+ _jv.Msg = "该项类型费用已存在,请勿重复添加!";
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
+ info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ info.LastUpdateUserId = dto.CurrUserId;
|
|
|
+ info.CreateTime = DateTime.Now;
|
|
|
+ info.CreateUserId = dto.CurrUserId;
|
|
|
+
|
|
|
+ var insert = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
|
|
|
+ if (insert > 0)
|
|
|
+ {
|
|
|
+ _jv.Msg = "操作成功!";
|
|
|
+ _jv.Code = StatusCodes.Status200OK;
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 编辑
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JsonView> EditAsync(GamesBudgetMasterEditDto dto)
|
|
|
+ {
|
|
|
+ var info = _mapper.Map<Grp_GamesBudgetMaster>(dto);
|
|
|
+
|
|
|
+ info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ info.LastUpdateUserId = dto.CurrUserId;
|
|
|
+
|
|
|
+ var edit = await _sqlSugar.Updateable(info)
|
|
|
+ .IgnoreColumns(x => new { x.CreateTime, x.CreateUserId, x.DeleteTime, x.DeleteUserId, x.IsDel })
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+
|
|
|
+ if (edit > 0)
|
|
|
+ {
|
|
|
+ _jv.Msg = "操作成功!";
|
|
|
+ _jv.Code = StatusCodes.Status200OK;
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<JsonView> DelAsync(GamesBudgetMasterDelDto dto)
|
|
|
+ {
|
|
|
+ var del = await _sqlSugar.Updateable<Grp_GamesBudgetMaster>()
|
|
|
+ .SetColumns(x => x.DeleteUserId == dto.CurrUserId)
|
|
|
+ .SetColumns(x => x.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
|
|
|
+ .SetColumns(x => x.IsDel == 1)
|
|
|
+ .Where(x => x.Id == dto.Id)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+
|
|
|
+ if (del > 0)
|
|
|
+ {
|
|
|
+ _jv.Msg = "操作成功!";
|
|
|
+ _jv.Code = StatusCodes.Status200OK;
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+ return _jv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|