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

import cn.axzo.msg.center.message.domain.param.CardStyleSaveOrUpdateParam;
import cn.axzo.msg.center.message.domain.param.MessageTemplateV3SaveOrUpdateParam;
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.axzo.msg.center.service.template.request.MessageTemplateV3CreateRequest;
import cn.axzo.msg.center.service.template.request.MessageTemplateV3DeleteRequest;
import cn.axzo.msg.center.service.template.request.MessageTemplateV3PageRequest;
import cn.axzo.msg.center.service.template.request.MessageTemplateV3UpdateRequest;
import cn.axzo.msg.center.service.template.response.MessageTemplateV3DetailResponse;
import cn.axzo.msg.center.service.template.response.MessageTemplateV3PageResponse;
import cn.azxo.framework.common.model.CommonResponse;
import cn.azxo.framework.common.model.Page;
import com.alibaba.fastjson.JSON;
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) {
        log.info("CardStyleController#save,request:{}", JSON.toJSONString(request));
        return CommonResponse.success(
                cardStyleService.createCardStyle(CardStyleSaveOrUpdateParam.from(request)));
    }

    @Override
    public CommonResponse<Void> update(CardStyleUpdateRequest request) {
        log.info("CardStyleController#update,request:{}", JSON.toJSONString(request));
        cardStyleService.updateCardStyle(CardStyleSaveOrUpdateParam.from(request));
        return CommonResponse.success();
    }

    @Override
    public CommonResponse<Void> delete(CardStyleDeleteRequest request) {
        log.info("CardStyleController#delete,request:{}", JSON.toJSONString(request));
        cardStyleService.deleteCardStyle(CardStyleSaveOrUpdateParam.from(request));
        return CommonResponse.success();
    }

    @Override
    public CommonResponse<CardStyleDetailResponse> detail(String code) {
        log.info("CardStyleController#detail,code:{}", code);
        return CommonResponse.success(cardStyleService.detail(code));
    }

    @Override
    public CommonResponse<Page<CardStylePageResponse>> page(CardStylePageRequest request) {
        log.info("CardStyleController#page,request:{}", JSON.toJSONString(request));
        return CommonResponse.success(cardStyleService.page(request));
    }

}
