Skip to content

Commit

Permalink
6.15
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed May 31, 2020
1 parent b2da999 commit 8afc5fc
Show file tree
Hide file tree
Showing 25 changed files with 309 additions and 239 deletions.
5 changes: 3 additions & 2 deletions SiteServer.BackgroundPages/Ajax/AjaxCreateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ public NameValueCollection CreateSiteByOnlineTemplateName(int siteId, bool isImp
CacheUtils.Insert(cacheCurrentCountKey, "1");
CacheUtils.Insert(cacheMessageKey, "开始下载模板压缩包,可能需要几分钟,请耐心等待...");

var filePath = PathUtility.GetSiteTemplatesPath($"T_{onlineTemplateName}.zip");
var fileName = $"T_{onlineTemplateName}.zip";
var filePath = PathUtility.GetSiteTemplatesPath(fileName);
FileUtils.DeleteFileIfExists(filePath);
var downloadUrl = CloudUtils.Dl.GetTemplatesUrl(onlineTemplateName);
var downloadUrl = CloudUtils.Dl.GetTemplatesUrl(fileName);
WebClientUtils.SaveRemoteFileToLocal(downloadUrl, filePath);

CacheUtils.Insert(cacheCurrentCountKey, "2");
Expand Down
6 changes: 3 additions & 3 deletions SiteServer.Utils/CloudUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ public static class Root

public static string IconUrl => $"{Host}/assets/images/favicon.png";

public static string DocsCliUrl => $"{Host}/docs/cli/";
public static string DocsCliUrl => $"{Host}/docs/v6/cli/";

public static string GetDocsStlUrl(string tagName)
{
return $"{Host}/docs/stl/{tagName}/";
return $"{Host}/docs/v6/stl/{tagName}/";
}

public static string GetDocsStlUrl(string tagName, string fieldName, string attrTitle)
{
return $"{Host}/docs/stl/{tagName}/#{fieldName.ToLower()}-{attrTitle.ToLower()}";
return $"{Host}/docs/v6/stl/{tagName}/#{fieldName.ToLower()}-{attrTitle.ToLower()}";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public IHttpActionResult GetConfig()
foreach (var permissionSiteId in siteIdList)
{
var permissionSiteInfo = SiteManager.GetSiteInfo(permissionSiteId);
if (permissionSiteInfo == null) continue;

sites.Add(new
{
permissionSiteInfo.Id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
using SiteServer.Utils;
Expand All @@ -9,6 +10,7 @@

namespace SiteServer.API.Controllers.Pages.Cms
{
[OpenApiIgnore]
[RoutePrefix("pages/cms/editorLayerImage")]
public partial class PagesEditorLayerImageController : ApiController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
using SiteServer.CMS.Model;
using SiteServer.CMS.Model.Enumerations;

namespace SiteServer.API.Controllers.Pages.Cms
{
[OpenApiIgnore]
[RoutePrefix("pages/cms/editorLayerText")]
public partial class PagesEditorLayerTextController : ApiController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.Threading.Tasks;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.API.Results;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
Expand All @@ -10,7 +11,7 @@

namespace SiteServer.API.Controllers.Pages.Cms
{

[OpenApiIgnore]
[RoutePrefix("pages/cms/libraryEditor")]
public class PagesLibraryEditorController : ApiController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;
using System.Threading.Tasks;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.API.Results;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
Expand All @@ -11,7 +11,7 @@

namespace SiteServer.API.Controllers.Pages.Cms
{

[OpenApiIgnore]
[RoutePrefix("pages/cms/libraryImage")]
public partial class PagesLibraryImageController : ApiController
{
Expand Down Expand Up @@ -83,16 +83,15 @@ public LibraryImageInfo Create()
}

var libraryFileName = PathUtils.GetLibraryFileName(fileName);
var virtualDirectoryPath = PathUtils.GetLibraryVirtualPath(EUploadType.Image, libraryFileName);
var virtualPath = PathUtils.GetLibraryVirtualPath(EUploadType.Image, libraryFileName);

var directoryPath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, virtualDirectoryPath);
var filePath = PathUtils.Combine(directoryPath, libraryFileName);
var filePath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, virtualPath);

DirectoryUtils.CreateDirectoryIfNotExists(filePath);
file.SaveAs(filePath);

library.Title = fileName;
library.Url = PageUtils.Combine(virtualDirectoryPath, libraryFileName);
library.Url = virtualPath;

library.Id = DataProvider.LibraryImageDao.Insert(library);

Expand Down Expand Up @@ -131,6 +130,10 @@ public DefaultResult Delete([FromUri]int id)
return Request.Unauthorized<DefaultResult>();
}

var lib = DataProvider.LibraryImageDao.Get(id);
var filePath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, lib.Url);
FileUtils.DeleteFileIfExists(filePath);

DataProvider.LibraryImageDao.Delete(id);

return new DefaultResult
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.IO;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
using SiteServer.Utils;
using SiteServer.Utils.Enumerations;

namespace SiteServer.API.Controllers.Pages.Cms
{
[OpenApiIgnore]
[RoutePrefix("pages/cms/libraryLayerImage")]
public partial class PagesLibraryLayerImageController : ApiController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.IO;
using System.Threading.Tasks;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
using SiteServer.Utils;
using SiteServer.Utils.Enumerations;

namespace SiteServer.API.Controllers.Pages.Cms
{
[OpenApiIgnore]
[RoutePrefix("pages/cms/libraryLayerVideo")]
public partial class PagesLibraryLayerVideoController : ApiController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.API.Results;
using SiteServer.CMS.Core;
using SiteServer.CMS.Core.Office;
Expand All @@ -10,6 +10,7 @@

namespace SiteServer.API.Controllers.Pages.Cms
{
[OpenApiIgnore]
[RoutePrefix("pages/cms/libraryLayerWord")]
public partial class PagesLibraryLayerWordController : ApiController
{
Expand Down
24 changes: 21 additions & 3 deletions SiteServer.Web/Controllers/Pages/Cms/PagesLibraryTextController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;
using System.Threading.Tasks;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.API.Results;
using SiteServer.CMS.Core;
using SiteServer.CMS.Core.Office;
Expand All @@ -12,7 +12,7 @@

namespace SiteServer.API.Controllers.Pages.Cms
{

[OpenApiIgnore]
[RoutePrefix("pages/cms/libraryText")]
public partial class PagesLibraryTextController : ApiController
{
Expand Down Expand Up @@ -97,13 +97,31 @@ public LibraryTextInfo Create()
FileUtils.DeleteFileIfExists(filePath);

library.Title = fileName;
library.ImageUrl = PageUtils.Combine(virtualDirectoryPath, libraryFileName);
library.Content = wordContent;
library.Id = DataProvider.LibraryTextDao.Insert(library);

return library;
}

[HttpPut, Route(RouteId)]
public LibraryTextInfo Update([FromUri] int id, [FromBody] LibraryTextInfo library)
{
var auth = new AuthenticatedRequest();

if (!auth.IsAdminLoggin ||
!auth.AdminPermissionsImpl.HasSitePermissions(auth.SiteId,
ConfigManager.SitePermissions.Library))
{
return Request.Unauthorized<LibraryTextInfo>();
}

var lib = DataProvider.LibraryTextDao.Get(id);
lib.GroupId = library.GroupId;
DataProvider.LibraryTextDao.Update(lib);

return library;
}

[HttpDelete, Route(RouteId)]
public DefaultResult Delete([FromUri]int id)
{
Expand Down
2 changes: 2 additions & 0 deletions SiteServer.Web/Controllers/Preview/PreviewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.CMS.Api.Preview;
using SiteServer.Utils;
using SiteServer.CMS.Core;
Expand All @@ -20,6 +21,7 @@

namespace SiteServer.API.Controllers.Preview
{
[OpenApiIgnore]
public class PreviewController : ApiController
{
[HttpGet, Route(ApiRoutePreview.Route)]
Expand Down
12 changes: 9 additions & 3 deletions SiteServer.Web/Controllers/V1/AdministratorsController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.CMS.Api.V1;
using SiteServer.CMS.Core;
using SiteServer.CMS.DataCache;
Expand All @@ -8,9 +9,6 @@

namespace SiteServer.API.Controllers.V1
{
/// <summary>
/// Administrators
/// </summary>
[RoutePrefix("v1/administrators")]
public class AdministratorsController : ApiController
{
Expand All @@ -20,6 +18,7 @@ public class AdministratorsController : ApiController
private const string RouteActionsResetPassword = "actions/resetPassword";
private const string RouteAdministrator = "{id:int}";

[OpenApiOperation("新增管理员 API", "https://sscms.com/docs/v6/api/guide/administrators/create.html")]
[HttpPost, Route(Route)]
public IHttpActionResult Create([FromBody] AdministratorInfoCreateUpdate adminInfo)
{
Expand Down Expand Up @@ -47,6 +46,7 @@ public IHttpActionResult Create([FromBody] AdministratorInfoCreateUpdate adminIn
}
}

[OpenApiOperation("修改管理员 API", "https://sscms.com/docs/v6/api/guide/administrators/update.html")]
[HttpPut, Route(RouteAdministrator)]
public IHttpActionResult Update(int id, [FromBody] AdministratorInfoCreateUpdate adminInfo)
{
Expand Down Expand Up @@ -78,6 +78,7 @@ public IHttpActionResult Update(int id, [FromBody] AdministratorInfoCreateUpdate
}
}

[OpenApiOperation("删除管理员 API", "https://sscms.com/docs/v6/api/guide/administrators/delete.html")]
[HttpDelete, Route(RouteAdministrator)]
public IHttpActionResult Delete(int id)
{
Expand All @@ -103,6 +104,7 @@ public IHttpActionResult Delete(int id)
}
}

[OpenApiOperation("获取管理员 API", "https://sscms.com/docs/v6/api/guide/administrators/get.html")]
[HttpGet, Route(RouteAdministrator)]
public IHttpActionResult Get(int id)
{
Expand All @@ -128,6 +130,7 @@ public IHttpActionResult Get(int id)
}
}

[OpenApiOperation("获取管理员列表 API", "https://sscms.com/docs/v6/api/guide/administrators/list.html")]
[HttpGet, Route(Route)]
public IHttpActionResult List()
{
Expand All @@ -152,6 +155,7 @@ public IHttpActionResult List()
}
}

[OpenApiOperation("管理员登录 API", "https://sscms.com/docs/v6/api/guide/administrators/login.html")]
[HttpPost, Route(RouteActionsLogin)]
public IHttpActionResult Login()
{
Expand Down Expand Up @@ -212,6 +216,7 @@ public IHttpActionResult Login()
}
}

[OpenApiOperation("管理员退出登录 API", "https://sscms.com/docs/v6/api/guide/administrators/logout.html")]
[HttpPost, Route(RouteActionsLogout)]
public IHttpActionResult Logout()
{
Expand All @@ -233,6 +238,7 @@ public IHttpActionResult Logout()
}
}

[OpenApiOperation("修改管理员密码 API", "https://sscms.com/docs/v6/api/guide/administrators/resetPassword.html")]
[HttpPost, Route(RouteActionsResetPassword)]
public IHttpActionResult ResetPassword()
{
Expand Down
3 changes: 3 additions & 0 deletions SiteServer.Web/Controllers/V1/CaptchaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Web;
using System.Web.Http;
using NSwag.Annotations;
using SiteServer.BackgroundPages.Core;
using SiteServer.CMS.Core;
using SiteServer.Utils;
Expand All @@ -23,6 +24,7 @@ public class CaptchaInfo
public string Captcha { get; set; }
}

[OpenApiOperation("获取验证码图片 API", "https://sscms.com/docs/v6/api/guide/other/captchaGet.html")]
[HttpGet, Route(ApiRoute)]
public void Get(string name)
{
Expand Down Expand Up @@ -89,6 +91,7 @@ public void Get(string name)
response.End();
}

[OpenApiOperation("验证验证码 API", "https://sscms.com/docs/v6/api/guide/other/captchaCheck.html")]
[HttpPost, Route(ApiRouteActionsCheck)]
public IHttpActionResult Check(string name, [FromBody] CaptchaInfo captchaInfo)
{
Expand Down
Loading

0 comments on commit 8afc5fc

Please sign in to comment.