package com.bonus.sharedstation.app.controller;

import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.sharedstation.app.domain.MlMedicalInformation;
import com.bonus.sharedstation.app.dto.MlMedicalInformationDTO;
import com.bonus.sharedstation.app.service.IMlMedicalInformationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * 名流预约医院信息表(MlMedicalInformation)表控制层
 *
 * @author 云归
 * @since 2024-12-09 17:12:29
 */
@RestController
@RequestMapping("information/mlMedicalInformation")
@Tag(name = "App - 名流就医预约信息")
@Validated
@Slf4j
public class MlMedicalInformationController {
    @Resource
    private IMlMedicalInformationService mlMedicalInformationService;

    /**
     * 通过主键查询单条数据
     * @param mlMedicalInformation 主键
     * @return 单条数据
     */
    @PostMapping(value = "/selectById", produces = "application/json; charset=utf-8")
    @ApiOperation("根据ID查询名流就医预约信息")
    public AjaxResult queryById(@RequestBody MlMedicalInformation mlMedicalInformation) {
        return AjaxResult.success(this.mlMedicalInformationService.queryById(mlMedicalInformation));
    }


    /**
     * 新增数据
     * @param mlMedicalInformation 实体
     * @return 新增结果
     */
    @PostMapping(value = "/add", produces = "application/json; charset=utf-8")
    @ApiOperation("名流就医预约信息-新增")
    public AjaxResult add(@RequestBody @Valid MlMedicalInformation mlMedicalInformation) {
        return this.mlMedicalInformationService.insert(mlMedicalInformation);
    }

    /**
     * 编辑数据
     *
     * @param mlMedicalInformation 实体
     * @return 编辑结果
     */
    @PostMapping(value = "/update", produces = "application/json; charset=utf-8")
    @ApiOperation("名流就医预约信息-修改")
    public AjaxResult edit(@RequestBody MlMedicalInformation mlMedicalInformation) {
        return AjaxResult.success(this.mlMedicalInformationService.update(mlMedicalInformation));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    @ApiOperation("名流就医预约信息-删除")
    public AjaxResult deleteById(Integer id) {
        return AjaxResult.success(this.mlMedicalInformationService.deleteById(id));
    }

    /**
     * 分页查询
     * @param dto 入参
     * @return 查询所有
     */
    @ApiOperation("查询名流就医预约信息")
    @PostMapping("/getList")
    public AjaxResult getList(@RequestBody MlMedicalInformationDTO dto){
        return AjaxResult.success(mlMedicalInformationService.getListPage(dto));

    }

}

