package cn.axzo.msg.center.message.controller;

import cn.axzo.msg.center.message.domain.param.CardStyleSaveOrUpdateParam;
import cn.axzo.msg.center.message.service.CardStyleService;
import cn.axzo.msg.center.service.card.request.CardStyleCreateRequest;
import cn.axzo.msg.center.service.card.request.CardStyleDeleteRequest;
import cn.axzo.msg.center.service.card.request.CardStylePageRequest;
import cn.axzo.msg.center.service.card.request.CardStyleUpdateRequest;
import cn.axzo.msg.center.service.card.response.CardStyleDetailResponse;
import cn.axzo.msg.center.service.card.response.CardStylePageResponse;
import cn.axzo.msg.center.service.template.client.CardStyleClient;
import cn.azxo.framework.common.model.CommonResponse;
import cn.azxo.framework.common.model.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * 卡片样式
 *
 * @author xudawei@axzo.cn
 * @date 2024/12/10
 * @version 1.0
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class CardStyleController implements CardStyleClient {

    private final CardStyleService cardStyleService;

    @Override
    public CommonResponse<String> save(CardStyleCreateRequest request) {
        return CommonResponse.success(
                cardStyleService.createCardStyle(CardStyleSaveOrUpdateParam.from(request)));
    }

    @Override
    public CommonResponse<Void> update(CardStyleUpdateRequest request) {
        cardStyleService.updateCardStyle(CardStyleSaveOrUpdateParam.from(request));
        return CommonResponse.success();
    }

    @Override
    public CommonResponse<Void> delete(CardStyleDeleteRequest request) {
        cardStyleService.deleteCardStyle(CardStyleSaveOrUpdateParam.from(request));
        return CommonResponse.success();
    }

    @Override
    public CommonResponse<CardStyleDetailResponse> detail(String code) {
        return CommonResponse.success(cardStyleService.detail(code));
    }

    @Override
    public CommonResponse<Page<CardStylePageResponse>> page(CardStylePageRequest request) {
        return CommonResponse.success(cardStyleService.page(request));
    }

}
