package com.crm.ucard.controller;

import com.crm.rely.backend.core.constant.FeignClientAnnotation;
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 com.crm.ucard.service.UcardPermissionService;
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;

/**
 * 银行卡服务接口
 */
@Slf4j
@RestController
@RequestMapping("/ucard/permission/manager")
public class ManagerUcardPermissionController {

    @Autowired
    private UcardPermissionService ucardPermissionService;

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

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

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

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

}
