1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using AutoMapper;
- using OASystem.Domain;
- 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
- {
- public class AskDataRepository : BaseRepository<Res_AskData, QueryAskDataDto>
- {
- private readonly IMapper _mapper;
- public AskDataRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
- {
- _mapper = mapper;
- }
- public async Task<Result> QueryAskData(QueryAskDataDto dto)
- {
- Result result = new Result() { Code = -2, Msg = "未知错误" };
- try
- {
- string sqlWhere = string.Empty;
- if (!string.IsNullOrWhiteSpace(dto.Country))
- {
- sqlWhere += string.Format(@"And Country like '%{0}%'", dto.Country);
- }
- if (!string.IsNullOrWhiteSpace(dto.Area))
- {
- sqlWhere += string.Format(@"And Area like '%{0}%'", dto.Area);
- }
- if (!string.IsNullOrWhiteSpace(dto.Field))
- {
- sqlWhere += string.Format(@"And Field like '%{0}%'", dto.Field);
- }
- sqlWhere += string.Format(@"And IsDel={0}", 0);
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
- {
- Regex r = new Regex("And");
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
- }
- string sql = string.Format(@"select * from Res_AskData {0}", sqlWhere);
- List<Res_AskData> askDatd = await _sqlSugar.SqlQueryable<Res_AskData>(sql).ToListAsync();
- List<Grp_DelegationInfo> delegationInfo=await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a=>a.IsDel==0).ToListAsync();
- if (askDatd.Count != 0 && delegationInfo.Count!=0)
- {
- result = new Result() { Code = 0, Msg = "查询成功!", Data = new { askDatd= askDatd, delegationInfo= delegationInfo } };
- }
- else
- {
- result = new Result() { Code = 0, Msg = "暂无数据!", Data = new { askDatd = askDatd, delegationInfo = delegationInfo } };
- }
- }
- catch (Exception ex)
- {
- result = new Result() { Code = -2, Msg = "未知错误" };
- }
- return result;
- }
- }
- }
|