package com.hc.web.controller.browser.front;

import com.hc.business.model.UserAdviseAttachment;
import com.hc.business.service.UserAdviseAttachmentService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 新闻附件表(UserAdviseAttachment)表控制层
 *
 * @author makejava
 * @since 2024-01-20 11:48:47
 */

@RestController
@RequestMapping("/new/api/front/userAdviseAttachment")
public class FrontUserAdviseAttachmentController {

    /**
     * 服务对象
     */
    private final UserAdviseAttachmentService userAdviseAttachmentService;

    public FrontUserAdviseAttachmentController(UserAdviseAttachmentService userAdviseAttachmentService) {
        this.userAdviseAttachmentService = userAdviseAttachmentService;
    }


    @PostMapping("/insert")
    @ApiOperation(value = "新增附件", response = Result.class)
    public Result addAttachment(@Valid @RequestBody List<UserAdviseAttachment> userAdviseAttachmentList) {
        userAdviseAttachmentList.forEach(userAdviseAttachmentService::insert);
        return Result.success(userAdviseAttachmentList);
    }


    @GetMapping("/queryByUserAdviseId")
    @ApiOperation(value = "根据ID获取他的附件", response = Result.class)
    public Result queryByUserAdviseId(@RequestParam(defaultValue = "0") Integer userAdviseId) {
        return Result.success(userAdviseAttachmentService.queryByUserAdviseId(userAdviseId));
    }


}
