Search in sources :

Example 1 with IamMemberService

use of com.diboot.mobile.service.IamMemberService in project diboot by dibo-software.

the class MobilePluginInitializer method insertInitData.

/**
 * 插入初始化数据
 */
private synchronized void insertInitData() {
    // 插入mobile组件所需的数据字典
    // 插入iam组件所需的数据字典
    DictionaryService dictionaryService = ContextHelper.getBean(DictionaryService.class);
    if (dictionaryService != null && !dictionaryService.exists(Dictionary::getType, "MEMBER_STATUS")) {
        String[] DICT_INIT_DATA = { "{\"type\":\"MEMBER_STATUS\", \"itemName\":\"用户状态\", \"description\":\"Member用户状态\", \"children\":[{\"itemName\":\"有效\", \"itemValue\":\"A\", \"sortId\":1},{\"itemName\":\"无效\", \"itemValue\":\"I\", \"sortId\":2}]}" };
        // 插入数据字典
        for (String dictJson : DICT_INIT_DATA) {
            DictionaryVO dictVo = JSON.toJavaObject(dictJson, DictionaryVO.class);
            dictionaryService.createDictAndChildren(dictVo);
        }
        DICT_INIT_DATA = null;
    }
    IamMemberService iamMemberService = ContextHelper.getBean(IamMemberService.class);
    if (iamMemberService != null && iamMemberService.getEntityListCount(null) == 0) {
        IamMember iamMember = new IamMember();
        iamMember.setOrgId(0L).setNickname("DIBOOT-Mobile").setStatus(Cons.DICTCODE_ACCOUNT_STATUS.A.name()).setUserType(IamMember.class.getSimpleName()).setUserId(0L).setGender("M").setOpenid(S.newUuid());
        iamMemberService.createEntity(iamMember);
        // 创建账号
        IamAccount iamAccount = new IamAccount();
        iamAccount.setUserType(IamMember.class.getSimpleName()).setUserId(iamMember.getId()).setAuthType(Cons.DICTCODE_AUTH_TYPE.PWD.name()).setAuthAccount("admin").setAuthSecret("123456");
        ContextHelper.getBean(IamAccountService.class).createEntity(iamAccount);
    }
}
Also used : Dictionary(com.diboot.core.entity.Dictionary) DictionaryService(com.diboot.core.service.DictionaryService) DictionaryVO(com.diboot.core.vo.DictionaryVO) IamMember(com.diboot.mobile.entity.IamMember) IamMemberService(com.diboot.mobile.service.IamMemberService)

Aggregations

Dictionary (com.diboot.core.entity.Dictionary)1 DictionaryService (com.diboot.core.service.DictionaryService)1 DictionaryVO (com.diboot.core.vo.DictionaryVO)1 IamMember (com.diboot.mobile.entity.IamMember)1 IamMemberService (com.diboot.mobile.service.IamMemberService)1