 package com.huimv.management.controller;

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

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huimv.management.entity.HealthTreatmentPlanEntity;
import com.huimv.management.service.HealthTreatmentPlanService;
import com.huimv.common.utils.PageUtils;
import com.huimv.common.utils.R;



/**
 * 
 *
 * @author yinhao
 * @email yinhao@163.com
 * @date 2021-06-10 09:44:06
 */
@Api(tags = "治疗方案库表")
@RestController
@RequestMapping("management/healthtreatmentplan")
public class HealthTreatmentPlanController {
    @Autowired
    private HealthTreatmentPlanService healthTreatmentPlanService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = healthTreatmentPlanService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		HealthTreatmentPlanEntity healthTreatmentPlan = healthTreatmentPlanService.getById(id);

        return R.ok().put("healthTreatmentPlan", healthTreatmentPlan);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HealthTreatmentPlanEntity healthTreatmentPlan){
		healthTreatmentPlanService.save(healthTreatmentPlan);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HealthTreatmentPlanEntity healthTreatmentPlan){
		healthTreatmentPlanService.updateById(healthTreatmentPlan);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		healthTreatmentPlanService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
    /**
     * 查询全部
     */
   
    @RequestMapping("/findAll")
    public R findAll(){
        return R.ok().put("all",healthTreatmentPlanService.list());
    }
}
