feat: 功能持续更新.

pull/161/head
chen.ma 3 years ago
parent f855510889
commit e958249738

@ -7,6 +7,7 @@ import io.dynamic.threadpool.common.web.base.Results;
import io.dynamic.threadpool.server.model.biz.item.ItemQueryReqDTO; import io.dynamic.threadpool.server.model.biz.item.ItemQueryReqDTO;
import io.dynamic.threadpool.server.model.biz.item.ItemRespDTO; import io.dynamic.threadpool.server.model.biz.item.ItemRespDTO;
import io.dynamic.threadpool.server.model.biz.item.ItemSaveReqDTO; import io.dynamic.threadpool.server.model.biz.item.ItemSaveReqDTO;
import io.dynamic.threadpool.server.model.biz.item.ItemUpdateReqDTO;
import io.dynamic.threadpool.server.service.biz.ItemService; import io.dynamic.threadpool.server.service.biz.ItemService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -41,14 +42,14 @@ public class ItemController {
} }
@PostMapping("/item/update") @PostMapping("/item/update")
public Result updateItem() { public Result updateItem(ItemUpdateReqDTO reqDTO) {
itemService.updateItem(reqDTO);
return Results.success(); return Results.success();
} }
@DeleteMapping("/item/delete/{itemId}") @DeleteMapping("/item/delete/{namespace}/{itemId}")
public Result deleteItem(@PathVariable("itemId") String itemId) { public Result deleteItem(@PathVariable("namespace") String namespace, @PathVariable("itemId") String itemId) {
itemService.deleteItem(namespace, itemId);
return Results.success(); return Results.success();
} }
} }

@ -49,10 +49,17 @@ public interface ItemService {
void saveItem(ItemSaveReqDTO reqDTO); void saveItem(ItemSaveReqDTO reqDTO);
/** /**
* *
* *
* @param reqDTO * @param reqDTO
*/ */
void updateItem(ItemUpdateReqDTO reqDTO); void updateItem(ItemUpdateReqDTO reqDTO);
/**
*
*
* @param namespace
* @param itemId
*/
void deleteItem(String namespace, String itemId);
} }

@ -2,17 +2,21 @@ package io.dynamic.threadpool.server.service.biz;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import io.dynamic.threadpool.server.enums.DelEnum;
import io.dynamic.threadpool.server.mapper.ItemInfoMapper; import io.dynamic.threadpool.server.mapper.ItemInfoMapper;
import io.dynamic.threadpool.server.model.ItemInfo; import io.dynamic.threadpool.server.model.ItemInfo;
import io.dynamic.threadpool.server.model.biz.item.ItemQueryReqDTO; import io.dynamic.threadpool.server.model.biz.item.ItemQueryReqDTO;
import io.dynamic.threadpool.server.model.biz.item.ItemRespDTO; import io.dynamic.threadpool.server.model.biz.item.ItemRespDTO;
import io.dynamic.threadpool.server.model.biz.item.ItemSaveReqDTO; import io.dynamic.threadpool.server.model.biz.item.ItemSaveReqDTO;
import io.dynamic.threadpool.server.model.biz.item.ItemUpdateReqDTO; import io.dynamic.threadpool.server.model.biz.item.ItemUpdateReqDTO;
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolRespDTO;
import io.dynamic.threadpool.server.toolkit.BeanUtil; import io.dynamic.threadpool.server.toolkit.BeanUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -30,6 +34,9 @@ public class ItemServiceImpl implements ItemService {
@Resource @Resource
private ItemInfoMapper itemInfoMapper; private ItemInfoMapper itemInfoMapper;
@Autowired
private ThreadPoolService threadPoolService;
@Override @Override
public IPage<ItemRespDTO> queryItemPage(ItemQueryReqDTO reqDTO) { public IPage<ItemRespDTO> queryItemPage(ItemQueryReqDTO reqDTO) {
LambdaQueryWrapper<ItemInfo> wrapper = Wrappers.lambdaQuery(ItemInfo.class) LambdaQueryWrapper<ItemInfo> wrapper = Wrappers.lambdaQuery(ItemInfo.class)
@ -86,4 +93,22 @@ public class ItemServiceImpl implements ItemService {
} }
} }
@Override
public void deleteItem(String namespace, String itemId) {
List<ThreadPoolRespDTO> itemList = threadPoolService.getThreadPoolByItemId(itemId);
if (CollectionUtils.isNotEmpty(itemList)) {
throw new RuntimeException("项目包含线程池引用, 删除失败.");
}
int updateResult = itemInfoMapper.update(new ItemInfo(),
Wrappers.lambdaUpdate(ItemInfo.class)
.eq(ItemInfo::getTenantId, namespace)
.eq(ItemInfo::getItemId, itemId)
.set(ItemInfo::getDelFlag, DelEnum.DELETE.getIntCode()));
boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) {
throw new RuntimeException("删除失败.");
}
}
} }

@ -5,6 +5,8 @@ import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolQueryReqDTO;
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolRespDTO; import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolRespDTO;
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO; import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
import java.util.List;
/** /**
* Thread Pool Service. * Thread Pool Service.
* *
@ -29,6 +31,14 @@ public interface ThreadPoolService {
*/ */
ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO); ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO);
/**
* ItemId 线
*
* @param itemId
* @return
*/
List<ThreadPoolRespDTO> getThreadPoolByItemId(String itemId);
/** /**
* 线 * 线
* *

@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* Thread Pool Service Impl. * Thread Pool Service Impl.
@ -45,6 +46,13 @@ public class ThreadPoolServiceImpl implements ThreadPoolService {
return BeanUtil.convert(configAllInfo, ThreadPoolRespDTO.class); return BeanUtil.convert(configAllInfo, ThreadPoolRespDTO.class);
} }
@Override
public List<ThreadPoolRespDTO> getThreadPoolByItemId(String itemId) {
List<ConfigAllInfo> selectList = configInfoMapper
.selectList(Wrappers.lambdaUpdate(ConfigAllInfo.class).eq(ConfigAllInfo::getItemId, itemId));
return BeanUtil.convert(selectList, ThreadPoolRespDTO.class);
}
@Override @Override
public void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO) { public void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO) {
configService.insertOrUpdate(BeanUtil.convert(reqDTO, ConfigAllInfo.class)); configService.insertOrUpdate(BeanUtil.convert(reqDTO, ConfigAllInfo.class));

Loading…
Cancel
Save