package com.zhongshu.card.server.core.service.user;

import com.zhongshu.card.server.core.domain.org.OrganizationUser;
import com.zhongshu.card.server.core.domain.org.UserAccount;
import com.zhongshu.card.server.core.service.base.CommonService;
import com.zhongshu.card.server.core.service.base.SuperService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @author TRX
 * @date 2024/11/22
 */
@Slf4j
@Service
public class UserAboutInfoService extends SuperService {

    @Autowired
    private CommonService commonService;

    /**
     * 用户信息发生变化，更新其他关联的用户信息
     *
     * @param userAccount
     */
    public void updateUserAboutEntityInfo(UserAccount userAccount) {
        if (ObjectUtils.isNotEmpty(userAccount)) {
            // 更新关联的
            Map<String, Object> where = new HashMap<>();
            where.put("userId", userAccount.getUserId());

            Map<String, Object> standardData = new HashMap<>();
            standardData.put("name", userAccount.getName());
            commonService.updateData(where, standardData, OrganizationUser.class.getSimpleName());
        }
    }

}
