package org.springblade.modules.sqmy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.sqmy.pojo.entity.FzrhyRyEntity;
import org.springblade.modules.sqmy.service.IFzrhyRyService;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

/**
 * 每月安全负责人会议_参会人员 控制器
 *
 * @author wth
 * @since 2024-11-12
 */
@RestController
@AllArgsConstructor
@RequestMapping("/fzrhyRy")
@Api(value = "每月安全负责人会议_参会人员", tags = "每月安全负责人会议_参会人员接口")
public class FzrhyRyController extends BladeController {

	private final IFzrhyRyService fzrhyRyService;

	/**
	 * 每月安全负责人会议_参会人员 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes  = "传入fzrhyRy")
	public R<FzrhyRyEntity> detail(FzrhyRyEntity fzrhyRy) {
		FzrhyRyEntity detail = fzrhyRyService.getOne(Condition.getQueryWrapper(fzrhyRy));
		return R.data(detail);
	}


	/**
	 * 每月安全负责人会议_参会人员 自定义分页
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes  = "传入fzrhyRy")
	public R<IPage<FzrhyRyEntity>> page(Map<String, Object> params, Query query) {
		IPage<FzrhyRyEntity> pages = fzrhyRyService.selectFzrhyRyPage(Condition.getPage(query), params);
		return R.data(pages);
	}

	/**
	 * 每月安全负责人会议_参会人员 新增
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes  = "传入fzrhyRy")
	public R save(@Valid @RequestBody FzrhyRyEntity fzrhyRy) {
		return R.status(fzrhyRyService.save(fzrhyRy));
	}

	/**
	 * 每月安全负责人会议_参会人员 修改
	 */
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes  = "传入fzrhyRy")
	public R update(@Valid @RequestBody FzrhyRyEntity fzrhyRy) {
		return R.status(fzrhyRyService.updateById(fzrhyRy));
	}

	/**
	 * 每月安全负责人会议_参会人员 新增或修改
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes  = "传入fzrhyRy")
	public R submit(@Valid @RequestBody FzrhyRyEntity fzrhyRy) {
		return R.status(fzrhyRyService.saveOrUpdate(fzrhyRy));
	}

	/**
	 * 每月安全负责人会议_参会人员 删除
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 7)
	@ApiOperation(value = "逻辑删除", notes  = "传入ids")
	public R remove(@RequestParam String ids) {
		return R.status(fzrhyRyService.deleteLogic(Func.toLongList(ids)));
	}
}
