Commit 34dd276f authored by 吴春's avatar 吴春

提交代码

parent 4d0e2479
using VT.FW.DB;
using Mall.Common.Enum.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 教育-资讯管理实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_Article
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 资讯状态 1上架 2下架
/// </summary>
public int? ArticleStatus
{
get;
set;
}
/// <summary>
/// 排序
/// </summary>
public int? Sort
{
get;
set;
}
/// <summary>
/// 自动上架时间
/// </summary>
public DateTime? ShelvesDate { get; set; }
/// <summary>
/// 自动下架时间
/// </summary>
public DateTime? DownDate { get; set; }
/// <summary>
/// 虚拟浏览数量
/// </summary>
public int FictitiousBrowseNum
{
get;
set;
}
/// <summary>
/// 浏览数
/// </summary>
public int BrowseNum
{
get;
set;
}
/// <summary>
/// 标题
/// </summary>
public string Name { get; set; }
/// <summary>
/// 标签
/// </summary>
public string LableName { get; set; }
/// <summary>
/// 是否可以留言,0-否,1-是
/// </summary>
public int IsComment { get; set; }
/// <summary>
/// 资讯内容
/// </summary>
public string Describe { get; set; }
}
}
using VT.FW.DB;
using Mall.Common.Enum.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Enum.Goods;
using Mall.Common.Enum.User;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 教育-资讯评论管理实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_ArticleComment
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 用户id
/// </summary>
public int? UserId
{
get;
set;
}
/// <summary>
/// 资讯id
/// </summary>
public int ArticleId
{
get;
set;
}
/// <summary>
/// 客人名称
/// </summary>
public string UserName
{
get;
set;
}
/// <summary>
/// 用户头像
/// </summary>
public int? UserPhoto
{
get;
set;
}
/// <summary>
/// 评论类型 1 好评 2中评 3差评
/// </summary>
public GoodsCommentTypeEnum? CommentGrade
{
get;
set;
}
/// <summary>
/// 评分 1-5分
/// </summary>
public int? CommentScore { get; set; }
/// <summary>
/// 评论内容
/// </summary>
public string Content
{
get;
set;
}
/// <summary>
/// 评论图片
/// </summary>
public string CommentImage
{
get;
set;
}
/// <summary>
/// 回复
/// </summary>
public string Reply
{
get;
set;
}
/// <summary>
/// 来源
/// </summary>
public UserSourceEnum? PlatformSource
{
get;
set;
}
/// <summary>
/// 是否置顶 1是 2否
/// </summary>
public int? Is_Top
{
get;
set;
}
/// <summary>
/// 是否显示 1是 2否
/// </summary>
public int? Is_Show
{
get;
set;
}
/// <summary>
/// 是否匿名 1是 2否
/// </summary>
public int? Is_Anonymity
{
get;
set;
}
}
}
using Mall.Model.Entity.Education;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 资讯评论
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_ArticleComment_Extend : RB_Education_ArticleComment
{
/// <summary>
/// 资讯标题
/// </summary>
public string ArticleName { get; set; }
}
}
\ No newline at end of file
using Mall.Model.Entity.Education;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 教育-资讯管理扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_Article_Extend : RB_Education_Article
{
/// <summary>
/// 开始时间
/// </summary>
public string StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndTime { get; set; }
/// <summary>
/// 评论数
/// </summary>
public int CommentNum { get; set; }
}
}
......@@ -34,6 +34,10 @@ namespace Mall.Module.Education
/// </summary>
private readonly RB_Member_UserRepository member_UserRepository = new RB_Member_UserRepository();
/// <summary>
/// 会员信息
/// </summary>
private readonly RB_Education_ArticleRepository educationArticleRepository = new RB_Education_ArticleRepository();
#region 教师管理
/// <summary>
......@@ -795,5 +799,214 @@ namespace Mall.Module.Education
}
#endregion
#region 教育-资讯管理
/// <summary>
///资讯配置列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Article_Extend> GetArticlePageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Education_Article_Extend query)
{
List<RB_Education_Article_Extend> list = educationArticleRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
return list;
}
/// <summary>
/// 资讯配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Education_Article_Extend GetArticleModel(RB_Education_Article_Extend query)
{
RB_Education_Article_Extend model = educationArticleRepository.GetTeacherList(query).FirstOrDefault();
return model;
}
/// <summary>
///资讯列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public RB_Education_Article_Extend GetArticleInfo(RB_Education_Article_Extend query)
{
RB_Education_Article_Extend model = educationArticleRepository.GetTeacherList(query).FirstOrDefault();
return model;
}
/// <summary>
/// 资讯配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_Article_Extend> GetArticleList(RB_Education_Article_Extend query)
{
return educationArticleRepository.GetTeacherList(query);
}
/// <summary>
/// 新增/修改资讯配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateArticle(RB_Education_Article_Extend model)
{
bool flag = false;
try
{
if (model.ID == 0)
{
flag = educationArticleRepository.Insert(model) > 0;
}
else
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Education_Article_Extend.LableName),model.LableName},
{ nameof(RB_Education_Article_Extend.Name),model.Name},
{ nameof(RB_Education_Article_Extend.IsComment),model.IsComment},
{ nameof(RB_Education_Article_Extend.Describe),model.Describe},
{ nameof(RB_Education_Article_Extend.ArticleStatus),model.ArticleStatus},
{ nameof(RB_Education_Article_Extend.DownDate),model.DownDate},
{ nameof(RB_Education_Article_Extend.FictitiousBrowseNum),model.FictitiousBrowseNum},
{ nameof(RB_Education_Article_Extend.ShelvesDate),model.ShelvesDate},
{ nameof(RB_Education_Article_Extend.Sort),model.Sort},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_Article_Extend.ID),
FiledValue=model.ID,
OperatorEnum=OperatorEnum.Equal
}
};
flag = educationArticleRepository.Update(keyValues, wheres);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateArticle");
return false;
}
return flag;
}
/// <summary>
/// 批量上下架资讯
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool EnableArticleInfo(List<string> ids, int ArticleStatus, int uid, int mallBaseId)
{
var trans = educationArticleRepository.DbTransaction;
bool flag = false;
try
{
foreach (var item in ids)
{
if (!string.IsNullOrWhiteSpace(item))
{
Dictionary<string, object> cols = new Dictionary<string, object>()
{
{ nameof(RB_Education_Article.ArticleStatus),ArticleStatus},
{ nameof(RB_Education_Article.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_Article.ID),
FiledValue=Convert.ToInt32(item),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Education_Article.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Education_Article.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
}
};
flag = educationArticleRepository.Update(cols, wheres1, trans);
}
}
educationArticleRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "EnableArticleInfo");
educationArticleRepository.DBSession.Rollback("EnableArticleInfo");
return false;
}
return flag;
}
/// <summary>
/// 批量删除资讯
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool DelArticleInfo(List<string> ids, int uid, int mallBaseId)
{
var trans = educationArticleRepository.DbTransaction;
bool flag = false;
try
{
foreach (var item in ids)
{
if (!string.IsNullOrWhiteSpace(item))
{
Dictionary<string, object> cols = new Dictionary<string, object>()
{
{ nameof(RB_Education_Article.Status),0},
{ nameof(RB_Education_Article.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_Article.ID),
FiledValue=Convert.ToInt32(item),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Education_Article.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Education_Article.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
}
};
flag = educationArticleRepository.Update(cols, wheres1, trans);
}
}
educationArticleRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "DelArticleInfo");
educationArticleRepository.DBSession.Rollback("DelArticleInfo");
return false;
}
return flag;
}
#endregion
}
}
using Mall.Model.Entity.Education;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Repository.Education
{
/// <summary>
/// 资讯评论仓储层
/// </summary>
public class RB_Education_ArticleCommentRepository : BaseRepository<RB_Education_ArticleComment>
{
}
}
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Education
{
/// <summary>
/// 仓储层
/// </summary>
public class RB_Education_ArticleRepository : BaseRepository<RB_Education_Article>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Education_Article); } }
/// <summary>
/// 网课-老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Article_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Education_Article_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Education_Article_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.ID)}={query.ID}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.Name)} like '%{query.Name}%'");
}
if (query.ArticleStatus > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.ArticleStatus)}={query.ArticleStatus}");
}
if (!string.IsNullOrEmpty(query.StartTime))
{
builder.Append($" and g.{nameof(RB_Education_Article_Extend.CreateDate)} >='{query.StartTime}'");
}
if (!string.IsNullOrEmpty(query.EndTime))
{
builder.Append($" and g.{nameof(RB_Education_Article_Extend.CreateDate)} <='{query.EndTime + " 23:59:59"}'");
}
}
return GetPage<RB_Education_Article_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 网课-老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Article_Extend> GetTeacherList(RB_Education_Article_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Education_Article_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.ID)}={query.ID}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.Name)} like '%{query.Name}%'");
}
if (query.ArticleStatus > 0)
{
builder.Append($" AND {nameof(RB_Education_Article_Extend.ArticleStatus)}={query.ArticleStatus}");
}
if (!string.IsNullOrEmpty(query.StartTime))
{
builder.Append($" and g.{nameof(RB_Education_Article_Extend.CreateDate)} >='{query.StartTime}'");
}
if (!string.IsNullOrEmpty(query.EndTime))
{
builder.Append($" and g.{nameof(RB_Education_Article_Extend.CreateDate)} <='{query.EndTime + " 23:59:59"}'");
}
}
return Get<RB_Education_Article_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -26,7 +26,7 @@ namespace Mall.WebApi.Controllers.Education
private Module.User.UserModule UserModule = new Module.User.UserModule();
#region 教师信息
[HttpPost]
public ApiResult GetGuidePageListRepository()
public ApiResult GetTeacherPageList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
......@@ -677,5 +677,157 @@ namespace Mall.WebApi.Controllers.Education
#endregion
#region 资讯管理
/// <summary>
/// 资讯列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetArticlePageList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_Education_Article_Extend demodel = JsonConvert.DeserializeObject<RB_Education_Article_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.ArticleStatus = -1;
var list = educationModule.GetArticlePageListRepository(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.Name,
CreateDateStr = x.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
x.ArticleStatus,
x.IsComment,
x.CommentNum,
x.BrowseNum,
x.FictitiousBrowseNum
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 上下架资讯状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult EnableArticleInfo()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
string idInfo = parmsJob.GetStringValue("Ids");
int articleStatus = parmsJob.GetInt("ArticleStatus", 0);
if (string.IsNullOrWhiteSpace(idInfo))
{
return ApiResult.Failed("请传递参数");
}
if (articleStatus == 0)
{
return ApiResult.Failed("请选择您要操作的类型");
}
bool flag = educationModule.EnableArticleInfo(idInfo.Split(",").ToList(), articleStatus, UserInfo.TenantId, parms.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 删除资讯
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelArticleInfo()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
string idInfo = parmsJob.GetStringValue("Ids");
if (string.IsNullOrWhiteSpace(idInfo))
{
return ApiResult.Failed("请传递参数");
}
bool flag = educationModule.DelArticleInfo(idInfo.Split(",").ToList(), UserInfo.TenantId, parms.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
public ApiResult GetArticleModel()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Education_Article_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
query.ArticleStatus = -1;
var oldLogisticsModel = educationModule.GetArticleInfo(query);
if (oldLogisticsModel == null)
{
oldLogisticsModel = new RB_Education_Article_Extend();
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 保存资讯信息
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateArticle()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Education_Article_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
if (query == null)
{
return ApiResult.Failed("请传入资讯信息");
}
else
{
if (string.IsNullOrWhiteSpace(query.Name))
{
return ApiResult.Failed("请输入资讯标题");
}
if (string.IsNullOrWhiteSpace(query.LableName))
{
return ApiResult.Failed("请输入标签");
}
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = educationModule.AddOrUpdateArticle(query);
if (result)
{
return ApiResult.Success("资讯信息保存成功");
}
else
{
return ApiResult.Failed("资讯信息保存失败");
}
}
}
#endregion
}
}
\ No newline at end of file
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