package org.dromara.main.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.main.domain.bo.MainBackCategoryBo;
import org.dromara.main.domain.vo.MainBackCategoryVo;
import org.dromara.main.service.IMainBackCategoryService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/backCategory")
public class MainBackCategoryController extends BaseController {

    private final IMainBackCategoryService mainBackCategoryService;

    /**
     * 查询背调条款分类列表
     */
    @GetMapping("/list")
    public R<List<MainBackCategoryVo>> list(MainBackCategoryBo bo) {
        return R.ok(mainBackCategoryService.queryList(bo));
    }

    /**
     * 新增背调条款分类
     */
    @PostMapping()
    public R<Void> add(@Validated @RequestBody MainBackCategoryBo bo) {
        return toAjax(mainBackCategoryService.insertByBo(bo));
    }

    /**
     * 修改背调条款分类
     */
    @PutMapping()
    public R<Void> edit(@Validated @RequestBody MainBackCategoryBo bo) {
        return toAjax(mainBackCategoryService.updateByBo(bo));
    }

    /**
     * 删除背调条款分类
     */
    @DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids) {
        return toAjax(mainBackCategoryService.deleteWithValidByIds(List.of(ids), true));
    }
}
