package com.xiaoniu.subsystem.business.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.xiaoniu.common.core.result.R;
import com.xiaoniu.common.core.utils.BeanUtil;
import com.xiaoniu.subsystem.business.domain.ManageFile;
import com.xiaoniu.subsystem.business.domain.ProfileFile;
import com.xiaoniu.subsystem.business.domain.vo.ManageFileVO;
import com.xiaoniu.subsystem.business.domain.vo.ProfileFileVO;
import com.xiaoniu.subsystem.business.service.IManageFileService;
import com.xiaoniu.subsystem.business.service.IProfileFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
@Tag(name = "资料详情管理表2", description = "资料详情管理表接口2")
@RequestMapping("/manageFile")
public class ManageFileController {

    private IManageFileService manageFileService;

    /**
     * 列表 资料详情
     */
    @GetMapping("/listByProfileId")
    @ApiOperationSupport(order = 1)
    @Operation(summary = "资料详情列表", description = "传入profile")
    public R<List<ManageFileVO>> list(@Validated
                                       @Parameter(description = "资料主键", required = true)
                                       @RequestParam Long profileId) {
        List<ManageFile> list = manageFileService.list(
                new LambdaQueryWrapper<ManageFile>()
                        .eq(ManageFile::getProfileId,profileId));
        return R.data(BeanUtil.copy(list, ManageFileVO.class));
    }

}
