package com.engine.organization.wrapper;

import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.organization.entity.extend.param.ExtendFieldSearchParam;
import com.engine.organization.entity.extend.param.ExtendInfoChangeParam;
import com.engine.organization.entity.extend.param.ExtendTitleSaveParam;
import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam;
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.service.FieldDefinedService;
import com.engine.organization.service.impl.FieldDefinedServiceImpl;
import com.engine.organization.util.response.ReturnResult;
import weaver.hrm.User;

import java.util.List;
import java.util.Map;

/**
 * @Author weaver_cl
 * @description:
 * @Date 2022/6/13
 * @Version V1.0
 **/
public class FieldDefinedWrapper extends Service {

    private FieldDefinedService getFieldDefinedService(User user) {
        return ServiceUtil.getService(FieldDefinedServiceImpl.class, user);
    }


    public ReturnResult getTree(ModuleTypeEnum moduleTypeEnum) {
        List<TypeTreeVO> treeDTOS = getFieldDefinedService(user).getTree(moduleTypeEnum);
        return ReturnResult.successed(treeDTOS);
    }

    /**
     * 获取标题分组
     *
     * @param groupType
     * @return
     */
    public Map<String, Object> getTabInfo(String groupType) {
        return getFieldDefinedService(user).getTabInfo(groupType);
    }

    /**
     * 分组维护
     *
     * @param param
     * @return
     */
    public Map<String, Object> saveGroup(ExtendTitleSaveParam param) {
        return getFieldDefinedService(user).saveGroup(param);
    }

    /**
     * 新建分组
     *
     * @param param
     * @return
     */
    public Map<String, Object> saveTitle(ExtendTitleSaveParam param) {
        return getFieldDefinedService(user).saveTitle(param);
    }


    public ReturnResult changeTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) {
        getFieldDefinedService(user).changeTree(moduleTypeEnum, fieldTypeTreeParam);
        return ReturnResult.successed();
    }


    public int deleteTitle(ExtendTitleSaveParam param) {
        return getFieldDefinedService(user).deleteTitle(param);
    }


    public ReturnResult deleteTree(Long id) {
        getFieldDefinedService(user).deleteTree(id);
        return ReturnResult.successed();
    }

    public ReturnResult saveTree(ModuleTypeEnum moduleTypeEnum, FieldTypeTreeParam fieldTypeTreeParam) {
        getFieldDefinedService(user).saveTree(moduleTypeEnum, fieldTypeTreeParam);
        return ReturnResult.successed();
    }

    public int saveFields(String data) {
        return getFieldDefinedService(user).saveFields(data);
    }

    public Map<String, Object> getFieldDefinedInfo(ExtendFieldSearchParam param) {
        return getFieldDefinedService(user).getFieldDefinedInfo(param);
    }

    public void deleteFieldDefined(ExtendFieldSearchParam param) {
        getFieldDefinedService(user).deleteFieldDefined(param);
    }

    public void changeGroup(ExtendInfoChangeParam param) {
        getFieldDefinedService(user).changeGroup(param);
    }

    public Map<String, Object> getHasRight(ModuleTypeEnum moduleTypeEnum) {
        return getFieldDefinedService(user).getHasRight(moduleTypeEnum);
    }
}
