Browse Source

给新闻 添加发布到 本地CMS网站新闻功能

新疆影视学院高职
edy 3 years ago
parent
commit
44e42731f6
7 changed files with 281 additions and 2 deletions
  1. +60
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NewsController.cs
  2. +5
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.cshtml
  3. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.js
  4. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Index.js
  5. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config
  6. +174
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs
  7. +27
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs

+ 60
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NewsController.cs View File

@@ -1,6 +1,13 @@
using Learun.Application.OA;
using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;

namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
{
@@ -14,6 +21,7 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
public class NewsController : MvcControllerBase
{
private NewsIBLL newsIBLL = new NewsBLL();
WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();

#region 视图功能
/// <summary>
@@ -82,7 +90,57 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
{
entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent);
newsIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");

#region 发送到网站
if (entity.IsSend == "1")
{
//获取配置文件
string siteId = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["SiteId"]);
string channelId = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["ChannelId"]);
string ApiKey = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["ApiKey"]);
SemdNewList SendNew = new SemdNewList
{
Title = entity.F_FullHead,
SubTitle = entity.F_BriefHead,
Content = entity.F_NewsContent,
Author = entity.F_AuthorName,
Source = entity.F_SourceName,
AddDate = DateTime.Now,
Tags = entity.F_TagWord,
AddUserName = entity.F_CreateUserName,
};
WebHeaderCollection ApiId = new WebHeaderCollection
{
{ "X-SS-API-KEY", ApiKey }
};
string responses = Util.HttpMethods.HttpPosts("http://localhost:8005/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId);

#endregion
#region 修改审核状态
JavaScriptSerializer Jss = new JavaScriptSerializer();
Dictionary<string, object> DicText = (Dictionary<string, object>)Jss.DeserializeObject(responses);
string Nid = DicText["id"].ToString();
AuditList AList = new AuditList();
if (Nid != null)
{
AList.siteId = siteId;
List<contents> listCon = new List<contents>();
//这里应该循环,如果多个
contents con = new contents();
con.channelId = Convert.ToInt32(channelId);
con.id = Convert.ToInt32(Nid);
listCon.Add(con);
AList.contents = listCon;
AList.reasons = "终审通过";
Util.HttpMethods.HttpPosts("http://localhost:8005/api/v1/contents/actions/check", AList.ToJson(), ApiId);
}
#endregion
return Success("发布成功!");
}
else
{
return Success("保存成功!");
}
}
/// <summary>
/// 删除表单数据
@@ -97,5 +155,6 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
return Success("删除成功!");
}
#endregion

}
}

+ 5
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.cshtml View File

@@ -4,10 +4,14 @@
}

<div class="lr-form-wrap" id="form">
<div class="col-xs-12 lr-form-item">
<div class="col-xs-6 lr-form-item">
<div class="lr-form-item-title">新闻标题<font face="宋体">*</font></div>
<input id="F_FullHead" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" placeholder="请输入标题" />
</div>
<div class="col-xs-6 lr-form-item">
<div class="lr-form-item-title">是否下发到CMS</div>
<div id="IsSend" ></div>
</div>
<div class="col-xs-6 lr-form-item">
<div class="lr-form-item-title">新闻栏目<font face="宋体">*</font></div>
<div id="F_CategoryId" isvalid="yes" checkexpession="NotNull"></div>


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.js View File

@@ -17,6 +17,11 @@ var bootstrap = function ($, learun) {
page.initData();
},
bind: function () {
$('#IsSend').lrselect({
data: [{ text: "是", value: "1" }, { text: "否", value: "0" }],
text: "text",
value: "value"
})
//新闻栏目
$('#F_CategoryId').lrDataItemSelect({ code: 'NewsCategory', maxHeight: 230 });
//内容编辑器


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Index.js View File

@@ -20,6 +20,11 @@ var bootstrap = function ($, learun) {
var keyword = $('#txt_Keyword').val();
page.search({ keyword: keyword });
});
$('#IsSend').lrselect({
data: [{ text: "是", value: "1" }, { text: "是", value: "否" }],
text: "text",
value: "value"
})
// 刷新
$('#lr_refresh').on('click', function () {
location.reload();


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config View File

@@ -167,4 +167,9 @@
<add key="ForbidLoginNum" value="5"/>
<!-- 禁止登录时间(分钟) -->
<add key="ForbidLoginMinutes" value="10"/>
<!--下发新闻配置-->
<add key="SiteId" value="1"/>
<add key="ChannelId" value="6"/>
<add key="ApiKey" value="343d69b8-32c3-4731-8c2f-92fdf3d8818e"/>
</appSettings>

+ 174
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs View File

@@ -1,5 +1,6 @@
using Learun.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace Learun.Application.OA
@@ -206,6 +207,12 @@ namespace Learun.Application.OA
/// </summary>
[NotMapped]
public string RTime { get; set; }

/// <summary>
/// 是否下发到网站
/// </summary>
[NotMapped]
public string IsSend { get; set; }
#endregion

#region 扩展操作
@@ -240,6 +247,173 @@ namespace Learun.Application.OA
}
#endregion

}


