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

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;

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

@RestController
@RequestMapping("/new/api/back/userAdviseAttachment")
public class BackUserAdviseAttachmentController {

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

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

    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 UserAdviseAttachment", response = Result.class)
    public Result selectDetail(@PathVariable("id") Integer id) {
        return Result.success(this.userAdviseAttachmentService.queryById(id));
    }

    @PostMapping("/insert")
    @ApiOperation(value = "新增 UserAdviseAttachment", response = Result.class)
    public Result addUserAdviseAttachment(@Valid @RequestBody UserAdviseAttachment userAdviseAttachment) {
        return Result.success(userAdviseAttachmentService.insert(userAdviseAttachment));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 UserAdviseAttachment", response = Result.class)
    public Result updateUserAdviseAttachment(@RequestBody UserAdviseAttachment userAdviseAttachment) {
        return Result.success(userAdviseAttachmentService.update(userAdviseAttachment));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "依据主键删除 UserAdviseAttachment", response = Result.class)
    public Result deleteUserAdviseAttachment(@PathVariable("id") Integer id) {
        return Result.success(userAdviseAttachmentService.deleteById(id));
    }

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


}
