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.CardAppCommonProblemDto;
import com.crm.rely.backend.core.dto.ucard.CardAppCommonProblemTypeDto;
import com.crm.rely.backend.core.dto.ucard.CardAppPrivacyPolicyDto;
import com.crm.rely.backend.core.dto.ucard.CardAppVersionDto;
import com.crm.rely.backend.core.entity.base.BaseDeleteEntities;
import com.crm.rely.backend.core.entity.ucard.*;
import com.crm.rely.backend.exception.ServiceException;
import com.crm.ucard.service.UcardAppCommonProblemService;
import com.crm.ucard.service.UcardAppCommonProblemTypeService;
import com.crm.ucard.service.UcardAppPrivacyPolicyService;
import com.crm.ucard.service.UcardAppVersionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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/app/manager")
public class ManagerUcardAppController {

    @Autowired
    private UcardAppVersionService ucardAppVersionService;
    @Autowired
    private UcardAppCommonProblemService ucardAppCommonProblemService;
    @Autowired
    private UcardAppPrivacyPolicyService ucardAppPrivacyPolicyService;
    @Autowired
    private UcardAppCommonProblemTypeService ucardAppCommonProblemTypeService;

    /**
     * app版本配置列表
     */
    @PostMapping("/version/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardAppVersionDto> getCardAppVersionPageList(@RequestBody CardAppVersionPageEntity entity) throws ServiceException{
        return ucardAppVersionService.getCardAppVersionPageList(entity);
    }

    /**
     * 新增app版本
     */
    @PostMapping("/version/add")
    @FeignClientAnnotation
    BaseResultDto addCardAppVersion(@RequestBody CardAppVersionAddEntity entity) throws ServiceException{
        return ucardAppVersionService.addCardAppVersion(entity);
    }

    /**
     * 修改app版本
     */
    @PostMapping("/version/update")
    @FeignClientAnnotation
    BaseResultDto updateCardAppVersion(@RequestBody CardAppVersionUpdateEntity entity) throws ServiceException{
        return ucardAppVersionService.updateCardAppVersion(entity);
    }

    /**
     * 删除app版本
     */
    @PostMapping("/version/delete")
    @FeignClientAnnotation
    BaseResultDto deleteCardAppVersion(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return ucardAppVersionService.deleteCardAppVersion(entity);
    }

    /**
     * 获取最新一条app版本配置
     */
    @PostMapping("/version/detail")
    @FeignClientAnnotation
    public BaseResultDto getLatestCardAppVersion(@RequestBody @Validated CardAppVersionDetailEntity entity) throws ServiceException {
        return ucardAppVersionService.getLatestCardAppVersion(entity);
    }

    /**
     * app常见问题列表
     */
    @PostMapping("/common/problem/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardAppCommonProblemDto> getCardAppCommonProblemPageList(@RequestBody CardAppCommonProblemPageEntity entity) throws ServiceException{
        return ucardAppCommonProblemService.getCardAppCommonProblemPageList(entity);
    }

    /**
     * 新增app常见问题
     */
    @PostMapping("/common/problem/add")
    @FeignClientAnnotation
    BaseResultDto addCardAppCommonProblem(@RequestBody CardAppCommonProblemAddEntity entity) throws ServiceException{
        return ucardAppCommonProblemService.addCardAppCommonProblem(entity);
    }

    /**
     * 修改app常见问题
     */
    @PostMapping("/common/problem/update")
    @FeignClientAnnotation
    BaseResultDto updateCardAppCommonProblem(@RequestBody CardAppCommonProblemUpdateEntity entity) throws ServiceException{
        return ucardAppCommonProblemService.updateCardAppCommonProblem(entity);
    }

    /**
     * 删除app常见问题
     */
    @PostMapping("/common/problem/delete")
    @FeignClientAnnotation
    BaseResultDto deleteCardAppCommonProblem(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return ucardAppCommonProblemService.deleteCardAppCommonProblem(entity);
    }

    /**
     * app隐私政策列表
     */
    @PostMapping("/privacy/policy/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardAppPrivacyPolicyDto> getCardAppPrivacyPolicyPageList(@RequestBody CardAppPrivacyPolicyPageEntity entity) throws ServiceException{
        return ucardAppPrivacyPolicyService.getCardAppPrivacyPolicyPageList(entity);
    }

    /**
     * 新增app隐私政策
     */
    @PostMapping("/privacy/policy/add")
    @FeignClientAnnotation
    BaseResultDto addCardAppPrivacyPolicy(@RequestBody @Validated CardAppPrivacyPolicyAddEntity entity) throws ServiceException{
        return ucardAppPrivacyPolicyService.addCardAppPrivacyPolicy(entity);
    }

    /**
     * 修改app隐私政策
     */
    @PostMapping("/privacy/policy/update")
    @FeignClientAnnotation
    BaseResultDto updateCardAppPrivacyPolicy(@RequestBody @Validated CardAppPrivacyPolicyUpdateEntity entity) throws ServiceException{
        return ucardAppPrivacyPolicyService.updateCardAppPrivacyPolicy(entity);
    }

    /**
     * 删除app隐私政策
     */
    @PostMapping("/privacy/policy/delete")
    @FeignClientAnnotation
    BaseResultDto deleteCardAppPrivacyPolicy(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return ucardAppPrivacyPolicyService.deleteCardAppPrivacyPolicy(entity);
    }

    /**
     * app常见问题类型列表
     */
    @PostMapping("/common/problem/type/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardAppCommonProblemTypeDto> getCardAppCommonProblemTypePageList(@RequestBody CardAppCommonProblemTypePageEntity entity) throws ServiceException{
        return ucardAppCommonProblemTypeService.getCardAppCommonProblemTypePageList(entity);
    }

    /**
     * 新增app常见问题类型
     */
    @PostMapping("/common/problem/type/add")
    @FeignClientAnnotation
    BaseResultDto addCardAppCommonProblemType(@RequestBody @Validated CardAppCommonProblemTypeAddEntity entity) throws ServiceException{
        return ucardAppCommonProblemTypeService.addCardAppCommonProblemType(entity);
    }

    /**
     * 修改app常见问题类型
     */
    @PostMapping("/common/problem/type/update")
    @FeignClientAnnotation
    BaseResultDto updateCardAppCommonProblemType(@RequestBody @Validated CardAppCommonProblemTypeUpdateEntity entity) throws ServiceException{
        return ucardAppCommonProblemTypeService.updateCardAppCommonProblemType(entity);
    }

    /**
     * 删除app常见问题类型
     */
    @PostMapping("/common/problem/type/delete")
    @FeignClientAnnotation
    BaseResultDto deleteCardAppCommonProblemType(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return ucardAppCommonProblemTypeService.deleteCardAppCommonProblemType(entity);
    }

    /**
     * 常见问题类型下拉列表
     */
    @PostMapping("/common/problem/type/dropdown")
    @FeignClientAnnotation
    BaseResultDto cardAppCommonProblemTypeDropdown(@RequestBody @Validated CardAppCommonProblemTypeDropdown entity) throws ServiceException{
        return ucardAppCommonProblemTypeService.cardAppCommonProblemTypeDropdown(entity);
    }

}
