1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using AutoMapper;
- using Datory;
- using GxPress.Common.AppOptions;
- using GxPress.Common.Tools;
- using GxPress.Repository.Interface.Analyze;
- using Microsoft.Extensions.Options;
- using SqlKata;
- namespace GxPress.Repository.Implement.Analyze
- {
- /// <summary>
- /// 分析
- /// </summary>
- public class AnalyzeRepository : IAnalyzeRepository
- {
- private readonly Repository<Entity.Analyze.Analyze> _repository;
- private readonly IMapper _mapper;
- public AnalyzeRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
- {
- var databaseType = StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
- var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
- _repository = new Repository<Entity.Analyze.Analyze>(database);
- _mapper = mapper;
- }
- public IDatabase Database => _repository.Database;
- public string TableName => _repository.TableName;
- public List<TableColumn> TableColumns => _repository.TableColumns;
- public async Task<Entity.Analyze.Analyze> GetAsync(Query query)
- {
- return await _repository.GetAsync(query);
- }
- public async Task<bool> DeleteAsync(int id)
- {
- return await _repository.DeleteAsync(id);
- }
- public async Task<int> CountAsync(Query query)
- {
- return await _repository.CountAsync(query);
- }
- public async Task<bool> DeleteAsync(SqlKata.Query query)
- {
- return await _repository.DeleteAsync(query) > 0;
- }
- public async Task<int> InsertAsync(Entity.Analyze.Analyze analyze)
- {
- return await _repository.InsertAsync(analyze);
- }
- public async Task<IEnumerable<Entity.Analyze.Analyze>> GetAllAsync(Query query)
- {
- return await _repository.GetAllAsync(query);
- }
- public async Task<bool> ExistsAsync(Query query)
- {
- return await _repository.ExistsAsync(query);
- }
- }
- }
|