package com.yida.data.customForm.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.customform.CoreCustomFormAuth;
import com.yida.data.customForm.service.CoreCustomFormAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 表单对应管理员权限表 Controller
 *
 * @author ccl
 * @date 2021-11-05 15:41:13
 */
@Api(tags = "后台--表单权限")
@Slf4j
@Validated
@RestController
@RequestMapping("coreCustomFormAuth")
@RequiredArgsConstructor
public class CoreCustomFormAuthController {

    private final CoreCustomFormAuthService coreCustomFormAuthService;

    @ApiOperation("新增或修改表单基本权限")
    @PostMapping("saveOrUpdateFormAuth")
    public ResultBean saveOrUpdateFormAuth (@RequestBody CoreCustomFormAuth formAuth){
        coreCustomFormAuthService.saveOrUpdate(formAuth);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("批量删除表单基本权限")
    @PostMapping("delFormAuth")
    public ResultBean delFormAuth (@RequestBody List<Long> authIds){
        coreCustomFormAuthService.removeByIds(authIds);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询权限列表")
    @GetMapping("findFormAuthList")
    public ResultBean<List<CoreCustomFormAuth>> findFormAuthList (){

        return ResultBean.buildSuccess(coreCustomFormAuthService.list());
    }

}
