package com.eitc.patient.controller;

import com.eitc.common.annotation.Log;
import com.eitc.common.core.controller.BaseController;
import com.eitc.common.core.domain.AjaxResult;
import com.eitc.common.enums.BusinessType;
import com.eitc.patient.service.IDiagnosisTypeCostProjectService;
import com.eitc.patient.vo.DiagnosisTypeCostProjectInfoVO;
import com.eitc.patient.vo.DiagnosisTypeCostProjectVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;

/**
 * DiagnosisTypeCostProjectController
 *
 * @author mtx
 * @date: 2024/05/17 15:51
 */
@Api(tags = "诊断分类收费项目")
@RestController
@RequestMapping("/diagnosis-type-cost-project")
public class DiagnosisTypeCostProjectController extends BaseController {

    @Resource
    private IDiagnosisTypeCostProjectService diagnosisTypeCostProjectService;

    /**
     * 查询收费分类详情列表
     */
    @GetMapping("/list")
    @ApiOperation("查询收费分类详情列表")
    public AjaxResult list(DiagnosisTypeCostProjectInfoVO entry) {
        List<DiagnosisTypeCostProjectInfoVO> list = diagnosisTypeCostProjectService.findList(entry);
        return success(list);
    }

    /**
     * 新增诊断分类收费项目
     */
    @Log(title = "新增诊断分类收费项目", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增诊断分类收费项目")
    public AjaxResult add(@Valid @RequestBody DiagnosisTypeCostProjectVO vo) {
        diagnosisTypeCostProjectService.add(vo);
        return success();
    }

    /**
     * 删除收费分类详情
     */
    @Log(title = "删除收费分类详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    @ApiOperation("删除收费分类详情")
    public AjaxResult remove(String ids) {
        List<String> idList = Arrays.asList(ids.split(","));
        return toAjax(diagnosisTypeCostProjectService.removeBatchByIds(idList));
    }

}
