31 changed files with 633 additions and 65 deletions
@ -0,0 +1,12 @@ |
|||||
|
package org.dromara.workflow.api.domain; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class RemoteFlowNode { |
||||
|
|
||||
|
private Long definitionId; |
||||
|
|
||||
|
private String permission_flag; |
||||
|
|
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package org.dromara.business.domain.bo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
@Schema(name = "流回调对象") |
||||
|
public class BusinessHookBo { |
||||
|
|
||||
|
@Schema(name = "流应用名") |
||||
|
private String app; |
||||
|
|
||||
|
@Schema(name = "TCP链接唯一ID") |
||||
|
private String id; |
||||
|
|
||||
|
@Schema(name = "播放器ip/推流器ip") |
||||
|
private String ip; |
||||
|
|
||||
|
@Schema(name = "播放url参数/推流url参数") |
||||
|
private String params; |
||||
|
|
||||
|
@Schema(name = "播放器端口号/推流器端口号") |
||||
|
private String port; |
||||
|
|
||||
|
@Schema(name = "播放的协议,可能是rtsp、rtmp、http") |
||||
|
private String schema; |
||||
|
|
||||
|
@Schema(name = "流ID") |
||||
|
private String stream; |
||||
|
|
||||
|
@Schema(name = "流虚拟主机") |
||||
|
private String vhost; |
||||
|
|
||||
|
@Schema(name = "服务器 id,通过配置文件设置") |
||||
|
private String mediaServerId; |
||||
|
|
||||
|
@Schema(name = "文件名") |
||||
|
private String file_name; |
||||
|
|
||||
|
@Schema(name = "文件绝对路径") |
||||
|
private String file_path; |
||||
|
|
||||
|
@Schema(name = "文件大小,单位字节") |
||||
|
private String file_size; |
||||
|
|
||||
|
@Schema(name = "文件所在目录路径") |
||||
|
private String folder; |
||||
|
|
||||
|
@Schema(name = "开始录制时间戳") |
||||
|
private Integer start_time; |
||||
|
|
||||
|
@Schema(name = "录制时长,单位秒") |
||||
|
private Float time_len; |
||||
|
|
||||
|
@Schema(name = "http/rtsp/rtmp点播相对url路径") |
||||
|
private String url; |
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
package org.dromara.workflow.controller; |
||||
|
|
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.workflow.common.ConditionalOnEnable; |
||||
|
import org.dromara.workflow.domain.FlowDepart; |
||||
|
import org.dromara.workflow.service.FlwDepartService; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
@Tag(name = "流程部门管理") |
||||
|
@ConditionalOnEnable |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/depart") |
||||
|
public class FlwDepartController { |
||||
|
|
||||
|
|
||||
|
private final FlwDepartService flwDepartService; |
||||
|
|
||||
|
/** |
||||
|
* 查询流程部门关系 |
||||
|
* flowCode |
||||
|
*/ |
||||
|
@Operation(summary = "查询流程部门关系",description = "查询流程部门关系") |
||||
|
@GetMapping("/{flowCode}/getInfo") |
||||
|
public R<FlowDepart> getInfo(@PathVariable String flowCode) { |
||||
|
return R.ok(flwDepartService.getInfo(flowCode)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 绑定流程部门关系 |
||||
|
* flowCode |
||||
|
*/ |
||||
|
@Operation(summary = "绑定流程部门关系",description = "绑定流程部门关系") |
||||
|
@PostMapping("/bind/depart") |
||||
|
public R<FlowDepart> bindDepart(@Validated({AddGroup.class}) @RequestBody FlowDepart flowDepart) { |
||||
|
return R.ok(flwDepartService.bindDepart(flowDepart)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package org.dromara.workflow.domain; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import jakarta.validation.constraints.NotNull; |
||||
|
import lombok.Data; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.workflow.handler.ListTypeHandler; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 部门流程关系表 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName(value = "flow_depart",autoResultMap = true) |
||||
|
public class FlowDepart { |
||||
|
|
||||
|
|
||||
|
@TableId(type = IdType.ASSIGN_ID) |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 流程类型 |
||||
|
*/ |
||||
|
@NotNull(message = "流程类型不能为空", groups = AddGroup.class) |
||||
|
private String flowType; |
||||
|
|
||||
|
/** |
||||
|
* 流程编码 |
||||
|
*/ |
||||
|
@NotNull(message = "流程编码不能为空", groups = AddGroup.class) |
||||
|
private String flowCode; |
||||
|
|
||||
|
/** |
||||
|
* 租户编号 |
||||
|
*/ |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** |
||||
|
* 部门id集合 |
||||
|
*/ |
||||
|
@NotNull(message = "部门id不能为空", groups = AddGroup.class) |
||||
|
@TableField(value = "dept_ids",typeHandler = ListTypeHandler.class) |
||||
|
List<Long> departIds; |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
package org.dromara.workflow.handler; |
||||
|
|
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.apache.ibatis.type.JdbcType; |
||||
|
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
import org.apache.ibatis.type.MappedTypes; |
||||
|
import org.apache.ibatis.type.TypeHandler; |
||||
|
import org.dromara.workflow.utils.JsonUtil; |
||||
|
|
||||
|
import java.sql.CallableStatement; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@MappedJdbcTypes(JdbcType.VARCHAR) |
||||
|
@MappedTypes({List.class}) |
||||
|
public class ListTypeHandler implements TypeHandler<List<Long>> { |
||||
|
|
||||
|
@Override |
||||
|
public void setParameter(PreparedStatement ps, int i, List<Long> list, JdbcType jdbcType) throws SQLException { |
||||
|
ps.setString(i, JsonUtil.toJson(list)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Long> getResult(ResultSet rs, String columnName) throws SQLException { |
||||
|
if (StringUtils.isBlank(rs.getString(columnName))) { |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
return JsonUtil.jsonToList(rs.getString(columnName), Long.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Long> getResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
|
if (StringUtils.isBlank(rs.getString(columnIndex))) { |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
return JsonUtil.jsonToList(rs.getString(columnIndex), Long.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Long> getResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
|
String value = cs.getString(columnIndex); |
||||
|
|
||||
|
if (StringUtils.isBlank(value)) { |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
return JsonUtil.jsonToList(value, Long.class); |
||||
|
} |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
package org.dromara.workflow.mapper; |
||||
|
|
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
import org.dromara.workflow.domain.FlowDepart; |
||||
|
|
||||
|
public interface FlwDepartMapper extends BaseMapperPlus<FlowDepart, FlowDepart> { |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
package org.dromara.workflow.service; |
||||
|
|
||||
|
import org.dromara.workflow.domain.FlowDepart; |
||||
|
|
||||
|
public interface FlwDepartService { |
||||
|
FlowDepart getInfo(String flowCode); |
||||
|
|
||||
|
FlowDepart bindDepart(FlowDepart flowDepart); |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
package org.dromara.workflow.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.dromara.workflow.domain.FlowDepart; |
||||
|
import org.dromara.workflow.mapper.FlwDepartMapper; |
||||
|
import org.dromara.workflow.service.FlwDepartService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
public class FlwDepartServiceImpl extends ServiceImpl<FlwDepartMapper, FlowDepart> implements FlwDepartService { |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public FlowDepart getInfo(String flowCode) { |
||||
|
LambdaQueryWrapper<FlowDepart> wrapper = new LambdaQueryWrapper<>(); |
||||
|
wrapper.eq(FlowDepart::getFlowCode, flowCode); |
||||
|
|
||||
|
return this.baseMapper.selectOne(wrapper); |
||||
|
} |
||||
|
|
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public FlowDepart bindDepart(FlowDepart flowDepart) { |
||||
|
//首先清楚原来的
|
||||
|
LambdaQueryWrapper<FlowDepart> updateWrapper = new LambdaQueryWrapper<>(); |
||||
|
updateWrapper.eq(FlowDepart::getFlowCode, flowDepart.getFlowCode()); |
||||
|
this.baseMapper.delete(updateWrapper); |
||||
|
|
||||
|
this.baseMapper.insert(flowDepart); |
||||
|
|
||||
|
return flowDepart; |
||||
|
} |
||||
|
} |
@ -0,0 +1,126 @@ |
|||||
|
package org.dromara.workflow.utils; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
|
import com.fasterxml.jackson.core.type.TypeReference; |
||||
|
import com.fasterxml.jackson.databind.JavaType; |
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import java.lang.reflect.Field; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.LinkedHashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 定义响应结构 |
||||
|
*/ |
||||
|
public class JsonUtil { |
||||
|
|
||||
|
private static ObjectMapper MAPPER; |
||||
|
static{ |
||||
|
MAPPER=new ObjectMapper(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将对象转换成json字符串。 |
||||
|
* @param data |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String toJson(Object data){ |
||||
|
String string = null; |
||||
|
try { |
||||
|
string = MAPPER.writeValueAsString(data); |
||||
|
if(StringUtils.isEmpty(string)){ |
||||
|
return null; |
||||
|
} |
||||
|
return string; |
||||
|
} catch (JsonProcessingException e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将json结果集转化为对象 |
||||
|
* |
||||
|
* @param jsonData json数据 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static <T> T jsonToPojo(String jsonData, Class<T> beanType) { |
||||
|
try { |
||||
|
T t = MAPPER.readValue(jsonData, beanType); |
||||
|
return t; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将json数据转换成pojo对象list |
||||
|
* <p>Title: jsonToList</p> |
||||
|
* <p>Description: </p> |
||||
|
* @param jsonData |
||||
|
* @param beanType |
||||
|
* @return |
||||
|
*/ |
||||
|
public static <T>List<T> jsonToList(String jsonData, Class<T> beanType) { |
||||
|
JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType); |
||||
|
try { |
||||
|
List<T> list = MAPPER.readValue(jsonData, javaType); |
||||
|
return list; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将Object对象里面的属性和值转化成Map对象 |
||||
|
* |
||||
|
* @param obj |
||||
|
* @return |
||||
|
* @throws IllegalAccessException |
||||
|
*/ |
||||
|
public static Map<String, Object> objectToMap(Object obj){ |
||||
|
try { |
||||
|
Map<String, Object> map = new HashMap<String,Object>(); |
||||
|
Class<?> clazz = obj.getClass(); |
||||
|
for (Field field : clazz.getDeclaredFields()) { |
||||
|
field.setAccessible(true); |
||||
|
String fieldName = field.getName(); |
||||
|
if(ObjectUtil.isNotEmpty(field.get(obj))){ |
||||
|
Object value = field.get(obj); |
||||
|
map.put(fieldName, value); |
||||
|
}else{ |
||||
|
map.put(fieldName, ""); |
||||
|
} |
||||
|
} |
||||
|
return map; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static Map<String, Object> jsonToMap(String json){ |
||||
|
try { |
||||
|
return MAPPER.readValue(json, new TypeReference<Map<String, Object>>(){}); |
||||
|
} catch (JsonProcessingException e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static LinkedHashMap<String, String> jsonToStrMap(String json){ |
||||
|
try { |
||||
|
return MAPPER.readValue(json, new TypeReference<LinkedHashMap<String, String>>(){}); |
||||
|
} catch (JsonProcessingException e) { |
||||
|
e.printStackTrace(); |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper |
||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="org.dromara.workflow.mapper.FlwDepartMapper"> |
||||
|
|
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue