package com.xiaoniu.subsystem.business.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.Profile;
import com.xiaoniu.subsystem.business.domain.ProfileFile;
import com.xiaoniu.subsystem.business.domain.dto.ProfilePageDTO;
import com.xiaoniu.subsystem.business.domain.vo.ProfileFileVO;
import com.xiaoniu.subsystem.business.domain.vo.ProfileVO;
import com.xiaoniu.subsystem.business.service.IProfileFileService;
import com.xiaoniu.subsystem.business.service.IProfileService;
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.apache.commons.lang3.StringUtils;
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;

/**
 * <p>
 * 资料和文件关联表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-11-28 05:13:47
 */
@RestController
@AllArgsConstructor
@Tag(name = "资料详情管理表", description = "资料详情管理表接口")
@RequestMapping("/profileFile")
public class ProfileFileController {

    private IProfileFileService profileFileService;

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

}
