You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
4.1 KiB
107 lines
4.1 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Znyc.Cloudcar.Admin.Commons;
|
|
using Znyc.Cloudcar.Admin.Commons.Entitys;
|
|
using Znyc.Cloudcar.Admin.Commons.Mapping;
|
|
using Znyc.Cloudcar.Admin.Commons.Pages;
|
|
using Znyc.Cloudcar.Admin.Commons.Services;
|
|
using Znyc.Cloudcar.Admin.Security.Dtos;
|
|
using Znyc.Cloudcar.Admin.Security.Entitys;
|
|
using Znyc.Cloudcar.Admin.Security.IRepositories;
|
|
using Znyc.Cloudcar.Admin.Security.IServices;
|
|
|
|
namespace Znyc.Cloudcar.Admin.Security.Services
|
|
{
|
|
public class FeedbackService : BaseService<FeedbackEntity, FeedbackOutputDto, long>, IFeedbackService
|
|
{
|
|
private readonly IFeedbackRepository _feedbackRepository;
|
|
private readonly IFeedbackPicRepository _feedbackPicRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
public FeedbackService(IFeedbackRepository repository,
|
|
IFeedbackPicRepository feedbackPicRepository,
|
|
IUserRepository userRepository
|
|
) : base(repository)
|
|
{
|
|
_feedbackRepository = repository;
|
|
_feedbackPicRepository = feedbackPicRepository;
|
|
_userRepository = userRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 意见反馈分页查询
|
|
/// </summary>
|
|
/// <param name="search">查询条件</param>
|
|
/// <returns></returns>
|
|
public async Task<PageResult<FeedbackOutputDto>> FindWithPagerSearchAsync(SearchFeedbackModel search)
|
|
{
|
|
bool order = search.Order == "asc" ? false : true;
|
|
string where = GetDataPrivilege(false);
|
|
|
|
if (search.State >= 0)
|
|
{
|
|
@where += $" and State={search.State}";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(search.StartTime))
|
|
{
|
|
@where += $" and CreatedTime >='{search.StartTime} 00:00:00'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(search.EndTime))
|
|
{
|
|
@where += $" and CreatedTime <='{search.EndTime} 23:59:59'";
|
|
}
|
|
PagerInfo pagerInfo = new PagerInfo
|
|
{
|
|
CurrenetPageIndex = search.CurrenetPageIndex,
|
|
PageSize = search.PageSize
|
|
};
|
|
List<FeedbackOutputDto> list = (await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order)).MapTo<FeedbackOutputDto>();
|
|
List<UserOutputDto> usersList = (await _userRepository.GetListWhereAsync(" `State`=10")).MapTo<UserOutputDto>();
|
|
List<FeedbackPicEntity> picList = (await _feedbackPicRepository.GetListWhereAsync(" IsEnabled=true order by Sort")).MapTo<FeedbackPicEntity>();
|
|
foreach (var item in list)
|
|
{
|
|
var user = usersList.Find(x => x.Id == item.UserId);
|
|
|
|
|
|
item.UserName = user.UserName;
|
|
item.Phone = user.Phone;
|
|
item.AvatarUrl = CommonConst.Default_Image_Prefix + user.AvatarUrl;
|
|
item.FeedbackPic = picList.FindAll(x => x.FeedbackId == item.Id).Select(x => CommonConst.Default_FeedbackPic_Prefix + x.PicUrl).ToList();
|
|
}
|
|
|
|
PageResult<FeedbackOutputDto> pageResult = new PageResult<FeedbackOutputDto>
|
|
{
|
|
CurrentPage = pagerInfo.CurrenetPageIndex,
|
|
Items = list,
|
|
ItemsPerPage = pagerInfo.PageSize,
|
|
TotalItems = pagerInfo.RecordCount
|
|
};
|
|
return pageResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑意见反馈
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public async Task<CommonResult> UpdateAsync(FeedbackEntity input)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
FeedbackEntity info = await repository.GetAsync(input.Id);
|
|
if (!(info?.Id > 0))
|
|
{
|
|
result.Success = false;
|
|
result.ErrMsg = "信息不存在";
|
|
return result;
|
|
}
|
|
info.State = input.State;
|
|
await repository.UpdateAsync(info, input.Id).ConfigureAwait(false);
|
|
result.Success = true;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|