package com.ruoyi.web.work.domain.base;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lsw
 * @date 2024-04-16
 */
@Data
@Accessors(chain = true)
public class BaseData {
    private static final long serialVersionUID = 1L;

    //部门名称
    @TableField(exist = false)
    private String deptName;

    //开始日期
    @TableField(exist = false)
    @JsonIgnore
    private String dateBegin;

    //结束日期
    @TableField(exist = false)
    @JsonIgnore
    private String dateEnd;

    @TableField(exist = false)
    @JsonIgnore
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
            params.put("common", "(p.dept_id = #{deptId} OR p.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))");
        }
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }
}
