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.Framework.Api; using Txgy.RBS.IServices; namespace Txgy.RBS.Services { public class GlobalConfigService : BaseService, IGlobalConfigService { private readonly IMapper _iMapper; public GlobalConfigService(ISqlSugarClient client, IMapper iMapper) : base(client) { this._iMapper = iMapper; } public ApiResult AddGlobalConfig(GlobalConfigDTO globalConfigDTO) { int res = 0; global_config global_Config = _iMapper.Map(globalConfigDTO); res = _Client.Insertable(global_Config).ExecuteCommand(); if (res > 0) { return new ApiResult(); } return new ApiResult() { Message = "添加失败" }; } public List GetAllGlobalConfig() { var global_Config = _Client.Queryable().ToList(); return _iMapper.Map>(global_Config); } public GlobalConfigDTO GetGlobalConfig(int id) { return new GlobalConfigDTO(); } public ApiResult UpdateGlobalConfig(GlobalConfigDTO GlobalConfigDTO) { global_config global_Config = _iMapper.Map (GlobalConfigDTO); int res= _Client.Updateable(global_Config).ExecuteCommand(); if(res > 0) { return new ApiResult(); } return new ApiResult() { Message = "更新失败" }; } } }