package com.kxs.system.biz.controller.kxsapp;


import com.kxs.common.core.util.R;
import com.kxs.common.security.util.SecurityUtils;
import com.kxs.system.api.dto.kxsapp.FeedBackDto;
import com.kxs.system.api.model.KxsFeedback;
import com.kxs.system.biz.service.KxsFeedbackService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 意见反馈
 *
 * @author 系统
 * @since 2023-12-15 12:16:33
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("feedback")
public class FeedbackController {

    private final KxsFeedbackService kxsFeedbackService;

    @PostMapping("/save")
    public R save(@Valid @RequestBody FeedBackDto feedBackDto){

        KxsFeedback kxsFeedback = new KxsFeedback();
        BeanUtils.copyProperties(feedBackDto, kxsFeedback);

        Long userId = SecurityUtils.getUser().getId();
        kxsFeedback.setUserId(userId.intValue());
        return R.ok(kxsFeedbackService.save(kxsFeedback));
    }
    @GetMapping("/getAllFeedBackType")
    public R getAllFeedBackType(){
        return R.ok(kxsFeedbackService.getAllFeedBackType());
    }
}
