package com.xinelu.manage.controller.scheduleplan;

import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.manage.domain.scheduleplan.SchedulePlan;
import com.xinelu.manage.service.scheduleplan.ISchedulePlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
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;

/**
 * @description: 医生排班计划控制器
 * @author: haown
 * @create: 2023-09-22 10:14
 **/
@Api(tags = "医生排班计划控制器")
@RestController
@RequestMapping("/system/schedule/plan")
public class SchedulePlanController extends BaseController {

	@Resource
	private ISchedulePlanService schedulePlanService;

	/**
	 * 查询排班计划列表
	 */
	@ApiOperation("查询排班计划分页列表")
	@GetMapping("/list")
	public TableDataInfo list(SchedulePlan plan) {
		startPage();
		List<SchedulePlan> list = schedulePlanService.getList(plan);
		return getDataTable(list);
	}

	/**
	 * 查询排班计划列表
	 */
	@ApiOperation("查询排班计划列表")
	@GetMapping("/getList")
	public R<List<SchedulePlan>> getList(SchedulePlan plan) {
		List<SchedulePlan> list = schedulePlanService.getList(plan);
		return R.ok(list);
	}

	@ApiOperation("新增医生排班计划")
	@PostMapping("add")
	public R<String> add(@RequestBody SchedulePlan schedulePlan) {
		try {
			schedulePlanService.save(schedulePlan);
			return R.ok();
		} catch (Exception e) {
			return R.fail("保存失败");
		}
	}

}
