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("张三"));
}
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);
}
}
Aggregations