You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using AutoMapper;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Txgy.RBS.DbModel.Models;
|
|
using Txgy.RBS.DTO;
|
|
using Txgy.RBS.Framework.Api;
|
|
using Txgy.RBS.IServices;
|
|
|
|
namespace Txgy.RBS.Services
|
|
{
|
|
public class ResultInfoService : BaseService, IResultInfoService
|
|
{
|
|
private readonly IMapper _iMapper;
|
|
|
|
public ResultInfoService(ISqlSugarClient client, IMapper iMapper) : base(client)
|
|
{
|
|
this._iMapper = iMapper;
|
|
}
|
|
|
|
public ApiResult AddResultInfo(ResultJsonDTO resultJsonDTO)
|
|
{
|
|
int res = 0;
|
|
result_json result_Json = _iMapper.Map<result_json>(resultJsonDTO);
|
|
|
|
res = _Client.Insertable(result_Json).ExecuteCommand();
|
|
if (res > 0)
|
|
{
|
|
return new ApiResult();
|
|
}
|
|
return new ApiResult() { Message = "添加失败" };
|
|
}
|
|
|
|
public ApiResult DeleteResultInfo(int id)
|
|
{
|
|
int res= _Client.Deleteable<result_json>(p=>p.id==id).ExecuteCommand();
|
|
if (res > 0)
|
|
{
|
|
return new ApiResult();
|
|
}
|
|
return new ApiResult() { Message = "删除失败" };
|
|
}
|
|
|
|
public List<ResultJsonDTO> GetAllResultInfo()
|
|
{
|
|
var projects = _Client.Queryable<result_json>().ToList();
|
|
return _iMapper.Map<List<ResultJsonDTO>>(projects);
|
|
}
|
|
|
|
|
|
public ResultJsonDTO GetResultInfo(int id)
|
|
{
|
|
result_json result_Json = _Client.Queryable<result_json>().First(c => c.id == id);
|
|
ResultJsonDTO resultJsonDTO = _iMapper.Map<ResultJsonDTO>(result_Json);
|
|
return resultJsonDTO;
|
|
}
|
|
|
|
public ApiResult UpdateResultInfo(ResultJsonDTO resultJsonDTO)
|
|
{
|
|
result_json result_Json = _iMapper.Map<result_json> (resultJsonDTO);
|
|
int res= _Client.Updateable<result_json>(result_Json).ExecuteCommand();
|
|
if(res > 0)
|
|
{
|
|
return new ApiResult();
|
|
}
|
|
return new ApiResult() { Message = "更新失败" };
|
|
}
|
|
}
|
|
}
|