package com.ruoyi.xq.controller.app;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.xq.domain.PairSuccess;
import com.ruoyi.xq.dto.app.other.FeedbackReq;
import com.ruoyi.xq.service.FeedbackService;
import com.ruoyi.xq.service.PairSuccessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
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 java.util.List;

@RestController
@RequestMapping("/api/other")
@Tag(name = "其他接口")
@Slf4j
public class OtherController {

    @Autowired
    private FeedbackService feedbackService;
    @Autowired
    private PairSuccessService pairSuccessService;


    @PostMapping("/feedback")
    @Operation(summary = "留言反馈")
    @Log(title = "留言反馈", businessType = BusinessType.OTHER, isSaveDb = true)
    public R<Void> feedback(@RequestBody FeedbackReq req){
        req.setUserId(LoginHelper.getUserId());
        feedbackService.feedback(req);
        return R.ok();
    }

    @PostMapping("/pairSuccess")
    @Operation(summary = "成功案例")
    @Log(title = "成功案例", businessType = BusinessType.OTHER, isPrintResponseData = false,isSaveDb = false)
    public R<List<PairSuccess>> pairSuccess(){
        List<PairSuccess> list = pairSuccessService.list(Wrappers.lambdaQuery(PairSuccess.class)
                .eq(PairSuccess::getEnableStatus, 1)
                .orderByAsc(PairSuccess::getSort));
        return R.ok(list);
    }

}
