导航
服务职责
IdentityService服务类主要负责操作用户、组、用户与组、用户信息; 操作租户,以及给租户下面添加人或者组;
设置系统当前操作人。
获取方式:
identityService = processEngine.getIdentityService();
实现类:
IdentityServiceImpl
用户相关表总结
用户操作
创建用户两种方式及密码加密
/**
* 生成的用户密码未加密
* insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_, SALT_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 )
*
*/
@Test
public void test1(){
UserEntity userEntity = new UserEntity();
userEntity.setId("gjf");
userEntity.setFirstName("guo");
userEntity.setLastName("jianfeng");
userEntity.setEmail("guojianfeng@ysstech.com");
userEntity.setDbPassword("gjf");
userEntity.setSalt("1");
identityService.saveUser(userEntity);
}
/**
* 生成的用户密码会进行加密
* insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_, SALT_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 )
*
*/
@Test
public void test2(){
UserEntity userEntity = new UserEntity();
userEntity.setId("gjf2");
userEntity.setFirstName("guo");
userEntity.setLastName("jianfeng2");
userEntity.setEmail("guojianfeng2@ysstech.com");
userEntity.setPassword("gjf2");
identityService.saveUser(userEntity);
}
用户列表查询
@Test
public void test3() {
UserQuery userQuery = identityService.createUserQuery();
//select distinct RES.* from ACT_ID_USER RES order by RES.ID_ asc LIMIT ? OFFSET ?
//2147483647(Integer), 0(Integer)
List<User> list = userQuery.list();
}
Mysql分页写法
方法一:select from table limit (pageNumber - 1)pageSize,pageSize
方法二:**select from table limit pageSize offset (pageNumber - 1)pageSize
camunda支持第二种
方法二:select from table limit pageSize offset (pageNumber - 1)pageSize
//select distinct RES.* from ACT_ID_USER RES order by RES.ID_ asc LIMIT ? OFFSET ?
// Parameters: 1(Integer), 2(Integer)
List<User> users = userQuery.listPage(2, 1);
删除用户
Preparing: select * from ACT_ID_INFO where USER_ID_ = ? and KEY_ = ? and PARENT_ID_ is null
Parameters: gjf1(String), picture(String)
Total: 0
Preparing: select * from ACT_ID_INFO where USER_ID_ = ?
Parameters: gjf1(String)
Total: 0
Preparing: select * from ACT_ID_USER where ID_ = ?
Parameters: gjf1(String)
Total: 0
@Test
public void test4(){
identityService.deleteUser("gjf1");
}
组操作
保存组
/**
* insert into ACT_ID_GROUP (ID_, NAME_, TYPE_, REV_) values ( ?, ?, ?, 1 )
* yss(String), 赢时胜(String), 公司(String)
*/
@Test
public void saveGroup(){
GroupEntity groupEntity = new GroupEntity();
groupEntity.setId("yss");
groupEntity.setName("赢时胜");
groupEntity.setType("公司");
identityService.saveGroup(groupEntity);
}
组查询
@Test
public void queryGroup(){
GroupQuery groupQuery = identityService.createGroupQuery();
List<Group> list = groupQuery.list();
}
组与用户建立关系
@Test
public void queryGroupUserShip() {
identityService.createMembership("gjf2", "yss");
}
删除组
/**
* Preparing: select * from ACT_ID_GROUP where ID_ = ?
* Parameters: yss(String)
* Total: 1
* Preparing: select distinct RES.* from ACT_ID_TENANT RES inner join ACT_ID_TENANT_MEMBER TM on RES.ID_ = TM.TENANT_ID_ WHERE TM.GROUP_ID_ = ? order by RES.ID_ asc LIMIT ? OFFSET ?
* Parameters: yss(String), 2147483647(Integer), 0(Integer)
* Total: 0
* Preparing: delete from ACT_ID_MEMBERSHIP where GROUP_ID_ = ?
* Parameters: yss(String)
* Preparing: delete from ACT_ID_TENANT_MEMBER where GROUP_ID_ = ?
* Parameters: yss(String)
* Preparing: delete from ACT_ID_GROUP where ID_ = ? and REV_ = ?
* Parameters: yss(String), 1(Integer)
*/
@Test
public void deleteGroup() {
identityService.deleteGroup("yss");
}