package com.wzj.soopin.im.domain.bo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.dromara.common.core.domain.BaseBO;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import com.wzj.soopin.im.domain.SysMessageTemplate;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 消息模板业务对象
 *
 * @author ruoyi
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysMessageTemplateBo extends BaseBO<SysMessageTemplate> {

    /**
     * 模板ID
     */
    @NotNull(message = "模板ID不能为空", groups = {EditGroup.class})
    private Long id;

    /**
     * 模板名称
     */
    @NotBlank(message = "模板名称不能为空", groups = {AddGroup.class, EditGroup.class})
    @Size(max = 100, message = "模板名称长度不能超过{max}个字符")
    private String name;

    /**
     * 模板编码
     */
//    @NotBlank(message = "模板编码不能为空", groups = { AddGroup.class, EditGroup.class })
//    @Size(max = 50, message = "模板编码长度不能超过{max}个字符")
    private String code;

    /**
     * 模板类型（SMS=短信 MAIL=邮件 WECHAT=微信 SYSTEM=系统消息）
     */
    @NotBlank(message = "模板类型不能为空", groups = {AddGroup.class, EditGroup.class})
    @Size(max = 20, message = "模板类型长度不能超过{max}个字符")
    private String type;

    /**
     * 模板内容
     */
    @NotBlank(message = "模板内容不能为空", groups = {AddGroup.class, EditGroup.class})
    private String content;

    /**
     * 状态（0正常 1停用）
     */
    private String status;
    /**
     * 标题
     */
    private String title;


    private String ext;

    private String action;

    private String description;


    @Override
    public LambdaQueryWrapper<SysMessageTemplate> toWrapper() {
        return super.toWrapper().eq(id != null, SysMessageTemplate::getId, id)
            .eq(StringUtils.isNotBlank(type), SysMessageTemplate::getType, type)
            .eq(StringUtils.isNotBlank(type), SysMessageTemplate::getType, type)
            .eq(StringUtils.isNotBlank(name), SysMessageTemplate::getName, name)
            .eq(StringUtils.isNotBlank(content), SysMessageTemplate::getContent, content)
            .eq(StringUtils.isNotBlank(status), SysMessageTemplate::getStatus, status)
            .eq(StringUtils.isNotBlank(title), SysMessageTemplate::getTitle, title);

    }
}
