package com.engine.organization.wrapper;

import com.alibaba.fastjson.JSON;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.annotation.Log;
import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam;
import com.engine.organization.entity.hrmresource.param.SearchTemplateParam;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.enums.LogModuleNameEnum;
import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.service.HrmResourceService;
import com.engine.organization.service.impl.HrmResourceServiceImpl;
import com.engine.organization.util.OrganizationWrapper;
import weaver.hrm.User;

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

/**
 * @author:dxfeng
 * @createTime: 2022/06/21
 * @version: 1.0
 */
public class HrmResourceWrapper extends OrganizationWrapper {
    private HrmResourceService getHrmResourceService(User user) {
        return ServiceUtil.getService(HrmResourceServiceImpl.class, user);
    }


    public Map<String, Object> getSearchTree(SearchTreeParams params) {
        return getHrmResourceService(user).getSearchTree(params);
    }

    public Map<String, Object> listPage(Map<String, Object> params) {
        return getHrmResourceService(user).listPage(params);
    }

    public Map<String, Object> getSaveForm() {
        return getHrmResourceService(user).getSaveForm();
    }

    @Log(operateType = OperateTypeEnum.ADD, operateModule = LogModuleNameEnum.RESOURCE, operateDesc = "新增人员")
    public Long saveBaseForm(Map<String, Object> params) {
        Long resourceId = getHrmResourceService(user).saveBaseForm(params);
        writeOperateLog(new Object() {
        }.getClass(), params.get("last_name").toString(), JSON.toJSONString(params), "新增人员");
        return resourceId;
    }

    public Map<String, Object> getBaseForm(Map<String, Object> params) {
        return getHrmResourceService(user).getBaseForm(params);
    }

    public int updateForm(Map<String, Object> params) {
        int updateForm = getHrmResourceService(user).updateForm(params);
        return updateForm;
    }

    public Map<String, Object> getSearchCondition(Map<String, Object> params) {
        return getHrmResourceService(user).getSearchCondition(params);
    }

    public Integer saveSearchTemplate(SearchTemplateParam params) {
        return getHrmResourceService(user).saveSearchTemplate(params);
    }

    public void deleteSearchTemplate(Integer id) {
        getHrmResourceService(user).deleteSearchTemplate(id);
    }

    public String getTemplateSelectKeys(Map<String, Object> params) {
        return getHrmResourceService(user).getTemplateSelectKeys(params);
    }

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

    public Map<String, Object> getTabForm(Map<String, Object> params) {
        return getHrmResourceService(user).getTabForm(params);
    }

    public long saveTabForm(HrmRelationSaveParam params) {
        return getHrmResourceService(user).saveTabForm(params);
    }

    public long updateTabForm(HrmRelationSaveParam params) {
        return getHrmResourceService(user).updateTabForm(params);
    }

    public List<SearchTemplateParam> getSearchTemplate(Map<String, Object> params) {
        return getHrmResourceService(user).getSearchTemplate(params);
    }

    public Integer saveCustomTemplate(SearchTemplateParam params) {
        return getHrmResourceService(user).saveCustomTemplate(params);
    }

    public Integer updateCustomTemplate(Map<String, Object> params) {
        return getHrmResourceService(user).updateCustomTemplate(params);
    }

    public void deleteCustomTemplate(Integer id) {
        getHrmResourceService(user).deleteCustomTemplate(id);
    }

    public Map<String, Object> getCustomTemplate(Map<String,Object> params){
        return getHrmResourceService(user).getCustomTemplate(params);
    }

    public Map<String, Object> getCustomTransferData(Map<String, Object> params) {
        return getHrmResourceService(user).getCustomTransferData(params);
    }
}
