Commit 4eabd141 authored by 黄奎's avatar 黄奎

新增实体类

parent 218d6e2d
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Web
{
/// <summary>
/// 新闻管理实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Web_News
{
/// <summary>
/// 新闻编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 新闻标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 新闻图片
/// </summary>
public string Img { get; set; }
/// <summary>
/// 新闻内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 新闻类型编号
/// </summary>
public int TypeId { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public DateStateEnum Status { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateDate { get; set; }
/// <summary>
/// 创建人编号
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 学校编号
/// </summary>
public int School_Id { get; set; }
}
}
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.Web
{
/// <summary>
/// 新闻类型管理实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Web_NewsType
{
/// <summary>
/// 新闻类型编号(主键)
/// </summary>
public int Id { get; set; }
/// <summary>
/// 新闻类型名称
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 图片
/// </summary>
public string Image { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public DateStateEnum Status { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateDate { get; set; }
/// <summary>
/// 创建人编号
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 学校编号
/// </summary>
public int School_Id { get; set; }
}
}
using Edu.Model.Entity.Web;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Web
{
/// <summary>
/// 新闻类型管理视图实体类
/// </summary>
public class RB_Web_NewsType_ViewModel : RB_Web_NewsType
{
}
}
using Edu.Model.Entity.Web;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.Web
{
/// <summary>
/// 新闻管理视图实体类
/// </summary>
public class RB_Web_News_ViewModel : RB_Web_News
{
}
}
using Edu.Model.ViewModel.Web;
using Edu.Repository.Web;
using System.Collections.Generic;
using VT.FW.DB;
namespace Edu.Module.Web
{
/// <summary>
/// 网站新闻处理类
/// </summary>
public class WebNewsModule
{
/// <summary>
/// 网站新闻管理仓储层对象
/// </summary>
private readonly RB_Web_NewsRepository web_NewsRepository = new RB_Web_NewsRepository();
/// <summary>
/// 网站新闻类型仓储层对象
/// </summary>
private readonly RB_Web_NewsTypeRepository web_NewsTypeRepository = new RB_Web_NewsTypeRepository();
#region 新闻管理
/// <summary>
/// 获取网站新闻分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示调试</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_News_ViewModel> GetWebNewsPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Web_News_ViewModel query)
{
return web_NewsRepository.GetWebNewsPageRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 获取网站新闻列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_News_ViewModel> GetWebNewsListModule(RB_Web_News_ViewModel query)
{
return web_NewsRepository.GetWebNewsListRepository(query);
}
/// <summary>
/// 新增修改新闻
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetWebNewsModule(RB_Web_News_ViewModel model)
{
bool flag;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Web_News_ViewModel.Title),model.Title },
{nameof(RB_Web_News_ViewModel.Img),model.Img },
{nameof(RB_Web_News_ViewModel.Content),model.Content },
{nameof(RB_Web_News_ViewModel.TypeId),model.TypeId },
};
flag = web_NewsRepository.Update(fileds, new WhereHelper(nameof(RB_Web_News_ViewModel.Id), model.Id));
}
else
{
var newId = web_NewsRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编号获取网站新闻详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Web_News_ViewModel GetWebNewsModule(object Id)
{
return web_NewsRepository.GetEntity<RB_Web_News_ViewModel>(Id);
}
/// <summary>
/// 修改网站新闻状态
/// </summary>
/// <param name="Id"></param>
/// <param name="Status">0-正常,1-删除</param>
/// <returns></returns>
public bool RemoveWebNewsStatusModule(int Id, int Status)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Web_News_ViewModel.Status),Status },
};
var flag = web_NewsRepository.Update(fileds, new WhereHelper(nameof(RB_Web_News_ViewModel.Id), Id));
return flag;
}
#endregion
#region 新闻类型管理
/// <summary>
/// 获取网站新闻类型分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示调试</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_NewsType_ViewModel> GetWebNewsTypePageModule(int pageIndex, int pageSize, out long rowsCount, RB_Web_NewsType_ViewModel query)
{
return web_NewsTypeRepository.GetWebNewsTypePageRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 获取网站新闻类型列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_NewsType_ViewModel> GetWebNewsTypeListModule(RB_Web_NewsType_ViewModel query)
{
return web_NewsTypeRepository.GetWebNewsTypeListRepository(query);
}
/// <summary>
/// 新增修改新闻类型
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetWebNewsTypeModule(RB_Web_NewsType_ViewModel model)
{
bool flag;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Web_NewsType_ViewModel.TypeName),model.TypeName },
{nameof(RB_Web_NewsType_ViewModel.Image),model.Image },
};
flag = web_NewsTypeRepository.Update(fileds, new WhereHelper(nameof(RB_Web_NewsType_ViewModel.Id), model.Id));
}
else
{
var newId = web_NewsTypeRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 根据编号获取网站新闻类型详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Web_NewsType_ViewModel GetWebNewsTypeModule(object Id)
{
return web_NewsTypeRepository.GetEntity<RB_Web_NewsType_ViewModel>(Id);
}
/// <summary>
/// 修改网站新闻类型状态
/// </summary>
/// <param name="Id"></param>
/// <param name="Status">0-正常,1-删除</param>
/// <returns></returns>
public bool RemoveWebNewsTypeStatusModule(int Id, int Status)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Web_NewsType_ViewModel.Status),Status },
};
var flag = web_NewsTypeRepository.Update(fileds, new WhereHelper(nameof(RB_Web_NewsType_ViewModel.Id), Id));
return flag;
}
#endregion
}
}
using Edu.Common.Enum;
using Edu.Model.Entity.Web;
using Edu.Model.ViewModel.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Web
{
/// <summary>
/// 新闻管理仓储层
/// </summary>
public class RB_Web_NewsRepository:BaseRepository<RB_Web_News>
{
/// <summary>
/// 获取网站新闻分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示调试</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_News_ViewModel> GetWebNewsPageRepository(int pageIndex, int pageSize, out long rowsCount, RB_Web_News_ViewModel query)
{
rowsCount = 0;
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Web_News AS A
WHERE 1=1
");
if (query == null)
{
return new List<RB_Web_News_ViewModel>();
}
else
{
if (query.Group_Id > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_News_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.Title))
{
builder.AppendFormat(" AND A.{0} LIKE @Title ", nameof(RB_Web_News_ViewModel.Title));
parameters.Add("Title", "%" + query.Title.Trim() + "%");
}
if (query.Status > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_Nav_ViewModel.Status), (int)query.Status);
}
if (query.TypeId > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_News_ViewModel.TypeId), query.TypeId);
}
}
return GetPage<RB_Web_News_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取网站新闻列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_News_ViewModel> GetWebNewsListRepository(RB_Web_News_ViewModel query)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Web_News AS A
WHERE 1=1
");
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_News_ViewModel.Status), (int)DateStateEnum.Normal);
if (query == null)
{
return new List<RB_Web_News_ViewModel>();
}
else
{
if (query.Group_Id > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_News_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.Title))
{
builder.AppendFormat(" AND A.{0} LIKE @Title ", nameof(RB_Web_News_ViewModel.Title));
parameters.Add("Title", "%" + query.Title.Trim() + "%");
}
if (query.TypeId > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_News_ViewModel.TypeId), query.TypeId);
}
}
return Get<RB_Web_News_ViewModel>(builder.ToString()).ToList();
}
}
}
using Edu.Common.Enum;
using Edu.Model.Entity.Web;
using Edu.Model.ViewModel.Web;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Web
{
public class RB_Web_NewsTypeRepository:BaseRepository<RB_Web_NewsType>
{
/// <summary>
/// 获取网站新闻类型分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示调试</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_NewsType_ViewModel> GetWebNewsTypePageRepository(int pageIndex, int pageSize, out long rowsCount, RB_Web_NewsType_ViewModel query)
{
rowsCount = 0;
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Web_NewsType AS A
WHERE 1=1
");
if (query == null)
{
return new List<RB_Web_NewsType_ViewModel>();
}
else
{
if (query.Group_Id > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_NewsType_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.TypeName))
{
builder.AppendFormat(" AND A.{0} LIKE @TypeName ", nameof(RB_Web_NewsType_ViewModel.TypeName));
parameters.Add("TypeName", "%" + query.TypeName.Trim() + "%");
}
if (query.Status > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_NewsType_ViewModel.Status), (int)query.Status);
}
}
return GetPage<RB_Web_NewsType_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取网站新闻类型列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Web_NewsType_ViewModel> GetWebNewsTypeListRepository(RB_Web_NewsType_ViewModel query)
{
var parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Web_NewsType AS A
WHERE 1=1
");
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_NewsType_ViewModel.Status), (int)DateStateEnum.Normal);
if (query == null)
{
return new List<RB_Web_NewsType_ViewModel>();
}
else
{
if (query.Group_Id > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Web_NewsType_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.TypeName))
{
builder.AppendFormat(" AND A.{0} LIKE @TypeName ", nameof(RB_Web_NewsType_ViewModel.TypeName));
parameters.Add("TypeName", "%" + query.TypeName.Trim() + "%");
}
}
return Get<RB_Web_NewsType_ViewModel>(builder.ToString()).ToList();
}
}
}
......@@ -27,6 +27,11 @@ namespace Edu.WebApi.Controllers.Web
/// </summary>
private readonly WebMenuModule menuModule = new WebMenuModule();
/// <summary>
/// 网站新闻管理处理类对象
/// </summary>
private readonly WebNewsModule newsModule = new WebNewsModule();
#region 网站导航管理
/// <summary>
/// 获取网站导航列表
......@@ -65,7 +70,7 @@ namespace Edu.WebApi.Controllers.Web
var list = navModule.GetWebNavPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: list);
return ApiResult.Success(data: pageModel);
}
/// <summary>
......@@ -166,7 +171,7 @@ namespace Edu.WebApi.Controllers.Web
var list = menuModule.GetWebMenuPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: list);
return ApiResult.Success(data: pageModel);
}
/// <summary>
......@@ -187,6 +192,8 @@ namespace Edu.WebApi.Controllers.Web
Icon = base.ParmJObj.GetStringValue("Icon"),
SortNum = base.ParmJObj.GetInt("SortNum"),
};
extModel.School_Id = base.UserInfo.School_Id;
extModel.Group_Id = base.UserInfo.Group_Id;
extModel.CreateBy = base.UserInfo.Id;
extModel.CreateDate = DateTime.Now;
extModel.Status = DateStateEnum.Normal;
......@@ -221,5 +228,177 @@ namespace Edu.WebApi.Controllers.Web
#endregion
#region 新闻管理
/// <summary>
/// 获取网站新闻类型列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetWebNewsTypeList()
{
var query = new RB_Web_NewsType_ViewModel()
{
TypeName = base.ParmJObj.GetStringValue("TypeName"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = newsModule.GetWebNewsTypeListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取新闻类型分页
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetWebNewsTypePage()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Web_NewsType_ViewModel()
{
TypeName = base.ParmJObj.GetStringValue("TypeName"),
Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = newsModule.GetWebNewsTypePageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 新增修改网站新闻类型
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetWebNewsType()
{
var extModel = new RB_Web_NewsType_ViewModel()
{
Id = base.ParmJObj.GetInt("Id"),
TypeName = base.ParmJObj.GetStringValue("TypeName"),
Image = base.ParmJObj.GetStringValue("Image"),
};
extModel.School_Id = base.UserInfo.School_Id;
extModel.Group_Id = base.UserInfo.Group_Id;
extModel.CreateBy = base.UserInfo.Id;
extModel.CreateDate = DateTime.Now;
extModel.Status = DateStateEnum.Normal;
bool flag = newsModule.SetWebNewsTypeModule(extModel);
return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
}
/// <summary>
/// 获取网站新闻类型详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetWebNewsType()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var extModel = newsModule.GetWebNewsTypeModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 修改网站新闻类型状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveWebNewsTypeStatus()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var Status = base.ParmJObj.GetInt("Status", 0);
var flag = newsModule.RemoveWebNewsTypeStatusModule(Id, Status);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取网站新闻列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetWebNewsList()
{
var query = new RB_Web_News_ViewModel()
{
Title = base.ParmJObj.GetStringValue("Title"),
TypeId= base.ParmJObj.GetInt("TypeId"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = newsModule.GetWebNewsListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取新闻分页
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetWebNewsPage()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Web_News_ViewModel()
{
Title = base.ParmJObj.GetStringValue("Title"),
TypeId = base.ParmJObj.GetInt("TypeId"),
Status = (DateStateEnum)base.ParmJObj.GetInt("Status"),
};
query.Group_Id = base.UserInfo.Group_Id;
var list = newsModule.GetWebNewsPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 新增修改网站新闻
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetWebNews()
{
var extModel = new RB_Web_News_ViewModel()
{
Id = base.ParmJObj.GetInt("Id"),
Title = base.ParmJObj.GetStringValue("Title"),
Img = base.ParmJObj.GetStringValue("Img"),
Content = base.ParmJObj.GetStringValue("Content"),
TypeId = base.ParmJObj.GetInt("TypeId"),
};
extModel.School_Id = base.UserInfo.School_Id;
extModel.Group_Id = base.UserInfo.Group_Id;
extModel.CreateBy = base.UserInfo.Id;
extModel.CreateDate = DateTime.Now;
extModel.Status = DateStateEnum.Normal;
bool flag = newsModule.SetWebNewsModule(extModel);
return flag ? ApiResult.Success(data: extModel) : ApiResult.Failed();
}
/// <summary>
/// 获取网站新闻详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetWebNews()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var extModel = newsModule.GetWebNewsModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 修改网站新闻状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveWebNewsStatus()
{
var Id = base.ParmJObj.GetInt("Id", 0);
var Status = base.ParmJObj.GetInt("Status", 0);
var flag = newsModule.RemoveWebNewsStatusModule(Id, Status);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment