Commit fd169da4 authored by 吴春's avatar 吴春
parents 16c3846a d61ef1cc
using Mall.Common.Enum;
using System;
using VT.FW.DB;
namespace Mall.Model.Entity.MarketingCenter
{
/// <summary>
/// 分享分类表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Share_Category
{
/// <summary>
/// 分类编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 分类名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 层级
/// </summary>
public int Level { get; set; }
/// <summary>
/// 父节点编号
/// </summary>
public int ParentId { get; set; }
/// <summary>
/// 删除状态(1-删除)
/// </summary>
public DateStateEnum Status { get; set; }
/// <summary>
/// 商户号
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateDate { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateDate { get; set; }
}
}
using Mall.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.MarketingCenter
{
/// <summary>
/// 分享详情实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Share_Friend
{
/// <summary>
/// 主键
/// </summary>
public int Id { get; set; }
/// <summary>
/// 分类编号
/// </summary>
public int CateId { get; set; }
/// <summary>
/// 商品编号
/// </summary>
public int GoodsId { get; set; }
/// <summary>
/// 封面图
/// </summary>
public string CoverImg { get; set; }
/// <summary>
/// 素材图片
/// </summary>
public string MaterialImg { get; set; }
/// <summary>
/// 素材文案
/// </summary>
public string MaterialInfo { get; set; }
/// <summary>
/// 链接地址
/// </summary>
public string LinkUrl { get; set; }
/// <summary>
/// 是否置顶(1-是)
/// </summary>
public int IsTop { get; set; }
/// <summary>
/// 排序
/// </summary>
public int SortNum { get; set; }
/// <summary>
/// 删除状态(1-删除)
/// </summary>
public DateStateEnum Status { get; set; }
/// <summary>
/// 商户号
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateDate { get; set; }
/// <summary>
/// 更新人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateDate { get; set; }
}
}
using Mall.Model.Entity.MarketingCenter;
using System;
using VT.FW.DB;
namespace Mall.Model.Extend.MarketingCenter
{
/// <summary>
/// 分享分类扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Share_Category_Extend : RB_Share_Category
{
}
}
using Mall.Model.Entity.MarketingCenter;
using System;
using VT.FW.DB;
namespace Mall.Model.Extend.MarketingCenter
{
/// <summary>
/// 分享详情扩展实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Share_Friend_Extend : RB_Share_Friend
{
}
}
\ No newline at end of file
using Mall.Common.Enum;
using Mall.Model.Extend.MarketingCenter;
using Mall.Repository.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Module.MarketingCenter
{
/// <summary>
/// 分享处理类
/// </summary>
public class ShareModule
{
/// <summary>
/// 分享分类仓储层对象
/// </summary>
private readonly RB_Share_CategoryRepository share_CategoryRepository = new RB_Share_CategoryRepository();
/// <summary>
/// 分享详情实体仓储层对象
/// </summary>
private readonly RB_Share_FriendRepository share_FriendRepository = new RB_Share_FriendRepository();
/// <summary>
/// 获取分享分类分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Category_Extend> GetShareCategoryPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Share_Category_Extend query)
{
return share_CategoryRepository.GetShareCategoryPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 获取分享分类列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Category_Extend> GetShareCategoryListModule(RB_Share_Category_Extend query)
{
return share_CategoryRepository.GetShareCategoryListRepository(query);
}
/// <summary>
/// 获取分享详情分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Friend_Extend> GetShareFriendPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Share_Friend_Extend query)
{
return share_FriendRepository.GetShareFriendPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 获取分享详情列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Friend_Extend> GetShareFriendListModule(RB_Share_Friend_Extend query)
{
return share_FriendRepository.GetShareFriendListRepository(query);
}
/// <summary>
/// 新增修改分类
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetShareCategoryModule(RB_Share_Category_Extend extModel)
{
bool flag = false;
if (extModel.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Category_Extend.Name),extModel.Name },
{nameof(RB_Share_Category_Extend.Level),extModel.Level },
{nameof(RB_Share_Category_Extend.ParentId),extModel.ParentId },
{nameof(RB_Share_Category_Extend.UpdateDate),extModel.UpdateDate },
};
flag = share_CategoryRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Category_Extend.Id), extModel.Id));
}
else
{
var newId = share_CategoryRepository.Insert(extModel);
extModel.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 删除分享分类
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveShareCategoryModule(object Id)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Category_Extend.Status),(int) DateStateEnum.Delete},
};
flag = share_CategoryRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Category_Extend.Id), Id));
return flag;
}
/// <summary>
/// 获取分享分类实体
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Share_Category_Extend GetShareCategoryModule(object Id)
{
return share_CategoryRepository.GetEntity<RB_Share_Category_Extend>(Id);
}
/// <summary>
/// 新增修改分享详情
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetShareFriendModule(RB_Share_Friend_Extend extModel)
{
bool flag = false;
if (extModel.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Friend_Extend.CateId),extModel.CateId },
{nameof(RB_Share_Friend_Extend.GoodsId),extModel.GoodsId },
{nameof(RB_Share_Friend_Extend.CoverImg),extModel.CoverImg },
{nameof(RB_Share_Friend_Extend.MaterialImg),extModel.MaterialImg },
{nameof(RB_Share_Friend_Extend.MaterialInfo),extModel.MaterialInfo },
{nameof(RB_Share_Friend_Extend.LinkUrl),extModel.LinkUrl },
{nameof(RB_Share_Friend_Extend.IsTop),extModel.IsTop },
{nameof(RB_Share_Friend_Extend.SortNum),extModel.SortNum },
{nameof(RB_Share_Friend_Extend.UpdateBy),extModel.UpdateBy },
{nameof(RB_Share_Friend_Extend.UpdateDate),extModel.UpdateDate },
};
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), extModel.Id));
}
else
{
var newId = share_FriendRepository.Insert(extModel);
extModel.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 获取分享详情实体
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Share_Friend_Extend GetShareFriendModule(object Id)
{
return share_FriendRepository.GetEntity<RB_Share_Friend_Extend>(Id);
}
/// <summary>
/// 根据编号删除分享详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveShareFriendModule(object Id)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Friend_Extend.Status),(int) DateStateEnum.Delete},
};
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), Id));
return flag;
}
}
}
using Mall.Model.Entity.MarketingCenter;
using Mall.Model.Extend.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Mall.Repository.MarketingCenter
{
/// <summary>
/// 分享分类仓储层
/// </summary>
public class RB_Share_CategoryRepository : BaseRepository<RB_Share_Category>
{
/// <summary>
/// 获取分享分类分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Category_Extend> GetShareCategoryPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Share_Category_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_share_category
WHERE 1=1 AND Status=0
");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.Name)} like '%{query.Name}%'");
}
}
return GetPage<RB_Share_Category_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取分享分类列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Category_Extend> GetShareCategoryListRepository(RB_Share_Category_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_share_category
WHERE 1=1 AND Status=0
");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.Name)} like '%{query.Name}%'");
}
}
return Get<RB_Share_Category_Extend>(builder.ToString()).ToList();
}
}
}
using Mall.Model.Entity.MarketingCenter;
using Mall.Model.Extend.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Mall.Repository.MarketingCenter
{
/// <summary>
/// 分享详情实体仓储层
/// </summary>
public class RB_Share_FriendRepository : BaseRepository<RB_Share_Friend>
{
/// <summary>
/// 获取分享详情分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowsCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Friend_Extend> GetShareFriendPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Share_Friend_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_share_friend
WHERE 1=1 AND Status=0
");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Friend_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Friend_Extend.MallBaseId)}={query.MallBaseId}");
}
}
return GetPage<RB_Share_Friend_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取分享详情列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Share_Friend_Extend> GetShareFriendListRepository(RB_Share_Friend_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT *
FROM rb_share_friend
WHERE 1=1 AND Status=0
");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Friend_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Share_Friend_Extend.MallBaseId)}={query.MallBaseId}");
}
}
return Get<RB_Share_Friend_Extend>(builder.ToString()).ToList();
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Extend.MarketingCenter;
using Mall.Module.MarketingCenter;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Mall.WebApi.Controllers.MarketingCenter
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class ShareController : BaseController
{
/// <summary>
/// 分享处理类对象
/// </summary>
private readonly ShareModule shareModule = new ShareModule();
/// <summary>
/// 获取分享分类分页列表
/// </summary>
/// <returns></returns>
public ApiResult GetShareCategoryPageList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
var query = JsonConvert.DeserializeObject<RB_Share_Category_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
var list = shareModule.GetShareCategoryPageListModule(pagelist.pageIndex, pagelist.pageSize, out long count, query);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list;
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取分享分类列表
/// </summary>
/// <returns></returns>
public ApiResult GetShareCategoryList()
{
var query = JsonConvert.DeserializeObject<RB_Share_Category_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = RequestParm.MallBaseId;
var list = shareModule.GetShareCategoryListModule(query);
return ApiResult.Success("", list);
}
/// <summary>
/// 新增修改分享分类
/// </summary>
/// <returns></returns>
public ApiResult SetShareCategory()
{
var extModel = JsonConvert.DeserializeObject<RB_Share_Category_Extend>(RequestParm.msg.ToString());
extModel.TenantId = UserInfo.TenantId;
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.CreateDate = DateTime.Now;
extModel.UpdateDate = DateTime.Now;
bool flag = shareModule.SetShareCategoryModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 删除分享分类
/// </summary>
/// <returns></returns>
public ApiResult RemoveShareCategory()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
bool flag = shareModule.RemoveShareCategoryModule(Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号获取分享分类
/// </summary>
/// <returns></returns>
public ApiResult GetShareCategory()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
var extModel = shareModule.GetShareCategoryModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 获取分享详情分页列表
/// </summary>
/// <returns></returns>
public ApiResult GetShareFriendPageList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
var query = JsonConvert.DeserializeObject<RB_Share_Friend_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
var list = shareModule.GetShareFriendPageListModule(pagelist.pageIndex, pagelist.pageSize, out long count, query);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list;
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取分享详情列表
/// </summary>
/// <returns></returns>
public ApiResult GetShareFriendList()
{
var query = JsonConvert.DeserializeObject<RB_Share_Friend_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = RequestParm.MallBaseId;
var list = shareModule.GetShareFriendListModule(query);
return ApiResult.Success("", list);
}
/// <summary>
/// 新增修改分享详情
/// </summary>
/// <returns></returns>
public ApiResult SetShareFriend()
{
var extModel = JsonConvert.DeserializeObject<RB_Share_Friend_Extend>(RequestParm.msg.ToString());
extModel.TenantId = UserInfo.TenantId;
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.CreateDate = DateTime.Now;
extModel.UpdateDate = DateTime.Now;
bool flag = shareModule.SetShareFriendModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号删除分享详情
/// </summary>
/// <returns></returns>
public ApiResult RemoveShareFriend()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
bool flag = shareModule.RemoveShareFriendModule(Id);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号获取分享详情实体
/// </summary>
/// <returns></returns>
public ApiResult GetShareFriend()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
var extModel = shareModule.GetShareFriendModule(Id);
return ApiResult.Success(data: extModel);
}
}
}
\ 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