12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using AutoMapper;
- using Datory;
- using GxPress.Common.AppOptions;
- using GxPress.Common.Tools;
- using GxPress.Entity.WaitHandle;
- using GxPress.Repository.Interface.WaitHandle;
- using Microsoft.Extensions.Options;
- using SqlKata;
- namespace GxPress.Repository.Implement.WaitHandle
- {
- public class WaitHandleLabelRepository: IWaitHandleLabelRepository
- {
- private readonly Repository<WaitHandleLabel> _repository;
- private readonly IMapper _mapper;
- public WaitHandleLabelRepository(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<WaitHandleLabel>(database);
- _mapper = mapper;
- }
- public IDatabase Database => _repository.Database;
- public string TableName => _repository.TableName;
- public List<TableColumn> TableColumns => _repository.TableColumns;
- public async Task<int> InsertAsync(WaitHandleLabel waitHandleLabel)
- {
- return await _repository.InsertAsync(waitHandleLabel);
- }
- public async Task<bool> UpdateAsync(WaitHandleLabel waitHandleLabel)
- {
- return await _repository.UpdateAsync(waitHandleLabel);
- }
- public async Task<bool> UpdateAsync(Query query)
- {
- return await _repository.UpdateAsync(query)>0;
- }
- public async Task<bool> DeleteAsync(int id)
- {
- return await _repository.DeleteAsync(id);
- }
- public async Task<bool> DeleteAsync(Query query)
- {
- return await _repository.DeleteAsync(query)>0;
- }
- public async Task<WaitHandleLabel> GetAsync(Query query)
- {
- return await _repository.GetAsync(query);
- }
- public async Task<WaitHandleLabel> GetAsync(int id)
- {
- return await _repository.GetAsync(id);
- }
- public async Task<IEnumerable<WaitHandleLabel>> GetAllAsync(Query query)
- {
- return await _repository.GetAllAsync(query);
- }
- public async Task<int> CountAsync(Query query)
- {
- return await _repository.CountAsync(query);
- }
- }
- }
|