优化分组树

结构优化
648540858 2023-11-15 11:24:56 +08:00
parent bcd5ce25ca
commit fd71a96580
3 changed files with 18 additions and 6 deletions

View File

@ -20,7 +20,6 @@ import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.assertj.core.util.Lists;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -680,6 +679,11 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
@Override @Override
public void removeFromGroup(UpdateCommonChannelToGroup params) { public void removeFromGroup(UpdateCommonChannelToGroup params) {
commonGbChannelMapper.removeFromGroup(params); if (!params.getCommonGbIds().isEmpty()) {
commonGbChannelMapper.removeFromGroupByIds(params.getCommonGbIds());
}
if (!ObjectUtils.isEmpty(params.getCommonGbBusinessGroupID().trim())){
commonGbChannelMapper.removeFromGroupByGroupId(params.getCommonGbBusinessGroupID());
}
} }
} }

View File

@ -383,12 +383,20 @@ public interface CommonGbChannelMapper {
void updateChannelToGroup(@Param("commonGbChannel") UpdateCommonChannelToGroup commonGbChannel); void updateChannelToGroup(@Param("commonGbChannel") UpdateCommonChannelToGroup commonGbChannel);
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='commonGbChannel.commonGbIds' item='item' separator=';'>" + "<foreach collection='commonGbIds' item='item' separator=';'>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_gb_channel" +
" SET common_gb_business_group_id = null" + " SET common_gb_business_group_id = null" +
" WHERE common_gb_id = #{item}" + " WHERE common_gb_id = #{item}" +
"</foreach>" + "</foreach>" +
"</script>"}) "</script>"})
void removeFromGroup(@Param("commonGbChannel") UpdateCommonChannelToGroup commonGbChannel); void removeFromGroupByIds(@Param("commonGbIds") List<Integer> commonGbIds);
@Update({"<script>" +
" UPDATE" +
" wvp_common_gb_channel" +
" SET common_gb_business_group_id = null" +
" WHERE common_gb_business_group_id = #{commonGbBusinessGroupID}" +
"</script>"})
void removeFromGroupByGroupId(@Param("commonGbBusinessGroupID") String commonGbBusinessGroupID);
} }

View File

@ -171,11 +171,11 @@ public class CommonChannelController {
commonGbChannelService.updateChannelToGroup(params); commonGbChannelService.updateChannelToGroup(params);
} }
@Operation(summary = "为通道添加分组") @Operation(summary = "从分组中移除通道")
@ResponseBody @ResponseBody
@PostMapping("/group/remove") @PostMapping("/group/remove")
public void removeFromGroup(@RequestBody UpdateCommonChannelToGroup params){ public void removeFromGroup(@RequestBody UpdateCommonChannelToGroup params){
assert params.getCommonGbBusinessGroupID() != null; assert params.getCommonGbBusinessGroupID() != null || !params.getCommonGbIds().isEmpty();
commonGbChannelService.removeFromGroup(params); commonGbChannelService.removeFromGroup(params);
} }