Add User api service
This commit is contained in:
parent
3f6c1f92ce
commit
9757cbea45
|
@ -1,9 +1,16 @@
|
||||||
|
|
||||||
using LFlow.Base.Interfaces;
|
using LFlow.Base.Interfaces;
|
||||||
|
using LFlow.Base.Interfaces.BusinessInterface;
|
||||||
|
using LFlow.User.Model.Dto;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace LFlow.User.Controllers
|
namespace LFlow.User.Controllers
|
||||||
{
|
{
|
||||||
public class UserController : BaseController
|
public class UserController(IUserService<UserDto> service) : BaseController
|
||||||
{
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public string Get(string id)
|
||||||
|
{
|
||||||
|
return service?.GetById(id)?.ToString() ?? "No service";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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; }
|
||||||
|
}
|
|
@ -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}]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<UserModel, string>
|
||||||
|
{
|
||||||
|
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<UserModel> Search(UserModel whereObj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> WhereSearchId(UserModel whereObj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<UserModel, string> repo) : IUserService<UserDto>
|
||||||
|
{
|
||||||
|
public UserDto DeleteById(string id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDto GetById(string id)
|
||||||
|
{
|
||||||
|
var user = repo.Get(id);
|
||||||
|
return Mapper.Map<UserDto>(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDto Save(UserDto entity)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserDto> Search(UserDto whereObj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue