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.
65 lines
2.2 KiB
65 lines
2.2 KiB
2 years ago
|
using Znyc.CloudCar.Auth.HttpContextUser;
|
||
|
using Znyc.CloudCar.IRepository.Feedback;
|
||
|
using Znyc.CloudCar.IServices.Feedback;
|
||
|
using Znyc.CloudCar.Model.Dtos.Feedback;
|
||
|
using Znyc.CloudCar.Model.Entities;
|
||
|
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
|
||
|
|
||
|
namespace Znyc.CloudCar.Services.Feedback
|
||
|
{
|
||
|
public class FeedbackService : IFeedbackService
|
||
|
{
|
||
|
private readonly IFeedbackRepository _feedbackRepository;
|
||
|
private readonly IHttpContextUser _httpContextUser;
|
||
|
private readonly IFeedbackPicRepository _feedbackPicRepository;
|
||
|
|
||
|
public FeedbackService(
|
||
|
IFeedbackRepository feedbackRepository,
|
||
|
IHttpContextUser httpContextUser,
|
||
|
IFeedbackPicRepository feedbackPicRepository
|
||
|
)
|
||
|
{
|
||
|
_feedbackRepository = feedbackRepository;
|
||
|
_httpContextUser = httpContextUser;
|
||
|
_feedbackPicRepository = feedbackPicRepository;
|
||
|
_feedbackPicRepository = feedbackPicRepository;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 新增意见反馈
|
||
|
/// </summary>
|
||
|
/// <param name="input"></param>
|
||
|
/// <returns></returns>
|
||
|
public async Task<ResponseOutput> AddFeedbackAsync(FeedbackAddInput input)
|
||
|
{
|
||
|
FeedbackEntity entity = new FeedbackEntity
|
||
|
{
|
||
|
UserId = _httpContextUser.Id,
|
||
|
Content = input.Content,
|
||
|
State = 0,
|
||
|
Result = "",
|
||
|
Note = ""
|
||
|
};
|
||
|
entity = await _feedbackRepository.InsertAsync(entity);
|
||
|
for (int i = 0; i < input.FeedbackPic.Count; i++)
|
||
|
{
|
||
|
FeedbackPicEntity feedbackPicEntity = new FeedbackPicEntity
|
||
|
{
|
||
|
FeedbackId = entity.Id,
|
||
|
PicUrl = input.FeedbackPic[i],
|
||
|
Sort = i + 1,
|
||
|
IsEnabled = true,
|
||
|
};
|
||
|
await _feedbackPicRepository.InsertAsync(feedbackPicEntity);
|
||
|
}
|
||
|
ResponseOutput response = new ResponseOutput()
|
||
|
{
|
||
|
Msg = "反馈成功!",
|
||
|
Successed = true,
|
||
|
Code = 1
|
||
|
};
|
||
|
return response;
|
||
|
}
|
||
|
}
|
||
|
}
|