public class SemdNewList
{
/// <summary>
/// 添加人
/// </summary>
[NotMapped]
public string AddUserName { get; set; }
/// <summary>
/// 修改人
/// </summary>
[NotMapped]
public string LastEditUserName { get; set; }
/// <summary>
/// 投稿人
/// </summary>
[NotMapped]
public string WritingUserName { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[NotMapped]
public DateTime? LastEditDate { get; set; }
/// <summary>
/// 排序
/// </summary>
[NotMapped]
public int? Taxis { get; set; }
/// <summary>
/// 内容组
/// </summary>
[NotMapped]
public string GroupNameCollection { get; set; }
/// <summary>
/// 标签
/// </summary>
[NotMapped]
public string Tags { get; set; }
/// <summary>
/// 来源内容Id
/// </summary>
[NotMapped]
public int? SourceId { get; set; }
/// <summary>
/// 引用内容Id
/// </summary>
[NotMapped]
public int? ReferenceId { get; set; }
/// <summary>
/// 是否终审通过通过
/// </summary>
[NotMapped]
public string IsChecked { get; set; }
/// <summary>
/// 未终审通过情况下,处于第几级审核状态
/// </summary>
[NotMapped]
public int? CheckedLevel { get; set; }
/// <summary>
/// 总点击量
/// </summary>
[NotMapped]
public int? Hits { get; set; }
/// <summary>
/// 日点击
/// </summary>
[NotMapped]
public int? HitsByDay { get; set; }
/// <summary>
/// 月点击
/// </summary>
[NotMapped]
public int? HitsByMonth { get; set; }
/// <summary>
/// 最后点击时间
/// </summary>
[NotMapped]
public DateTime? LastHitsDate { get; set; }
/// <summary>
/// 标题
/// </summary>
[NotMapped]
public string Title { get; set; }
[NotMapped]
/// <summary>
/// 是否置顶内容
/// </summary>
public int? IsTop { get; set; }
/// <summary>
/// 是否置顶内容
/// </summary>
[NotMapped]
public int? IsRecommend { get; set; }
/// <summary>
/// 是否热点内容
/// </summary>
[NotMapped]
public int? IsHot { get; set; }
/// <summary>
/// 是否醒目内容
/// </summary>
[NotMapped]
public int? IsColor { get; set; }
/// <summary>
/// 外部链接
/// </summary>
[NotMapped]
public string LinkUrl { get; set; }
/// <summary>
/// 添加时间
/// </summary>
[NotMapped]
public DateTime? AddDate { get; set; }
/// <summary>
/// 内容副标题
/// </summary>
[NotMapped]
public string SubTitle { get; set; }
/// <summary>
/// 内容图片
/// </summary>
[NotMapped]
public string ImageUrl { get; set; }
/// <summary>
/// 内容视频
/// </summary>
[NotMapped]
public string VideoUrl { get; set; }
/// <summary>
/// 内容附件
/// </summary>
[NotMapped]
public string FileUrl { get; set; }
/// <summary>
/// 内容正文
/// </summary>
[NotMapped]
public string Content { get; set; }
/// <summary>
/// 内容摘要
/// </summary>
[NotMapped]
public string Summary { get; set; }
/// <summary>
/// 作者
/// </summary>
[NotMapped]
public string Author { get; set; }
/// <summary>
/// 来源
/// </summary>
[NotMapped]
public string Source { get; set; }
}

public class AuditList
{
public string siteId { get; set; }
public List<contents> contents { get; set; }
public string reasons { get; set; }
}

public class contents
{
public int channelId { get; set; }
public int id { get; set; }
}
}

+ 27
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs View File

@@ -148,5 +148,32 @@ namespace Learun.Util
}
return result;
}
public static string HttpPosts(string url, string json, WebHeaderCollection header)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/json;charset=UTF-8";
req.Headers.Add(header);
byte[] data = Encoding.UTF8.GetBytes(json);//把字符串转换为字节

req.ContentLength = data.Length; //请求长度

using (Stream reqStream = req.GetRequestStream()) //获取
{
reqStream.Write(data, 0, data.Length);//向当前流中写入字节
reqStream.Close(); //关闭当前流
}

HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); //响应结果
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
}
}

Loading…
Cancel
Save