package com.hotwj.platform.resourceManagement.companyPermissionGrant.controller;

import com.hotwj.platform.resourceManagement.companyPermissionGrant.domain.bo.HotCompanyPermissionGrantBo;
import com.hotwj.platform.resourceManagement.companyPermissionGrant.domain.vo.HotCompanyPermissionGrantVo;
import com.hotwj.platform.resourceManagement.companyPermissionGrant.service.IHotCompanyPermissionGrantService;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/resourceManagement/companyPermissionGrant")
public class HotCompanyPermissionGrantController extends BaseController {

    private final IHotCompanyPermissionGrantService hotCompanyPermissionGrantService;

    @GetMapping("/list")
    public TableDataInfo<HotCompanyPermissionGrantVo> list(HotCompanyPermissionGrantBo bo, PageQuery pageQuery) {
        return hotCompanyPermissionGrantService.queryPageList(bo, pageQuery);
    }

    @GetMapping("/{id}")
    public R<HotCompanyPermissionGrantVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
        return R.ok(hotCompanyPermissionGrantService.queryById(id));
    }

    @PostMapping
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotCompanyPermissionGrantBo bo) {
        return toAjax(hotCompanyPermissionGrantService.insertByBo(bo));
    }

    @PutMapping
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotCompanyPermissionGrantBo bo) {
        return toAjax(hotCompanyPermissionGrantService.updateByBo(bo));
    }

    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
        return toAjax(hotCompanyPermissionGrantService.deleteWithValidByIds(java.util.List.of(ids), true));
    }
}
