optimize: 优化 config 业务代码逻辑以及格式.

pull/161/head
chen.ma 3 years ago
parent 35dd34472a
commit 7c22923dff

@ -11,6 +11,11 @@ import lombok.Data;
@Data @Data
public class TenantUpdateReqDTO { public class TenantUpdateReqDTO {
/**
* id
*/
private Long id;
/** /**
* tenantId * tenantId
*/ */

@ -17,10 +17,18 @@ public interface TenantService {
/** /**
* Get tenant by id. * Get tenant by id.
* *
* @param tenantIdId * @param id
* @return * @return
*/ */
TenantRespDTO getTenantById(String tenantIdId); TenantRespDTO getTenantById(String id);
/**
* Get tenant by tenantId.
*
* @param tenantId
* @return
*/
TenantRespDTO getTenantByTenantId(String tenantId);
/** /**
* Query tenant page. * Query tenant page.

@ -1,4 +1,4 @@
package com.github.dynamic.threadpool.config.service.biz; package com.github.dynamic.threadpool.config.service.biz.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -11,6 +11,7 @@ import com.github.dynamic.threadpool.config.event.LocalDataChangeEvent;
import com.github.dynamic.threadpool.config.mapper.ConfigInfoMapper; import com.github.dynamic.threadpool.config.mapper.ConfigInfoMapper;
import com.github.dynamic.threadpool.config.model.ConfigAllInfo; import com.github.dynamic.threadpool.config.model.ConfigAllInfo;
import com.github.dynamic.threadpool.config.service.ConfigChangePublisher; import com.github.dynamic.threadpool.config.service.ConfigChangePublisher;
import com.github.dynamic.threadpool.config.service.biz.ConfigService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

@ -1,4 +1,4 @@
package com.github.dynamic.threadpool.config.service.biz; package com.github.dynamic.threadpool.config.service.biz.impl;
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;
@ -14,6 +14,8 @@ import com.github.dynamic.threadpool.config.model.biz.item.ItemRespDTO;
import com.github.dynamic.threadpool.config.model.biz.item.ItemSaveReqDTO; import com.github.dynamic.threadpool.config.model.biz.item.ItemSaveReqDTO;
import com.github.dynamic.threadpool.config.model.biz.item.ItemUpdateReqDTO; import com.github.dynamic.threadpool.config.model.biz.item.ItemUpdateReqDTO;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO;
import com.github.dynamic.threadpool.config.service.biz.ItemService;
import com.github.dynamic.threadpool.config.service.biz.ThreadPoolService;
import com.github.dynamic.threadpool.config.toolkit.BeanUtil; import com.github.dynamic.threadpool.config.toolkit.BeanUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -83,10 +85,10 @@ public class ItemServiceImpl implements ItemService {
@Override @Override
public void updateItem(ItemUpdateReqDTO reqDTO) { public void updateItem(ItemUpdateReqDTO reqDTO) {
ItemInfo itemInfo = BeanUtil.convert(reqDTO, ItemInfo.class); ItemInfo itemInfo = BeanUtil.convert(reqDTO, ItemInfo.class);
int updateResult = itemInfoMapper.update(itemInfo, Wrappers int updateResult = itemInfoMapper.update(itemInfo,
.lambdaUpdate(ItemInfo.class) Wrappers.lambdaUpdate(ItemInfo.class)
.eq(ItemInfo::getTenantId, reqDTO.getTenantId()) .eq(ItemInfo::getTenantId, reqDTO.getTenantId())
.eq(ItemInfo::getItemId, reqDTO.getItemId())); .eq(ItemInfo::getItemId, reqDTO.getItemId()));
boolean retBool = SqlHelper.retBool(updateResult); boolean retBool = SqlHelper.retBool(updateResult);
if (!retBool) { if (!retBool) {

@ -1,4 +1,4 @@
package com.github.dynamic.threadpool.config.service.biz; package com.github.dynamic.threadpool.config.service.biz.impl;
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;
@ -9,6 +9,8 @@ import com.github.dynamic.threadpool.config.model.ConfigAllInfo;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolQueryReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolQueryReqDTO;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolRespDTO;
import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO; import com.github.dynamic.threadpool.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
import com.github.dynamic.threadpool.config.service.biz.ConfigService;
import com.github.dynamic.threadpool.config.service.biz.ThreadPoolService;
import com.github.dynamic.threadpool.config.toolkit.BeanUtil; import com.github.dynamic.threadpool.config.toolkit.BeanUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

@ -32,7 +32,7 @@ public class TenantController {
@GetMapping("/query/{tenantId}") @GetMapping("/query/{tenantId}")
public Result<TenantRespDTO> queryNameSpace(@PathVariable("tenantId") String tenantId) { public Result<TenantRespDTO> queryNameSpace(@PathVariable("tenantId") String tenantId) {
return Results.success(tenantService.getTenantById(tenantId)); return Results.success(tenantService.getTenantByTenantId(tenantId));
} }
@PostMapping("/save") @PostMapping("/save")

@ -1,6 +1,8 @@
server: server:
port: 6691 port: 6691
tenant: hippo
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver

Loading…
Cancel
Save