package com.kingtom.shengtai.app.affair.service;

import java.util.HashMap;
import java.util.Map;

import com.kingtom.kirin.app.affair.model.AffairInfo;
import com.kingtom.kirin.app.affair.service.IAffairService;
import com.kingtom.kirin.core.common.utils.JsonUtils;
import com.kingtom.kirin.core.resource.ResourceConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 应用模块名称</p>
 * 代码描述</p>
 * Copyright: Copyright (C) 2024 , Inc. All rights reserved. <p>
 * Company: 成都诚唐科技有限责任公司</p>
 *
 * @author wany
 * @since 2024/1/2
 */
@Service
public class AffairService{

    @Autowired
    private IAffairService affairService;

    public void createUserJoinOrgAffair(String userId, String name, String phone){
        AffairInfo info = new AffairInfo();
        info.setType(UserJoinOrgHandler.NAME);
        info.setSourceType(ResourceConst.ResourceTypeEnum.SystemUser.getKey());
        info.setSourceId(userId);
        Map<String, String> data = new HashMap<>();
        data.put("userId", userId);
        data.put("name", name);
        data.put("phone", phone);
        info.setData(JsonUtils.toJson(data));
        affairService.createAffair(info);
    }

    public void createSupplierAffair(String userId, String data){
        AffairInfo info = new AffairInfo();
        info.setType(SupplierJoinHandler.NAME);
        info.setSourceType(ResourceConst.ResourceTypeEnum.SystemUser.getKey());
        info.setSourceId(userId);
        info.setData(data);
        affairService.createAffair(info);
    }

}
