package org.springblade.modules.api.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.modules.groupon.entity.FileContent;
import org.springblade.modules.groupon.service.IFileContentService;
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.annotation.Resource;
import javax.validation.Valid;
import java.util.Objects;

/**
 * 图文表，存储意见，投诉等信息 控制器
 *
 * @author BladeX
 * @since 2023-06-15
 */
@RestController
@AllArgsConstructor
@RequestMapping(CommonConstant.API_URL+"/filecontent")
@Api(value = "图文表，存储意见，投诉等信息", tags = "图文表，存储意见，投诉等信息接口")
public class ApiFileContentController extends BladeController {

    @Resource
    private IFileContentService fileContentService;

    /**
     * 新增 图文表，存储意见，投诉等信息
     */
    @PostMapping("/saveFilecontent")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入fileContent")
    public R save(@Valid @RequestBody FileContent fileContent) {
        fileContent.setStatus(0);
        if (Objects.isNull(fileContent.getPhone())){
            fileContent.setPhone(getUser().getAccount());
        }
        fileContentService.save(fileContent);
        return R.success("建议添加成功");
    }




}
