package com.njcn.supervision.controller.file;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.supervision.pojo.po.file.FileUrl;
import com.njcn.supervision.service.file.IFileUrlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import com.njcn.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 文件信息录入表	 前端控制器
 * </p>
 *
 * @author wr
 * @since 2024-08-14
 */
@RestController
@RequestMapping("/fileUrl")
@Slf4j
@Api(tags = "文件信息")
@RequiredArgsConstructor
public class FileUrlController extends BaseController {

    private final IFileUrlService fileUrlService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/getFileById")
    @ApiOperation("根据id查询文件信息集合")
    public HttpResult<List<FileUrl>> getFileUrlList(String id) {
        String methodDescribe = getMethodDescribe("getFileUrlList");
        List<FileUrl> fileUrlList = fileUrlService.getFileUrlList(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, fileUrlList, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addOrUpdateFile")
    @ApiOperation("批量添加和修改文件信息")
    public HttpResult<Boolean> addOrUpdateFile(@RequestBody  List<FileUrl> list) {
        String methodDescribe = getMethodDescribe("addOrUpdateFile");
        Boolean b = fileUrlService.addOrUpdateFile(list);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }
}

