v1.0.0
This commit is contained in:
30
CC.Yi.API/Controllers/StudentController.cs
Normal file
30
CC.Yi.API/Controllers/StudentController.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using CC.Yi.IBLL;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC.Yi.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class StudentController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<StudentController> _logger;
|
||||
private IstudentBll _studentBll;
|
||||
public StudentController(ILogger<StudentController> logger, IstudentBll studentBll)
|
||||
{
|
||||
_studentBll = studentBll;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Test()
|
||||
{
|
||||
var data = _studentBll.GetAllEntities().ToList();
|
||||
return Content(Common.JsonFactory.JsonToString(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using CC.Yi.IBLL;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC.Yi.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
private IstudentBll _studentBll;
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger, IstudentBll studentBll)
|
||||
{
|
||||
_studentBll = studentBll;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Test()
|
||||
{
|
||||
var data= _studentBll.GetEntities(n => n.id >= 0).ToList();
|
||||
return Content(Common.JsonFactory.JsonToString(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace CC.Yi.API
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,10 @@ namespace CC.Yi.BLL
|
||||
{
|
||||
CurrentDal = cd;
|
||||
}
|
||||
//public abstract void SetCurrentDal();
|
||||
//public BaseBll()//基类的构造方法
|
||||
//{
|
||||
// SetCurrentDal();//该方法由子类去实现
|
||||
//}
|
||||
public IQueryable<T> GetAllEntities()
|
||||
{
|
||||
return CurrentDal.GetAllEntities();
|
||||
}
|
||||
|
||||
public IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,13 @@ namespace CC.Yi.DAL
|
||||
return Db.Set<T>().Where(whereLambda).AsQueryable();
|
||||
}
|
||||
|
||||
public int GetCount(Expression<Func<T, bool>> whereLambda) //统计数量
|
||||
public IQueryable<T> GetAllEntities()
|
||||
{
|
||||
return Db.Set<T>().AsQueryable();
|
||||
}
|
||||
|
||||
|
||||
public int GetCount(Expression<Func<T, bool>> whereLambda)
|
||||
{
|
||||
return Db.Set<T>().Where(whereLambda).Count();
|
||||
}
|
||||
|
||||
@@ -7,23 +7,53 @@ namespace CC.Yi.IBLL
|
||||
{
|
||||
public interface IBaseBll<T> where T : class, new()
|
||||
{
|
||||
#region
|
||||
//得到全部实体
|
||||
#endregion
|
||||
IQueryable<T> GetAllEntities();
|
||||
#region
|
||||
//通过表达式得到实体
|
||||
#endregion
|
||||
IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
int GetCount(Expression<Func<T, bool>> whereLambda);//统计数量
|
||||
#region
|
||||
//通过表达式得到实体,分页版本
|
||||
#endregion
|
||||
IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
|
||||
|
||||
#region
|
||||
//通过表达式统计数量
|
||||
#endregion
|
||||
int GetCount(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//分组
|
||||
//通过表达式分组
|
||||
#endregion
|
||||
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
|
||||
|
||||
IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
|
||||
|
||||
#region
|
||||
//添加实体
|
||||
#endregion
|
||||
T Add(T entity);
|
||||
|
||||
#region
|
||||
//更新实体
|
||||
#endregion
|
||||
bool Update(T entity);
|
||||
|
||||
#region
|
||||
//删除实体
|
||||
#endregion
|
||||
bool Delete(T entity);
|
||||
|
||||
#region
|
||||
//通过id删除实体
|
||||
#endregion
|
||||
bool Delete(int id);
|
||||
|
||||
#region
|
||||
//通过id列表删除多个实体
|
||||
#endregion
|
||||
int DeleteList(List<int> ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,44 +6,48 @@ namespace CC.Yi.IDAL
|
||||
{
|
||||
public interface IBaseDal<T> where T : class, new()
|
||||
{
|
||||
#region
|
||||
//得到全部实体
|
||||
#endregion
|
||||
IQueryable<T> GetAllEntities();
|
||||
|
||||
#region
|
||||
//通过表达式得到实体
|
||||
#endregion
|
||||
IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//统计数量
|
||||
#endregion
|
||||
int GetCount(Expression<Func<T, bool>> whereLambda);//统计数量
|
||||
|
||||
#region
|
||||
//分组
|
||||
#endregion
|
||||
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
|
||||
|
||||
|
||||
#region
|
||||
//通过得到实体,分页版本
|
||||
//通过表达式得到实体,分页版本
|
||||
#endregion
|
||||
IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
|
||||
|
||||
#region
|
||||
//添加实体
|
||||
//通过表达式统计数量
|
||||
#endregion
|
||||
int GetCount(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//通过表达式分组
|
||||
#endregion
|
||||
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
|
||||
|
||||
#region
|
||||
//添加单个实体
|
||||
#endregion
|
||||
T Add(T entity);
|
||||
|
||||
#region
|
||||
//更新实体
|
||||
//更新单个实体
|
||||
#endregion
|
||||
bool Update(T entity);
|
||||
|
||||
#region
|
||||
//删除实体
|
||||
//删除单个实体
|
||||
#endregion
|
||||
bool Delete(T entity);
|
||||
|
||||
#region
|
||||
//通过id进行删除实体
|
||||
//通过id删除实体
|
||||
#endregion
|
||||
bool Detete(int id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user