欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PowerJob的UserService工作流程源碼解讀

 更新時間:2024年01月23日 09:07:36   作者:codecraft  
這篇文章主要介紹了PowerJob的UserService工作流程源碼解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

本文主要研究一下PowerJob的UserService

UserService

tech/powerjob/server/core/service/UserService.java

@Service
public class UserService {
    @Resource
    private UserInfoRepository userInfoRepository;
    /**
     * 保存/修改 用戶
     * @param userInfoDO user
     */
    public void save(UserInfoDO userInfoDO) {
        userInfoDO.setGmtCreate(new Date());
        userInfoDO.setGmtModified(userInfoDO.getGmtCreate());
        userInfoRepository.saveAndFlush(userInfoDO);
    }
    /**
     * 根據(jù)用戶ID字符串獲取用戶信息詳細列表
     * @param userIds 逗號分割的用戶ID信息
     * @return 用戶信息詳細列表
     */
    public List<UserInfoDO> fetchNotifyUserList(String userIds) {
        if (StringUtils.isEmpty(userIds)) {
            return Lists.newLinkedList();
        }
        // 去重
        Set<Long> userIdList = Splitter.on(",").splitToList(userIds).stream().map(Long::valueOf).collect(Collectors.toSet());
        List<UserInfoDO> res = userInfoRepository.findByIdIn(Lists.newLinkedList(userIdList));
        res.forEach(x -> x.setPassword(null));
        return res;
    }
}
UserService提供了save及fetchNotifyUserList方法,基于UserInfoRepository來實現(xiàn)

UserInfoDO

tech/powerjob/server/persistence/remote/model/UserInfoDO.java

@Data
@Entity
@Table(indexes = {
        @Index(name = "uidx01_user_info", columnList = "username"),
        @Index(name = "uidx02_user_info", columnList = "email")
})
public class UserInfoDO {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")
    private Long id;
    private String username;
    private String password;
    /**
     * 手機號
     */
    private String phone;
    /**
     * 郵箱地址
     */
    private String email;
    /**
     * webHook
     */
    private String webHook;
    /**
     * 擴展字段
     */
    private String extra;
    private Date gmtCreate;
    private Date gmtModified;
}
UserInfoDO定義了username、email兩個唯一鍵

UserInfoRepository

tech/powerjob/server/persistence/remote/repository/UserInfoRepository.java

public interface UserInfoRepository extends JpaRepository<UserInfoDO, Long> {
    List<UserInfoDO> findByUsernameLike(String username);
    List<UserInfoDO> findByIdIn(List<Long> userIds);
}
UserInfoRepository基于JpaRepository,聲明了findByUsernameLike、findByIdIn方法

InstanceManager

tech/powerjob/server/core/instance/InstanceManager.java

private void alert(Long instanceId, String alertContent) {
        InstanceInfoDO instanceInfo = instanceInfoRepository.findByInstanceId(instanceId);
        JobInfoDO jobInfo;
        try {
            jobInfo = instanceMetadataService.fetchJobInfoByInstanceId(instanceId);
        } catch (Exception e) {
            log.warn("[InstanceManager-{}] can't find jobInfo, alarm failed.", instanceId);
            return;
        }
        JobInstanceAlarm content = new JobInstanceAlarm();
        BeanUtils.copyProperties(jobInfo, content);
        BeanUtils.copyProperties(instanceInfo, content);
        List&lt;UserInfoDO&gt; userList = SpringUtils.getBean(UserService.class).fetchNotifyUserList(jobInfo.getNotifyUserIds());
        if (!StringUtils.isEmpty(alertContent)) {
            content.setResult(alertContent);
        }
        alarmCenter.alarmFailed(content, AlarmUtils.convertUserInfoList2AlarmTargetList(userList));
    }
InstanceManager的alert會根據(jù)jobInfo.getNotifyUserIds()區(qū)查找fetchNotifyUserList出來的userList,最后通過alarmCenter.alarmFailed給指定用戶發(fā)送報警信息

小結(jié)

UserService提供了save及fetchNotifyUserList方法,基于UserInfoRepository來實現(xiàn);InstanceManager的alert會根據(jù)jobInfo.getNotifyUserIds()區(qū)查找fetchNotifyUserList出來的userList,最后通過alarmCenter.alarmFailed給指定用戶發(fā)送報警信息。

以上就是PowerJob的UserService工作流程源碼解讀的詳細內(nèi)容,更多關(guān)于PowerJob UserService的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 詳解shrio的認證(登錄)過程

    詳解shrio的認證(登錄)過程

    這篇文章主要介紹了shrio的認證(登錄)過程,幫助大家更好的理解和使用shrio框架,感興趣的朋友可以了解下
    2021-02-02
  • Java后端長時間無操作自動退出的實現(xiàn)方式

    Java后端長時間無操作自動退出的實現(xiàn)方式

    這篇文章主要介紹了Java后端長時間無操作自動退出的實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • java實現(xiàn)簡易點菜器

    java實現(xiàn)簡易點菜器

    這篇文章主要為大家詳細介紹了java實現(xiàn)簡易點菜器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • Java中MessageFormat的使用詳解

    Java中MessageFormat的使用詳解

    本文主要介紹了Java中MessageFormat的使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-06-06
  • Springboot集成JWT實現(xiàn)登錄注冊的示例代碼

    Springboot集成JWT實現(xiàn)登錄注冊的示例代碼

    本文主要介紹了Springboot集成JWT實現(xiàn)登錄注冊的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-06-06
  • MyBatis-Plus中使用EntityWrappe進行列表數(shù)據(jù)倒序設(shè)置方式

    MyBatis-Plus中使用EntityWrappe進行列表數(shù)據(jù)倒序設(shè)置方式

    這篇文章主要介紹了MyBatis-Plus中使用EntityWrappe進行列表數(shù)據(jù)倒序設(shè)置方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • Java如何處理延遲任務過程解析

    Java如何處理延遲任務過程解析

    這篇文章主要介紹了Java如何處理延遲任務過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-10-10
  • JavaFx實現(xiàn)登錄成功跳轉(zhuǎn)到程序主頁面

    JavaFx實現(xiàn)登錄成功跳轉(zhuǎn)到程序主頁面

    這篇文章主要為大家詳細介紹了JavaFx實現(xiàn)登錄成功跳轉(zhuǎn)到程序主頁面,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • springmvc開啟異步請求報錯Java code using the Servlet API or

    springmvc開啟異步請求報錯Java code using the Ser

    這篇文章主要為大家介紹了springmvc開啟異步請求報錯Java code using the Servlet API or解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2024-02-02
  • Java多線程之哲學家就餐問題詳解

    Java多線程之哲學家就餐問題詳解

    這篇文章主要介紹了Java多線程之哲學家就餐問題詳解,文中有非常詳細的代碼示例,對正在學習java的小伙伴們有非常好的幫助,需要的朋友可以參考下
    2021-04-04

最新評論