From 550bfdf8bfc7e9e510e4fcc37849d06cd4803ea0 Mon Sep 17 00:00:00 2001 From: songgaoshuai <1742057357@qq.com> Date: Wed, 7 Jun 2023 13:52:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E5=9E=8B=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E7=94=A8=E6=88=B7=EF=BC=8C=E7=BB=84=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActModelController.java | 62 ++++++++++++++++ .../domain/vo/GroupRepresentation.java | 27 +++++++ .../vo/ResultListDataRepresentation.java | 70 +++++++++++++++++++ .../domain/vo/UserRepresentation.java | 30 ++++++++ 4 files changed, 189 insertions(+) create mode 100644 ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/GroupRepresentation.java create mode 100644 ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/ResultListDataRepresentation.java create mode 100644 ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/UserRepresentation.java diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/ActModelController.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/ActModelController.java index af2545299..73f19ee02 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/ActModelController.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/ActModelController.java @@ -1,11 +1,14 @@ package org.dromara.workflow.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; import lombok.RequiredArgsConstructor; import org.dromara.common.core.domain.R; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.validate.AddGroup; import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.json.utils.JsonUtils; @@ -14,16 +17,27 @@ import org.dromara.common.log.enums.BusinessType; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.web.core.BaseController; +import org.dromara.system.domain.SysRole; +import org.dromara.system.domain.SysUser; +import org.dromara.system.mapper.SysRoleMapper; +import org.dromara.system.mapper.SysUserMapper; +import org.dromara.system.service.ISysUserService; import org.dromara.workflow.domain.bo.ModelBo; import org.dromara.workflow.domain.vo.AccountVo; +import org.dromara.workflow.domain.vo.GroupRepresentation; +import org.dromara.workflow.domain.vo.ResultListDataRepresentation; +import org.dromara.workflow.domain.vo.UserRepresentation; import org.dromara.workflow.service.IActModelService; import org.flowable.engine.RepositoryService; import org.flowable.engine.repository.Model; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.MultiValueMap; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; /** @@ -41,6 +55,10 @@ public class ActModelController extends BaseController { private final IActModelService iActModelService; + private final SysUserMapper sysUserMapper; + + private final SysRoleMapper sysRoleMapper; + /** * 分页查询模型 @@ -141,4 +159,48 @@ public class ActModelController extends BaseController { iActModelService.exportZip(modelId, response); } + /** + * 查询用户 + * + * @param filter 参数 + */ + @GetMapping(value = "/rest/editor-users") + public ResultListDataRepresentation getUsers(@RequestParam(value = "filter", required = false) String filter) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StringUtils.isNotBlank(filter), SysUser::getNickName, filter); + List sysUsers = sysUserMapper.selectList(wrapper); + List userRepresentations = new ArrayList<>(); + for (SysUser sysUser : sysUsers) { + UserRepresentation userRepresentation = new UserRepresentation(); + userRepresentation.setFullName(sysUser.getNickName()); + userRepresentation.setLastName(sysUser.getNickName()); + userRepresentation.setTenantId(sysUser.getTenantId()); + userRepresentation.setEmail(sysUser.getEmail()); + userRepresentation.setId(sysUser.getUserId().toString()); + userRepresentations.add(userRepresentation); + } + return new ResultListDataRepresentation(userRepresentations); + } + + /** + * 查询用户组 + * + * @param filter 参数 + */ + @GetMapping(value = "/rest/editor-groups") + public ResultListDataRepresentation getGroups(@RequestParam(required = false, value = "filter") String filter) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.like(StringUtils.isNotBlank(filter), SysRole::getRoleName, filter); + List sysRoles = sysRoleMapper.selectList(wrapper); + List result = new ArrayList<>(); + for (SysRole sysRole : sysRoles) { + GroupRepresentation groupRepresentation = new GroupRepresentation(); + groupRepresentation.setId(sysRole.getRoleId().toString()); + groupRepresentation.setName(sysRole.getRoleName()); + groupRepresentation.setType(sysRole.getRoleKey()); + result.add(groupRepresentation); + } + return new ResultListDataRepresentation(result); + } + } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/GroupRepresentation.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/GroupRepresentation.java new file mode 100644 index 000000000..02614033c --- /dev/null +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/GroupRepresentation.java @@ -0,0 +1,27 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.workflow.domain.vo; + +import lombok.Data; + +/** + * @author Joram Barrez + */ +@Data +public class GroupRepresentation{ + + protected String id; + protected String name; + protected String type; + +} diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/ResultListDataRepresentation.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/ResultListDataRepresentation.java new file mode 100644 index 000000000..fb6dd769f --- /dev/null +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/ResultListDataRepresentation.java @@ -0,0 +1,70 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.workflow.domain.vo; + +import java.util.List; + +/** + * @author Tijs Rademakers + */ +public class ResultListDataRepresentation { + + protected Integer size; + protected Long total; + protected Integer start; + protected List data; + + public ResultListDataRepresentation() { + } + + public ResultListDataRepresentation(List data) { + this.data = data; + if (data != null) { + size = data.size(); + total = (long) data.size(); + start = 0; + } + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public Long getTotal() { + return total; + } + + public void setTotal(Long total) { + this.total = total; + } + + public Integer getStart() { + return start; + } + + public void setStart(Integer start) { + this.start = start; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/UserRepresentation.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/UserRepresentation.java new file mode 100644 index 000000000..d990a920d --- /dev/null +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/UserRepresentation.java @@ -0,0 +1,30 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.workflow.domain.vo; + +import lombok.Data; + +/** + * @author Joram Barrez + */ +@Data +public class UserRepresentation { + + protected String id; + protected String firstName; + protected String lastName; + protected String email; + protected String fullName; + protected String tenantId; + +}