package com.crm.manager.controller;

import com.crm.manager.service.ucard.UcardPermissionFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.ucard.CardPermissionDto;
import com.crm.rely.backend.core.entity.ucard.CardPermissionAddEntity;
import com.crm.rely.backend.core.entity.ucard.CardPermissionDeleteEntity;
import com.crm.rely.backend.core.entity.ucard.CardPermissionPageEntity;
import com.crm.rely.backend.core.entity.ucard.CardPermissionUpdateEntity;
import com.crm.rely.backend.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * ucard权限服务接口
 */
@Slf4j
@RestController
@RequestMapping("/ucard/permission")
public class UcardPermissionController {

    @Autowired
    private UcardPermissionFeignService ucardPermissionFeignService;

    /**
     * 卡权限分页列表
     */
    @PostMapping("/page")
    public ResultWithPagerDto<CardPermissionDto> queryPermissionPageList(@RequestBody CardPermissionPageEntity entity) throws ServiceException {
        return ucardPermissionFeignService.queryPermissionPageList(entity);
    }

    /**
     * 新增卡权限
     */
    @PostMapping("/add")
    public BaseResultDto permissionAdd(@RequestBody CardPermissionAddEntity entity) throws ServiceException {
        return ucardPermissionFeignService.permissionAdd(entity);
    }

    /**
     * 更新卡权限
     */
    @PostMapping("/update")
    public BaseResultDto permissionUpdate(@RequestBody CardPermissionUpdateEntity entity) throws ServiceException {
        return ucardPermissionFeignService.permissionUpdate(entity);
    }

    /**
     * 删除卡权限
     */
    @PostMapping("/delete")
    public BaseResultDto permissionDelete(@RequestBody CardPermissionDeleteEntity entity) throws ServiceException {
        return ucardPermissionFeignService.permissionDelete(entity);
    }

}
