package com.zd.laboratory.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.zd.common.core.domain.R;
import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.page.TableDataInfo;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.common.swagger.config.Knife4jConfiguration;
import com.zd.laboratory.domain.LabSubject;
import com.zd.laboratory.service.AlgorithmService;
import com.zd.system.api.domain.Algorithm;
import com.zd.system.api.domain.AlgorithmVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author: zhoupan
 * @Date: 2021/11/30/11:04
 * @Description:
 */
@Api(tags = {"算法结果"})
@ApiSupport(author = Knife4jConfiguration.Author.ZP)
@RestController
@RequestMapping("/algorithm")
public class AlgorithmController extends BaseController {

    @Autowired
    AlgorithmService algorithmService;

    /**
     * 查询算法结果列表
     */
    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_ALGORITHM + PerFun.LIST)
    @ApiOperation("查询算法结果列表")
    @GetMapping("/list")
    public TableDataInfo<AlgorithmVO> list(AlgorithmVO algorithm) {
        startPage();
        List<AlgorithmVO> algorithmVOS = algorithmService.queryList(algorithm);
        return getDataTable(algorithmVOS);
    }


    @PostMapping("/save")
    public R saveData(@RequestBody Algorithm algorithm) {
        return  R.ok(algorithmService.saveData(algorithm));
    }


    @GetMapping("/getId/{id}")
    public Object getId(@PathVariable Long id){
        return algorithmService.getId(id);
    }

    @PostMapping("/update")
    public int update(@RequestBody Algorithm algorithm){
        return algorithmService.update(algorithm);
    }

    @GetMapping("/del/{id}")
    public Object del(@PathVariable Long id){
        return algorithmService.del(id);
    }
}
