导航

image.png

image.png

服务职责

IdentityService服务类主要负责操作用户、组、用户与组、用户信息; 操作租户,以及给租户下面添加人或者组;
设置系统当前操作人。

获取方式:

identityService = processEngine.getIdentityService();

实现类:

IdentityServiceImpl

用户相关表总结

image.png

用户操作

创建用户两种方式及密码加密

  1. /**
  2. * 生成的用户密码未加密
  3. * insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_, SALT_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 )
  4. *
  5. */
  6. @Test
  7. public void test1(){
  8. UserEntity userEntity = new UserEntity();
  9. userEntity.setId("gjf");
  10. userEntity.setFirstName("guo");
  11. userEntity.setLastName("jianfeng");
  12. userEntity.setEmail("guojianfeng@ysstech.com");
  13. userEntity.setDbPassword("gjf");
  14. userEntity.setSalt("1");
  15. identityService.saveUser(userEntity);
  16. }
  17. /**
  18. * 生成的用户密码会进行加密
  19. * insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_, SALT_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 )
  20. *
  21. */
  22. @Test
  23. public void test2(){
  24. UserEntity userEntity = new UserEntity();
  25. userEntity.setId("gjf2");
  26. userEntity.setFirstName("guo");
  27. userEntity.setLastName("jianfeng2");
  28. userEntity.setEmail("guojianfeng2@ysstech.com");
  29. userEntity.setPassword("gjf2");
  30. identityService.saveUser(userEntity);
  31. }

image.png

用户列表查询

  1. @Test
  2. public void test3() {
  3. UserQuery userQuery = identityService.createUserQuery();
  4. //select distinct RES.* from ACT_ID_USER RES order by RES.ID_ asc LIMIT ? OFFSET ?
  5. //2147483647(Integer), 0(Integer)
  6. List<User> list = userQuery.list();
  7. }

Mysql分页写法

方法一:select from table limit (pageNumber - 1)pageSize,pageSize
方法二:**select from table limit pageSize offset (pageNumber - 1)pageSize

image.png

camunda支持第二种

方法二:select from table limit pageSize offset (pageNumber - 1)pageSize

  1. //select distinct RES.* from ACT_ID_USER RES order by RES.ID_ asc LIMIT ? OFFSET ?
  2. // Parameters: 1(Integer), 2(Integer)
  3. List<User> users = userQuery.listPage(2, 1);

删除用户

  1. Preparing: select * from ACT_ID_INFO where USER_ID_ = ? and KEY_ = ? and PARENT_ID_ is null
  2. Parameters: gjf1(String), picture(String)
  3. Total: 0
  4. Preparing: select * from ACT_ID_INFO where USER_ID_ = ?
  5. Parameters: gjf1(String)
  6. Total: 0
  7. Preparing: select * from ACT_ID_USER where ID_ = ?
  8. Parameters: gjf1(String)
  9. Total: 0
  1. @Test
  2. public void test4(){
  3. identityService.deleteUser("gjf1");
  4. }

组操作

保存组

  1. /**
  2. * insert into ACT_ID_GROUP (ID_, NAME_, TYPE_, REV_) values ( ?, ?, ?, 1 )
  3. * yss(String), 赢时胜(String), 公司(String)
  4. */
  5. @Test
  6. public void saveGroup(){
  7. GroupEntity groupEntity = new GroupEntity();
  8. groupEntity.setId("yss");
  9. groupEntity.setName("赢时胜");
  10. groupEntity.setType("公司");
  11. identityService.saveGroup(groupEntity);
  12. }


组查询

  1. @Test
  2. public void queryGroup(){
  3. GroupQuery groupQuery = identityService.createGroupQuery();
  4. List<Group> list = groupQuery.list();
  5. }

组与用户建立关系

  1. @Test
  2. public void queryGroupUserShip() {
  3. identityService.createMembership("gjf2", "yss");
  4. }

删除组

  1. /**
  2. * Preparing: select * from ACT_ID_GROUP where ID_ = ?
  3. * Parameters: yss(String)
  4. * Total: 1
  5. * 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 ?
  6. * Parameters: yss(String), 2147483647(Integer), 0(Integer)
  7. * Total: 0
  8. * Preparing: delete from ACT_ID_MEMBERSHIP where GROUP_ID_ = ?
  9. * Parameters: yss(String)
  10. * Preparing: delete from ACT_ID_TENANT_MEMBER where GROUP_ID_ = ?
  11. * Parameters: yss(String)
  12. * Preparing: delete from ACT_ID_GROUP where ID_ = ? and REV_ = ?
  13. * Parameters: yss(String), 1(Integer)
  14. */
  15. @Test
  16. public void deleteGroup() {
  17. identityService.deleteGroup("yss");
  18. }

租户操作

新建租户

image.png

租户下面添加人或者添加组

image.png

租户下面人查询

image.png

租户下面组查询

image.png

用户信息

保存用户信息

image.png

image.png

获取用户信息

image.png

设置用户信息

image.png

添加用户图像

image.png

删除用户信息

image.png