package com.crm.manager.controller;

import com.crm.manager.service.ucard.UcardAppFeignService;
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 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;

/**
 * ucard app服务接口
 *
 */
@Slf4j
@RestController
@RequestMapping("/ucard/app")
public class UcardAppController {

    @Autowired
    private UcardAppFeignService ucardAppFeignService;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}
