package org.dromara.system.domain.bo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.core.domain.model.BaseAudit;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.system.domain.CommissionTemplate;

/**
 * 分成比例模板业务对象 commission_template
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = CommissionTemplate.class, reverseConvertGenerate = false)
@Schema(name = "CommissionTemplateBo", description = "分成比例模板业务对象")
public class CommissionTemplateBo extends BaseAudit {
    /** 主键 */
    @Schema(description = "主键")
    private Integer id;

    /** 模板名称，唯一标识一个分成模板 */
    @Schema(description = "模板名称，唯一标识一个分成模板")
    @NotBlank(message = "模板名称不能为空")
    @Size(max = 100, message = "模板名称长度不能超过100个字符")
    private String templateName;

    /** 模板描述 */
    @Schema(description = "模板描述")
    @Size(max = 255, message = "模板描述长度不能超过255个字符")
    private String description;

    /** 模板类型 */
    @Schema(description = "类型")
    private String templateType;

    /** 是否启用：1=启用，0=禁用 */
    @Schema(description = "是否启用：1=启用，0=禁用")
    private Integer isActive;

    /**
     * 构建分页查询条件
     */
    public LambdaQueryWrapper<CommissionTemplate> toWrapper() {
        LambdaQueryWrapper<CommissionTemplate> wrapper = new LambdaQueryWrapper<>();
        if (this.getTemplateName() != null && !this.getTemplateName().isEmpty()) {
            wrapper.like(CommissionTemplate::getTemplateName, this.getTemplateName());
        }
        if (this.getIsActive() != null) {
            wrapper.eq(CommissionTemplate::getIsActive, this.getIsActive());
        }
        return wrapper;
    }
}
