package com.yonge.cooleshow.auth.dal.wrapper;

import com.alibaba.fastjson.JSON;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Optional;

/**
 * 微信模板消息内容
 * 2023-02-01 14:21:57
 */
@ApiModel(value = "WxTemplateMessageWrapper对象", description = "微信模板消息内容查询对象")
public class WxTemplateMessageWrapper {

    @Data
	@Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" WxTemplateMessageQuery-微信模板消息内容")
    public static class WxTemplateMessageQuery implements QueryInfo {

    	@ApiModelProperty("当前页")
        private Integer page;

        @ApiModelProperty("分页行数")
        private Integer rows;

        @ApiModelProperty("关键字匹配")
		private String keyword;

        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static WxTemplateMessageQuery from(String json) {
            return JSON.parseObject(json, WxTemplateMessageQuery.class);
        }
    }

	@ApiModel(" WxTemplateMessage-微信模板消息内容")
    public static class WxTemplateMessage {

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static WxTemplateMessage from(String json) {
            return JSON.parseObject(json, WxTemplateMessage.class);
        }
	}

}
