package com.backendsys.modules.material.controller;

import com.backendsys.modules.common.config.security.annotations.Anonymous;
import com.backendsys.modules.common.config.security.utils.SecurityUtil;
import com.backendsys.modules.common.utils.Result;
import com.backendsys.modules.material.entity.MaterialFeedback;
import com.backendsys.modules.material.service.MaterialFeedbackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@Tag(name = "素材需求反馈管理")
public class MaterialFeedbackController {

    @Autowired
    private MaterialFeedbackService materialFeedbackService;

    @Operation(summary = "获取素材需求反馈列表")
    @GetMapping("/api/material/getMaterialFeedbackList")
    public Result getMaterialFeedbackList(MaterialFeedback materialFeedback) {
        return Result.success().put("data", materialFeedbackService.selectMaterialFeedbackList(materialFeedback));
    }

    @Operation(summary = "发送素材需求反馈")
    @PostMapping("/api/material/sendMaterialFeedback")
    public Result sendMaterialFeedback(@Validated(MaterialFeedback.Create.class) @RequestBody MaterialFeedback materialFeedback) {
        materialFeedback.setUser_id(SecurityUtil.getUserId());
        return Result.success().put("data", materialFeedbackService.sendMaterialFeedback(materialFeedback));
    }

}
