package com.yiqi.api.controller.system;

import com.yiqi.app.domain.AppFeedback;
import com.yiqi.app.service.IAppFeedbackService;
import com.yiqi.common.constant.UrlConstants;
import com.yiqi.common.core.controller.BaseController;
import com.yiqi.common.core.domain.AuthHolder;
import com.yiqi.common.core.domain.R;
import com.yiqi.common.enums.FeedbackStatus;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.system.domain.SysFeedback;
import com.yiqi.system.domain.dto.weapp.WeAppFeedbackSaveDTO;
import com.yiqi.system.service.ISysFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = "意见反馈")
@RestController
@RequestMapping(value = UrlConstants.wxappApi + "/feedback")
public class WeAppFeedbackController extends BaseController {

    @Autowired
    private IAppFeedbackService appFeedbackService;

    @ApiOperation("提交意见反馈")
    @PostMapping(value = "add")
    private R add(@RequestBody @Valid WeAppFeedbackSaveDTO weAppFeedbackSaveDTO) throws Exception{
        AppFeedback appFeedback = new AppFeedback();
        appFeedback.setContent(weAppFeedbackSaveDTO.getFeedbackContent());
        appFeedback.setFeedbackType(weAppFeedbackSaveDTO.getFeedbackType());
        appFeedback.setCreateTime(DateUtils.getNowDate());
        appFeedback.setUserId(AuthHolder.userId());
        appFeedback.setStatus(FeedbackStatus.NOT_DEAL.getCode());
        appFeedbackService.save(appFeedback);
        return R.ok();
    }
}
