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.elderlyassesspsychologysocial.ElderlyAssessPsychologySocialPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyassesspsychologysocial.ElderlyAssessPsychologySocialRespVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.elderlyassesspsychologysocial.ElderlyAssessPsychologySocialSaveReqVO;
import cn.iocoder.yudao.module.system.service.biz.ElderlyAssessPsychologySocialService;
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;

@Tag(name = "管理后台 - 长者心理社交情况")
@RestController
@RequestMapping("/elderly-assess-psychology-social")
@Validated
public class ElderlyAssessPsychologySocialController {

    @Resource
    private ElderlyAssessPsychologySocialService elderlyAssessPsychologySocialService;

    @PostMapping("/create")
    @Operation(summary = "创建长者心理社交情况")
    public CommonResult<Long> create(@Valid @RequestBody ElderlyAssessPsychologySocialSaveReqVO createReqVO) {
        if (createReqVO.getTenantId() == null) {
            createReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        return success(elderlyAssessPsychologySocialService.create(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新长者心理社交情况")
    @TenantIgnore
    public CommonResult<Boolean> update(@Valid @RequestBody ElderlyAssessPsychologySocialSaveReqVO updateReqVO) {
        if (updateReqVO.getTenantId() == null) {
            updateReqVO.setTenantId(TenantContextHolder.getTenantId());
        }
        elderlyAssessPsychologySocialService.update(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除长者心理社交情况")
    @Parameter(name = "id", description = "编号", required = true)
    @TenantIgnore
    public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
        elderlyAssessPsychologySocialService.delete(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得长者心理社交情况详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1")
    @TenantIgnore
    public CommonResult<ElderlyAssessPsychologySocialRespVO> get(@RequestParam("id") Long id) {
        return success(elderlyAssessPsychologySocialService.get(id));
    }

    @GetMapping("/page")
    @Operation(summary = "获得长者心理社交情况分页")
    @TenantIgnore
    public CommonResult<PageResult<ElderlyAssessPsychologySocialRespVO>> page(@Valid ElderlyAssessPsychologySocialPageReqVO pageReqVO) {
        if (pageReqVO.getTenantIds() == null) {
            pageReqVO.setTenantIds(new Long[]{TenantContextHolder.getTenantId()});
        }
        return success(elderlyAssessPsychologySocialService.getPage(pageReqVO));
    }
}
