package com.engine.organization.service.impl;

import com.engine.core.impl.Service;
import com.engine.organization.entity.staff.param.StaffOutParam;
import com.engine.organization.service.StaffOutService;
import com.engine.organization.util.OrganizationAssert;
import weaver.systeminfo.SystemEnv;

/**
 * @Author liang.cheng
 * @Date 2023/9/1 10:27 AM
 * @Description: 编制外部调用
 * @Version 1.0
 */
public class StaffOutServiceImpl  extends Service implements StaffOutService {


    @Override
    public Integer changeStaff(StaffOutParam staffOutParam) {
        OrganizationAssert.notNull(staffOutParam.getNum(), SystemEnv.getHtmlLabelName(547466,user.getLanguage()));
        OrganizationAssert.notNull(staffOutParam.getPlanId(),SystemEnv.getHtmlLabelName(547467,user.getLanguage()));
        FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl(user);
        buildStaffOutParam(staffOutParam);
        return functionFactory.actuator(staffOutParam.getType(), staffOutParam);
    }

    @Override
    public Integer transactionOnJob(StaffOutParam staffOutParam) {
        FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl(user);
        buildStaffOutParam(staffOutParam);
        return functionFactory.actuator(staffOutParam.getType(), staffOutParam);
    }

    private void buildStaffOutParam(StaffOutParam param) {
        if (param.getCompany() != null && param.getDepartment() != null && param.getJob() != null) {
            param.setDimension(3);
        }else if(param.getCompany() != null && param.getDepartment() != null) {
            param.setDimension(2);
        }else if (param.getCompany() != null) {
            param.setDimension(1);
        }

    }
}
