67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using LFlow.Base.Interfaces;
|
|
using LFlow.Base.Utils;
|
|
using LFlow.Home.Models.DataModels;
|
|
|
|
|
|
// using LFlow.Interfaces;
|
|
using LFlow.Home.Models.DtoModel;
|
|
using LFlow.Base.BusinessInterface;
|
|
using Serilog;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace LFlow.Home.Services;
|
|
/// <summary>
|
|
/// 服务直接作为控制器
|
|
/// </summary>
|
|
/// <param name="repo"></param>
|
|
/// <param name="logger"></param>
|
|
public class HomeService(IRepo<HomeModel, string> repo, ILogger logger) : BaseController, IHomeService<HomeDto?, string>
|
|
{
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public HomeDto? DeleteById(string id)
|
|
{
|
|
var result = repo.Delete(id);
|
|
return Mapper.Map<HomeDto>(result);
|
|
}
|
|
/// <summary>
|
|
/// 获取
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public HomeDto? GetById(string id)
|
|
{
|
|
logger.Information($"GetById id -> {id}");
|
|
var result = repo.Get(id);
|
|
return Mapper.Map<HomeDto>(result);
|
|
}
|
|
/// <summary>
|
|
/// 保存 (修改或者新增,按主键判断)
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public HomeDto? Save(HomeDto entity)
|
|
{
|
|
var result = repo.SaveOrUpdate(Mapper.Map<HomeModel>(entity), false);
|
|
return Mapper.Map<HomeDto>(result);
|
|
}
|
|
/// <summary>
|
|
/// 搜索
|
|
/// </summary>
|
|
/// <param name="whereObj"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
[HttpGet]
|
|
public List<HomeDto>? Search(HomeDto whereObj)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|