001/*
002 *    Copyright 2024-2025, Warm-Flow (290631660@qq.com).
003 *
004 *    Licensed under the Apache License, Version 2.0 (the "License");
005 *    you may not use this file except in compliance with the License.
006 *    You may obtain a copy of the License at
007 *
008 *       https://www.apache.org/licenses/LICENSE-2.0
009 *
010 *    Unless required by applicable law or agreed to in writing, software
011 *    distributed under the License is distributed on an "AS IS" BASIS,
012 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *    See the License for the specific language governing permissions and
014 *    limitations under the License.
015 */
016package org.dromara.warm.flow.core.service;
017
018import org.dromara.warm.flow.core.entity.Task;
019import org.dromara.warm.flow.core.entity.User;
020import org.dromara.warm.flow.core.orm.service.IWarmService;
021
022import java.util.List;
023
024/**
025 * 流程用户Service接口
026 *
027 * @author xiarg
028 * @since 2024/5/10 13:55
029 */
030public interface UserService extends IWarmService<User> {
031
032    /**
033     * 设置流程用户
034     *
035     * @param addTasks 待办任务
036     * @return List<User>
037     * @author xiarg
038     * @since 2024/5/10 13:59
039     */
040    List<User> taskAddUsers(List<Task> addTasks);
041
042    /**
043     * 设置流程用户
044     *
045     * @param addTasks 待办任务
046     * @param taskId   任务id
047     * @return List<User>
048     * @author xiarg
049     * @since 2024/5/10 13:59
050     */
051    List<User> setSkipUser(List<Task> addTasks, Long taskId);
052
053    /**
054     * 待办任务增加流程人员
055     *
056     * @param task 待办任务任务信息
057     * @return List<User>
058     * @author xiarg
059     * @since 2024/5/10 15:45
060     */
061    List<User> taskAddUser(Task task);
062
063    /**
064     * 根据待办任务id删除流程用户
065     *
066     * @param ids 待办任务id集合
067     * @author xiarg
068     * @since 2024/5/10 13:59
069     */
070    void deleteByTaskIds(List<Long> ids);
071
072    /**
073     * 根据(待办任务,实例,历史表,节点等)id查询权限人或者处理人
074     *
075     * @param associated 待办任务id集合
076     * @param type       用户表类型
077     * @author xiarg
078     * @since 2024/5/120 13:59
079     */
080    List<String> getPermission(Long associated, String... type);
081
082    /**
083     * 根据(待办任务,实例,历史表,节点等)id查询权限人或者处理人
084     *
085     * @param associated 待办任务id
086     * @param types      用户表类型
087     * @return List<User>
088     */
089    List<User> listByAssociatedAndTypes(Long associated, String... types);
090
091    /**
092     * 根据(待办任务,实例,历史表,节点等)id查询权限人或者处理人
093     *
094     * @param associateds (待办任务,实例,历史表,节点等)id集合
095     * @param types       用户表类型
096     * @return List<User>
097     */
098    List<User> getByAssociateds(List<Long> associateds, String... types);
099
100    /**
101     * 根据办理人查询
102     *
103     * @param associated  待办任务id
104     * @param processedBy 办理人
105     * @param types       用户表类型
106     * @return List<User>
107     */
108    List<User> listByProcessedBys(Long associated, String processedBy, String... types);
109
110    /**
111     * 根据办理人查询
112     *
113     * @param associated   待办任务id
114     * @param processedBys 办理人id集合
115     * @param types        用户表类型
116     * @return List<User>
117     */
118    List<User> getByProcessedBys(Long associated, List<String> processedBys, String... types);
119
120    /**
121     * 根据关联id更新权限人
122     *
123     * @param associated  关联人id
124     * @param permissions 权限人
125     * @param type        权限人类型
126     * @param clear       是否清空待办任务的计划审批人
127     * @param handler     存储委派时的办理人
128     * @return 结果
129     * @author xiarg
130     * @since 2024/5/10 11:19
131     */
132    boolean updatePermission(Long associated, List<String> permissions, String type, boolean clear, String handler);
133
134    /**
135     * 构造用户比表信息
136     *
137     * @param associated     关联id
138     * @param permissionList 权限标识集合
139     * @param type           用户类型
140     * @return 结果
141     */
142    List<User> structureUser(Long associated, List<String> permissionList, String type);
143
144    /**
145     * 构造用户比表信息
146     *
147     * @param associated 关联id
148     * @param permission 权限标识
149     * @param type       用户类型
150     * @return 结果
151     */
152    User structureUser(Long associated, String permission, String type);
153
154    /**
155     * 构造用户比表信息
156     *
157     * @param associated     关联id
158     * @param permissionList 权限标识集合
159     * @param type           用户类型
160     * @param handler        办理人(记录委派人)
161     * @return 结果
162     */
163    List<User> structureUser(Long associated, List<String> permissionList, String type, String handler);
164
165    /**
166     * 构造用户比表信息
167     *
168     * @param associated 关联id
169     * @param permission 权限标识
170     * @param type       用户类型
171     * @param handler    办理人(记录委派人)
172     * @return 结果
173     */
174    User structureUser(Long associated, String permission, String type, String handler);
175
176}