package cn.iocoder.yudao.module.system.controller.admin.biz;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyactivityimage.ElderlyBuildFloorActivityImagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyactivityimage.ElderlyBuildFloorActivityImageRespVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyactivityimage.ElderlyBuildFloorActivityImageSaveReqVO;
import cn.iocoder.yudao.module.system.service.biz.ElderlyBuildFloorActivityImageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 管理后台 - 楼层活动图片记录 Controller
 *
 * @author 系统管理员
 */
@Tag(name = "管理后台 - 楼层活动图片记录")
@RestController
@RequestMapping("/elderly-build-floor-activity-image")
@Validated
public class ElderlyBuildFloorActivityImageController {

    @Resource
    private ElderlyBuildFloorActivityImageService elderlyBuildFloorActivityImageService;

    @PostMapping("/create")
    @Operation(summary = "创建楼层活动图片记录")
    public CommonResult<Long> create(@Valid @RequestBody ElderlyBuildFloorActivityImageSaveReqVO createReqVO) {
        if (createReqVO.getTenantId() == null) {
            createReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        return success(elderlyBuildFloorActivityImageService.createElderlyBuildFloorActivityImage(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新楼层活动图片记录")
    @TenantIgnore
    public CommonResult<Boolean> update(@Valid @RequestBody ElderlyBuildFloorActivityImageSaveReqVO updateReqVO) {
        if (updateReqVO.getTenantId() == null) {
            updateReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        elderlyBuildFloorActivityImageService.updateElderlyBuildFloorActivityImage(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除楼层活动图片记录")
    @Parameter(name = "id", description = "编号", required = true)
    @TenantIgnore
    public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
        elderlyBuildFloorActivityImageService.deleteElderlyBuildFloorActivityImage(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得楼层活动图片记录详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1")
    @TenantIgnore
    public CommonResult<ElderlyBuildFloorActivityImageRespVO> get(@RequestParam("id") Long id) {
        return success(elderlyBuildFloorActivityImageService.getElderlyBuildFloorActivityImage(id));
    }

    @GetMapping("/page")
    @Operation(summary = "获得楼层活动图片记录分页")
    @TenantIgnore
    public CommonResult<PageResult<ElderlyBuildFloorActivityImageRespVO>> page(@Valid ElderlyBuildFloorActivityImagePageReqVO pageReqVO) {
        if (pageReqVO.getTenantId() == null) {
            pageReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        return success(elderlyBuildFloorActivityImageService.getElderlyBuildFloorActivityImagePage(pageReqVO));
    }
}
