package digital.laboratory.platform.inspection.controller;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.inspection.entity.ScreenInfo;
import digital.laboratory.platform.inspection.entity.TaskInfo;
import digital.laboratory.platform.inspection.service.ScreenInfoService;
import digital.laboratory.platform.inspection.service.TaskInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/*
 *@title TaskInfoController
 *@description
 *@author xy
 *@version 1.0
 *@create 2023/12/8 11:24
 */
@RestController
@RequestMapping("/screenInfo")
@Api(tags = "03-筛查基本信息管理", description = "筛查基本信息管理")
public class ScreenInfoController {
    @Resource
    private ScreenInfoService screenInfoService;
    //添加接口
    @PostMapping("/addScreenInfo")
    @ApiOperation(value = "添加筛查基本信息",notes = "添加筛查基本信息,同时也作为其他系统调用的外部接口")
    public R addScreenInfo(@RequestBody ScreenInfo screenInfo){
        ScreenInfo ret=screenInfoService.addScreenInfo(screenInfo);
        if(ret!=null){
            return R.ok(ret,"添加成功");
        }else {
            return R.failed("false","添加失败");
        }

    }
    //修改接口
    @PostMapping("/updateScreenInfo")
    @ApiOperation(value = "修改筛查基本信息",notes = "")
    public R updateScreenInfo(@RequestBody ScreenInfo screenInfo){
        ScreenInfo ret=screenInfoService.updateScreenInfo(screenInfo);
        if(ret!=null){
            return R.ok(ret,"添加成功");
        }else {
            return R.failed("false","添加失败");
        }
    }
    //删除数据
    @DeleteMapping("/deleteScreenInfo")
    @ApiOperation(value = "删除筛查基本信息",notes = "")
    public R deleteScreenInfo(String id){
        Assert.notBlank(id,"参数id不能为空");
        boolean ret=screenInfoService.deleteScreenInfo(id);
        if(ret){
            return R.ok("true","删除成功");
        }else {
            return R.failed("false","删除成功");
        }
    }
    //显示列表分页
    @GetMapping("/getScreenPageList")
    @ApiOperation(value = "获取分页数据",notes = "")
    public R getScreenPageList(Page page,ScreenInfo screenInfo,String keywords){
        return R.ok(screenInfoService.getScreenPageList(page,screenInfo,keywords),"获取数据成功");
    }
    //显示列表
    @GetMapping("/getScreenList")
    @ApiOperation(value = "获取列表",notes = "")
    public R getScreenList(ScreenInfo screenInfo,String keywords){
        return R.ok(screenInfoService.getScreenList(screenInfo,keywords),"获取数据成功");
    }
}
