diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index d10b11a6..bb267175 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -192,14 +192,14 @@ - + 没啥说,登录 - + 没啥说,注册 @@ -224,7 +224,7 @@ - + 自己更新密码 @@ -438,21 +438,21 @@ - + 给多用户设置多角色 - + 添加角色包含菜单 - + 更新角色信息 @@ -466,7 +466,7 @@ - + 更改角色数据权限 @@ -501,7 +501,7 @@ - + 给多用户设置多角色 @@ -515,21 +515,21 @@ - + 更新用户信息 - + 更新个人中心信息 - + 添加用户 @@ -701,5 +701,41 @@ + + + 增 + + + + + + + 查 + + + + + + + 查 + + + + + + + 删 + + + + + + + 更 + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/AgreeController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/AgreeController.cs index 0bfe0e0c..e76c7a02 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/AgreeController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/AgreeController.cs @@ -6,8 +6,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Yi.Framework.Common.Attribute; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel.Vo; using Yi.Framework.Interface; using Yi.Framework.Interface.BBS; using Yi.Framework.Model.BBS.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/ArticleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/ArticleController.cs index 6c9865d5..20684cf5 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/ArticleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/ArticleController.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel.Vo; +using Yi.Framework.DTOModel.Base.Vo; using Yi.Framework.Interface; using Yi.Framework.Interface.BBS; using Yi.Framework.Model.BBS.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/CommentController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/CommentController.cs index 521b59e8..0903f0b9 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/CommentController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BBS/CommentController.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel.Vo; +using Yi.Framework.DTOModel.Base.Vo; using Yi.Framework.Interface; using Yi.Framework.Interface.BBS; using Yi.Framework.Model.BBS.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/AccountController.cs index ca30359f..8efd9aa9 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/AccountController.cs @@ -12,7 +12,7 @@ using Yi.Framework.Common.Helper; using Yi.Framework.Common.Models; using Yi.Framework.Core; using Yi.Framework.Core.Cache; -using Yi.Framework.DTOModel; +using Yi.Framework.DTOModel.Base.Dto; using Yi.Framework.Interface; using Yi.Framework.Interface.RABC; using Yi.Framework.Model.RABC.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/RoleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/RoleController.cs index 519ee379..2c350da9 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/RoleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/RoleController.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel; +using Yi.Framework.DTOModel.Base.Dto; using Yi.Framework.Interface; using Yi.Framework.Interface.RABC; using Yi.Framework.Model.RABC.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/UserController.cs index e28dc5a3..979bd12b 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/UserController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RABC/UserController.cs @@ -10,7 +10,7 @@ using Yi.Framework.Common.Const; using Yi.Framework.Common.Enum; using Yi.Framework.Common.Helper; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel; +using Yi.Framework.DTOModel.Base.Dto; using Yi.Framework.Interface; using Yi.Framework.Interface.RABC; using Yi.Framework.Model.RABC.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs new file mode 100644 index 00000000..f98c18ba --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs @@ -0,0 +1,98 @@ + +using Microsoft.AspNetCore.Mvc; +using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel.RABC.Student; +using Yi.Framework.Interface.RABC; + +namespace Brick.IFServer.Controllers +{ + [ApiController] + [Route("[controller]")] + public class StudentController : ControllerBase + { + + private readonly ILogger _logger; + private readonly IStudentService _studentService; + public StudentController(ILogger logger, IStudentService studentService) + { + _logger = logger; + _studentService = studentService; + } + + [HttpDelete] + [Route("ErrorTest")] + public Result ErrorTest() + { + _studentService.GetError(); + return Result.Success(); + } + + /// + /// + /// + /// + /// + [HttpPost] + public async Task> Create(StudentCreateInput studentCreateInput) + { + var result = await _studentService.CreateAsync(studentCreateInput); + + return Result.Success().SetData(result); + + } + + /// + /// + /// + /// + /// + [HttpGet] + [Route("{id}")] + public async Task> GetById(Guid id) + { + var result = await _studentService.GetByIdAsync(id); + return Result.Success().SetData(result); + } + + /// + /// + /// + /// + /// + [HttpGet] + public async Task>> GetLsit() + { + var result = await _studentService.GetListAsync(); + + return Result>.Success().SetData(result); + } + + /// + /// ɾ + /// + /// + /// + [HttpDelete] + public async Task> Del(List ids) + { + await _studentService.DeleteAsync(ids); + return Result.Success(); + } + + /// + /// + /// + /// + /// + /// + [HttpPut] + [Route("{id}")] + public async Task> Update(Guid id, StudentUpdateInput studentUpdateInput) + { + var result = await _studentService.UpdateAsync(id, studentUpdateInput); + return Result.Success().SetData(result); + } + + + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index d44570fd..ee93ef51 100644 Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Attribute/AutowiredAttribute.cs b/Yi.Framework.Net6/Yi.Framework.Common/Attribute/AutowiredAttribute.cs index dd774be5..ec89d56f 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Attribute/AutowiredAttribute.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Attribute/AutowiredAttribute.cs @@ -4,10 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace System +namespace Yi.Framework.Common.Attribute { [AttributeUsage(AttributeTargets.Property)] - public class AutowiredAttribute : Attribute + public class AutowiredAttribute : System.Attribute { } } diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/BusinessException.cs b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/BusinessException.cs new file mode 100644 index 00000000..b4116638 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/BusinessException.cs @@ -0,0 +1,47 @@ +using System; +using System.Runtime.Serialization; +using Microsoft.Extensions.Logging; +using Yi.Framework.Common.Enum; + +namespace Yi.Framework.Common.Exceptions; + +[Serializable] +public class BusinessException : Exception, + IHasErrorCode, + IHasErrorDetails, + IHasLogLevel +{ + public ResultCodeEnum Code { get; set; } + + public string Details { get; set; } + + public LogLevel LogLevel { get; set; } + + public BusinessException( + ResultCodeEnum code = ResultCodeEnum.NotSuccess, + string message = null, + string details = null, + Exception innerException = null, + LogLevel logLevel = LogLevel.Warning) + : base(message, innerException) + { + Code = code; + Details = details; + LogLevel = logLevel; + } + + /// + /// 序列化参数的构造函数 + /// + public BusinessException(SerializationInfo serializationInfo, StreamingContext context) + : base(serializationInfo, context) + { + + } + + public BusinessException WithData(string name, object value) + { + Data[name] = value; + return this; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/ExceptionExtensions.cs b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/ExceptionExtensions.cs new file mode 100644 index 00000000..29e7296d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/ExceptionExtensions.cs @@ -0,0 +1,42 @@ +using System; +using System.Runtime.ExceptionServices; +using Microsoft.Extensions.Logging; +using Yi.Framework.Common.Enum; + +namespace Yi.Framework.Common.Exceptions; + +/// +/// չ +/// +public static class ExceptionExtensions +{ + /// + /// ʹ ٴ׳쳣 + /// + /// Exception to be re-thrown + public static void ReThrow(this Exception exception) + { + ExceptionDispatchInfo.Capture(exception).Throw(); + } + + /// + /// ȡ쳣е־ȼ + /// + /// + /// + /// + public static LogLevel GetLogLevel(this Exception exception, LogLevel defaultLevel = LogLevel.Error) + { + return (exception as IHasLogLevel)?.LogLevel ?? defaultLevel; + } + /// + /// ȡ쳣е־ + /// + /// + /// + /// + public static ResultCodeEnum GetLogErrorCode(this Exception exception, ResultCodeEnum defaultCode = ResultCodeEnum.NotSuccess) + { + return (exception as IHasErrorCode)?.Code ?? defaultCode; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasErrorCode.cs b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasErrorCode.cs new file mode 100644 index 00000000..74efb4c9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasErrorCode.cs @@ -0,0 +1,8 @@ +using Yi.Framework.Common.Enum; + +namespace Yi.Framework.Common.Exceptions; + +public interface IHasErrorCode +{ + ResultCodeEnum Code { get; } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasErrorDetails.cs b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasErrorDetails.cs new file mode 100644 index 00000000..ed892d21 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasErrorDetails.cs @@ -0,0 +1,6 @@ +namespace Yi.Framework.Common.Exceptions; + +public interface IHasErrorDetails +{ + string Details { get; } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasLogLevel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasLogLevel.cs new file mode 100644 index 00000000..7c273baa --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/IHasLogLevel.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.Logging; + +namespace Yi.Framework.Common.Exceptions; + +/// +/// ԵĽӿ +/// +public interface IHasLogLevel +{ + /// + /// Log severity. + /// + LogLevel LogLevel { get; set; } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/UserFriendlyException.cs b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/UserFriendlyException.cs new file mode 100644 index 00000000..b47ab9be --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Exceptions/UserFriendlyException.cs @@ -0,0 +1,38 @@ +using System; +using System.Runtime.Serialization; +using Microsoft.Extensions.Logging; +using Yi.Framework.Common.Enum; + +namespace Yi.Framework.Common.Exceptions; + +/// +/// ûѺ쳣 +/// +[Serializable] +public class UserFriendlyException : BusinessException +{ + public UserFriendlyException( + string message, + ResultCodeEnum code = ResultCodeEnum.NotSuccess, + string details = null, + Exception innerException = null, + LogLevel logLevel = LogLevel.Warning) + : base( + code, + message, + details, + innerException, + logLevel) + { + Details = details; + } + + /// + /// лĹ캯 + /// + public UserFriendlyException(SerializationInfo serializationInfo, StreamingContext context) + : base(serializationInfo, context) + { + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs index 345f657d..f0f75e4b 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs @@ -7,66 +7,66 @@ namespace Yi.Framework.Common.Models public class Result { public static IStringLocalizer _local; - public ResultCodeEnum code { get; set; } + public ResultCodeEnum Code { get; set; } - public bool status { get; set; } - public string message { get; set; } - public object data { get; set; } - public static Result Expire(ResultCodeEnum code, string msg="") + public bool Status { get; set; } + public string Message { get; set; } + public object Data { get; set; } + public static Result Expire(ResultCodeEnum Code, string msg="") { - return new Result() { code = code, status=false, message = Get(msg, "token_expiration") }; + return new Result() { Code = Code, Status=false, Message = Get(msg, "token_expiration") }; } public static Result Error(string msg = "") { - return new Result() { code = ResultCodeEnum.NotSuccess,status=false, message =Get(msg, "fail") }; + return new Result() { Code = ResultCodeEnum.NotSuccess, Status = false, Message = Get(msg, "fail") }; } public static Result Success(string msg = "") { - return new Result() { code = ResultCodeEnum.Success,status=true, message =Get( msg, "succeed" )}; + return new Result() { Code = ResultCodeEnum.Success, Status = true, Message = Get( msg, "succeed" )}; } public static Result SuccessError(string msg = "") { - return new Result() { code = ResultCodeEnum.Success, status = false, message = Get(msg, "fail") }; + return new Result() { Code = ResultCodeEnum.Success, Status = false, Message = Get(msg, "fail") }; } public static Result UnAuthorize(string msg = "") { - return new Result() { code = ResultCodeEnum.NoPermission,status=false, message = Get(msg, "unAuthorize") }; + return new Result() { Code = ResultCodeEnum.NoPermission, Status = false, Message = Get(msg, "unAuthorize") }; } - public Result SetStatus(bool _status) + public Result SetStatus(bool _Status) { - if (_status) + if (_Status) { - this.code = ResultCodeEnum.Success; - this.message = "操作成功"; + this.Code = ResultCodeEnum.Success; + this.Message = "操作成功"; } else { - this.code = code = ResultCodeEnum.NotSuccess; - this.message = "操作失败"; + this.Code = ResultCodeEnum.NotSuccess; + this.Message = "操作失败"; } - this.status = _status; + this.Status = _Status; return this; } public Result SetData(object obj) { - this.data = obj; + this.Data = obj; return this; } public Result SetCode(ResultCodeEnum Code) { - this.code = Code; + this.Code = Code; return this; } public Result StatusFalse() { - this.status = false; + this.Status = false; return this; } public Result StatusTrue() { - this.status = true; + this.Status = true; return this; } @@ -81,31 +81,31 @@ namespace Yi.Framework.Common.Models } public class Result { - public ResultCodeEnum code { get; set; } - public string message { get; set; } - public T data { get; set; } + public ResultCodeEnum Code { get; set; } + public string Message { get; set; } + public T Data { get; set; } public static Result Error(string msg = "fail") { - return new Result() { code = ResultCodeEnum.NotSuccess, message = msg }; + return new Result() { Code = ResultCodeEnum.NotSuccess, Message = msg }; } public static Result Success(string msg = "succeed") { - return new Result() { code = ResultCodeEnum.Success, message = msg }; + return new Result() { Code = ResultCodeEnum.Success, Message = msg }; } public static Result UnAuthorize(string msg = "unAuthorize") { - return new Result() { code = ResultCodeEnum.NoPermission, message = msg }; + return new Result() { Code = ResultCodeEnum.NoPermission, Message = msg }; } public Result SetData(T TValue) { - this.data = TValue; + this.Data = TValue; return this; } public Result SetCode(ResultCodeEnum Code) { - this.code = Code; + this.Code = Code; return this; } } diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/GiveRoleSetMenuDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/GiveRoleSetMenuDto.cs similarity index 86% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/GiveRoleSetMenuDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/GiveRoleSetMenuDto.cs index 488ab7c5..97d9d28a 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/GiveRoleSetMenuDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/GiveRoleSetMenuDto.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class GiveRoleSetMenuDto { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/GiveUserSetRoleDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/GiveUserSetRoleDto.cs similarity index 71% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/GiveUserSetRoleDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/GiveUserSetRoleDto.cs index 123afd52..fbda4fb1 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/GiveUserSetRoleDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/GiveUserSetRoleDto.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class GiveUserSetRoleDto { public List UserIds { get; set; } - public List RoleIds { get; set;} + public List RoleIds { get; set; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/LoginDto.cs similarity index 89% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/LoginDto.cs index 789eaa59..6629baf4 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/LoginDto.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class LoginDto { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RegisterDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/RegisterDto.cs similarity index 87% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/RegisterDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/RegisterDto.cs index 662c4fed..74bcb847 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/RegisterDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/RegisterDto.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class RegisterDto { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/RoleInfoDto.cs similarity index 89% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/RoleInfoDto.cs index 977c1218..e1a764fb 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/RoleInfoDto.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Yi.Framework.Model.RABC.Entitys; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class RoleInfoDto { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/UpdatePasswordDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UpdatePasswordDto.cs similarity index 86% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/UpdatePasswordDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UpdatePasswordDto.cs index fe7788a1..d3879c01 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/UpdatePasswordDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UpdatePasswordDto.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class UpdatePasswordDto { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UserInfoDto.cs similarity index 90% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UserInfoDto.cs index 87487498..e5ce5920 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UserInfoDto.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Yi.Framework.Model.RABC.Entitys; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class UserInfoDto { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UserRoleMenuDto.cs similarity index 60% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UserRoleMenuDto.cs index 51c7ebbe..5637a9e3 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Dto/UserRoleMenuDto.cs @@ -5,15 +5,15 @@ using System.Text; using System.Threading.Tasks; using Yi.Framework.Model.RABC.Entitys; -namespace Yi.Framework.DTOModel +namespace Yi.Framework.DTOModel.Base.Dto { public class UserRoleMenuDto { - public UserEntity User { get; set; }=new (); + public UserEntity User { get; set; } = new(); public HashSet Roles { get; set; } = new(); - public HashSet Menus { get; set; }=new(); + public HashSet Menus { get; set; } = new(); - public List RoleCodes { get; set; } =new(); + public List RoleCodes { get; set; } = new(); public List PermissionCodes { get; set; } = new(); } } diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/ArticleVo.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/ArticleVo.cs similarity index 95% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/ArticleVo.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/ArticleVo.cs index 721de83d..7235193e 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/ArticleVo.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/ArticleVo.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel.Vo +namespace Yi.Framework.DTOModel.Base.Vo { public class ArticleVo { diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/CommentVo.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/CommentVo.cs similarity index 90% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/CommentVo.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/CommentVo.cs index 598e438a..d9dcf8ef 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/CommentVo.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/CommentVo.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel.Vo +namespace Yi.Framework.DTOModel.Base.Vo { public class CommentVo { @@ -51,11 +51,11 @@ namespace Yi.Framework.DTOModel.Vo /// /// 被回复的用户信息 /// - public UserVo? UserInfo { get; set; } + public UserVo UserInfo { get; set; } /// /// 创建评论的用户信息 /// - public UserVo? CreateUserInfo { get; set; } + public UserVo CreateUserInfo { get; set; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/UserVo.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/UserVo.cs similarity index 94% rename from Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/UserVo.cs rename to Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/UserVo.cs index 3620f95d..6d320dbf 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/Vo/UserVo.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Base/Vo/UserVo.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Yi.Framework.DTOModel.Vo +namespace Yi.Framework.DTOModel.Base.Vo { /// /// 前端只需要这些数据即可 diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/MapperConfig/StudentProfile.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/MapperConfig/StudentProfile.cs new file mode 100644 index 00000000..9f967223 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/MapperConfig/StudentProfile.cs @@ -0,0 +1,22 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.RABC.Entitys; + +namespace Yi.Framework.DTOModel.RABC.Student.MapperConfig +{ + public class StudentProfile : Profile + { + public StudentProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentCreateInput.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentCreateInput.cs new file mode 100644 index 00000000..3008d1c6 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentCreateInput.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Yi.Framework.DTOModel.RABC.Student +{ + public class StudentCreateInput + { + public string Name { get; set; } + public string Remark { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentCreateUpdateInput.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentCreateUpdateInput.cs new file mode 100644 index 00000000..0aa5d646 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentCreateUpdateInput.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Yi.Framework.DTOModel.RABC.Student +{ + public class StudentCreateUpdateInput + { + public string Name { get; set; } + public string Remark { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentGetOutput.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentGetOutput.cs new file mode 100644 index 00000000..d528989f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentGetOutput.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Yi.Framework.Model.Base; + +namespace Yi.Framework.DTOModel.RABC.Student +{ + public class StudentGetOutput : EntityDto + { + public string Name { get; set; } + public string Remark { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentListOutput.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentListOutput.cs new file mode 100644 index 00000000..63b9e045 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentListOutput.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Yi.Framework.Model.Base; + +namespace Yi.Framework.DTOModel.RABC.Student +{ + public class StudentListOutput : EntityDto + { + public string Name { get; set; } + public string Remark { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentUpdateInput.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentUpdateInput.cs new file mode 100644 index 00000000..7568cf0a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RABC/Student/StudentUpdateInput.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Yi.Framework.DTOModel.RABC.Student +{ + public class StudentUpdateInput + { + public string Name { get; set; } + public string Remark { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj b/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj index d0fe5f85..a4953289 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj @@ -8,4 +8,9 @@ + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs index 58532533..7c1e95f7 100644 --- a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs @@ -7,6 +7,7 @@ using System; using Yi.Framework.WebCore; using Yi.Framework.WebCore.AspNetCoreExtensions; using Yi.Framework.WebCore.BuilderExtend; +using Yi.Framework.WebCore.CommonExtend; namespace Yi.Framework.ElasticSearchProcessor { diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IRoleService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IRoleService.cs index 5ffc5b3b..954f0c38 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IRoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IRoleService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel; +using Yi.Framework.DTOModel.Base.Dto; using Yi.Framework.Interface.Base; using Yi.Framework.Model.RABC.Entitys; using Yi.Framework.Repository; diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IStudentService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IStudentService.cs new file mode 100644 index 00000000..1be028f8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IStudentService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.DTOModel.RABC.Student; +using Yi.Framework.Interface.Base.Crud; + +namespace Yi.Framework.Interface.RABC +{ + public interface IStudentService : ICrudAppService + { + void GetError(); + Task> GetListAsync(); + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IUserService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IUserService.cs index 7fda956d..41198d2d 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IUserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/RABC/IUserService.cs @@ -2,10 +2,10 @@ using System.Threading.Tasks; using System; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel; using Yi.Framework.Interface.Base; using Yi.Framework.Model.RABC.Entitys; using Yi.Framework.Repository; +using Yi.Framework.DTOModel.Base.Dto; namespace Yi.Framework.Interface.RABC { diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Base/IEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/Base/IEntity.cs index 25e3510d..a4937365 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/Base/IEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/Base/IEntity.cs @@ -16,7 +16,7 @@ namespace Yi.Framework.Model.Base /// Returns an array of ordered keys for this entity. /// /// - object[] GetKeys(); + //object[] GetKeys(); } /// diff --git a/Yi.Framework.Net6/Yi.Framework.Model/RABC/Entitys/StudentEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/RABC/Entitys/StudentEntity.cs new file mode 100644 index 00000000..8bf2ed05 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/RABC/Entitys/StudentEntity.cs @@ -0,0 +1,20 @@ +using SqlSugar; +using System; +using Yi.Framework.Model.Base; + +namespace Yi.Framework.Model.RABC.Entitys +{ + [SugarTable("Student")] + public class StudentEntity : IEntity, IMultiTenant + { + public string Name { get; set; } + public string Remark { get; set; } + + [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)] + public Guid Id { get; set; } + + [SugarColumn(ColumnName = "TenantId")] + public Guid? TenantId { get; set; } + + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/WebCore/OcelotExtension.cs b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/WebCore/OcelotExtension.cs index 20c73cb8..f5e8f673 100644 --- a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/WebCore/OcelotExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/WebCore/OcelotExtension.cs @@ -41,7 +41,7 @@ namespace Yi.Framework.OcelotGateway.WebCore //--------------------------------------管道执行--------------------------------------------- GateStartBuilder.Run(dataContext); //--------------------------------------处理结果--------------------------------------------- - if (dataContext.Result.status) + if (dataContext.Result.Status) { //--------------------------------------中间件执行--------------------------------------------- await next(context); diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs index a0b7dc77..02500dc0 100644 --- a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs @@ -9,9 +9,9 @@ using Microsoft.Extensions.Logging; using System; using Yi.Framework.Common.IOCOptions; using Yi.Framework.Core; -using Yi.Framework.Core.ConsulExtend; using Yi.Framework.WebCore; using Yi.Framework.WebCore.AspNetCoreExtensions; +using Yi.Framework.WebCore.CommonExtend; namespace Yi.Framework.SMSProcessor { diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs index a2c942e3..ae16ab67 100644 --- a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs @@ -15,7 +15,6 @@ using Yi.Framework.Common.IOCOptions; using Yi.Framework.Common.Models; using Yi.Framework.Common.QueueModel; using Yi.Framework.Core; -using Yi.Framework.Core.ConsulExtend; using Yi.Framework.Core.SMS; namespace Yi.Framework.SMSProcessor diff --git a/Yi.Framework.Net6/Yi.Framework.Service/RABC/RoleService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RABC/RoleService.cs index 87526e73..de39724b 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/RABC/RoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/RABC/RoleService.cs @@ -4,13 +4,13 @@ using System.Threading.Tasks; using System; using Yi.Framework.Common.Base; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel; using Yi.Framework.Interface; using Yi.Framework.Model.RABC.Entitys; using Yi.Framework.Repository; using Yi.Framework.Service.Base; using Yi.Framework.Uow.Interceptors; using Yi.Framework.Interface.RABC; +using Yi.Framework.DTOModel.Base.Dto; namespace Yi.Framework.Service.RABC { diff --git a/Yi.Framework.Net6/Yi.Framework.Service/RABC/StudentService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RABC/StudentService.cs new file mode 100644 index 00000000..731fafab --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/RABC/StudentService.cs @@ -0,0 +1,55 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Yi.Framework.Common.Exceptions; +using Yi.Framework.DTOModel.RABC.Student; +using Yi.Framework.Interface.RABC; +using Yi.Framework.Model.RABC.Entitys; +using Yi.Framework.Repository; +using Yi.Framework.Service.Base.Crud; + +namespace Yi.Framework.Service.RABC +{ + public class StudentService : CrudAppService, IStudentService + { + public StudentService(IRepository repository, IMapper mapper) : base(repository, mapper) + { + } + + public async Task> GetListAsync() + { + return await MapToGetListOutputDtosAsync(await Repository.GetListAsync()); + } + + public void GetError() + { + throw new ApplicationException("查询错误"); + } + public void GetError2() + { + throw new UserFriendlyException("友好错误"); + } + + /// + /// 校验配置项是否已存在 + /// + /// + /// + /// + /// + //private async Task ValidateKeyAsync(string key, Guid? id = null) + //{ + // Expression> expression = e => e.Name == key; + // if (id.HasValue) + // { + // expression = expression.And(e => e.Id != id.Value); + // } + // var existsData = await Repository.GetListAsync(expression); + // if (existsData != null) + // { + // throw new UserFriendlyException(); + // } + //} + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Service/RABC/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RABC/UserService.cs index 4b0418d8..68ad0e8e 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/RABC/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/RABC/UserService.cs @@ -7,12 +7,12 @@ using Yi.Framework.Common.Base; using Yi.Framework.Common.Const; using Yi.Framework.Common.Helper; using Yi.Framework.Common.Models; -using Yi.Framework.DTOModel; using Yi.Framework.Interface; using Yi.Framework.Model.RABC.Entitys; using Yi.Framework.Repository; using Yi.Framework.Service.Base; using Yi.Framework.Interface.RABC; +using Yi.Framework.DTOModel.Base.Dto; namespace Yi.Framework.Service.RABC { diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs index 300e7db8..b227fba3 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using System.IO; +using Yi.Framework.DTOModel.RABC.Student.MapperConfig; using Yi.Framework.WebCore.Mapper; namespace Yi.Framework.WebCore.AspNetCoreExtensions @@ -13,7 +14,9 @@ namespace Yi.Framework.WebCore.AspNetCoreExtensions { public static IServiceCollection AddAutoMapperService(this IServiceCollection services) { - services.AddAutoMapper(typeof(AutoMapperProfile)); + //这里会通过反射自动注入的,先临时这样 + services.AddAutoMapper(typeof(AutoMapperProfile),typeof(StudentProfile)); + return services; } } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/AutoFacExtend/PropertiesAutowiredModule.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/AutoFacExtend/PropertiesAutowiredModule.cs index f976fa47..03ac301b 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/AutoFacExtend/PropertiesAutowiredModule.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/AutoFacExtend/PropertiesAutowiredModule.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.EntityFrameworkCore; -using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs index 6bcfa4ea..afe5c18e 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs @@ -6,7 +6,7 @@ using Yi.Framework.Common.Const; using Yi.Framework.Common.Enum; using Yi.Framework.Common.Models; using Yi.Framework.Core.Cache; -using Yi.Framework.DTOModel; +using Yi.Framework.DTOModel.Base.Dto; using Yi.Framework.Model.RABC.Entitys; using Yi.Framework.WebCore.CommonExtend; diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs index 26c0f917..49191dd4 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Mapper/Profile/AutoMapperProfile.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Yi.Framework.DTOModel.Vo; +using Yi.Framework.DTOModel.Base.Vo; using Yi.Framework.Model.BBS.Entitys; using Yi.Framework.Model.RABC.Entitys; diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs index 256dced0..bbebf049 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Builder; +using log4net.Core; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json; @@ -7,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Yi.Framework.Common.Enum; +using Yi.Framework.Common.Exceptions; using Yi.Framework.Common.Models; namespace Yi.Framework.WebCore.MiddlewareExtend @@ -17,11 +19,12 @@ namespace Yi.Framework.WebCore.MiddlewareExtend public class ErrorHandExtension { private readonly RequestDelegate next; - private ILogger _logger; - public ErrorHandExtension(RequestDelegate next,ILogger logger) + //private readonly IErrorHandle _errorHandle; + public ErrorHandExtension(RequestDelegate next/*, IErrorHandle errorHandle*/) { this.next = next; - _logger = logger; + //this._logger = loggerFactory.CreateLogger(); + //_errorHandle = errorHandle; } public async Task Invoke(HttpContext context) @@ -30,14 +33,19 @@ namespace Yi.Framework.WebCore.MiddlewareExtend { await next(context); } + catch (BusinessException businessEx) + { + var statusCode = 200; + await HandleExceptionAsync(context, statusCode, businessEx.Message, businessEx.Code); + } catch (Exception ex) { + //await _errorHandle.Invoer(context, ex); var statusCode = context.Response.StatusCode; if (ex is ArgumentException) { statusCode = 200; } - _logger.LogError($"中间件抓取错误\r\n错误信息:{ex.Message}\r\n堆栈信息“{ex.StackTrace}"); await HandleExceptionAsync(context, statusCode, ex.Message); } finally @@ -45,9 +53,9 @@ namespace Yi.Framework.WebCore.MiddlewareExtend var statusCode = context.Response.StatusCode; var msg = ""; - switch (statusCode) + switch (statusCode) { - case 401: msg = "未授权";break; + case 401: msg = "未授权"; break; case 403: msg = "未授权"; break; case 404: msg = "未找到服务"; break; case 502: msg = "请求错误"; break; @@ -59,22 +67,20 @@ namespace Yi.Framework.WebCore.MiddlewareExtend } } //异常错误信息捕获,将错误信息用Json方式返回 - private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg) + private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg, ResultCodeEnum code = ResultCodeEnum.NotSuccess) { - Result resp; + Result result; if (statusCode == 401) { - resp = Result.UnAuthorize(msg); + result = Result.UnAuthorize(msg); } else { - resp = Result.Error(msg); + result = Result.Error(msg).SetCode(code); } - resp.SetCode((ResultCodeEnum)statusCode); - var result = JsonConvert.SerializeObject(resp); + context.Response.ContentType = "application/json;charset=utf-8"; - - return context.Response.WriteAsync(result); + return context.Response.WriteAsync(JsonConvert.SerializeObject(result)); } } //扩展方法 diff --git a/Yi.Framework.Net6/Yi.Framework.XUnitTest/CrudTest/AccountTest.cs b/Yi.Framework.Net6/Yi.Framework.XUnitTest/CrudTest/AccountTest.cs index c47d5799..4c7c2aa4 100644 --- a/Yi.Framework.Net6/Yi.Framework.XUnitTest/CrudTest/AccountTest.cs +++ b/Yi.Framework.Net6/Yi.Framework.XUnitTest/CrudTest/AccountTest.cs @@ -1,6 +1,7 @@ using Yi.Framework.Common.Const; using Yi.Framework.Core; using Yi.Framework.Interface; +using Yi.Framework.Interface.RABC; namespace Yi.Framework.XUnitTest { diff --git a/Yi.Framework.Net6/Yi.Framework.XUnitTest/Startup.cs b/Yi.Framework.Net6/Yi.Framework.XUnitTest/Startup.cs index 32516009..2ad4dad0 100644 --- a/Yi.Framework.Net6/Yi.Framework.XUnitTest/Startup.cs +++ b/Yi.Framework.Net6/Yi.Framework.XUnitTest/Startup.cs @@ -22,7 +22,7 @@ namespace Yi.Framework.XUnitTest host.ConfigureAppConfiguration(builder => { builder.AddJsonFile("appsettings.json"); - builder.AddJsonFile("appsettings.Development.json"); + //builder.AddJsonFile("appsettings.Development.json"); }); host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); host.ConfigureContainer(containerBuilder => @@ -51,6 +51,10 @@ namespace Yi.Framework.XUnitTest _iServiceCollection = services; } + /// + /// 这里配置服务 + /// + /// public void ConfigureTrueServices(IServiceCollection services) { services.AddQuartzService(); @@ -58,6 +62,10 @@ namespace Yi.Framework.XUnitTest _iServiceCollection = services; } + /// + /// 这里兼容配置管道 + /// + /// public void Configure(IServiceProvider services) { var appBuild = WebApplication.CreateBuilder(); diff --git a/Yi.Framework.Net6/Yi.Framework.XUnitTest/Yi.Framework.XUnitTest.csproj b/Yi.Framework.Net6/Yi.Framework.XUnitTest/Yi.Framework.XUnitTest.csproj index a1e6a5b2..81560a83 100644 --- a/Yi.Framework.Net6/Yi.Framework.XUnitTest/Yi.Framework.XUnitTest.csproj +++ b/Yi.Framework.Net6/Yi.Framework.XUnitTest/Yi.Framework.XUnitTest.csproj @@ -16,11 +16,6 @@ - - PreserveNewest - true - PreserveNewest - PreserveNewest true