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.module.system.controller.admin.biz.vo.RelativesPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.RelativesDO;
import cn.iocoder.yudao.module.system.service.biz.RelativesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;


@Tag(name = "管理后台 - 亲属管理")
@RestController
@RequestMapping("/relatives")
public class RelativesController {

    @Resource
    private RelativesService relativesService;


    @GetMapping("/queryPage")
    @Operation(summary = "亲属列表")
    public CommonResult<PageResult<RelativesDO>> queryPage(@Valid RelativesPageReqVO pageReqVO) {
        return CommonResult.success(relativesService.queryPage(pageReqVO));
    }


    @GetMapping("/getDetailsByElderId")
    @Operation(summary = "根据长者ID查询亲属信息")
    @PermitAll
    public CommonResult<List<RelativesDO>>  getDetailsByElderId(@RequestParam("elderId") Long elderId){
        return CommonResult.success(relativesService.getDetailsByElderId(elderId));
    }


}
