开始业务模块

This commit is contained in:
橙子
2023-01-25 17:48:48 +08:00
parent 80723496d0
commit 99787950a8
60 changed files with 773 additions and 60 deletions

View File

@@ -73,7 +73,7 @@ namespace Yi.Framework.Auth.JwtBearer.Authentication
AuthenticateResult result = AuthenticateResult.Fail("未发现授权令牌");
_context.Request.Headers.TryGetValue("Authorization", out StringValues values);
string valStr = values.ToString();
if (!string.IsNullOrWhiteSpace(valStr))
if (!string.IsNullOrWhiteSpace(valStr) && valStr.Length>10)
{
var tokenHeader = valStr.Substring(0, 6);
if (tokenHeader == "Bearer")

View File

@@ -26,6 +26,7 @@ namespace Yi.Framework.Autofac.Extensions
}
});
services.AddAutoMapper(profileList.ToArray());
return services;
}

View File

@@ -41,6 +41,11 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories
}
public async Task<bool> UpdateIgnoreNullAsync(T updateObj)
{
return await _Db.Updateable(updateObj).IgnoreColumns(true).ExecuteCommandAsync() > 0;
}
public override async Task<bool> DeleteAsync(T deleteObj)
{
//逻辑删除

View File

@@ -14,7 +14,7 @@ namespace Yi.Framework.Core.Exceptions
IHasErrorDetails,
IHasLogLevel
{
public ResultCodeEnum Code { get; set; }
public int Code { get; set; }
public string? Details { get; set; }
@@ -28,7 +28,7 @@ namespace Yi.Framework.Core.Exceptions
LogLevel logLevel = LogLevel.Warning)
: base(message, innerException)
{
Code = code;
Code =(int) code;
Details = details;
LogLevel = logLevel;
}

View File

@@ -14,14 +14,14 @@ namespace Yi.Framework.Core.Exceptions
IHasErrorDetails,
IHasLogLevel
{
public ResultCodeEnum Code { get; set; }
public int Code { get; set; }
public string? Details { get; set; }
public LogLevel LogLevel { get; set; }
public BusinessException(
ResultCodeEnum code = ResultCodeEnum.NotSuccess,
int code = (int)ResultCodeEnum.NotSuccess,
string? message = null,
string? details = null,
Exception? innerException = null,

View File

@@ -35,8 +35,8 @@ public static class ExceptionExtensions
/// <param name="exception"></param>
/// <param name="defaultLevel"></param>
/// <returns></returns>
public static ResultCodeEnum GetLogErrorCode(this Exception exception, ResultCodeEnum defaultCode = ResultCodeEnum.NotSuccess)
public static int GetLogErrorCode(this Exception exception, ResultCodeEnum defaultCode = ResultCodeEnum.NotSuccess)
{
return (exception as IHasErrorCode)?.Code ?? defaultCode;
return (exception as IHasErrorCode)?.Code ?? (int)defaultCode;
}
}

View File

@@ -9,6 +9,6 @@ namespace Yi.Framework.Core.Exceptions
{
internal interface IHasErrorCode
{
ResultCodeEnum Code { get; }
int Code { get; }
}
}

View File

@@ -9,8 +9,24 @@ using Yi.Framework.Core.Enums;
namespace Yi.Framework.Core.Exceptions
{
public class UserFriendlyException: BusinessException
public class UserFriendlyException : BusinessException
{
public UserFriendlyException(
string message,
int code = (int)ResultCodeEnum.NotSuccess,
string? details = null,
Exception? innerException = null,
LogLevel logLevel = LogLevel.Warning)
: base(
code,
message,
details,
innerException,
logLevel)
{
Details = details;
}
public UserFriendlyException(
string message,
ResultCodeEnum code = ResultCodeEnum.NotSuccess,
@@ -18,7 +34,7 @@ namespace Yi.Framework.Core.Exceptions
Exception? innerException = null,
LogLevel logLevel = LogLevel.Warning)
: base(
code,
(int)code,
message,
details,
innerException,

View File

@@ -26,7 +26,7 @@ namespace Yi.Framework.Ddd.Entities
[Serializable]
public abstract class Entity<TKey> : Entity, IEntity<TKey>, IEntity
{
public virtual TKey Id { get; protected set; }
public virtual TKey Id { get; set; }
protected Entity()
{

View File

@@ -18,6 +18,6 @@ namespace Yi.Framework.Ddd.Entities
//
// 摘要:
// Unique identifier for this entity.
TKey Id { get;}
TKey Id { get; set; }
}
}

View File

@@ -43,6 +43,7 @@ namespace Yi.Framework.Ddd.Repositories
Task<bool> UpdateAsync(T updateObj);
Task<bool> UpdateRangeAsync(List<T> updateObjs);
Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
Task<bool> UpdateIgnoreNullAsync(T updateObj);
//删除
Task<bool> DeleteAsync(T deleteObj);

View File

@@ -82,6 +82,12 @@ namespace Yi.Framework.Ddd.Services
return Task.CompletedTask;
}
protected virtual Task<TEntity> MapToEntityAsync(TUpdateInput updateInput)
{
var entity = _mapper.Map<TEntity>(updateInput);
return Task.FromResult(entity);
}
/// <summary>
/// 增
/// </summary>
@@ -125,12 +131,14 @@ namespace Yi.Framework.Ddd.Services
{
throw new ArgumentNullException(nameof(id));
}
var entity = await _repository.GetByIdAsync(id);
var entity = await MapToEntityAsync(input);
entity.Id = id;
await _repository.UpdateIgnoreNullAsync(entity);
await MapToEntityAsync(input, entity);
await _repository.UpdateAsync(entity);
var newEntity = await _repository.GetByIdAsync(id);
return await MapToGetOutputDtoAsync(entity);
return await MapToGetOutputDtoAsync(newEntity);
}
}
}

View File

@@ -62,7 +62,7 @@ where TEntityDto : IEntityDto<TKey>
/// <param name="id"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<TGetOutputDto> GetAsync(TKey id)
public virtual async Task<TGetOutputDto> GetAsync(TKey id)
{
if (id is null)
{
@@ -79,7 +79,7 @@ where TEntityDto : IEntityDto<TKey>
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
public virtual async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
{
var totalCount = await _repository.CountAsync(_ => true);

View File

@@ -7,10 +7,20 @@ TemplateFactory templateFactory = new();
//选择需要生成的模板提供者
//string modelName = "GlobalSetting";
//string nameSpaces = "Yi.BBS";
//List<string> entityNames = new() { "Setting" };
//string modelName = "Exhibition";
//string nameSpaces = "Yi.BBS";
//List<string> entityNames = new() { "Banner" };
string modelName = "Forum";
string nameSpaces = "Yi.BBS";
List<string> entityNames = new() { "Plate" };
foreach (var entityName in entityNames)
{
templateFactory.CreateTemplateProviders((option) =>

View File

@@ -12,7 +12,7 @@ namespace Yi.Framework.Template.Provider.Server
{
public CreateInputVoTemplateProvider(string modelName, string entityName, string nameSpaces) : base(modelName, entityName, nameSpaces)
{
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}CreateInputVo.cs";
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}\{TemplateConst.EntityName}CreateInputVo.cs";
TemplatePath = $@"..\..\..\Template\Server\CreateInputVoTemplate.txt";
EntityPath = $@"{TemplateConst.BuildEntityPath}\{nameSpaces}.Domain\{TemplateConst.ModelName}\Entities\{TemplateConst.EntityName}Entity.cs";
}

View File

@@ -12,7 +12,7 @@ namespace Yi.Framework.Template.Provider.Server
{
public GetListInputVoTemplateProvider(string modelName, string entityName, string nameSpaces) : base(modelName, entityName, nameSpaces)
{
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}GetListInputVo.cs";
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}\{TemplateConst.EntityName}GetListInputVo.cs";
TemplatePath = $@"..\..\..\Template\Server\GetListInputVoTemplate.txt";
EntityPath = $@"{TemplateConst.BuildEntityPath}\{nameSpaces}.Domain\{TemplateConst.ModelName}\Entities\{TemplateConst.EntityName}Entity.cs";
}

View File

@@ -12,7 +12,7 @@ namespace Yi.Framework.Template.Provider.Server
{
public GetListOutputDtoTemplateProvider(string modelName, string entityName, string nameSpaces) : base(modelName, entityName, nameSpaces)
{
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}GetListOutputDto.cs";
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}\{TemplateConst.EntityName}GetListOutputDto.cs";
TemplatePath = $@"..\..\..\Template\Server\GetListOutputDtoTemplate.txt";
EntityPath = $@"{TemplateConst.BuildEntityPath}\{nameSpaces}.Domain\{TemplateConst.ModelName}\Entities\{TemplateConst.EntityName}Entity.cs";
}

View File

@@ -12,7 +12,7 @@ namespace Yi.Framework.Template.Provider.Server
{
public UpdateInputVoTemplateProvider(string modelName, string entityName, string nameSpaces) : base(modelName, entityName, nameSpaces)
{
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}UpdateInputVo.cs";
BuildPath = $@"{TemplateConst.BuildRootPath}\{nameSpaces}.Application.Contracts\{TemplateConst.ModelName}\Dtos\{TemplateConst.EntityName}\{TemplateConst.EntityName}UpdateInputVo.cs";
TemplatePath = $@"..\..\..\Template\Server\UpdateInputVoTemplate.txt";
EntityPath = $@"{TemplateConst.BuildEntityPath}\{nameSpaces}.Domain\{TemplateConst.ModelName}\Entities\{TemplateConst.EntityName}Entity.cs";
}

View File

@@ -9,7 +9,7 @@ using Yi.Framework.Ddd.Services.Abstract;
namespace #NameSpaces#.Application.Contracts.#ModelName#
{
/// <summary>
/// #EntityName#<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// #EntityName#服务抽象
/// </summary>
public interface I#EntityName#Service : ICrudAppService<#EntityName#GetOutputDto, #EntityName#GetListOutputDto, long, #EntityName#GetListInputVo, #EntityName#CreateInputVo, #EntityName#UpdateInputVo>
{

View File

@@ -1,3 +1,4 @@
global using Yi.Framework.Core.Attributes;
global using Yi.Framework.Core.Helper;
global using Yi.Framework.Core.Model;
global using Yi.Framework.Core.Model;
global using Yi.Framework.Core.Exceptions;

View File

@@ -4,15 +4,46 @@
<name>Yi.BBS.Application.Contracts</name>
</assembly>
<members>
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.PlateCreateInputVo">
<member name="T:Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner.BannerCreateInputVo">
<summary>
Banner输入创建对象
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Exhibition.IBannerService">
<summary>
Banner抽象
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.Discuss.DiscussCreateInputVo">
<summary>
Discuss输入创建对象
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Forum.Dtos.Plate.PlateCreateInputVo">
<summary>
Plate输入创建对象
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Forum.IDiscussService">
<summary>
Discuss服务抽象
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.Forum.IPlateService">
<summary>
Plate<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Plate服务抽象
</summary>
</member>
<member name="T:Yi.BBS.Application.Contracts.GlobalSetting.ISettingService">
<summary>
Setting应用抽象
</summary>
</member>
<member name="M:Yi.BBS.Application.Contracts.GlobalSetting.ISettingService.GetTitleAsync">
<summary>
获取配置标题
</summary>
<returns></returns>
</member>
</members>
</doc>

View File

@@ -4,10 +4,63 @@
<name>Yi.BBS.Application</name>
</assembly>
<members>
<member name="T:Yi.BBS.Application.Exhibition.BannerService">
<summary>
Banner服务实现
</summary>
</member>
<member name="T:Yi.BBS.Application.Forum.DiscussService">
<summary>
Discuss服务实现
</summary>
</member>
<member name="T:Yi.BBS.Application.Forum.PlateService">
<summary>
Plate服务实现
</summary>
</member>
<member name="T:Yi.BBS.Application.GlobalSetting.SettingService">
<summary>
Setting服务实现
</summary>
</member>
<member name="M:Yi.BBS.Application.GlobalSetting.SettingService.GetTitleAsync">
<summary>
获取配置标题
</summary>
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="T:Yi.BBS.Application.GlobalSetting.TempService">
<summary>
临时服务,之后用其他模块代替
</summary>
</member>
<member name="M:Yi.BBS.Application.GlobalSetting.TempService.PostLoginAsync">
<summary>
登录
</summary>
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="M:Yi.BBS.Application.GlobalSetting.TempService.PostLogged">
<summary>
判断是否有登录
</summary>
<returns></returns>
</member>
<member name="M:Yi.BBS.Application.GlobalSetting.TempService.PostlogOut">
<summary>
退出登录
</summary>
<returns></returns>
</member>
<member name="M:Yi.BBS.Application.GlobalSetting.TempService.GetUserInfoByIdAsync(System.Int64)">
<summary>
获取用户信息
</summary>
<param name="id"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@@ -4,7 +4,7 @@
"Yi.BBS.Web": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:19003",
"environmentVariables": {

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner
{
/// <summary>
/// Banner输入创建对象
/// </summary>
public class BannerCreateInputVo
{
public string Name { get; set; }
public string? Logo { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner
{
public class BannerGetListInputVo : PagedAndSortedResultRequestDto
{
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner
{
public class BannerGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos
{
public class BannerGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner
{
public class BannerUpdateInputVo
{
public string? Name { get; set; }
public string? Logo { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Exhibition.Dtos;
using Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner;
using Yi.Framework.Ddd.Services.Abstract;
namespace Yi.BBS.Application.Contracts.Exhibition
{
/// <summary>
/// Banner抽象
/// </summary>
public interface IBannerService : ICrudAppService<BannerGetOutputDto, BannerGetListOutputDto, long, BannerGetListInputVo, BannerCreateInputVo, BannerUpdateInputVo>
{
}
}

View File

@@ -4,20 +4,21 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
{
/// <summary>
/// Plate输入创建对象
/// Discuss输入创建对象
/// </summary>
public class PlateCreateInputVo
public class DiscussCreateInputVo
{
public long Id { get; set; }
public string Title { get; set; }
public string PlateType { get; set; }
public string Introduction { get; set; }
public string Types { get; set; }
public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
{
public class DiscussGetListInputVo : PagedAndSortedResultRequestDto
{
}
}

View File

@@ -5,17 +5,18 @@ using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
{
public class PlateGetListOutputDto : IEntityDto<long>
public class DiscussGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Title { get; set; }
public string PlateType { get; set; }
public string Introduction { get; set; }
public string Types { get; set; }
public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -7,15 +7,16 @@ using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
{
public class PlateGetListInputVo : PagedAndSortedResultRequestDto
public class DiscussGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Title { get; set; }
public string PlateType { get; set; }
public string Introduction { get; set; }
public string Types { get; set; }
public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -4,17 +4,17 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Forum.Dtos
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
{
public class PlateUpdateInputVo
public class DiscussUpdateInputVo
{
public long Id { get; set; }
public string Title { get; set; }
public string PlateType { get; set; }
public string Introduction { get; set; }
public string Types { get; set; }
public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string? Color { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Plate
{
/// <summary>
/// Plate输入创建对象
/// </summary>
public class PlateCreateInputVo
{
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Plate
{
public class PlateGetListInputVo : PagedAndSortedResultRequestDto
{
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Plate
{
public class PlateGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
}
}

View File

@@ -10,12 +10,8 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
public class PlateGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public string Title { get; set; }
public string PlateType { get; set; }
public string Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.Forum.Dtos.Plate
{
public class PlateUpdateInputVo
{
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Application.Contracts.Forum.Dtos.Discuss;
using Yi.Framework.Ddd.Services.Abstract;
namespace Yi.BBS.Application.Contracts.Forum
{
/// <summary>
/// Discuss服务抽象
/// </summary>
public interface IDiscussService : ICrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, long, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>
{
}
}

View File

@@ -4,12 +4,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Application.Contracts.Forum.Dtos.Plate;
using Yi.Framework.Ddd.Services.Abstract;
namespace Yi.BBS.Application.Contracts.Forum
{
/// <summary>
/// Plate<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// Plate服务抽象
/// </summary>
public interface IPlateService : ICrudAppService<PlateGetOutputDto, PlateGetListOutputDto, long, PlateGetListInputVo, PlateCreateInputVo, PlateUpdateInputVo>
{

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.GlobalSetting.Dtos.Temp
{
public class ActionJwtDto
{
public int Id { get; set; }
public string ActionName { get; set; }
public string Router { get; set; }
public string Icon { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Application.Contracts.GlobalSetting.Dtos.Temp
{
public class LoginDto
{
public LoginDto(string token)
{
Token = token;
}
public string Token { get; set; }
public LoginUserInfoDto User{get;set;}
}
public class LoginUserInfoDto
{
public long Id { get; set; }
public string UserName { get; set; }
public int Level { get; set; }
public string Icon { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Services.Abstract;
namespace Yi.BBS.Application.Contracts.GlobalSetting
{
/// <summary>
/// Setting应用抽象
/// </summary>
public interface ISettingService : IApplicationService
{
/// <summary>
/// 获取配置标题
/// </summary>
/// <returns></returns>
Task<string> GetTitleAsync();
}
}

View File

@@ -0,0 +1,18 @@
using Yi.BBS.Application.Contracts.Exhibition;
using NET.AutoWebApi.Setting;
using Yi.BBS.Application.Contracts.Exhibition.Dtos;
using Yi.BBS.Domain.Exhibition.Entities;
using Yi.Framework.Ddd.Services;
using Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner;
namespace Yi.BBS.Application.Exhibition
{
/// <summary>
/// Banner服务实现
/// </summary>
[AppService]
public class BannerService : CrudAppService<BannerEntity, BannerGetOutputDto, BannerGetListOutputDto, long, BannerGetListInputVo, BannerCreateInputVo, BannerUpdateInputVo>,
IBannerService, IAutoApiService
{
}
}

View File

@@ -0,0 +1,24 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Exhibition.Dtos;
using Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner;
using Yi.BBS.Domain.Exhibition.Entities;
namespace Yi.BBS.Application.Exhibition.MapperConfig
{
public class BannerProfile: Profile
{
public BannerProfile()
{
CreateMap<BannerGetListInputVo, BannerEntity>();
CreateMap<BannerCreateInputVo, BannerEntity>();
CreateMap<BannerUpdateInputVo, BannerEntity>();
CreateMap<BannerEntity, BannerGetListOutputDto>();
CreateMap<BannerEntity, BannerGetOutputDto>();
}
}
}

View File

@@ -0,0 +1,27 @@
using Yi.BBS.Application.Contracts.Forum;
using NET.AutoWebApi.Setting;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Domain.Forum.Entities;
using Yi.Framework.Ddd.Services;
using Yi.BBS.Application.Contracts.Forum.Dtos.Discuss;
using Microsoft.AspNetCore.Mvc;
using Yi.Framework.Ddd.Dtos;
namespace Yi.BBS.Application.Forum
{
/// <summary>
/// Discuss服务实现
/// </summary>
[AppService]
public class DiscussService : CrudAppService<DiscussEntity, DiscussGetOutputDto, DiscussGetListOutputDto, long, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
IDiscussService, IAutoApiService
{
public async Task<PagedResultDto<DiscussGetListOutputDto>> GetPlateIdAsync([FromRoute] long plateId, [FromQuery] DiscussGetListInputVo input)
{
var entities = await _repository.GetPageListAsync(x => x.PlateId == plateId, input);
var items= await MapToGetListOutputDtosAsync(entities);
var total = await _repository.CountAsync(x=>x.IsDeleted==false);
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
}
}
}

View File

@@ -0,0 +1,24 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Application.Contracts.Forum.Dtos.Discuss;
using Yi.BBS.Domain.Forum.Entities;
namespace Yi.BBS.Application.Forum.MapperConfig
{
public class DiscussProfile: Profile
{
public DiscussProfile()
{
CreateMap<DiscussGetListInputVo, DiscussEntity>();
CreateMap<DiscussCreateInputVo, DiscussEntity>();
CreateMap<DiscussUpdateInputVo, DiscussEntity>();
CreateMap<DiscussEntity, DiscussGetListOutputDto>();
CreateMap<DiscussEntity, DiscussGetOutputDto>();
}
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Application.Contracts.Forum.Dtos.Plate;
using Yi.BBS.Domain.Forum.Entities;
namespace Yi.BBS.Application.Forum.MapperConfig

View File

@@ -3,6 +3,7 @@ using NET.AutoWebApi.Setting;
using Yi.BBS.Application.Contracts.Forum.Dtos;
using Yi.BBS.Domain.Forum.Entities;
using Yi.Framework.Ddd.Services;
using Yi.BBS.Application.Contracts.Forum.Dtos.Plate;
namespace Yi.BBS.Application.Forum
{

View File

@@ -0,0 +1,25 @@
using Yi.BBS.Application.Contracts.GlobalSetting;
using NET.AutoWebApi.Setting;
using Yi.BBS.Domain.GlobalSetting.Entities;
using Yi.Framework.Ddd.Services;
namespace Yi.BBS.Application.GlobalSetting
{
/// <summary>
/// Setting服务实现
/// </summary>
[AppService]
public class SettingService : ApplicationService,
ISettingService, IAutoApiService
{
/// <summary>
/// 获取配置标题
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<string> GetTitleAsync()
{
return Task.FromResult("你好世界");
}
}
}

View File

@@ -0,0 +1,76 @@
using Yi.BBS.Application.Contracts.GlobalSetting;
using NET.AutoWebApi.Setting;
using Yi.BBS.Domain.GlobalSetting.Entities;
using Yi.Framework.Ddd.Services;
using Microsoft.AspNetCore.Mvc;
using Yi.BBS.Application.Contracts.GlobalSetting.Dtos.Temp;
using Yi.BBS.Domain.Shared;
namespace Yi.BBS.Application.GlobalSetting
{
/// <summary>
///临时服务,之后用其他模块代替
/// </summary>
[AppService]
public class TempService : ApplicationService, IAutoApiService
{
/// <summary>
/// 登录
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[Route("/api/account/login")]
public Task<LoginDto> PostLoginAsync()
{
bool loginSucces = true;
if (!loginSucces)
{
throw new UserFriendlyException("登录失败", (int)BbsHttpStatusEnum.LoginFailed, "用户或者密码错误");
}
var dto = new LoginDto("token");
dto.User = new LoginUserInfoDto { Icon = "", Id = 0, Level = 1, UserName = "橙子" };
return Task.FromResult(dto);
}
/// <summary>
/// 判断是否有登录
/// </summary>
/// <returns></returns>
[Route("/api/account/logged")]
public Task<bool> PostLogged()
{
return Task.FromResult(true);
}
/// <summary>
/// 退出登录
/// </summary>
/// <returns></returns>
[Route("/api/account/logout")]
public Task PostlogOut()
{
return Task.CompletedTask;
}
/// <summary>
/// 获取用户信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Route("/api/account/user/{id}")]
public Task<List<ActionJwtDto>> GetUserInfoByIdAsync(long id)
{
var dto = new List<ActionJwtDto>();
dto.Add(new ActionJwtDto { Router = "/index", ActionName = "首页" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
//dto.Add(new ActionJwtDto { Router = "", ActionName = "" });
return Task.FromResult(dto);
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Domain.Shared
{
public enum BbsHttpStatusEnum
{
LoginFailed=1900
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Domain.Shared.Exhibition.ConstClasses
{
/// <summary>
/// 常量定义
/// </summary>
public class BannerConst
{
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.BBS.Domain.Shared.Forum.ConstClasses
{
/// <summary>
/// 常量定义
/// </summary>
public class DiscussConst
{
}
}

View File

@@ -0,0 +1,22 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.BBS.Domain.Exhibition.Entities
{
[SugarTable("Banner")]
public class BannerEntity : IEntity<long>, ISoftDelete
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Color { get; set; }
public bool IsDeleted { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.BBS.Domain.Forum.Entities
{
[SugarTable("Discuss")]
public class DiscussEntity : IEntity<long>, ISoftDelete
{
public DiscussEntity(long plateId)
{
PlateId = plateId;
}
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string Title { get; set; }
public string Types { get; set; }
public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string? Color { get; set; }
public bool IsDeleted { get; set; }
public long PlateId { get; set; }
}
}

View File

@@ -14,14 +14,9 @@ namespace Yi.BBS.Domain.Forum.Entities
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string Title { get; set; }
public string PlateType { get; set; }
public string Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; }
public int SeeNum { get; set; }
public string Content { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public bool IsDeleted { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.BBS.Domain.GlobalSetting.Entities
{
[SugarTable("Setting")]
public class SettingEntity : IEntity<long>
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public int CommentPage { get; set; }
public int DiscussPage { get; set; }
public int CommentExperience { get; set; }
public int DiscussExperience { get; set; }
public string Title { get; set; }
}
}