package com.engine.organization.wrapper;

import com.api.browser.bean.SearchConditionGroup;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.organization.entity.department.param.*;
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
import com.engine.organization.entity.job.vo.SingleJobTreeVO;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.service.DepartmentService;
import com.engine.organization.service.impl.DepartmentServiceImpl;
import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.response.ReturnResult;
import weaver.hrm.User;

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

/**
 * @Author weaver_cl
 * @description:
 * @Date 2022/5/20
 * @Version V1.0
 **/
public class DepartmentWrapper extends Service {

    public DepartmentService getDepartmentService(User user) {
        return ServiceUtil.getService(DepartmentServiceImpl.class, user);
    }

    public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) {
        PageInfo<SingleDeptTreeVO> singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param);
        return ReturnResult.successed(singleDeptTreeVOS);
    }

    /**
     * 部门联查岗位
     *
     * @param param
     * @return
     */
    public PageInfo<SingleJobTreeVO> getJobListByPid(QuerySingleDeptListParam param) {
        return getDepartmentService(user).getJobListByPid(param);
    }

    /**
     * 左侧树
     *
     * @param params
     * @return
     */
    public Map<String, Object> getSearchTree(SearchTreeParams params) {
        return getDepartmentService(user).getSearchTree(params);
    }

    /**
     * 列表数据展示
     *
     * @param param
     * @return
     */
    public Map<String, Object> listPage(DeptSearchParam param) {
        return getDepartmentService(user).listPage(param);
    }

    /**
     * 获取保存表单
     *
     * @return
     */
    public Map<String, Object> getSaveForm() {
        return getDepartmentService(user).getSaveForm();
    }

    /**
     * 保存部门基础信息
     *
     * @param params
     * @return
     */
    public Long saveBaseForm(Map<String, Object> params) {
        return getDepartmentService(user).saveBaseForm(params);
    }


    /**
     * 更新禁用标记
     *
     * @param params
     */
    public int updateForbiddenTagById(DeptSearchParam params) {
        return getDepartmentService(user).updateForbiddenTagById(params);
    }

    /**
     * 更新分部主表、拓展表、明细表
     *
     * @param params
     * @return
     */
    public Long updateForm(Map<String, Object> params) {
        return getDepartmentService(user).updateForm(params);
    }

    /**
     * 根据ID批量删除
     *
     * @param ids
     */
    public int deleteByIds(Collection<Long> ids) {
        return getDepartmentService(user).deleteByIds(ids);
    }

    /**
     * 获取搜索条件
     *
     * @param params
     * @return
     */
    public Map<String, Object> getSearchCondition(Map<String, Object> params) {
        return getDepartmentService(user).getSearchCondition(params);
    }

    /**
     * 获取列表页面按钮信息
     *
     * @return
     */
    public Map<String, Object> getHasRight() {
        return getDepartmentService(user).getHasRight();
    }

    /**
     * 获取基本信息表单
     *
     * @param params
     * @return
     */
    public Map<String, Object> getDeptBaseForm(Map<String, Object> params) {
        return getDepartmentService(user).getDeptBaseForm(params);
    }

    /**
     * 复制表单
     *
     * @return
     */
    public List<SearchConditionGroup> getCopyForm() {
        return getDepartmentService(user).getCopyForm();
    }

    /**
     * 复制岗位到指定部门
     *
     * @param copyParam
     * @return
     */
    public int copyDepartment(DeptCopyParam copyParam) {
        return getDepartmentService(user).copyDepartment(copyParam);
    }

    /**
     * 获取合并表单
     *
     * @param id
     * @return
     */
    public List<SearchConditionGroup> getMergeForm(Long id) {
        return getDepartmentService(user).getMergeForm(id);
    }

    /**
     * 合并到指定部门
     *
     * @param mergeParam
     * @return
     */
    public int mergeDepartment(DepartmentMergeParam mergeParam) {
        return getDepartmentService(user).mergeDepartment(mergeParam);
    }

    /**
     * 获取转移表单
     *
     * @return
     */
    public List<SearchConditionGroup> getMoveForm() {
        return getDepartmentService(user).getMoveForm();
    }

    /**
     * 转移到指定分部或部门
     *
     * @param moveParam
     * @return
     */
    public int moveDepartment(DepartmentMoveParam moveParam) {
        return getDepartmentService(user).moveDepartment(moveParam);
    }
}
