|
|
|
|
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 ProjectInfoService : BaseService, IProjectInfoService
|
|
|
|
|
{
|
|
|
|
|
private readonly IMapper _iMapper;
|
|
|
|
|
|
|
|
|
|
public ProjectInfoService(ISqlSugarClient client, IMapper iMapper) : base(client)
|
|
|
|
|
{
|
|
|
|
|
this._iMapper = iMapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ApiResult AddProjectInfo(ProjectInfoDTO project)
|
|
|
|
|
{
|
|
|
|
|
int res = 0;
|
|
|
|
|
project_info project_Info = _iMapper.Map<project_info>(project);
|
|
|
|
|
|
|
|
|
|
res = _Client.Insertable(project_Info).ExecuteCommand();
|
|
|
|
|
if (res > 0)
|
|
|
|
|
{
|
|
|
|
|
return new ApiResult();
|
|
|
|
|
}
|
|
|
|
|
return new ApiResult() { Message = "添加失败" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ApiResult DeleteProjectInfo(int id)
|
|
|
|
|
{
|
|
|
|
|
int res= _Client.Deleteable<project_info>(p=>p.id==id).ExecuteCommand();
|
|
|
|
|
if (res > 0)
|
|
|
|
|
{
|
|
|
|
|
return new ApiResult();
|
|
|
|
|
}
|
|
|
|
|
return new ApiResult() { Message = "删除失败" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ProjectInfoDTO> GetAllProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
var projects = _Client.Queryable<project_info>().ToList();
|
|
|
|
|
return _iMapper.Map<List<ProjectInfoDTO>>(projects);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProjectInfoDTO GetCurrentProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
var curProject = _Client.Queryable<current_project>().First();
|
|
|
|
|
project_info projectInfo = _Client.Queryable<project_info>().First(c => c.id == curProject.current_project_id);
|
|
|
|
|
ProjectInfoDTO projectInfoDTO= _iMapper.Map<project_info, ProjectInfoDTO>(projectInfo);
|
|
|
|
|
return projectInfoDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProjectInfoDTO GetProjectInfo(int id)
|
|
|
|
|
{
|
|
|
|
|
project_info projectInfo = _Client.Queryable<project_info>().First(c => c.id == id);
|
|
|
|
|
ProjectInfoDTO projectInfoDTO = _iMapper.Map<project_info, ProjectInfoDTO>(projectInfo);
|
|
|
|
|
return projectInfoDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ApiResult UpdateProjectInfo(ProjectInfoDTO project)
|
|
|
|
|
{
|
|
|
|
|
project_info projectInfo = _iMapper.Map<ProjectInfoDTO, project_info> (project);
|
|
|
|
|
int res= _Client.Updateable<project_info>(projectInfo).ExecuteCommand();
|
|
|
|
|
if(res > 0)
|
|
|
|
|
{
|
|
|
|
|
return new ApiResult();
|
|
|
|
|
}
|
|
|
|
|
return new ApiResult() { Message = "更新失败" };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|