mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-15 00:57:14 +08:00
refactor: 💥 调整后端请求、响应参数模型命名风格
XxxRequest => XxxReq XxxVO => XxxResp
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.tool.model.request;
|
||||
package top.charles7c.cnadmin.tool.model.req;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,7 +38,7 @@ import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "代码生成配置信息")
|
||||
public class GenConfigRequest implements Serializable {
|
||||
public class GenConfigReq implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.tool.model.vo;
|
||||
package top.charles7c.cnadmin.tool.model.resp;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -31,7 +31,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "表信息")
|
||||
public class TableVO implements Serializable {
|
||||
public class TableResp implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@@ -20,12 +20,12 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||
import top.charles7c.cnadmin.tool.model.request.GenConfigRequest;
|
||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||
import top.charles7c.cnadmin.tool.model.req.GenConfigReq;
|
||||
import top.charles7c.cnadmin.tool.model.resp.TableResp;
|
||||
|
||||
/**
|
||||
* 代码生成业务接口
|
||||
@@ -46,7 +46,7 @@ public interface GeneratorService {
|
||||
* @throws SQLException
|
||||
* /
|
||||
*/
|
||||
PageDataVO<TableVO> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException;
|
||||
PageDataResp<TableResp> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException;
|
||||
|
||||
/**
|
||||
* 查询生成配置信息
|
||||
@@ -73,12 +73,12 @@ public interface GeneratorService {
|
||||
/**
|
||||
* 保存代码生成配置信息
|
||||
*
|
||||
* @param request
|
||||
* @param req
|
||||
* 代码生成配置信息
|
||||
* @param tableName
|
||||
* 表名称
|
||||
*/
|
||||
void saveConfig(GenConfigRequest request, String tableName);
|
||||
void saveConfig(GenConfigReq req, String tableName);
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
|
@@ -47,7 +47,7 @@ import top.charles7c.cnadmin.common.constant.StringConsts;
|
||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
||||
import top.charles7c.cnadmin.common.exception.ServiceException;
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
import top.charles7c.cnadmin.common.model.resp.PageDataResp;
|
||||
import top.charles7c.cnadmin.common.util.TemplateUtils;
|
||||
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
|
||||
import top.charles7c.cnadmin.tool.config.properties.GeneratorProperties;
|
||||
@@ -57,8 +57,8 @@ import top.charles7c.cnadmin.tool.mapper.GenConfigMapper;
|
||||
import top.charles7c.cnadmin.tool.model.entity.FieldConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.entity.GenConfigDO;
|
||||
import top.charles7c.cnadmin.tool.model.query.TableQuery;
|
||||
import top.charles7c.cnadmin.tool.model.request.GenConfigRequest;
|
||||
import top.charles7c.cnadmin.tool.model.vo.TableVO;
|
||||
import top.charles7c.cnadmin.tool.model.req.GenConfigReq;
|
||||
import top.charles7c.cnadmin.tool.model.resp.TableResp;
|
||||
import top.charles7c.cnadmin.tool.service.GeneratorService;
|
||||
import top.charles7c.cnadmin.tool.util.MetaUtils;
|
||||
import top.charles7c.cnadmin.tool.util.Table;
|
||||
@@ -80,7 +80,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
private final GenConfigMapper genConfigMapper;
|
||||
|
||||
@Override
|
||||
public PageDataVO<TableVO> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException {
|
||||
public PageDataResp<TableResp> pageTable(TableQuery query, PageQuery pageQuery) throws SQLException {
|
||||
List<Table> tableList = MetaUtils.getTables(dataSource);
|
||||
String tableName = query.getTableName();
|
||||
if (StrUtil.isNotBlank(tableName)) {
|
||||
@@ -91,14 +91,15 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
Comparator.comparing(Table::getCreateTime)
|
||||
.thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime()))
|
||||
.reversed());
|
||||
List<TableVO> tableVOList = BeanUtil.copyToList(tableList, TableVO.class);
|
||||
PageDataVO<TableVO> pageDataVO = PageDataVO.build(pageQuery.getPage(), pageQuery.getSize(), tableVOList);
|
||||
for (TableVO tableVO : pageDataVO.getList()) {
|
||||
List<TableResp> tableRespList = BeanUtil.copyToList(tableList, TableResp.class);
|
||||
PageDataResp<TableResp> pageDataResp =
|
||||
PageDataResp.build(pageQuery.getPage(), pageQuery.getSize(), tableRespList);
|
||||
for (TableResp tableResp : pageDataResp.getList()) {
|
||||
long count = genConfigMapper.selectCount(
|
||||
Wrappers.lambdaQuery(GenConfigDO.class).eq(GenConfigDO::getTableName, tableVO.getTableName()));
|
||||
tableVO.setIsConfiged(count > 0);
|
||||
Wrappers.lambdaQuery(GenConfigDO.class).eq(GenConfigDO::getTableName, tableResp.getTableName()));
|
||||
tableResp.setIsConfiged(count > 0);
|
||||
}
|
||||
return pageDataVO;
|
||||
return pageDataResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,10 +167,10 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveConfig(GenConfigRequest request, String tableName) {
|
||||
public void saveConfig(GenConfigReq req, String tableName) {
|
||||
// 保存字段配置
|
||||
fieldConfigMapper.delete(Wrappers.lambdaQuery(FieldConfigDO.class).eq(FieldConfigDO::getTableName, tableName));
|
||||
List<FieldConfigDO> fieldConfigList = request.getFieldConfigs();
|
||||
List<FieldConfigDO> fieldConfigList = req.getFieldConfigs();
|
||||
for (FieldConfigDO fieldConfig : fieldConfigList) {
|
||||
if (fieldConfig.getShowInForm()) {
|
||||
CheckUtils.throwIfNull(fieldConfig.getFormType(), "字段 [{}] 的表单类型不能为空", fieldConfig.getFieldName());
|
||||
@@ -193,7 +194,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
fieldConfigMapper.insertBatch(fieldConfigList);
|
||||
|
||||
// 保存或更新生成配置信息
|
||||
GenConfigDO newGenConfig = request.getGenConfig();
|
||||
GenConfigDO newGenConfig = req.getGenConfig();
|
||||
String frontendPath = newGenConfig.getFrontendPath();
|
||||
if (StrUtil.isNotBlank(frontendPath)) {
|
||||
CheckUtils.throwIf(!StrUtil.containsAll(frontendPath, "src", "views"), "前端路径配置错误");
|
||||
|
Reference in New Issue
Block a user