package com.yn.bftl.thirdparty.modules.log.abstracts;

import com.yn.bftl.common.modules.auth.entity.User;
import com.yn.bftl.common.modules.company.entity.Company;
import com.yn.bftl.common.modules.customer.entity.Customer;
import com.yn.bftl.thirdparty.common.enums.OperatorType;
import com.yn.bftl.thirdparty.common.service.BaseMemberService;

/**
 * 日志相关抽象类
 * 用于LoggerService类数据使用
 * 抽象编写公共的方法使用
 *
 * @author chendehuihuo
 * @date 2021-11-12
 **/
public abstract class AbstractLogService extends BaseMemberService {

    protected Company getCompany() {

        try {
            Company company = null;
            OperatorType member_type = getMemberType();
            if (member_type == OperatorType.MEMBER_CUSTOMER) {
                Customer customer = (Customer) getMemberObject();
                company = customer.getCompany();
            } else if (member_type == OperatorType.MEMBER_USER) {
                User user = (User) getMemberObject();
                company = user.getCompany();
            }
            if (company != null) {
                return company;
            }
        } catch (Exception ignored) { }
        return null;
    }
}
