Search in sources :

Example 26 with Dictionary

use of com.diboot.core.entity.Dictionary in project diboot by dibo-software.

the class BaseServiceTest method testDictExtdata.

@Test
public void testDictExtdata() {
    QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("parent_id", 0).eq("type", "GENDER");
    Dictionary dictionary = dictionaryService.getSingleEntity(queryWrapper);
    if (dictionary.getExtdata() == null) {
        dictionary.setExtdata("{\"createByName\":\"张三\"}");
        dictionaryService.updateEntity(dictionary);
        dictionary = dictionaryService.getSingleEntity(queryWrapper);
    }
    Assert.assertTrue(dictionary.getExtdata() != null);
    Assert.assertTrue(dictionary.getFromExt("createByName").equals("张三"));
}
Also used : Dictionary(com.diboot.core.entity.Dictionary) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with Dictionary

use of com.diboot.core.entity.Dictionary 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)27 Test (org.junit.Test)21 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)8 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)5 DictionaryVO (com.diboot.core.vo.DictionaryVO)5 Transactional (org.springframework.transaction.annotation.Transactional)5 BusinessException (com.diboot.core.exception.BusinessException)3 DictionaryService (com.diboot.core.service.DictionaryService)3 SimpleDictionaryVO (diboot.core.test.binder.vo.SimpleDictionaryVO)3 User (diboot.core.test.binder.entity.User)2 ArrayList (java.util.ArrayList)2 BaseMapper (com.baomidou.mybatisplus.core.mapper.BaseMapper)1 EntityInfoCache (com.diboot.core.binding.parser.EntityInfoCache)1 DynamicMemoryCacheManager (com.diboot.core.cache.DynamicMemoryCacheManager)1 IamResourcePermissionListVO (com.diboot.iam.vo.IamResourcePermissionListVO)1 IamMember (com.diboot.mobile.entity.IamMember)1 IamMemberService (com.diboot.mobile.service.IamMemberService)1 CcCityInfo (diboot.core.test.binder.entity.CcCityInfo)1 MulColJoinVO (diboot.core.test.binder.vo.MulColJoinVO)1