camunda流程引擎如此简单「三」用户及权限系统
2021/12/26 23:37:35
本文主要是介绍camunda流程引擎如此简单「三」用户及权限系统,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
package com.camunda.demo.controller; import io.swagger.annotations.ApiOperation; import org.camunda.bpm.engine.IdentityService; import org.camunda.bpm.engine.identity.*; import org.camunda.bpm.engine.impl.identity.Account; import org.camunda.bpm.engine.impl.persistence.entity.GroupEntity; import org.camunda.bpm.engine.impl.persistence.entity.TenantEntity; import org.camunda.bpm.engine.impl.persistence.entity.UserEntity; import org.camunda.bpm.engine.task.Task; import org.camunda.bpm.engine.task.TaskQuery; import org.camunda.commons.utils.IoUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import java.io.File; import java.lang.annotation.Native; import java.util.HashMap; import java.util.List; import java.util.Map; @Controller public class BpmUserContorller { @Autowired IdentityService identityService; /** * insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_, SALT_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 ) Update counts: [1] * Parameters: zcc1(String), zcc(String), zcc(String), zcc@qq.com(String), 1(String), 1(String) */ @ApiOperation(value = "启动流程", notes = "根据流程定义key启动最新版本并且无租户的流程") @RequestMapping(value = "/saveUser", method = RequestMethod.POST, consumes = "application/json") public void saveUser(@RequestBody UserEntity userEntity) throws Exception{ userEntity.setId("zcc1"); userEntity.setEmail("zcc@qq.com"); userEntity.setFirstName("zcc"); userEntity.setLastName("zcc"); userEntity.setDbPassword("1"); userEntity.setSalt("1"); identityService.saveUser(userEntity); } @ApiOperation(value = "查询用户", notes = "查询用户") @RequestMapping(value = "/UserQuery/{first}", method = RequestMethod.POST, consumes = "application/json") public void createUserQuery(@PathVariable String first){ UserQuery userQuery = identityService.createUserQuery().userFirstName(first); List<User> list = userQuery.list(); // 需要分页到话 // int maxResult=3; // int fistResult=maxResult*(1-1); // UserQuery userQuery = identityService.createUserQuery(); for (int i=0;i<list.size();i++){ User user = list.get(i); System.out.println(user.getFirstName()); System.out.println(user.getLastName()); System.out.println(user.getId()); System.out.println(user.getPassword()); System.out.println(user.getEmail()); } } /** * delete from ACT_ID_USER where ID_ = ? and REV_ = ? * delete from ACT_ID_MEMBERSHIP where USER_ID_ = ? Update counts: [0] * Result 1: delete from ACT_ID_TENANT_MEMBER where USER_ID_ = ? Update counts: [0] * Result 2: delete from ACT_ID_USER where ID_ = ? and REV_ = ? Update counts: [1] */ @ApiOperation(value = "启动流程", notes = "根据流程定义key启动最新版本并且无租户的流程") @RequestMapping(value = "/deleteUser/{userId}", method = RequestMethod.GET, consumes = "application/json") public void deleteUser(@PathVariable String userId){ identityService.deleteUser(userId); } /** * insert into ACT_ID_GROUP (ID_, NAME_, TYPE_, REV_) values ( ?, ?, ?, 1 ) * Parameters: group1(String), 项目1(String), 工作流(String) */ @ApiOperation(value = "启动流程", notes = "根据流程定义key启动最新版本并且无租户的流程") @RequestMapping(value = "/saveGroup", method = RequestMethod.POST, consumes = "application/json") public void saveGroup(@RequestBody GroupEntity groupEntity) throws Exception{ groupEntity.setId("group1"); groupEntity.setName("项目1"); groupEntity.setType("工作流"); identityService.saveGroup(groupEntity); } /** * select distinct RES.* from ACT_ID_GROUP RES order by RES.ID_ asc LIMIT ? OFFSET ? * 组查询可以和用户查询一样添加查询条件 */ @ApiOperation(value = "查询群组", notes = "查询群组") @RequestMapping(value = "/groupQuery", method = RequestMethod.GET, consumes = "application/json") public void createGroupQuery(){ GroupQuery groupQuery = identityService.createGroupQuery(); List<Group> list = groupQuery.list(); for (int i=0;i<list.size();i++){ Group group = list.get(i); System.out.println(group.getId()); System.out.println(group.getName()); System.out.println(group.getType()); } } /** * 创建组和用户的联系 * insert into ACT_ID_MEMBERSHIP (USER_ID_, GROUP_ID_) values ( ?, ? ) */ @ApiOperation(value = "查询群组", notes = "查询群组") @RequestMapping(value = "/groupQueryMembership", method = RequestMethod.GET, consumes = "application/json") public void createMembership(){ String userId="zcc2";String groupId="group1"; identityService.createMembership(userId,groupId); } /** * delete from ACT_ID_GROUP where ID_ = ? and REV_ = ? * delete from ACT_ID_MEMBERSHIP where GROUP_ID_ = ? Update counts: [1] * delete from ACT_ID_TENANT_MEMBER where GROUP_ID_ = ? Update counts: [0] *delete from ACT_ID_GROUP where ID_ = ? and REV_ = ? Update counts: [1] */ @ApiOperation(value = "删除群组", notes = "删除群组") @RequestMapping(value = "/deleteGroup", method = RequestMethod.POST, consumes = "application/json") public void deleteGroup(){ String groupId="group1"; identityService.deleteGroup(groupId); } /** * 租户存在的目的就是区分不同的系统,A系统和B系统的用户是不一样的,所以要区分 * insert into ACT_ID_TENANT (ID_, NAME_, REV_) values ( ?, ?, 1 ) * Parameters: A(String), A系统(String) */ @ApiOperation(value = "保存租户", notes = "保存租户") @RequestMapping(value = "/saveTenant", method = RequestMethod.POST, consumes = "application/json") public void saveTenant(){ TenantEntity tenantEntity=new TenantEntity(); tenantEntity.setId("A"); tenantEntity.setName("A系统"); identityService.saveTenant(tenantEntity); } /** * 租户和用户 * insert into ACT_ID_TENANT_MEMBER (ID_, TENANT_ID_, USER_ID_, GROUP_ID_) values ( ?, ?, ?, ? ) * Parameters: 101(String), A(String), zcc2(String), null */ @ApiOperation(value = "创建租户和人之间到关系", notes = "创建租户和群组之间到关系") @RequestMapping(value = "/createTenantUserMembership", method = RequestMethod.POST, consumes = "application/json") public void createTenantUserMembership(){ String tenantId="A";String userId="zcc2"; identityService.createTenantUserMembership(tenantId,userId); } /** * 租户和组 * insert into ACT_ID_TENANT_MEMBER (ID_, TENANT_ID_, USER_ID_, GROUP_ID_) values ( ?, ?, ?, ? ) * 201(String), A(String), null, group1(String) */ @ApiOperation(value = "创建租户和群组之间到关系") @RequestMapping(value = "/createTenantGroupMembership", method = RequestMethod.POST, consumes = "application/json") public void createTenantGroupMembership(){ String tenantId="A";String groupId="group1"; identityService.createTenantGroupMembership(tenantId,groupId); } /** * 查询租户下面有哪些用户 * select distinct RES.* from ACT_ID_USER RES inner join ACT_ID_TENANT_MEMBER TM on RES.ID_ = TM.USER_ID_ WHERE TM.TENANT_ID_ = ? order by RES.ID_ asc LIMIT ? OFFSET ? * Parameters: A(String), 2147483647(Integer), 0(Integer) */ @ApiOperation(value = "查询租户和人之间到关系") @RequestMapping(value = "/createUserQueryMemberOfTenant", method = RequestMethod.POST, consumes = "application/json") public void createUserQueryMemberOfTenant(){ String tenantId="A"; UserQuery userQuery = identityService.createUserQuery(); List<User> list = userQuery.memberOfTenant(tenantId).list(); for (int i=0;i<list.size();i++){ User user = list.get(i); System.out.println(user.getFirstName()); System.out.println(user.getLastName()); System.out.println(user.getId()); System.out.println(user.getPassword()); System.out.println(user.getEmail()); } } /** * 查询租户下面有哪些组 *select distinct RES.* from ACT_ID_GROUP RES inner join ACT_ID_TENANT_MEMBER TM on RES.ID_ = TM.GROUP_ID_ WHERE TM.TENANT_ID_ = ? order by RES.ID_ asc LIMIT ? OFFSET ? * Parameters: A(String), 2147483647(Integer), 0(Integer) */ @ApiOperation(value = "查询群组和租户间到关系") @RequestMapping(value = "/createGroupQueryMemberOfTenant", method = RequestMethod.POST, consumes = "application/json") public void createGroupQueryMemberOfTenant(){ String tenantId="A"; GroupQuery groupQuery = identityService.createGroupQuery(); List<Group> list = groupQuery.memberOfTenant(tenantId).list(); for (int i=0;i<list.size();i++){ Group group = list.get(i); System.out.println(group.getId()); System.out.println(group.getName()); System.out.println(group.getType()); } } /** * 添加用户相关信息 * insert into ACT_ID_INFO (ID_, USER_ID_, TYPE_, KEY_, VALUE_, PASSWORD_, PARENT_ID_, REV_) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) * Parameters: 301(String), zcc2(String), account(String), zccAccountName(String), zccAccountUsername(String), java.io.ByteArrayInputStream@5ef0d29e(ByteArrayInputStream), null */ @ApiOperation(value = "更新用户信息") @RequestMapping(value = "/setUserAccount", method = RequestMethod.POST, consumes = "application/json") public void setUserAccount(){ String userId="zcc2"; String userPassword="1"; String accountName="zccAccountName"; String accountUsername="zccAccountUsername"; String accountPassword="zccAccountPassword"; Map<String, String> accountDetails=new HashMap<>(); accountDetails.put("a","a"); identityService.setUserAccount(userId,userPassword,accountName,accountUsername,accountPassword,accountDetails); } /** * 查询用户相关信息 * select * from ACT_ID_INFO where USER_ID_ = ? and KEY_ = ? and PARENT_ID_ is null * Parameters: zcc2(String), zccAccountName(String) */ @ApiOperation(value = "查询用户相关信息") @RequestMapping(value = "/getUserAccount", method = RequestMethod.POST, consumes = "application/json") public void getUserAccount(){ String userId="zcc2"; String userPassword="1"; String accountName="zccAccountName"; Account userAccount = identityService.getUserAccount(userId, userPassword, accountName); System.out.println("@@@@@"); System.out.println(userAccount); } /** * 添加用户图像信息 * insert into ACT_ID_INFO (ID_, USER_ID_, TYPE_, KEY_, VALUE_, PASSWORD_, PARENT_ID_, REV_) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) * Parameters: 501(String), zcc2(String), null, picture(String), 502(String), null, null * insert into ACT_GE_BYTEARRAY(ID_, NAME_, BYTES_, DEPLOYMENT_ID_, TENANT_ID_, TYPE_, CREATE_TIME_, ROOT_PROC_INST_ID_, REMOVAL_TIME_, REV_) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, 1 ) * Parameters: 502(String), jpg(String), java.io.ByteArrayInputStream@58bf8650(ByteArrayInputStream), null, null, 1(Integer), 2019-10-07 01:56:06.029(Timestamp), null, null */ @ApiOperation(value = "保存图片") @RequestMapping(value = "/setUserPicture", method = RequestMethod.POST, consumes = "application/json") public void setUserPicture(){ String userId="zcc2"; /** * public Picture(byte[] bytes, String mimeType) { * this.bytes = bytes; * this.mimeType = mimeType; * } */ byte[] bytes = IoUtil.fileAsByteArray(new File("src/main/resources/2.jpg")); Picture picture=new Picture(bytes,"jpg"); //void setUserPicture(String userId, Picture picture); identityService.setUserPicture(userId,picture); } }
这篇关于camunda流程引擎如此简单「三」用户及权限系统的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-10Rakuten 乐天积分系统从 Cassandra 到 TiDB 的选型与实战
- 2025-01-09CMS内容管理系统是什么?如何选择适合你的平台?
- 2025-01-08CCPM如何缩短项目周期并降低风险?
- 2025-01-08Omnivore 替代品 Readeck 安装与使用教程
- 2025-01-07Cursor 收费太贵?3分钟教你接入超低价 DeepSeek-V3,代码质量逼近 Claude 3.5
- 2025-01-06PingCAP 连续两年入选 Gartner 云数据库管理系统魔力象限“荣誉提及”
- 2025-01-05Easysearch 可搜索快照功能,看这篇就够了
- 2025-01-04BOT+EPC模式在基础设施项目中的应用与优势
- 2025-01-03用LangChain构建会检索和搜索的智能聊天机器人指南
- 2025-01-03图像文字理解,OCR、大模型还是多模态模型?PalliGema2在QLoRA技术上的微调与应用