21 changed files with 148 additions and 167 deletions
@ -1,15 +0,0 @@ |
|||
package org.dromara.workflow.mapper; |
|||
|
|||
import jakarta.validation.constraints.NotNull; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
import org.dromara.workflow.domain.FlowDepart; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface FlwDepartMapper extends BaseMapperPlus<FlowDepart, FlowDepart> { |
|||
FlowDepart getFlowDepart(@Param("deptId") Long deptId); |
|||
|
|||
Integer checkFlowDepart(@Param("deptIds") List<Long> departIds); |
|||
} |
@ -0,0 +1,13 @@ |
|||
package org.dromara.workflow.mapper; |
|||
|
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
import org.dromara.workflow.domain.FlowLabel; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface FlwLabelMapper extends BaseMapperPlus<FlowLabel, FlowLabel> { |
|||
FlowLabel getFlowLabel(@Param("labelId") String labelId); |
|||
|
|||
Integer checkFlowLabel(@Param("labelIds") List<String> labelIds); |
|||
} |
@ -1,11 +0,0 @@ |
|||
package org.dromara.workflow.service; |
|||
|
|||
import org.dromara.workflow.domain.FlowDepart; |
|||
|
|||
public interface FlwDepartService { |
|||
FlowDepart getInfo(String flowCode); |
|||
|
|||
FlowDepart bindDepart(FlowDepart flowDepart); |
|||
|
|||
FlowDepart getFlowDepart(Long deptId); |
|||
} |
@ -0,0 +1,11 @@ |
|||
package org.dromara.workflow.service; |
|||
|
|||
import org.dromara.workflow.domain.FlowLabel; |
|||
|
|||
public interface FlwLabelService { |
|||
FlowLabel getInfo(String flowCode); |
|||
|
|||
FlowLabel bindLabel(FlowLabel flowDepart); |
|||
|
|||
FlowLabel getFlowLabel(String labelId); |
|||
} |
@ -1,49 +0,0 @@ |
|||
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.common.core.exception.ServiceException; |
|||
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; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@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); |
|||
|
|||
//查询部门是否还存在别的流程
|
|||
if (this.baseMapper.checkFlowDepart(flowDepart.getDepartIds()) > 0){ |
|||
throw new ServiceException("所选的部门中,已存在在其他流程中,请检查后在提交!"); |
|||
} |
|||
|
|||
this.baseMapper.insert(flowDepart); |
|||
|
|||
return flowDepart; |
|||
} |
|||
|
|||
@Override |
|||
public FlowDepart getFlowDepart(Long deptId) { |
|||
return this.baseMapper.getFlowDepart(deptId); |
|||
} |
|||
} |
@ -0,0 +1,47 @@ |
|||
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.common.core.exception.ServiceException; |
|||
import org.dromara.workflow.domain.FlowLabel; |
|||
import org.dromara.workflow.mapper.FlwLabelMapper; |
|||
import org.dromara.workflow.service.FlwLabelService; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class FlwLabelServiceImpl extends ServiceImpl<FlwLabelMapper, FlowLabel> implements FlwLabelService { |
|||
|
|||
|
|||
@Override |
|||
public FlowLabel getInfo(String flowCode) { |
|||
LambdaQueryWrapper<FlowLabel> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.eq(FlowLabel::getFlowCode, flowCode); |
|||
|
|||
return this.baseMapper.selectOne(wrapper); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public FlowLabel bindLabel(FlowLabel flowDepart) { |
|||
LambdaQueryWrapper<FlowLabel> updateWrapper = new LambdaQueryWrapper<>(); |
|||
updateWrapper.eq(FlowLabel::getFlowCode, flowDepart.getFlowCode()); |
|||
this.baseMapper.delete(updateWrapper); |
|||
|
|||
//查询部门是否还存在别的流程
|
|||
if (this.baseMapper.checkFlowLabel(flowDepart.getLabelIds()) > 0){ |
|||
throw new ServiceException("所选的标签中,已存在在其他流程中,请检查后在提交!"); |
|||
} |
|||
|
|||
this.baseMapper.insert(flowDepart); |
|||
|
|||
return flowDepart; |
|||
} |
|||
|
|||
@Override |
|||
public FlowLabel getFlowLabel(String labelId) { |
|||
return this.baseMapper.getFlowLabel(labelId); |
|||
} |
|||
} |
@ -1,22 +0,0 @@ |
|||
<?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"> |
|||
|
|||
<select id="getFlowDepart" resultType="org.dromara.workflow.domain.FlowDepart"> |
|||
select fd.* from flow_depart fd where JSON_CONTAINS(fd.dept_ids, #{deptId}) |
|||
</select> |
|||
|
|||
<select id="checkFlowDepart" resultType="java.lang.Integer"> |
|||
SELECT |
|||
count(1) |
|||
FROM flow_depart fd |
|||
where |
|||
<foreach collection="deptIds" item="item" open="(" separator=" OR " close=")"> |
|||
JSON_CONTAINS(fd.dept_ids, CONCAT('"', #{item}, '"')) |
|||
</foreach> |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,22 @@ |
|||
<?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.FlwLabelMapper"> |
|||
|
|||
<select id="getFlowLabel" resultType="org.dromara.workflow.domain.FlowLabel"> |
|||
select fd.* from flow_depart fd where JSON_CONTAINS(fd.label_ids, #{labelId}) |
|||
</select> |
|||
|
|||
<select id="checkFlowLabel" resultType="java.lang.Integer"> |
|||
SELECT |
|||
count(1) |
|||
FROM flow_depart fd |
|||
where |
|||
<foreach collection="labelIds" item="item" open="(" separator=" OR " close=")"> |
|||
JSON_CONTAINS(fd.label_ids, CONCAT('"', #{item}, '"')) |
|||
</foreach> |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue