From 9757cbea450b6e806b415e31da5d7727002292cd Mon Sep 17 00:00:00 2001 From: Ling0925 <2449858657a@gmail.com> Date: Wed, 9 Oct 2024 17:09:09 +0800 Subject: [PATCH] Add User api service --- LFlow.User/Controllers/UserController.cs | 11 +++++-- LFlow.User/Model/DataModel/UserModel.cs | 14 ++++++++ LFlow.User/Model/Dto/UserDto.cs | 19 +++++++++++ LFlow.User/Repositorys/UserRepo.cs | 41 ++++++++++++++++++++++++ LFlow.User/Services/UserService.cs | 32 ++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 LFlow.User/Model/DataModel/UserModel.cs create mode 100644 LFlow.User/Model/Dto/UserDto.cs create mode 100644 LFlow.User/Repositorys/UserRepo.cs create mode 100644 LFlow.User/Services/UserService.cs diff --git a/LFlow.User/Controllers/UserController.cs b/LFlow.User/Controllers/UserController.cs index 52f9214..1984cb6 100644 --- a/LFlow.User/Controllers/UserController.cs +++ b/LFlow.User/Controllers/UserController.cs @@ -1,9 +1,16 @@ - using LFlow.Base.Interfaces; +using LFlow.Base.Interfaces.BusinessInterface; +using LFlow.User.Model.Dto; +using Microsoft.AspNetCore.Mvc; namespace LFlow.User.Controllers { - public class UserController : BaseController + public class UserController(IUserService service) : BaseController { + [HttpGet] + public string Get(string id) + { + return service?.GetById(id)?.ToString() ?? "No service"; + } } } diff --git a/LFlow.User/Model/DataModel/UserModel.cs b/LFlow.User/Model/DataModel/UserModel.cs new file mode 100644 index 0000000..5344444 --- /dev/null +++ b/LFlow.User/Model/DataModel/UserModel.cs @@ -0,0 +1,14 @@ +using System; +using LFlow.Base.Interfaces; + +namespace LFlow.User.Model.DataModel; + +public record UserModel : IDataModel +{ + public string? UserID { get; set; } + public string? UserName { get; set; } + + public string? UserNickName { get; set; } + public string? EmailAddress { get; set; } + public string? RoleId { get; set; } +} diff --git a/LFlow.User/Model/Dto/UserDto.cs b/LFlow.User/Model/Dto/UserDto.cs new file mode 100644 index 0000000..44284fd --- /dev/null +++ b/LFlow.User/Model/Dto/UserDto.cs @@ -0,0 +1,19 @@ +using System; +using LFlow.Base.Interfaces; + +namespace LFlow.User.Model.Dto; + +public class UserDto : IModel +{ + public string? UserID { get; set; } + public string? UserName { get; set; } + + public string? UserNickName { get; set; } + public string? EmailAddress { get; set; } + public string? RoleId { get; set; } + + public override string ToString() + { + return $"UserDto [{UserID}_{UserName}_{UserNickName}_{EmailAddress}]"; + } +} diff --git a/LFlow.User/Repositorys/UserRepo.cs b/LFlow.User/Repositorys/UserRepo.cs new file mode 100644 index 0000000..86f9c17 --- /dev/null +++ b/LFlow.User/Repositorys/UserRepo.cs @@ -0,0 +1,41 @@ +using System; +using LFlow.Base.Interfaces; +using LFlow.User.Model.DataModel; +using SqlSugar; + +namespace LFlow.User.Repositorys; + +public class UserRepo(ISqlSugarClient db) : IRepo +{ + public UserModel Delete(string id) + { + throw new NotImplementedException(); + } + + public UserModel Get(string id) + { + return new UserModel + { + UserID = id, + UserName = "Test User", + UserNickName = "Tester", + EmailAddress = "Test@Ling.chat", + + }; + } + + public UserModel SaveOrUpdate(UserModel entity, bool isUpdate) + { + throw new NotImplementedException(); + } + + public List Search(UserModel whereObj) + { + throw new NotImplementedException(); + } + + public List WhereSearchId(UserModel whereObj) + { + throw new NotImplementedException(); + } +} diff --git a/LFlow.User/Services/UserService.cs b/LFlow.User/Services/UserService.cs new file mode 100644 index 0000000..ea96580 --- /dev/null +++ b/LFlow.User/Services/UserService.cs @@ -0,0 +1,32 @@ +using System; +using LFlow.Base.Interfaces; +using LFlow.Base.Interfaces.BusinessInterface; +using LFlow.Base.Utils; +using LFlow.User.Model.DataModel; +using LFlow.User.Model.Dto; + +namespace LFlow.User.Services; + +public class UserService(IRepo repo) : IUserService +{ + public UserDto DeleteById(string id) + { + throw new NotImplementedException(); + } + + public UserDto GetById(string id) + { + var user = repo.Get(id); + return Mapper.Map(user); + } + + public UserDto Save(UserDto entity) + { + throw new NotImplementedException(); + } + + public List Search(UserDto whereObj) + { + throw new NotImplementedException(); + } +}