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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.extra.vo.RoomFacilityListPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.extra.vo.RoomFacilityListRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.extra.ElderlyExtraRoomFacilityListDO;
import cn.iocoder.yudao.module.system.service.extra.ElderlyExtraRoomFacilityListService;
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;

@Tag(name = "管理后台 - 房间设施设备清单")
@RestController @RequestMapping("/elderly/extra/roomFacilityList") @Validated
public class ElderlyExtraRoomFacilityListController {
    @Resource private ElderlyExtraRoomFacilityListService service;
    @PostMapping("/create") @Operation(summary = "创建房间设施设备清单") public CommonResult<Long> create(@Valid @RequestBody ElderlyExtraRoomFacilityListDO r) { return success(service.create(r)); }
    @PostMapping("/update") @Operation(summary = "编辑房间设施设备清单") public CommonResult<Boolean> update(@Valid @RequestBody ElderlyExtraRoomFacilityListDO r) { service.update(r); return success(true); }
    @DeleteMapping("/delete") @Operation(summary = "删除房间设施设备清单") @Parameter(name = "id", required = true) public CommonResult<Boolean> delete(@RequestParam("id") Long id) { service.delete(id); return success(true); }
    @GetMapping("/findPage") @Operation(summary = "房间设施设备清单分页列表") public CommonResult<PageResult<RoomFacilityListRespVO>> findPage(@Valid RoomFacilityListPageReqVO r) { return success(BeanUtils.toBean(service.findPage(r), RoomFacilityListRespVO.class)); }
    @GetMapping("/getListByElderId") @Operation(summary = "根据长者ID获取房间设施设备清单列表") @Parameter(name = "elderId", required = true) public CommonResult<List<ElderlyExtraRoomFacilityListDO>> getListByElderId(@RequestParam("elderId") Long elderId) { return success(service.getListByElderId(elderId)); }
    @GetMapping("/getDetail") @Operation(summary = "获取房间设施设备清单详情") @Parameter(name = "id", required = true) public CommonResult<ElderlyExtraRoomFacilityListDO> getDetail(@RequestParam("id") Long id) { return success(service.getDetail(id)); }
}
