添加项目文件。
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using JY.DAL.Repository;
|
||||
using JY.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace JY.DAL.Service
|
||||
{
|
||||
public interface IAlarmDataService : IService<AlarmData>
|
||||
{
|
||||
List<AlarmData> GetAlarmDataByTime(string startTime, string endTime);
|
||||
|
||||
List<AlarmData> GetAlarmCacheData();
|
||||
|
||||
int DeleteAlarmCacheData();
|
||||
}
|
||||
|
||||
public class AlarmDataService : Service<AlarmData>, IAlarmDataService
|
||||
{
|
||||
public AlarmDataService(IRepository<AlarmData> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
|
||||
public List<AlarmData> GetAlarmDataByTime(string startTime, string endTime)
|
||||
{
|
||||
return _repository.GetList(x => x.StartTime >= Convert.ToDateTime(startTime) && x.StartTime <= Convert.ToDateTime(endTime));
|
||||
}
|
||||
|
||||
public List<AlarmData> GetAlarmCacheData()
|
||||
{
|
||||
return _repository.GetList(x => x.Flag == 0);
|
||||
}
|
||||
|
||||
public int DeleteAlarmCacheData()
|
||||
{
|
||||
return _repository.Delete(x => x.Flag == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using JY.DAL.Repository;
|
||||
using JY.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JY.DAL.Service
|
||||
{
|
||||
public interface IBlankingDataService : IService<BlankingData>
|
||||
{
|
||||
int AddBlankData(BlankingData data);
|
||||
}
|
||||
public class BlankingDataService : Service<BlankingData>, IBlankingDataService
|
||||
{
|
||||
public BlankingDataService(IRepository<BlankingData> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
|
||||
public int AddBlankData(BlankingData data)
|
||||
{
|
||||
return _repository.Insert(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using JY.DAL.Repository;
|
||||
using JY.Model;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JY.DAL.Service
|
||||
{
|
||||
public interface IFeedingDataService : IService<FeedingData>
|
||||
{
|
||||
List<FeedingData> GetFeedingData(string barCode);
|
||||
|
||||
int AddFeedingData(FeedingData data);
|
||||
}
|
||||
|
||||
public class FeedingDataService : Service<FeedingData>, IFeedingDataService
|
||||
{
|
||||
public FeedingDataService(IRepository<FeedingData> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
|
||||
public List<FeedingData> GetFeedingData(string barCode)
|
||||
{
|
||||
return _repository.GetList(x => x.BarCode == barCode);
|
||||
}
|
||||
|
||||
public int AddFeedingData(FeedingData data)
|
||||
{
|
||||
return _repository.Insert(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace JY.DAL.Service
|
||||
{
|
||||
public interface IService<T> where T : class, new()
|
||||
{
|
||||
T GetById(object id);
|
||||
|
||||
T GetSingle(Expression<Func<T, bool>> predicate);
|
||||
|
||||
List<T> GetList();
|
||||
|
||||
List<T> GetList(Expression<Func<T, bool>> predicate);
|
||||
|
||||
List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null);
|
||||
|
||||
int Insert(T entity);
|
||||
|
||||
int Insert(List<T> entities);
|
||||
|
||||
int Update(T entity);
|
||||
|
||||
int Update(T entity, Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
int Delete(object id);
|
||||
|
||||
int Delete(Expression<Func<T, bool>> predicate);
|
||||
|
||||
int Delete(List<T> entities);
|
||||
|
||||
bool Any(Expression<Func<T, bool>> predicate);
|
||||
|
||||
int Count(Expression<Func<T, bool>> predicate = null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using JY.DAL.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace JY.DAL.Service
|
||||
{
|
||||
public class Service<T> : IService<T> where T : class, new()
|
||||
{
|
||||
protected readonly IRepository<T> _repository;
|
||||
|
||||
public Service(IRepository<T> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public T GetById(object id)
|
||||
{
|
||||
return _repository.GetById(id);
|
||||
}
|
||||
|
||||
public T GetSingle(Expression<Func<T, bool>> predicate)
|
||||
{
|
||||
return _repository.GetSingle(predicate);
|
||||
}
|
||||
|
||||
public List<T> GetList()
|
||||
{
|
||||
return _repository.GetList();
|
||||
}
|
||||
|
||||
public List<T> GetList(Expression<Func<T, bool>> predicate)
|
||||
{
|
||||
return _repository.GetList(predicate);
|
||||
}
|
||||
|
||||
public List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null)
|
||||
{
|
||||
return _repository.GetListPaged(pageIndex, pageSize, out totalCount, predicate, orderBy);
|
||||
}
|
||||
|
||||
public int Insert(T entity)
|
||||
{
|
||||
return _repository.Insert(entity);
|
||||
}
|
||||
|
||||
public int Insert(List<T> entities)
|
||||
{
|
||||
return _repository.Insert(entities);
|
||||
}
|
||||
|
||||
public int Update(T entity)
|
||||
{
|
||||
return _repository.Update(entity);
|
||||
}
|
||||
|
||||
public int Update(T entity, Expression<Func<T, bool>> whereExpression)
|
||||
{
|
||||
return _repository.Update(entity, whereExpression);
|
||||
}
|
||||
|
||||
public int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
|
||||
{
|
||||
return _repository.Update(columns, whereExpression);
|
||||
}
|
||||
|
||||
public int Delete(object id)
|
||||
{
|
||||
return _repository.Delete(id);
|
||||
}
|
||||
|
||||
public int Delete(Expression<Func<T, bool>> predicate)
|
||||
{
|
||||
return _repository.Delete(predicate);
|
||||
}
|
||||
|
||||
public int Delete(List<T> entities)
|
||||
{
|
||||
return _repository.Delete(entities);
|
||||
}
|
||||
|
||||
public bool Any(Expression<Func<T, bool>> predicate)
|
||||
{
|
||||
return _repository.Any(predicate);
|
||||
}
|
||||
|
||||
public int Count(Expression<Func<T, bool>> predicate = null)
|
||||
{
|
||||
return _repository.Count(predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user