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.elderlyactivitytext.ElderlyBuildFloorActivityTextPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyactivitytext.ElderlyBuildFloorActivityTextRespVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyactivitytext.ElderlyBuildFloorActivityTextSaveReqVO;
import cn.iocoder.yudao.module.system.service.biz.ElderlyBuildFloorActivityTextService;
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 java.util.List;

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

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

    @Resource
    private ElderlyBuildFloorActivityTextService elderlyBuildFloorActivityTextService;

    @PostMapping("/create")
    @Operation(summary = "创建楼层活动文字记录")
    public CommonResult<Boolean> create(@Valid @RequestBody ElderlyBuildFloorActivityTextSaveReqVO createReqVO) {
        return success(elderlyBuildFloorActivityTextService.createElderlyBuildFloorActivityText(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新楼层活动文字记录")
    @TenantIgnore
    public CommonResult<Boolean> update(@Valid @RequestBody ElderlyBuildFloorActivityTextSaveReqVO updateReqVO) {
        if (updateReqVO.getTenantId() == null) {
            updateReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        elderlyBuildFloorActivityTextService.updateElderlyBuildFloorActivityText(updateReqVO);
        return success(true);
    }

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

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

    @GetMapping("/page")
    @Operation(summary = "获得楼层活动文字记录分页")
    @TenantIgnore
    public CommonResult<PageResult<ElderlyBuildFloorActivityTextRespVO>> page(@Valid ElderlyBuildFloorActivityTextPageReqVO pageReqVO) {
        if (pageReqVO.getTenantId() == null) {
            pageReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        return success(elderlyBuildFloorActivityTextService.getElderlyBuildFloorActivityTextPage(pageReqVO));
    }
}
